1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
10 \*****************************************************************************/
15 //#include <sys/socket.h>
19 extern unsigned int mt_assign_pid;
26 Pdss1::Pdss1(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive, int mode) : PmISDN(type, mISDNport, portname, settings, channel, exclusive, mode)
28 p_callerinfo.itype = (mISDNport->ifport->interface->extension)?INFO_ITYPE_ISDN_EXTENSION:INFO_ITYPE_ISDN;
29 p_m_d_ntmode = mISDNport->ntmode;
30 p_m_d_tespecial = mISDNport->tespecial;
33 p_m_d_queue[0] = '\0';
34 p_m_d_notify_pending = NULL;
35 p_m_d_collect_cause = 0;
36 p_m_d_collect_location = 0;
38 PDEBUG(DEBUG_ISDN, "Created new mISDNPort(%s). Currently %d objects use, %s%s port #%d\n", portname, mISDNport->use, (mISDNport->ntmode)?"NT":"TE", (mISDNport->tespecial)?" (special)":"", p_m_portnum);
47 /* remove queued message */
48 if (p_m_d_notify_pending)
49 message_free(p_m_d_notify_pending);
54 * create layer 3 message
56 static struct l3_msg *create_l3msg(void)
64 FATAL("Cannot allocate memory, system overloaded.\n");
65 exit(0); // make gcc happy
69 * if we received a first reply to the setup message,
70 * we will check if we have now channel information
71 * return: <0: error, call is released, -cause is given
72 * 0: ok, nothing to do
74 int Pdss1::received_first_reply_to_setup(unsigned int cmd, int channel, int exclusive)
79 /* correct exclusive to 0, if no explicit channel was given */
80 if (exclusive<0 || channel<=0)
84 if (p_m_b_channel && p_m_b_exclusive) {
85 /*** we gave an exclusive channel (or if we are done) ***/
87 /* if not first reply, we are done */
88 if (p_state != PORT_STATE_OUT_SETUP)
91 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
92 add_trace("channel", "request", "%d (forced)", p_m_b_channel);
93 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
95 /* if give channel not accepted or not equal */
96 if (channel!=-1 && p_m_b_channel!=channel) {
97 add_trace("conclusion", NULL, "forced channel not accepted");
103 add_trace("conclusion", NULL, "channel was accepted");
104 add_trace("connect", "channel", "%d", p_m_b_channel);
107 /* activate our exclusive channel */
108 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
111 /*** we gave a non-exclusive channel ***/
113 /* if not first reply, we are done */
114 if (p_state != PORT_STATE_OUT_SETUP)
117 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
118 add_trace("channel", "request", "%d (suggest)", p_m_b_channel);
119 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
121 /* if channel was accepted as given */
122 if (channel==-1 || p_m_b_channel==channel) {
123 add_trace("conclusion", NULL, "channel was accepted as given");
124 add_trace("connect", "channel", "%d", p_m_b_channel);
126 p_m_b_exclusive = 1; // we are done
127 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
131 /* if channel value is faulty */
133 add_trace("conclusion", NULL, "illegal reply");
135 ret = -111; // protocol error
139 /* if channel was not accepted, try to get it */
140 ret = seize_bchannel(channel, 1); // exclusively
141 add_trace("channel", "available", ret<0?"no":"yes");
143 add_trace("conclusion", NULL, "replied channel not available");
147 add_trace("conclusion", NULL, "replied channel accepted");
148 add_trace("connect", "channel", "%d", p_m_b_channel);
151 /* activate channel given by remote */
152 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
155 /*** we sent 'any channel acceptable' ***/
157 /* if not first reply, we are done */
158 if (p_state != PORT_STATE_OUT_SETUP)
161 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
162 add_trace("channel", "request", "any");
163 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
164 /* if no channel was replied */
166 add_trace("conclusion", NULL, "no channel, protocol error");
168 ret = -111; // protocol error
172 /* we will see, if our received channel is available */
173 ret = seize_bchannel(channel, 1); // exclusively
174 add_trace("channel", "available", ret<0?"no":"yes");
176 add_trace("conclusion", NULL, "replied channel not available");
180 add_trace("conclusion", NULL, "replied channel accepted");
181 add_trace("connect", "channel", "%d", p_m_b_channel);
184 /* activate channel given by remote */
185 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
187 /*** we sent 'no channel available' ***/
189 /* if not the first reply, but a connect, we are forced */
190 if (cmd==MT_CONNECT && p_state!=PORT_STATE_OUT_SETUP) {
191 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (connect)", DIRECTION_NONE);
192 add_trace("channel", "request", "no-channel");
193 add_trace("channel", "reply", (channel>=0)?"%d%s":"(none)", channel, exclusive?" (forced)":"");
195 goto use_from_connect;
197 ret = seize_bchannel(CHANNEL_ANY, 0); // any channel
198 add_trace("channel", "available", ret<0?"no":"yes");
200 add_trace("conclusion", NULL, "no channel available during call-waiting");
204 add_trace("conclusion", NULL, "using channel %d", p_m_b_channel);
205 add_trace("connect", "channel", "%d", p_m_b_channel);
207 p_m_b_exclusive = 1; // we are done
209 /* activate channel given by remote */
210 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
214 /* if not first reply, we are done */
215 if (p_state != PORT_STATE_OUT_SETUP)
218 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
219 add_trace("channel", "request", "no-channel");
220 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
221 /* if first reply has no channel, we are done */
223 add_trace("conclusion", NULL, "no channel until connect");
228 /* we will see, if our received channel is available */
230 ret = seize_bchannel(channel, exclusive);
231 add_trace("channel", "available", ret<0?"no":"yes");
233 add_trace("conclusion", NULL, "replied channel not available");
237 add_trace("conclusion", NULL, "replied channel accepted");
238 add_trace("connect", "channel", "%d", p_m_b_channel);
240 p_m_b_exclusive = 1; // we are done
242 /* activate channel given by remote */
243 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
249 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
250 * in response to the setup reply
252 l3m = create_l3msg();
253 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
254 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
256 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
257 new_state(PORT_STATE_RELEASE);
259 return(-34); /* to epoint: no channel available */
264 * hunt bchannel for incoming setup or retrieve or resume
266 int Pdss1::hunt_bchannel(int channel, int exclusive)
268 struct select_channel *selchannel;
269 struct interface_port *ifport = p_m_mISDNport->ifport;
272 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (setup)", DIRECTION_NONE);
275 if (channel == CHANNEL_NO)
276 add_trace("channel", "request", "no-channel");
278 add_trace("channel", "request", (channel>0)?"%d%s":"any", channel, exclusive?" (forced)":"");
279 if (channel==CHANNEL_NO && p_type==PORT_TYPE_DSS1_TE_IN) {
280 add_trace("conclusion", NULL, "incoming call-waiting not supported for TE-mode");
282 return(-6); // channel unacceptable
284 if (channel <= 0) /* not given, no channel, whatever.. */
285 channel = CHANNEL_ANY; /* any channel */
286 add_trace("channel", "reserved", "%d", p_m_mISDNport->b_reserved);
287 if (p_m_mISDNport->b_reserved >= p_m_mISDNport->b_num) { // of out chan..
288 add_trace("conclusion", NULL, "all channels are reserved");
290 return(-34); // no channel
292 if (channel == CHANNEL_ANY)
295 /* check for given channel in selection list */
296 selchannel = ifport->in_channel;
298 if (selchannel->channel == channel || selchannel->channel == CHANNEL_FREE)
300 selchannel = selchannel->next;
305 /* exclusive channel requests must be in the list */
307 /* no exclusive channel */
309 add_trace("conclusion", NULL, "exclusively requested channel not in list");
311 return(-6); // channel unacceptable
313 /* get index for channel */
314 i = channel-1-(channel>=17);
315 if (i < 0 || i >= p_m_mISDNport->b_num || channel == 16) {
316 add_trace("conclusion", NULL, "exclusively requested channel outside interface range");
318 return(-6); // channel unacceptable
321 if (p_m_mISDNport->b_port[i] == NULL)
323 add_trace("conclusion", NULL, "exclusively requested channel is busy");
325 return(-6); // channel unacceptable
328 /* requested channels in list will be used */
330 /* get index for channel */
331 i = channel-1-(channel>=17);
332 if (i < 0 || i >= p_m_mISDNport->b_num || channel == 16) {
333 add_trace("info", NULL, "requested channel %d outside interface range", channel);
334 } else /* if inside range (else) check if available */
335 if (p_m_mISDNport->b_port[i] == NULL)
339 /* if channel is not available or not in list, it must be searched */
341 /* check for first free channel in list */
343 selchannel = ifport->in_channel;
345 switch(selchannel->channel) {
346 case CHANNEL_FREE: /* free channel */
347 add_trace("hunting", "channel", "free");
348 if (p_m_mISDNport->b_reserved >= p_m_mISDNport->b_num)
349 break; /* all channel in use or reserverd */
352 while(i < p_m_mISDNport->b_num) {
353 if (p_m_mISDNport->b_port[i] == NULL) {
354 channel = i+1+(i>=15);
362 add_trace("hunting", "channel", "%d", selchannel->channel);
363 if (selchannel->channel<1 || selchannel->channel==16)
364 break; /* invalid channels */
365 i = selchannel->channel-1-(selchannel->channel>=17);
366 if (i >= p_m_mISDNport->b_num)
367 break; /* channel not in port */
368 if (p_m_mISDNport->b_port[i] == NULL) {
369 channel = selchannel->channel;
375 break; /* found channel */
376 selchannel = selchannel->next;
379 add_trace("conclusion", NULL, "no channel available");
381 return(-6); // channel unacceptable
385 add_trace("conclusion", NULL, "channel available");
386 add_trace("connect", "channel", "%d", channel);
392 * handles all indications
394 /* CC_SETUP INDICATION */
395 void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
397 int calling_type, calling_plan, calling_present, calling_screen;
398 int calling_type2, calling_plan2, calling_present2, calling_screen2;
399 int called_type, called_plan;
400 int redir_type, redir_plan, redir_present, redir_screen, redir_reason;
401 int hlc_coding, hlc_presentation, hlc_interpretation, hlc_hlc, hlc_exthlc;
402 int bearer_coding, bearer_capability, bearer_mode, bearer_rate, bearer_multi, bearer_user;
403 int exclusive, channel;
405 unsigned char keypad[32] = "";
406 unsigned char useruser[128];
407 int useruser_len = 0, useruser_protocol;
408 class Endpoint *epoint;
409 struct lcr_msg *message;
411 /* process given callref */
412 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
413 add_trace("callref", "new", "0x%x", pid);
415 /* release in case the ID is already in use */
416 add_trace("error", NULL, "callref already in use");
418 l3m = create_l3msg();
419 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
420 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
421 add_trace("reason", NULL, "callref already in use");
423 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, pid, l3m);
424 new_state(PORT_STATE_RELEASE);
429 p_m_d_ces = pid >> 16;
432 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_IND, DIRECTION_IN);
433 dec_ie_calling_pn(l3m, &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id), &calling_type2, &calling_plan2, &calling_present2, &calling_screen2, (unsigned char *)p_callerinfo.id2, sizeof(p_callerinfo.id2));
434 dec_ie_called_pn(l3m, &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
435 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
436 /* te-mode: CNIP (calling name identification presentation) */
437 dec_facility_centrex(l3m, (unsigned char *)p_callerinfo.name, sizeof(p_callerinfo.name));
438 dec_ie_useruser(l3m, &useruser_protocol, useruser, &useruser_len);
439 dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
440 dec_ie_redir_nr(l3m, &redir_type, &redir_plan, &redir_present, &redir_screen, &redir_reason, (unsigned char *)p_redirinfo.id, sizeof(p_redirinfo.id));
441 dec_ie_channel_id(l3m, &exclusive, &channel);
442 dec_ie_hlc(l3m, &hlc_coding, &hlc_interpretation, &hlc_presentation, &hlc_hlc, &hlc_exthlc);
443 dec_ie_bearer(l3m, &bearer_coding, &bearer_capability, &bearer_mode, &bearer_rate, &bearer_multi, &bearer_user);
444 dec_ie_display(l3m, (unsigned char *)p_dialinginfo.display, sizeof(p_dialinginfo.display));
447 /* if blocked, release call with MT_RELEASE_COMPLETE */
448 if (p_m_mISDNport->ifport->block) {
449 l3m = create_l3msg();
450 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
451 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 27); /* temporary unavailable */
452 add_trace("reason", NULL, "port blocked");
454 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
455 new_state(PORT_STATE_RELEASE);
461 switch (calling_present) {
463 p_callerinfo.present = INFO_PRESENT_RESTRICTED;
466 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
469 p_callerinfo.present = INFO_PRESENT_ALLOWED;
472 switch (calling_screen) {
474 p_callerinfo.screen = INFO_SCREEN_USER;
477 p_callerinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
480 p_callerinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
483 p_callerinfo.screen = INFO_SCREEN_NETWORK;
486 switch (calling_type) {
488 p_callerinfo.ntype = INFO_NTYPE_NOTPRESENT;
491 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
494 p_callerinfo.ntype = INFO_NTYPE_INTERNATIONAL;
497 p_callerinfo.ntype = INFO_NTYPE_NATIONAL;
500 p_callerinfo.ntype = INFO_NTYPE_SUBSCRIBER;
503 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
506 p_callerinfo.isdn_port = p_m_portnum;
507 SCPY(p_callerinfo.interface, p_m_mISDNport->ifport->interface->name);
510 switch (calling_present2) {
512 p_callerinfo.present2 = INFO_PRESENT_RESTRICTED;
515 p_callerinfo.present2 = INFO_PRESENT_NOTAVAIL;
518 p_callerinfo.present2 = INFO_PRESENT_ALLOWED;
521 switch (calling_screen2) {
523 p_callerinfo.screen2 = INFO_SCREEN_USER;
526 p_callerinfo.screen2 = INFO_SCREEN_USER_VERIFIED_PASSED;
529 p_callerinfo.screen2 = INFO_SCREEN_USER_VERIFIED_FAILED;
532 p_callerinfo.screen2 = INFO_SCREEN_NETWORK;
535 switch (calling_type2) {
537 p_callerinfo.ntype2 = INFO_NTYPE_NOTPRESENT;
540 p_callerinfo.ntype2 = INFO_NTYPE_UNKNOWN;
543 p_callerinfo.ntype2 = INFO_NTYPE_INTERNATIONAL;
546 p_callerinfo.ntype2 = INFO_NTYPE_NATIONAL;
549 p_callerinfo.ntype2 = INFO_NTYPE_SUBSCRIBER;
552 p_callerinfo.ntype2 = INFO_NTYPE_UNKNOWN;
556 /* dialing information */
557 SCAT(p_dialinginfo.id, (char *)keypad);
558 switch (called_type) {
560 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
563 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
566 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
569 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
574 switch (redir_present) {
576 p_redirinfo.present = INFO_PRESENT_RESTRICTED;
579 p_redirinfo.present = INFO_PRESENT_NOTAVAIL;
582 p_redirinfo.present = INFO_PRESENT_ALLOWED;
585 switch (redir_screen) {
587 p_redirinfo.screen = INFO_SCREEN_USER;
590 p_redirinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
593 p_redirinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
596 p_redirinfo.screen = INFO_SCREEN_NETWORK;
599 switch (redir_reason) {
601 p_redirinfo.reason = INFO_REDIR_BUSY;
604 p_redirinfo.reason = INFO_REDIR_NORESPONSE;
607 p_redirinfo.reason = INFO_REDIR_UNCONDITIONAL;
610 p_redirinfo.reason = INFO_REDIR_CALLDEFLECT;
613 p_redirinfo.reason = INFO_REDIR_OUTOFORDER;
616 p_redirinfo.reason = INFO_REDIR_UNKNOWN;
619 switch (redir_type) {
621 p_redirinfo.ntype = INFO_NTYPE_NOTPRESENT;
624 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
627 p_redirinfo.ntype = INFO_NTYPE_INTERNATIONAL;
630 p_redirinfo.ntype = INFO_NTYPE_NATIONAL;
633 p_redirinfo.ntype = INFO_NTYPE_SUBSCRIBER;
636 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
639 p_redirinfo.isdn_port = p_m_portnum;
641 /* bearer capability */
642 switch (bearer_capability) {
644 p_capainfo.bearer_capa = INFO_BC_AUDIO;
645 bearer_user = (options.law=='a')?3:2;
648 p_capainfo.bearer_capa = bearer_capability;
651 switch (bearer_mode) {
653 p_capainfo.bearer_mode = INFO_BMODE_PACKET;
656 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
659 switch (bearer_user) {
661 p_capainfo.bearer_info1 = INFO_INFO1_NONE;
664 p_capainfo.bearer_info1 = bearer_user + 0x80;
671 p_capainfo.hlc = INFO_HLC_NONE;
674 p_capainfo.hlc = hlc_hlc + 0x80;
677 switch (hlc_exthlc) {
679 p_capainfo.exthlc = INFO_HLC_NONE;
682 p_capainfo.exthlc = hlc_exthlc + 0x80;
686 /* set bchannel mode */
687 if (p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED
688 || p_capainfo.bearer_capa==INFO_BC_DATARESTRICTED
689 || p_capainfo.bearer_capa==INFO_BC_VIDEO)
690 p_capainfo.source_mode = B_MODE_HDLC;
692 p_capainfo.source_mode = B_MODE_TRANSPARENT;
693 p_m_b_mode = p_capainfo.source_mode;
696 ret = channel = hunt_bchannel(channel, exclusive);
701 ret = seize_bchannel(channel, 1);
705 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
706 * in response to the setup
708 l3m = create_l3msg();
709 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
710 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
712 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
713 new_state(PORT_STATE_RELEASE);
717 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
719 /* create endpoint */
721 FATAL("Incoming call but already got an endpoint.\n");
722 if (!(epoint = new Endpoint(p_serial, 0)))
723 FATAL("No memory for Endpoint instance\n");
724 if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 0))) //incoming
725 FATAL("No memory for Endpoint Application instance\n");
726 epointlist_new(epoint->ep_serial);
728 /* send setup message to endpoit */
729 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
730 message->param.setup.isdn_port = p_m_portnum;
731 message->param.setup.port_type = p_type;
732 // message->param.setup.dtmf = !p_m_mISDNport->ifport->nodtmf;
733 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
734 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
735 memcpy(&message->param.setup.redirinfo, &p_redirinfo, sizeof(struct redir_info));
736 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
737 memcpy(message->param.setup.useruser.data, &useruser, useruser_len);
738 message->param.setup.useruser.len = useruser_len;
739 message->param.setup.useruser.protocol = useruser_protocol;
740 message_put(message);
742 new_state(PORT_STATE_IN_SETUP);
745 /* CC_INFORMATION INDICATION */
746 void Pdss1::information_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
749 unsigned char keypad[32] = "", display[128] = "";
750 struct lcr_msg *message;
752 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_IND, DIRECTION_IN);
753 dec_ie_called_pn(l3m, &type, &plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
754 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
755 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
756 dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
759 SCAT(p_dialinginfo.id, (char *)keypad);
762 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
765 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
768 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
771 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
774 SCPY(p_dialinginfo.display, (char *)display);
775 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_INFORMATION);
776 memcpy(&message->param.information, &p_dialinginfo, sizeof(struct dialing_info));
777 message_put(message);
778 /* reset overlap timeout */
782 /* CC_SETUP_ACCNOWLEDGE INDICATION */
783 void Pdss1::setup_acknowledge_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
785 int exclusive, channel;
786 int coding, location, progress;
788 struct lcr_msg *message;
789 int max = p_m_mISDNport->ifport->dialmax;
793 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_IND, DIRECTION_IN);
794 dec_ie_channel_id(l3m, &exclusive, &channel);
795 dec_ie_progress(l3m, &coding, &location, &progress);
798 /* process channel */
799 ret = received_first_reply_to_setup(cmd, channel, exclusive);
801 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
802 message->param.disconnectinfo.cause = -ret;
803 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
804 message_put(message);
805 new_state(PORT_STATE_RELEASE);
810 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_OVERLAP);
811 message_put(message);
813 new_state(PORT_STATE_OUT_OVERLAP);
815 number = p_m_d_queue;
816 while (number[0]) { /* as long we have something to dial */
817 if (max > (int)strlen(number) || max == 0)
818 max = (int)strlen(number);
820 nl3m = create_l3msg();
821 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
822 enc_ie_called_pn(nl3m, 0, 1, (unsigned char *)number, max);
824 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, nl3m);
827 p_m_d_queue[0] = '\0';
830 /* CC_PROCEEDING INDICATION */
831 void Pdss1::proceeding_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
833 int exclusive, channel;
834 int coding, location, progress;
836 struct lcr_msg *message;
837 int notify = -1, type, plan, present;
840 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_IND, DIRECTION_IN);
841 dec_ie_channel_id(l3m, &exclusive, &channel);
842 dec_ie_progress(l3m, &coding, &location, &progress);
843 dec_ie_notify(l3m, ¬ify);
844 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
847 ret = received_first_reply_to_setup(cmd, channel, exclusive);
849 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
850 message->param.disconnectinfo.cause = -ret;
851 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
852 message_put(message);
853 new_state(PORT_STATE_RELEASE);
857 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
858 message_put(message);
860 new_state(PORT_STATE_OUT_PROCEEDING);
866 if (type >= 0 || notify) {
867 if (!notify && type >= 0)
869 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
870 message->param.notifyinfo.notify = notify;
871 SCPY(message->param.notifyinfo.id, redir);
872 /* redirection number */
875 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
878 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
881 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
886 message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT;
889 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
892 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
895 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
898 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
901 message->param.notifyinfo.isdn_port = p_m_portnum;
902 message_put(message);
906 /* CC_ALERTING INDICATION */
907 void Pdss1::alerting_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
909 int exclusive, channel;
910 int coding, location, progress;
912 struct lcr_msg *message;
913 int notify = -1, type, plan, present;
916 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_IND, DIRECTION_IN);
917 dec_ie_channel_id(l3m, &exclusive, &channel);
918 dec_ie_progress(l3m, &coding, &location, &progress);
919 dec_ie_notify(l3m, ¬ify);
920 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
923 /* process channel */
924 ret = received_first_reply_to_setup(cmd, channel, exclusive);
926 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
927 message->param.disconnectinfo.cause = -ret;
928 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
929 message_put(message);
930 new_state(PORT_STATE_RELEASE);
934 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ALERTING);
935 message_put(message);
937 new_state(PORT_STATE_OUT_ALERTING);
943 if (type >= 0 || notify) {
944 if (!notify && type >= 0)
946 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
947 message->param.notifyinfo.notify = notify;
948 SCPY(message->param.notifyinfo.id, redir);
951 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
954 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
957 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
962 message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT;
965 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
968 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
971 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
974 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
977 message->param.notifyinfo.isdn_port = p_m_portnum;
978 message_put(message);
982 /* CC_CONNECT INDICATION */
983 void Pdss1::connect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
985 int exclusive, channel;
986 int type, plan, present, screen;
988 struct lcr_msg *message;
991 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_IND, DIRECTION_IN);
992 dec_ie_channel_id(l3m, &exclusive, &channel);
993 dec_ie_connected_pn(l3m, &type, &plan, &present, &screen, (unsigned char *)p_connectinfo.id, sizeof(p_connectinfo.id));
994 dec_ie_display(l3m, (unsigned char *)p_connectinfo.display, sizeof(p_connectinfo.display));
995 /* te-mode: CONP (connected name identification presentation) */
996 dec_facility_centrex(l3m, (unsigned char *)p_connectinfo.name, sizeof(p_connectinfo.name));
1000 bchannel_before = p_m_b_channel;
1001 ret = received_first_reply_to_setup(cmd, channel, exclusive);
1003 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1004 message->param.disconnectinfo.cause = -ret;
1005 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1006 message_put(message);
1007 new_state(PORT_STATE_RELEASE);
1012 /* connect information */
1015 p_connectinfo.present = INFO_PRESENT_RESTRICTED;
1018 p_connectinfo.present = INFO_PRESENT_NOTAVAIL;
1021 p_connectinfo.present = INFO_PRESENT_ALLOWED;
1026 p_connectinfo.screen = INFO_SCREEN_USER;
1029 p_connectinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
1032 p_connectinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
1035 p_connectinfo.screen = INFO_SCREEN_NETWORK;
1040 p_connectinfo.ntype = INFO_NTYPE_NOTPRESENT;
1043 p_connectinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1046 p_connectinfo.ntype = INFO_NTYPE_NATIONAL;
1049 p_connectinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1052 p_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
1055 p_connectinfo.isdn_port = p_m_portnum;
1056 SCPY(p_connectinfo.interface, p_m_mISDNport->ifport->interface->name);
1058 /* only in nt-mode we send connect ack. in te-mode it is done by stack itself or optional */
1060 /* send connect acknowledge */
1061 l3m = create_l3msg();
1062 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_RES, DIRECTION_OUT);
1063 /* if we had no bchannel before, we send it now */
1064 if (!bchannel_before && p_m_b_channel)
1065 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1067 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT_ACKNOWLEDGE, p_m_d_l3id, l3m);
1070 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_CONNECT);
1071 memcpy(&message->param.connectinfo, &p_connectinfo, sizeof(struct connect_info));
1072 message_put(message);
1074 new_state(PORT_STATE_CONNECT);
1077 /* CC_DISCONNECT INDICATION */
1078 void Pdss1::disconnect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1080 int location, cause;
1081 int coding, proglocation, progress;
1082 struct lcr_msg *message;
1083 unsigned char display[128] = "";
1085 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1086 dec_ie_progress(l3m, &coding, &proglocation, &progress);
1087 dec_ie_cause(l3m, &location, &cause);
1088 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1093 location = LOCATION_PRIVATE_LOCAL;
1096 /* release if remote sends us no tones */
1097 if (!p_m_mISDNport->earlyb) {
1100 l3m = create_l3msg();
1101 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
1102 enc_ie_cause(l3m, location, cause); /* normal */
1103 add_trace("reason", NULL, "no remote patterns");
1105 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
1107 /* sending release to endpoint */
1108 if (location == LOCATION_PRIVATE_LOCAL)
1109 location = LOCATION_PRIVATE_REMOTE;
1110 while(p_epointlist) {
1111 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1112 message->param.disconnectinfo.cause = cause;
1113 message->param.disconnectinfo.location = location;
1114 SCAT(message->param.disconnectinfo.display, (char *)display);
1115 message_put(message);
1117 free_epointlist(p_epointlist);
1119 new_state(PORT_STATE_RELEASE);
1124 /* sending disconnect to active endpoint and release to inactive endpoints */
1125 if (location == LOCATION_PRIVATE_LOCAL)
1126 location = LOCATION_PRIVATE_REMOTE;
1127 if (ACTIVE_EPOINT(p_epointlist)) {
1128 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_DISCONNECT);
1129 message->param.disconnectinfo.location = location;
1130 message->param.disconnectinfo.cause = cause;
1131 SCAT(message->param.disconnectinfo.display, (char *)display);
1132 message_put(message);
1134 while(INACTIVE_EPOINT(p_epointlist)) {
1135 message = message_create(p_serial, INACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1136 message->param.disconnectinfo.location = location;
1137 message->param.disconnectinfo.cause = cause;
1138 SCAT(message->param.disconnectinfo.display, (char *)display);
1139 message_put(message);
1141 free_epointid(INACTIVE_EPOINT(p_epointlist));
1143 new_state(PORT_STATE_IN_DISCONNECT);
1146 /* CC_DISCONNECT INDICATION */
1147 void Pdss1::disconnect_ind_i(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1149 int location, cause;
1152 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1153 if (p_m_d_collect_cause > 0) {
1154 add_trace("old-cause", "location", "%d", p_m_d_collect_location);
1155 add_trace("old-cause", "value", "%d", p_m_d_collect_cause);
1157 dec_ie_cause(l3m, &location, &cause);
1158 if (location == LOCATION_PRIVATE_LOCAL)
1159 location = LOCATION_PRIVATE_REMOTE;
1162 collect_cause(&p_m_d_collect_cause, &p_m_d_collect_location, cause, location);
1163 add_trace("new-cause", "location", "%d", p_m_d_collect_location);
1164 add_trace("new-cause", "value", "%d", p_m_d_collect_cause);
1169 /* CC_RELEASE INDICATION */
1170 void Pdss1::release_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1172 int location, cause;
1173 struct lcr_msg *message;
1174 unsigned char display[128] = "";
1176 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_IND, DIRECTION_IN);
1177 dec_ie_cause(l3m, &location, &cause);
1178 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1183 location = LOCATION_PRIVATE_LOCAL;
1186 /* sending release to endpoint */
1187 if (location == LOCATION_PRIVATE_LOCAL)
1188 location = LOCATION_PRIVATE_REMOTE;
1189 while(p_epointlist) {
1190 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1191 message->param.disconnectinfo.cause = cause;
1192 message->param.disconnectinfo.location = location;
1193 SCAT(message->param.disconnectinfo.display, (char *)display);
1194 message_put(message);
1196 free_epointlist(p_epointlist);
1199 new_state(PORT_STATE_RELEASE);
1203 /* CC_RESTART INDICATION */
1204 void Pdss1::restart_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1206 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESTART_IND, DIRECTION_IN);
1209 // L3 process is not toucht. (not even by network stack)
1212 /* CC_RELEASE_COMPLETE INDICATION (a reject) */
1213 void Pdss1::release_complete_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1215 int location, cause;
1216 struct lcr_msg *message;
1218 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_IND, DIRECTION_IN);
1219 /* in case layer 2 is down during setup, we send cause 27 loc 5 */
1220 if (p_state == PORT_STATE_OUT_SETUP && p_m_mISDNport->l1link == 0) {
1224 dec_ie_cause(l3m, &location, &cause);
1225 if (p_m_mISDNport->l1link < 0)
1226 add_trace("layer 1", NULL, "unknown");
1228 add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
1231 if (location == LOCATION_PRIVATE_LOCAL)
1232 location = LOCATION_PRIVATE_REMOTE;
1236 location = LOCATION_PRIVATE_LOCAL;
1239 /* sending release to endpoint */
1240 while(p_epointlist) {
1241 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1242 message->param.disconnectinfo.cause = cause;
1243 message->param.disconnectinfo.location = location;
1244 message_put(message);
1246 free_epointlist(p_epointlist);
1249 new_state(PORT_STATE_RELEASE);
1254 void Pdss1::t312_timeout_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1256 // not required, release is performed with MT_FREE
1259 /* CC_NOTIFY INDICATION */
1260 void Pdss1::notify_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1262 struct lcr_msg *message;
1263 int notify, type, plan, present;
1264 unsigned char notifyid[sizeof(message->param.notifyinfo.id)];
1265 unsigned char display[128] = "";
1267 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_IND, DIRECTION_IN);
1268 dec_ie_notify(l3m, ¬ify);
1269 dec_ie_redir_dn(l3m, &type, &plan, &present, notifyid, sizeof(notifyid));
1270 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1273 if (!ACTIVE_EPOINT(p_epointlist))
1275 /* notification indicator */
1279 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1280 message->param.notifyinfo.notify = notify;
1281 SCPY(message->param.notifyinfo.id, (char *)notifyid);
1282 /* redirection number */
1285 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
1288 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
1291 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
1296 message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT;
1299 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1302 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
1305 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1308 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1311 SCAT(message->param.notifyinfo.display, (char *)display);
1312 message->param.notifyinfo.isdn_port = p_m_portnum;
1313 message_put(message);
1317 /* CC_HOLD INDICATION */
1318 struct lcr_msg *message;
1319 void Pdss1::hold_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1321 // class Endpoint *epoint;
1323 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_IND, DIRECTION_IN);
1326 if (!ACTIVE_EPOINT(p_epointlist) || p_m_hold) {
1327 l3m = create_l3msg();
1328 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_REJECT_REQ, DIRECTION_OUT);
1329 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */
1330 add_trace("reason", NULL, "no endpoint");
1332 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_REJECT, p_m_d_l3id, l3m);
1337 /* notify the hold of call */
1338 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1339 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_HOLD;
1340 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1341 message_put(message);
1343 /* deactivate bchannel */
1344 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (hold)", DIRECTION_NONE);
1345 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1349 /* set hold state */
1352 epoint = find_epoint_id(ACTIVE_EPOINT(p_epointlist));
1353 if (epoint && p_m_d_ntmode) {
1354 p_m_timeout = p_settings.tout_hold;
1359 /* acknowledge hold */
1360 l3m = create_l3msg();
1361 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1363 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_ACKNOWLEDGE, p_m_d_l3id, l3m);
1367 /* CC_RETRIEVE INDICATION */
1368 void Pdss1::retrieve_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1370 struct lcr_msg *message;
1371 int channel, exclusive, cause;
1374 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_IND, DIRECTION_IN);
1375 dec_ie_channel_id(l3m, &exclusive, &channel);
1379 cause = 101; /* incompatible state */
1382 l3m = create_l3msg();
1383 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_REJECT_REQ, DIRECTION_OUT);
1384 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, cause);
1386 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_REJECT, p_m_d_l3id, l3m);
1391 /* notify the retrieve of call */
1392 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1393 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL;
1394 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1395 message_put(message);
1398 ret = channel = hunt_bchannel(channel, exclusive);
1403 ret = seize_bchannel(channel, 1);
1409 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1411 /* set hold state */
1415 /* acknowledge retrieve */
1416 l3m = create_l3msg();
1417 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1418 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1420 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_ACKNOWLEDGE, p_m_d_l3id, l3m);
1423 /* CC_SUSPEND INDICATION */
1424 void Pdss1::suspend_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1426 struct lcr_msg *message;
1427 class Endpoint *epoint;
1428 unsigned char callid[8];
1430 int ret = -31; /* normal, unspecified */
1432 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_IND, DIRECTION_IN);
1433 dec_ie_call_id(l3m, callid, &len);
1436 if (!ACTIVE_EPOINT(p_epointlist)) {
1438 l3m = create_l3msg();
1439 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_REJECT_REQ, DIRECTION_OUT);
1440 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1442 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_REJECT, p_m_d_l3id, l3m);
1449 /* check if call id is in use */
1450 epoint = epoint_first;
1452 if (epoint->ep_park) {
1453 if (epoint->ep_park_len == len)
1454 if (!memcmp(epoint->ep_park_callid, callid, len)) {
1455 ret = -84; /* call id in use */
1459 epoint = epoint->next;
1462 /* notify the hold of call */
1463 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1464 message->param.notifyinfo.notify = INFO_NOTIFY_USER_SUSPENDED;
1465 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1466 message_put(message);
1468 /* deactivate bchannel */
1469 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (suspend)", DIRECTION_NONE);
1470 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1474 /* sending suspend to endpoint */
1475 while (p_epointlist) {
1476 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_SUSPEND);
1477 memcpy(message->param.parkinfo.callid, callid, sizeof(message->param.parkinfo.callid));
1478 message->param.parkinfo.len = len;
1479 message_put(message);
1481 free_epointlist(p_epointlist);
1484 /* sending SUSPEND_ACKNOWLEDGE */
1485 l3m = create_l3msg();
1486 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1488 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_ACKNOWLEDGE, p_m_d_l3id, l3m);
1490 new_state(PORT_STATE_RELEASE);
1494 /* CC_RESUME INDICATION */
1495 void Pdss1::resume_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1497 unsigned char callid[8];
1499 int channel, exclusive;
1500 class Endpoint *epoint;
1501 struct lcr_msg *message;
1504 /* process given callref */
1505 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
1506 add_trace("callref", "new", "0x%x", pid);
1508 /* release is case the ID is already in use */
1509 add_trace("error", NULL, "callref already in use");
1511 l3m = create_l3msg();
1512 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1513 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
1514 add_trace("reason", NULL, "callref already in use");
1516 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, pid, l3m);
1517 new_state(PORT_STATE_RELEASE);
1522 p_m_d_ces = pid >> 16;
1525 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_IND, DIRECTION_IN);
1526 dec_ie_call_id(l3m, callid, &len);
1529 /* if blocked, release call */
1530 if (p_m_mISDNport->ifport->block) {
1538 /* channel_id (no channel is possible in message) */
1540 channel = -1; /* any channel */
1543 ret = channel = hunt_bchannel(channel, exclusive);
1547 // mode (if hdlc parked) to be done. never mind, this is almost never requested
1549 ret = seize_bchannel(channel, 1);
1553 l3m = create_l3msg();
1554 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1555 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1557 add_trace("reason", NULL, "port blocked");
1559 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, p_m_d_l3id, l3m);
1560 new_state(PORT_STATE_RELEASE);
1564 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1566 /* create endpoint */
1568 FATAL("Incoming resume but already got an endpoint.\n");
1569 ret = -85; /* no call suspended */
1570 epoint = epoint_first;
1572 if (epoint->ep_park) {
1573 ret = -83; /* suspended call exists, but this not */
1574 if (epoint->ep_park_len == len)
1575 if (!memcmp(epoint->ep_park_callid, callid, len))
1578 epoint = epoint->next;
1583 epointlist_new(epoint->ep_serial);
1584 if (!(epoint->portlist_new(p_serial, p_type, p_m_mISDNport->earlyb)))
1585 FATAL("No memory for portlist\n");
1586 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RESUME);
1587 message_put(message);
1589 /* notify the resume of call */
1590 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1591 message->param.notifyinfo.notify = INFO_NOTIFY_USER_RESUMED;
1592 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1593 message_put(message);
1595 /* sending RESUME_ACKNOWLEDGE */
1596 l3m = create_l3msg();
1597 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1598 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1600 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_ACKNOWLEDGE, p_m_d_l3id, l3m);
1602 new_state(PORT_STATE_CONNECT);
1606 /* CC_FACILITY INDICATION */
1607 void Pdss1::facility_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1609 unsigned char facil[256];
1611 struct lcr_msg *message;
1613 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_IND, DIRECTION_IN);
1614 dec_ie_facility(l3m, facil, &facil_len);
1621 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_FACILITY);
1622 message->param.facilityinfo.len = facil_len;
1623 memcpy(message->param.facilityinfo.data, facil, facil_len);
1624 message_put(message);
1628 /* CC_PROGRESS INDICATION */
1629 void Pdss1::progress_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1631 int coding, location, progress;
1633 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROGRESS_IND, DIRECTION_IN);
1634 dec_ie_progress(l3m, &coding, &location, &progress);
1640 * handler for isdn connections
1641 * incoming information are parsed and sent via message to the endpoint
1643 void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1650 PERROR("Pdss1(%s) timeout without cause.\n", p_name);
1653 if (l3m->cause[0] != 5) {
1654 PERROR("Pdss1(%s) expecting timeout with timer diagnostic. (got len=%d)\n", p_name, l3m->cause[0]);
1657 timer = (l3m->cause[3]-'0')*100;
1658 timer += (l3m->cause[4]-'0')*10;
1659 timer += (l3m->cause[5]-'0');
1660 l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN);
1661 add_trace("timer", NULL, "%d", timer);
1664 t312_timeout_ind(cmd, pid, l3m);
1668 if (p_state != PORT_STATE_IDLE)
1670 setup_ind(cmd, pid, l3m);
1673 case MT_INFORMATION:
1674 information_ind(cmd, pid, l3m);
1677 case MT_SETUP_ACKNOWLEDGE:
1678 if (p_state != PORT_STATE_OUT_SETUP) {
1679 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received setup_acknowledge, but we are not in outgoing setup state, IGNORING.\n", p_name);
1682 setup_acknowledge_ind(cmd, pid, l3m);
1685 case MT_CALL_PROCEEDING:
1686 if (p_state != PORT_STATE_OUT_SETUP
1687 && p_state != PORT_STATE_OUT_OVERLAP) {
1688 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received proceeding, but we are not in outgoing setup OR overlap state, IGNORING.\n", p_name);
1691 proceeding_ind(cmd, pid, l3m);
1695 if (p_state != PORT_STATE_OUT_SETUP
1696 && p_state != PORT_STATE_OUT_OVERLAP
1697 && p_state != PORT_STATE_OUT_PROCEEDING) {
1698 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding state, IGNORING.\n", p_name);
1701 alerting_ind(cmd, pid, l3m);
1705 if (p_state != PORT_STATE_OUT_SETUP
1706 && p_state != PORT_STATE_OUT_OVERLAP
1707 && p_state != PORT_STATE_OUT_PROCEEDING
1708 && p_state != PORT_STATE_OUT_ALERTING) {
1709 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding OR ALERTING state, IGNORING.\n", p_name);
1712 connect_ind(cmd, pid, l3m);
1713 if (p_m_d_notify_pending) {
1714 /* send pending notify message during connect */
1715 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1716 message_free(p_m_d_notify_pending);
1717 p_m_d_notify_pending = NULL;
1721 case MT_CONNECT_ACKNOWLEDGE:
1722 if (p_state == PORT_STATE_CONNECT_WAITING)
1723 new_state(PORT_STATE_CONNECT);
1724 if (p_m_d_notify_pending) {
1725 /* send pending notify message during connect-ack */
1726 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1727 message_free(p_m_d_notify_pending);
1728 p_m_d_notify_pending = NULL;
1733 disconnect_ind(cmd, pid, l3m);
1737 release_ind(cmd, pid, l3m);
1740 case MT_RELEASE_COMPLETE:
1741 release_complete_ind(cmd, pid, l3m);
1745 restart_ind(cmd, pid, l3m);
1749 notify_ind(cmd, pid, l3m);
1753 hold_ind(cmd, pid, l3m);
1757 retrieve_ind(cmd, pid, l3m);
1761 suspend_ind(cmd, pid, l3m);
1765 resume_ind(cmd, pid, l3m);
1769 facility_ind(cmd, pid, l3m);
1773 progress_ind(cmd, pid, l3m);
1777 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_L3ID_IND, DIRECTION_IN);
1778 add_trace("callref", NULL, "0x%x", p_m_d_l3id);
1783 /* sending release to endpoint in case we still have an endpoint
1784 * this is because we don't get any response if a release_complete is received (or a release in release state)
1786 while(p_epointlist) { // only if not already released
1787 struct lcr_msg *message;
1788 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1789 if (p_m_d_collect_cause) {
1790 message->param.disconnectinfo.cause = p_m_d_collect_cause;
1791 message->param.disconnectinfo.location = p_m_d_collect_location;
1793 message->param.disconnectinfo.cause = CAUSE_NOUSER;
1794 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1796 message_put(message);
1798 free_epointlist(p_epointlist);
1800 new_state(PORT_STATE_RELEASE);
1805 l1l2l3_trace_header(p_m_mISDNport, this, L3_UNKNOWN_IND, DIRECTION_IN);
1806 add_trace("unhandled", "cmd", "0x%x", cmd);
1811 void Pdss1::new_state(int state)
1813 // class Endpoint *epoint;
1816 if (state == PORT_STATE_IN_OVERLAP) {
1817 p_m_timeout = p_m_mISDNport->ifport->tout_dialing;
1820 if (state != p_state) {
1821 if (state == PORT_STATE_IN_SETUP
1822 || state == PORT_STATE_OUT_SETUP
1823 || state == PORT_STATE_IN_OVERLAP
1824 || state == PORT_STATE_OUT_OVERLAP) {
1825 p_m_timeout = p_m_mISDNport->ifport->tout_setup;
1828 if (state == PORT_STATE_IN_PROCEEDING
1829 || state == PORT_STATE_OUT_PROCEEDING) {
1830 p_m_timeout = p_m_mISDNport->ifport->tout_proceeding;
1833 if (state == PORT_STATE_IN_ALERTING
1834 || state == PORT_STATE_OUT_ALERTING) {
1835 p_m_timeout = p_m_mISDNport->ifport->tout_alerting;
1838 if (state == PORT_STATE_CONNECT
1839 || state == PORT_STATE_CONNECT_WAITING) {
1842 if (state == PORT_STATE_IN_DISCONNECT
1843 || state == PORT_STATE_OUT_DISCONNECT) {
1844 p_m_timeout = p_m_mISDNport->ifport->tout_disconnect;
1849 Port::new_state(state);
1856 int Pdss1::handler(void)
1860 if ((ret = PmISDN::handler()))
1863 /* handle destruction */
1864 if (p_m_delete && p_m_d_l3id==0) {
1874 * handles all messages from endpoint
1876 /* MESSAGE_INFORMATION */
1877 void Pdss1::message_information(unsigned int epoint_id, int message_id, union parameter *param)
1880 char *display = param->information.display;
1881 char *number = param->information.id;
1882 int max = p_m_mISDNport->ifport->dialmax;
1884 while (number[0]) { /* as long we have something to dial */
1885 if (max > (int)strlen(number) || max == 0)
1886 max = (int)strlen(number);
1888 l3m = create_l3msg();
1889 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1890 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)number, max);
1891 if ((p_m_d_ntmode || p_m_d_tespecial) && display[0]) {
1892 enc_ie_display(l3m, (unsigned char *)display);
1893 display = (char *)"";
1896 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1904 void Pdss1::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
1908 int plan, type, screen, present, reason;
1909 int plan2, type2, screen2, present2;
1910 int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
1911 int channel, exclusive;
1912 struct epoint_list *epointlist;
1913 int max = p_m_mISDNport->ifport->dialmax;
1915 /* release if port is blocked */
1916 if (p_m_mISDNport->ifport->block) {
1917 struct lcr_msg *message;
1919 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1920 message->param.disconnectinfo.cause = 27; // temp. unavail.
1921 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1922 message_put(message);
1923 new_state(PORT_STATE_RELEASE);
1928 /* copy setup infos to port */
1929 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
1930 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
1931 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
1932 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
1933 /* screen outgoing caller id */
1934 do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_m_mISDNport->ifport->interface);
1935 do_screen(1, p_callerinfo.id2, sizeof(p_callerinfo.id2), &p_callerinfo.ntype2, &p_callerinfo.present2, p_m_mISDNport->ifport->interface);
1937 /* only display at connect state: this case happens if endpoint is in connected mode */
1938 if (p_state==PORT_STATE_CONNECT) {
1939 if (p_type!=PORT_TYPE_DSS1_NT_OUT
1940 && p_type!=PORT_TYPE_DSS1_NT_IN)
1942 if (p_callerinfo.display[0]) {
1943 /* sending information */
1944 l3m = create_l3msg();
1945 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1946 if (p_m_d_ntmode || p_m_d_tespecial)
1947 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
1949 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1954 /* attach only if not already */
1955 epointlist = p_epointlist;
1957 if (epointlist->epoint_id == epoint_id)
1959 epointlist = epointlist->next;
1962 epointlist_new(epoint_id);
1966 if (p_m_b_channel) {
1967 channel = p_m_b_channel;
1968 exclusive = p_m_b_exclusive;
1970 channel = CHANNEL_ANY;
1971 /* nt-port with no channel, not reserverd */
1972 if (!p_m_b_channel && !p_m_b_reserve && p_type==PORT_TYPE_DSS1_NT_OUT)
1973 channel = CHANNEL_NO;
1976 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT);
1977 /* see MT_ASSIGN notes at do_layer3() */
1979 ret = p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ASSIGN, 0, NULL);
1980 if (mt_assign_pid == 0 || ret < 0) {
1981 struct lcr_msg *message;
1983 add_trace("callref", NULL, "no free id");
1985 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1986 message->param.disconnectinfo.cause = 47;
1987 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1988 message_put(message);
1989 new_state(PORT_STATE_RELEASE);
1993 p_m_d_l3id = mt_assign_pid;
1995 add_trace("callref", "new", "0x%x", p_m_d_l3id);
1998 /* preparing setup message */
1999 l3m = create_l3msg();
2000 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_REQ, DIRECTION_OUT);
2001 /* channel information */
2002 if (channel >= 0) /* it should */
2003 enc_ie_channel_id(l3m, exclusive, channel);
2004 /* caller information */
2006 switch (p_callerinfo.ntype) {
2007 case INFO_NTYPE_UNKNOWN:
2010 case INFO_NTYPE_INTERNATIONAL:
2013 case INFO_NTYPE_NATIONAL:
2016 case INFO_NTYPE_SUBSCRIBER:
2019 default: /* INFO_NTYPE_NOTPRESENT */
2023 switch (p_callerinfo.screen) {
2024 case INFO_SCREEN_USER:
2027 case INFO_SCREEN_USER_VERIFIED_PASSED:
2030 case INFO_SCREEN_USER_VERIFIED_FAILED:
2033 default: /* INFO_SCREEN_NETWORK */
2037 switch (p_callerinfo.present) {
2038 case INFO_PRESENT_ALLOWED:
2041 case INFO_PRESENT_RESTRICTED:
2044 default: /* INFO_PRESENT_NOTAVAIL */
2048 /* caller information 2 */
2050 switch (p_callerinfo.ntype2) {
2051 case INFO_NTYPE_UNKNOWN:
2054 case INFO_NTYPE_INTERNATIONAL:
2057 case INFO_NTYPE_NATIONAL:
2060 case INFO_NTYPE_SUBSCRIBER:
2063 default: /* INFO_NTYPE_NOTPRESENT */
2067 switch (p_callerinfo.screen2) {
2068 case INFO_SCREEN_USER:
2071 case INFO_SCREEN_USER_VERIFIED_PASSED:
2074 case INFO_SCREEN_USER_VERIFIED_FAILED:
2077 default: /* INFO_SCREEN_NETWORK */
2081 switch (p_callerinfo.present2) {
2082 case INFO_PRESENT_ALLOWED:
2085 case INFO_PRESENT_RESTRICTED:
2088 default: /* INFO_PRESENT_NOTAVAIL */
2093 enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id, type2, plan2, present2, screen2, (unsigned char *)p_callerinfo.id2);
2094 /* dialing information */
2095 if (p_dialinginfo.id[0]) { /* only if we have something to dial */
2096 if (max > (int)strlen(p_dialinginfo.id) || max == 0)
2097 max = (int)strlen(p_dialinginfo.id);
2098 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id, max);
2099 SCPY(p_m_d_queue, p_dialinginfo.id + max);
2101 /* sending complete */
2102 if (p_dialinginfo.sending_complete)
2103 enc_ie_complete(l3m, 1);
2104 /* sending user-user */
2105 if (param->setup.useruser.len) {
2106 enc_ie_useruser(l3m, param->setup.useruser.protocol, param->setup.useruser.data, param->setup.useruser.len);
2108 /* redirecting number */
2110 switch (p_redirinfo.ntype) {
2111 case INFO_NTYPE_UNKNOWN:
2114 case INFO_NTYPE_INTERNATIONAL:
2117 case INFO_NTYPE_NATIONAL:
2120 case INFO_NTYPE_SUBSCRIBER:
2123 default: /* INFO_NTYPE_NOTPRESENT */
2127 switch (p_redirinfo.screen) {
2128 case INFO_SCREEN_USER:
2131 case INFO_SCREEN_USER_VERIFIED_PASSED:
2134 case INFO_SCREEN_USER_VERIFIED_FAILED:
2137 default: /* INFO_SCREE_NETWORK */
2141 switch (p_redirinfo.reason) {
2142 case INFO_REDIR_BUSY:
2145 case INFO_REDIR_NORESPONSE:
2148 case INFO_REDIR_UNCONDITIONAL:
2151 case INFO_REDIR_CALLDEFLECT:
2154 case INFO_REDIR_OUTOFORDER:
2157 default: /* INFO_REDIR_UNKNOWN */
2161 switch (p_redirinfo.present) {
2162 case INFO_PRESENT_ALLOWED:
2165 case INFO_PRESENT_RESTRICTED:
2168 default: /* INFO_PRESENT_NOTAVAIL */
2172 /* sending redirecting number only in ntmode */
2173 if (type >= 0 && (p_m_d_ntmode || p_m_d_tespecial))
2174 enc_ie_redir_nr(l3m, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
2175 /* bearer capability */
2176 //printf("hlc=%d\n",p_capainfo.hlc);
2178 capability = p_capainfo.bearer_capa;
2179 mode = p_capainfo.bearer_mode;
2180 rate = (mode==INFO_BMODE_CIRCUIT)?0x10:0x00;
2181 switch (p_capainfo.bearer_info1) {
2182 case INFO_INFO1_NONE:
2186 user = p_capainfo.bearer_info1 & 0x7f;
2189 enc_ie_bearer(l3m, coding, capability, mode, rate, -1, user);
2191 if (p_capainfo.hlc) {
2195 hlc = p_capainfo.hlc & 0x7f;
2197 if (p_capainfo.exthlc)
2198 exthlc = p_capainfo.exthlc & 0x7f;
2199 enc_ie_hlc(l3m, coding, interpretation, presentation, hlc, exthlc);
2203 if (p_callerinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2204 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
2205 /* nt-mode: CNIP (calling name identification presentation) */
2206 // if (p_callerinfo.name[0] && (p_m_d_ntmode || p_m_d_tespecial))
2207 // enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
2210 /* send setup message now */
2211 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP, p_m_d_l3id, l3m);
2213 new_state(PORT_STATE_OUT_SETUP);
2216 /* MESSAGE_FACILITY */
2217 void Pdss1::message_facility(unsigned int epoint_id, int message_id, union parameter *param)
2221 /* facility will not be sent to external lines */
2222 if (!p_m_d_ntmode && !p_m_d_tespecial)
2225 /* sending facility */
2226 l3m = create_l3msg();
2227 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
2228 enc_ie_facility(l3m, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len);
2230 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
2233 /* MESSAGE_NOTIFY */
2234 void Pdss1::message_notify(unsigned int epoint_id, int message_id, union parameter *param)
2238 int plan = 0, type = -1, present = 0;
2240 // printf("if = %d\n", param->notifyinfo.notify);
2241 if (param->notifyinfo.notify>INFO_NOTIFY_NONE)
2242 notify = param->notifyinfo.notify & 0x7f;
2247 switch (param->notifyinfo.ntype) {
2248 case INFO_NTYPE_UNKNOWN:
2251 case INFO_NTYPE_INTERNATIONAL:
2254 case INFO_NTYPE_NATIONAL:
2257 case INFO_NTYPE_SUBSCRIBER:
2260 default: /* INFO_NTYPE_UNKNOWN */
2264 switch (param->notifyinfo.present) {
2265 case INFO_PRESENT_ALLOWED:
2268 case INFO_PRESENT_RESTRICTED:
2271 default: /* INFO_PRESENT_NOTAVAIL */
2277 if (notify<0 && !param->notifyinfo.display[0]) {
2278 /* nothing to notify, nothing to display */
2283 if (p_state!=PORT_STATE_CONNECT && p_state!=PORT_STATE_IN_PROCEEDING && p_state!=PORT_STATE_IN_ALERTING) {
2284 /* queue notification */
2285 if (p_m_d_notify_pending)
2286 message_free(p_m_d_notify_pending);
2287 p_m_d_notify_pending = message_create(ACTIVE_EPOINT(p_epointlist), p_serial, EPOINT_TO_PORT, message_id);
2288 memcpy(&p_m_d_notify_pending->param, param, sizeof(union parameter));
2290 /* sending notification */
2291 l3m = create_l3msg();
2292 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
2293 enc_ie_notify(l3m, notify);
2294 /* sending redirection number only in ntmode */
2295 if (type >= 0 && (p_m_d_ntmode || p_m_d_tespecial))
2296 enc_ie_redir_dn(l3m, type, plan, present, (unsigned char *)param->notifyinfo.id);
2297 if (param->notifyinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2298 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2300 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_NOTIFY, p_m_d_l3id, l3m);
2302 } else if (p_m_d_ntmode || p_m_d_tespecial) {
2303 /* sending information */
2304 l3m = create_l3msg();
2305 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2306 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2308 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2312 /* MESSAGE_OVERLAP */
2313 void Pdss1::message_overlap(unsigned int epoint_id, int message_id, union parameter *param)
2317 /* in case of sending complete, we proceed */
2318 if (p_dialinginfo.sending_complete) {
2319 PDEBUG(DEBUG_ISDN, "sending proceeding instead of setup_acknowledge, because address is complete.\n");
2320 message_proceeding(epoint_id, message_id, param);
2324 /* sending setup_acknowledge */
2325 l3m = create_l3msg();
2326 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_REQ, DIRECTION_OUT);
2327 /* channel information */
2328 if (p_state == PORT_STATE_IN_SETUP)
2329 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2330 /* progress information */
2331 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2332 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2333 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2334 if (p_m_mISDNport->tones)
2335 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2337 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, l3m);
2339 new_state(PORT_STATE_IN_OVERLAP);
2342 /* MESSAGE_PROCEEDING */
2343 void Pdss1::message_proceeding(unsigned int epoint_id, int message_id, union parameter *param)
2347 /* sending proceeding */
2348 l3m = create_l3msg();
2349 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2350 /* channel information */
2351 if (p_state == PORT_STATE_IN_SETUP)
2352 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2353 /* progress information */
2354 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2355 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2356 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2357 if (p_m_mISDNport->tones)
2358 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2360 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2362 new_state(PORT_STATE_IN_PROCEEDING);
2365 /* MESSAGE_ALERTING */
2366 void Pdss1::message_alerting(unsigned int epoint_id, int message_id, union parameter *param)
2370 /* NT-MODE in setup state we must send PROCEEDING first */
2371 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP) {
2372 /* sending proceeding */
2373 l3m = create_l3msg();
2374 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2375 /* channel information */
2376 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2377 /* progress information */
2378 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2379 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2380 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2381 if (p_m_mISDNport->tones)
2382 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2384 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2385 new_state(PORT_STATE_IN_PROCEEDING);
2388 /* sending alerting */
2389 l3m = create_l3msg();
2390 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_REQ, DIRECTION_OUT);
2391 /* channel information */
2392 if (p_state == PORT_STATE_IN_SETUP)
2393 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2394 /* progress information */
2395 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2396 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2397 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2398 if (p_m_mISDNport->tones)
2399 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2401 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ALERTING, p_m_d_l3id, l3m);
2403 new_state(PORT_STATE_IN_ALERTING);
2406 /* MESSAGE_CONNECT */
2407 void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parameter *param)
2410 int type, plan, present, screen;
2411 class Endpoint *epoint;
2413 /* NT-MODE in setup state we must send PROCEEDING first */
2414 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP) {
2415 /* sending proceeding */
2416 l3m = create_l3msg();
2417 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2418 /* channel information */
2419 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2421 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2422 new_state(PORT_STATE_IN_PROCEEDING);
2425 /* copy connected information */
2426 memcpy(&p_connectinfo, ¶m->connectinfo, sizeof(p_connectinfo));
2427 /* screen outgoing caller id */
2428 do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface);
2430 /* only display at connect state */
2431 if (p_state == PORT_STATE_CONNECT)
2432 if (p_connectinfo.display[0]) {
2433 /* sending information */
2434 l3m = create_l3msg();
2435 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2436 if (p_m_d_ntmode || p_m_d_tespecial)
2437 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2439 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2443 if (p_state!=PORT_STATE_IN_SETUP && p_state!=PORT_STATE_IN_OVERLAP && p_state!=PORT_STATE_IN_PROCEEDING && p_state!=PORT_STATE_IN_ALERTING) {
2444 /* connect command only possible in setup, proceeding or alerting state */
2448 /* preparing connect message */
2449 l3m = create_l3msg();
2450 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_REQ, DIRECTION_OUT);
2451 /* connect information */
2453 switch (p_connectinfo.ntype) {
2454 case INFO_NTYPE_UNKNOWN:
2457 case INFO_NTYPE_INTERNATIONAL:
2460 case INFO_NTYPE_NATIONAL:
2463 case INFO_NTYPE_SUBSCRIBER:
2466 default: /* INFO_NTYPE_NOTPRESENT */
2470 switch (param->connectinfo.screen) {
2471 case INFO_SCREEN_USER:
2474 case INFO_SCREEN_USER_VERIFIED_PASSED:
2477 case INFO_SCREEN_USER_VERIFIED_FAILED:
2480 default: /* INFO_SCREE_NETWORK */
2484 switch (p_connectinfo.present) {
2485 case INFO_PRESENT_ALLOWED:
2488 case INFO_PRESENT_RESTRICTED:
2491 default: /* INFO_PRESENT_NOTAVAIL */
2496 enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
2498 if (p_connectinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2499 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2500 /* nt-mode: CONP (connected name identification presentation) */
2501 // if (p_connectinfo.name[0] && (p_m_d_ntmode || p_m_d_tespecial))
2502 // enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
2504 if (p_m_d_ntmode || p_m_d_tespecial) {
2505 epoint = find_epoint_id(epoint_id);
2506 enc_ie_date(l3m, now, p_settings.no_seconds);
2509 /* finally send message */
2510 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT, p_m_d_l3id, l3m);
2513 new_state(PORT_STATE_CONNECT);
2515 new_state(PORT_STATE_CONNECT_WAITING);
2519 /* MESSAGE_DISCONNECT */
2520 void Pdss1::message_disconnect(unsigned int epoint_id, int message_id, union parameter *param)
2523 struct lcr_msg *message;
2526 /* we reject during incoming setup when we have no tones. also if we are in outgoing setup state */
2527 // if ((p_state==PORT_STATE_IN_SETUP && !p_m_mISDNport->tones)
2528 if (/* ||*/ p_state==PORT_STATE_OUT_SETUP) {
2529 /* sending release to endpoint */
2530 while(p_epointlist) {
2531 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
2532 memcpy(&message->param, param, sizeof(union parameter));
2533 message_put(message);
2535 free_epointlist(p_epointlist);
2537 /* sending release */
2538 l3m = create_l3msg();
2539 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
2541 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2543 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2544 new_state(PORT_STATE_RELEASE);
2549 /* workarround: NT-MODE in setup state we must send PROCEEDING first to make it work */
2550 if (p_state==PORT_STATE_IN_SETUP) {
2551 /* sending proceeding */
2552 l3m = create_l3msg();
2553 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2554 /* channel information */
2555 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2556 /* progress information */
2557 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2558 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2559 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2560 if (p_m_mISDNport->tones)
2561 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2563 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2564 new_state(PORT_STATE_IN_PROCEEDING);
2567 /* sending disconnect */
2568 l3m = create_l3msg();
2569 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2570 /* progress information */
2571 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2572 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2573 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2574 if (p_m_mISDNport->tones)
2575 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2577 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2579 if (param->disconnectinfo.display[0])
2580 p = param->disconnectinfo.display;
2581 if (p) if (*p && (p_m_d_ntmode || p_m_d_tespecial))
2582 enc_ie_display(l3m, (unsigned char *)p);
2584 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2585 new_state(PORT_STATE_OUT_DISCONNECT);
2588 /* MESSAGE_RELEASE */
2589 void Pdss1::message_release(unsigned int epoint_id, int message_id, union parameter *param)
2592 class Endpoint *epoint;
2596 * we may only release during incoming disconnect state.
2597 * this means that the endpoint doesnt require audio anymore
2599 if (p_state == PORT_STATE_IN_DISCONNECT
2600 || p_state == PORT_STATE_OUT_DISCONNECT) {
2601 /* sending release */
2602 l3m = create_l3msg();
2603 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2605 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2607 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
2608 new_state(PORT_STATE_RELEASE);
2610 free_epointid(epoint_id);
2611 // wait for callref to be released
2616 * if we are on incoming call setup, we may reject by sending a release_complete
2617 * also on outgoing call setup, we send a release complete, BUT this is not conform. (i don't know any other way)
2619 if (p_state==PORT_STATE_IN_SETUP
2620 || p_state==PORT_STATE_OUT_SETUP) {
2621 //#warning remove me
2622 //PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
2623 /* sending release complete */
2624 l3m = create_l3msg();
2625 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2627 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2629 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2630 new_state(PORT_STATE_RELEASE);
2632 free_epointid(epoint_id);
2633 // wait for callref to be released
2638 wirklich erst proceeding?:
2639 /* NT-MODE in setup state we must send PROCEEDING first */
2640 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP) {
2641 CALL_PROCEEDING_t *proceeding;
2643 /* sending proceeding */
2644 l3m = create_l3msg();
2645 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2646 /* channel information */
2647 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2648 /* progress information */
2649 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2650 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2651 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2652 if (p_m_mISDNport->tones)
2653 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2655 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2659 /* sending disconnect */
2660 l3m = create_l3msg();
2661 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2662 /* progress information */
2663 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2664 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2665 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2666 if (p_m_mISDNport->tones)
2667 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2669 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2671 epoint = find_epoint_id(epoint_id);
2672 if (param->disconnectinfo.display[0])
2673 p = param->disconnectinfo.display;
2674 if (p) if (*p && (p_m_d_ntmode || p_m_d_tespecial))
2675 enc_ie_display(l3m, (unsigned char *)p);
2677 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2678 new_state(PORT_STATE_OUT_DISCONNECT);
2680 free_epointid(epoint_id);
2681 // wait for release and callref to be released
2682 //#warning remove me
2683 //PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
2688 * endpoint sends messages to the port
2690 int Pdss1::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
2692 if (PmISDN::message_epoint(epoint_id, message_id, param))
2695 switch(message_id) {
2696 case MESSAGE_INFORMATION: /* overlap dialing */
2697 if (p_type==PORT_TYPE_DSS1_NT_OUT
2698 && p_state!=PORT_STATE_OUT_OVERLAP
2699 && p_state!=PORT_STATE_CONNECT
2700 && p_state!=PORT_STATE_OUT_DISCONNECT
2701 && p_state!=PORT_STATE_IN_DISCONNECT) {
2704 if (p_type==PORT_TYPE_DSS1_TE_OUT
2705 && p_state!=PORT_STATE_OUT_OVERLAP
2706 && p_state!=PORT_STATE_OUT_PROCEEDING
2707 && p_state!=PORT_STATE_OUT_ALERTING
2708 && p_state!=PORT_STATE_CONNECT
2709 && p_state!=PORT_STATE_OUT_DISCONNECT
2710 && p_state!=PORT_STATE_IN_DISCONNECT) {
2713 if ((p_type==PORT_TYPE_DSS1_NT_IN || p_type==PORT_TYPE_DSS1_TE_IN)
2714 && p_state!=PORT_STATE_IN_OVERLAP
2715 && p_state!=PORT_STATE_IN_PROCEEDING
2716 && p_state!=PORT_STATE_IN_ALERTING
2717 && p_state!=PORT_STATE_CONNECT
2718 && p_state!=PORT_STATE_CONNECT_WAITING
2719 && p_state!=PORT_STATE_OUT_DISCONNECT
2720 && p_state!=PORT_STATE_IN_DISCONNECT) {
2723 message_information(epoint_id, message_id, param);
2726 case MESSAGE_SETUP: /* dial-out command received from epoint */
2727 if (p_state!=PORT_STATE_IDLE
2728 && p_state!=PORT_STATE_CONNECT) {
2729 PERROR("Pdss1(%s) ignoring setup because isdn port is not in idle state (or connected for sending display info).\n", p_name);
2732 if (p_epointlist && p_state==PORT_STATE_IDLE)
2733 FATAL("Pdss1(%s): epoint pointer is set in idle state, how bad!!\n", p_name);
2734 message_setup(epoint_id, message_id, param);
2737 case MESSAGE_NOTIFY: /* display and notifications */
2738 message_notify(epoint_id, message_id, param);
2741 case MESSAGE_FACILITY: /* facility message */
2742 message_facility(epoint_id, message_id, param);
2745 case MESSAGE_OVERLAP: /* more information is needed */
2746 if (p_state!=PORT_STATE_IN_SETUP) {
2749 message_overlap(epoint_id, message_id, param);
2752 case MESSAGE_PROCEEDING: /* call of endpoint is proceeding */
2753 if (p_state!=PORT_STATE_IN_SETUP
2754 && p_state!=PORT_STATE_IN_OVERLAP) {
2757 message_proceeding(epoint_id, message_id, param);
2758 if (p_m_d_notify_pending) {
2759 /* send pending notify message during connect */
2760 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
2761 message_free(p_m_d_notify_pending);
2762 p_m_d_notify_pending = NULL;
2766 case MESSAGE_ALERTING: /* call of endpoint is ringing */
2767 if (p_state!=PORT_STATE_IN_SETUP
2768 && p_state!=PORT_STATE_IN_OVERLAP
2769 && p_state!=PORT_STATE_IN_PROCEEDING) {
2772 message_alerting(epoint_id, message_id, param);
2773 if (p_m_d_notify_pending) {
2774 /* send pending notify message during connect */
2775 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
2776 message_free(p_m_d_notify_pending);
2777 p_m_d_notify_pending = NULL;
2781 case MESSAGE_CONNECT: /* call of endpoint is connected */
2782 if (p_state!=PORT_STATE_IN_SETUP
2783 && p_state!=PORT_STATE_IN_OVERLAP
2784 && p_state!=PORT_STATE_IN_PROCEEDING
2785 && p_state!=PORT_STATE_IN_ALERTING
2786 && !(p_state==PORT_STATE_CONNECT && p_m_d_ntmode)) {
2789 message_connect(epoint_id, message_id, param);
2790 if (p_m_d_notify_pending) {
2791 /* send pending notify message during connect */
2792 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
2793 message_free(p_m_d_notify_pending);
2794 p_m_d_notify_pending = NULL;
2798 case MESSAGE_DISCONNECT: /* call has been disconnected */
2799 if (p_state!=PORT_STATE_IN_SETUP
2800 && p_state!=PORT_STATE_IN_OVERLAP
2801 && p_state!=PORT_STATE_IN_PROCEEDING
2802 && p_state!=PORT_STATE_IN_ALERTING
2803 && p_state!=PORT_STATE_OUT_SETUP
2804 && p_state!=PORT_STATE_OUT_OVERLAP
2805 && p_state!=PORT_STATE_OUT_PROCEEDING
2806 && p_state!=PORT_STATE_OUT_ALERTING
2807 && p_state!=PORT_STATE_CONNECT
2808 && p_state!=PORT_STATE_CONNECT_WAITING) {
2811 message_disconnect(epoint_id, message_id, param);
2814 case MESSAGE_RELEASE: /* release isdn port */
2815 if (p_state==PORT_STATE_RELEASE) {
2818 message_release(epoint_id, message_id, param);
2822 PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message_id);
2831 * data from isdn-stack (layer-3) to pbx (port class)
2833 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
2839 PDEBUG(DEBUG_ISDN, "cmd(0x%x) pid(0x%x)\n", cmd, pid);
2842 PDEBUG(DEBUG_ISDN, "ignoring dummy process from phone.\n");
2846 /* find Port object of type ISDN */
2850 if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1) {
2851 pdss1 = (class Pdss1 *)port;
2852 /* check out correct stack and id */
2853 if (pdss1->p_m_mISDNport == mISDNport) {
2854 if (pdss1->p_m_d_l3id & MISDN_PID_CR_FLAG) {
2855 /* local callref, so match value only */
2856 if ((pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == (pid & MISDN_PID_CRVAL_MASK))
2859 /* remote callref, ref + channel id */
2860 if (pdss1->p_m_d_l3id == pid)
2868 /* aktueller prozess */
2870 if (cmd == MT_ASSIGN) {
2871 /* stack gives us new layer 3 id (during connect) */
2872 l1l2l3_trace_header(mISDNport, pdss1, L3_NEW_L3ID_IND, DIRECTION_IN);
2873 add_trace("callref", "old", "0x%x", pdss1->p_m_d_l3id);
2874 /* nt-library now gives us a new id via CC_SETUP_CONFIRM */
2875 if ((pdss1->p_m_d_l3id&MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER)
2876 PERROR(" strange setup-procid 0x%x\n", pdss1->p_m_d_l3id);
2877 pdss1->p_m_d_l3id = pid;
2878 if (port->p_state == PORT_STATE_CONNECT)
2879 pdss1->p_m_d_ces = pid >> 16;
2880 add_trace("callref", "new", "0x%x", pdss1->p_m_d_l3id);
2884 /* if process id is master process, but a child disconnects */
2885 if (mISDNport->ntmode
2886 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2887 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) == MISDN_PID_MASTER) {
2888 if (cmd == MT_DISCONNECT
2889 || cmd == MT_RELEASE) {
2890 /* send special indication for child disconnect */
2891 pdss1->disconnect_ind_i(cmd, pid, l3m);
2894 if (cmd == MT_RELEASE_COMPLETE)
2897 /* if we have child pid and got different child pid message, ignore */
2898 if (mISDNport->ntmode
2899 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2900 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2901 && pid != pdss1->p_m_d_l3id)
2904 /* process message */
2905 pdss1->message_isdn(cmd, pid, l3m);
2912 /* creating port object, transparent until setup with hdlc */
2913 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2914 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0, B_MODE_TRANSPARENT)))
2916 FATAL("Cannot create Port instance.\n");
2917 pdss1->message_isdn(cmd, pid, l3m);
2921 /* creating port object, transparent until setup with hdlc */
2922 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2923 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0, B_MODE_TRANSPARENT)))
2924 FATAL("Cannot create Port instance.\n");
2925 pdss1->message_isdn(cmd, pid, l3m);
2929 PDEBUG(DEBUG_ISDN, "unused call ref released (l3id=0x%x)\n", pid);
2932 case MT_RELEASE_COMPLETE:
2933 PERROR("must be ignored by stack, not sent to app\n");
2937 // facility als broadcast
2941 PERROR("unhandled message: cmd(0x%x) pid(0x%x)\n", cmd, pid);
2944 if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT) {
2945 pdss1 = (class Pdss1 *)port;
2946 /* check out correct stack */
2947 if (pdss1->p_m_mISDNport == mISDNport)
2948 /* check out correct id */
2949 PERROR("unhandled message: pid=%x is not associated with port-dinfo=%x\n", pid, pdss1->p_m_d_l3id);