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;
33 p_m_d_notify_pending = NULL;
34 p_m_d_collect_cause = 0;
35 p_m_d_collect_location = 0;
37 PDEBUG(DEBUG_ISDN, "Created new mISDNPort(%s). Currently %d objects use, %s port #%d\n", portname, mISDNport->use, (mISDNport->ntmode)?"NT":"TE", p_m_portnum);
46 /* remove queued message */
48 message_free(p_m_d_queue);
50 if (p_m_d_notify_pending)
51 message_free(p_m_d_notify_pending);
56 * create layer 3 message
58 static struct l3_msg *create_l3msg(void)
66 FATAL("Cannot allocate memory, system overloaded.\n");
67 exit(0); // make gcc happy
71 * if we received a first reply to the setup message,
72 * we will check if we have now channel information
73 * return: <0: error, call is released, -cause is given
74 * 0: ok, nothing to do
76 int Pdss1::received_first_reply_to_setup(unsigned int cmd, int channel, int exclusive)
81 /* correct exclusive to 0, if no explicit channel was given */
82 if (exclusive<0 || channel<=0)
86 if (p_m_b_channel && p_m_b_exclusive)
88 /*** we gave an exclusive channel (or if we are done) ***/
90 /* if not first reply, we are done */
91 if (p_state != PORT_STATE_OUT_SETUP)
94 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
95 add_trace("channel", "request", "%d (forced)", p_m_b_channel);
96 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
98 /* if give channel not accepted or not equal */
99 if (channel!=-1 && p_m_b_channel!=channel)
101 add_trace("conclusion", NULL, "forced channel not accepted");
107 add_trace("conclusion", NULL, "channel was accepted");
108 add_trace("connect", "channel", "%d", p_m_b_channel);
111 /* activate our exclusive channel */
112 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
116 /*** we gave a non-exclusive channel ***/
118 /* if not first reply, we are done */
119 if (p_state != PORT_STATE_OUT_SETUP)
122 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
123 add_trace("channel", "request", "%d (suggest)", p_m_b_channel);
124 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
126 /* if channel was accepted as given */
127 if (channel==-1 || p_m_b_channel==channel)
129 add_trace("conclusion", NULL, "channel was accepted as given");
130 add_trace("connect", "channel", "%d", p_m_b_channel);
132 p_m_b_exclusive = 1; // we are done
133 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
137 /* if channel value is faulty */
140 add_trace("conclusion", NULL, "illegal reply");
142 ret = -111; // protocol error
146 /* if channel was not accepted, try to get it */
147 ret = seize_bchannel(channel, 1); // exclusively
148 add_trace("channel", "available", ret<0?"no":"yes");
151 add_trace("conclusion", NULL, "replied channel not available");
155 add_trace("conclusion", NULL, "replied channel accepted");
156 add_trace("connect", "channel", "%d", p_m_b_channel);
159 /* activate channel given by remote */
160 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
164 /*** we sent 'any channel acceptable' ***/
166 /* if not first reply, we are done */
167 if (p_state != PORT_STATE_OUT_SETUP)
170 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
171 add_trace("channel", "request", "any");
172 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
173 /* if no channel was replied */
176 add_trace("conclusion", NULL, "no channel, protocol error");
178 ret = -111; // protocol error
182 /* we will see, if our received channel is available */
183 ret = seize_bchannel(channel, 1); // exclusively
184 add_trace("channel", "available", ret<0?"no":"yes");
187 add_trace("conclusion", NULL, "replied channel not available");
191 add_trace("conclusion", NULL, "replied channel accepted");
192 add_trace("connect", "channel", "%d", p_m_b_channel);
195 /* activate channel given by remote */
196 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
199 /*** we sent 'no channel available' ***/
201 /* if not the first reply, but a connect, we are forced */
202 if (cmd==MT_CONNECT && p_state!=PORT_STATE_OUT_SETUP)
204 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (connect)", DIRECTION_NONE);
205 add_trace("channel", "request", "no-channel");
206 add_trace("channel", "reply", (channel>=0)?"%d%s":"(none)", channel, exclusive?" (forced)":"");
209 goto use_from_connect;
211 ret = seize_bchannel(CHANNEL_ANY, 0); // any channel
212 add_trace("channel", "available", ret<0?"no":"yes");
215 add_trace("conclusion", NULL, "no channel available during call-waiting");
219 add_trace("conclusion", NULL, "using channel %d", p_m_b_channel);
220 add_trace("connect", "channel", "%d", p_m_b_channel);
222 p_m_b_exclusive = 1; // we are done
224 /* activate channel given by remote */
225 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
229 /* if not first reply, we are done */
230 if (p_state != PORT_STATE_OUT_SETUP)
233 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
234 add_trace("channel", "request", "no-channel");
235 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
236 /* if first reply has no channel, we are done */
239 add_trace("conclusion", NULL, "no channel until connect");
244 /* we will see, if our received channel is available */
246 ret = seize_bchannel(channel, exclusive);
247 add_trace("channel", "available", ret<0?"no":"yes");
250 add_trace("conclusion", NULL, "replied channel not available");
254 add_trace("conclusion", NULL, "replied channel accepted");
255 add_trace("connect", "channel", "%d", p_m_b_channel);
257 p_m_b_exclusive = 1; // we are done
259 /* activate channel given by remote */
260 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
266 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
267 * in response to the setup reply
269 l3m = create_l3msg();
270 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
271 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
273 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
274 new_state(PORT_STATE_RELEASE);
276 return(-34); /* to epoint: no channel available */
281 * hunt bchannel for incoming setup or retrieve or resume
283 int Pdss1::hunt_bchannel(int channel, int exclusive)
285 struct select_channel *selchannel;
286 struct interface_port *ifport = p_m_mISDNport->ifport;
289 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (setup)", DIRECTION_NONE);
292 if (channel == CHANNEL_NO)
293 add_trace("channel", "request", "no-channel");
295 add_trace("channel", "request", (channel>0)?"%d%s":"any", channel, exclusive?" (forced)":"");
296 if (channel==CHANNEL_NO && p_type==PORT_TYPE_DSS1_TE_IN)
298 add_trace("conclusion", NULL, "incoming call-waiting not supported for TE-mode");
300 return(-6); // channel unacceptable
302 if (channel <= 0) /* not given, no channel, whatever.. */
303 channel = CHANNEL_ANY; /* any channel */
304 add_trace("channel", "reserved", "%d", p_m_mISDNport->b_reserved);
305 if (p_m_mISDNport->b_reserved >= p_m_mISDNport->b_num) // of out chan..
307 add_trace("conclusion", NULL, "all channels are reserved");
309 return(-34); // no channel
311 if (channel == CHANNEL_ANY)
315 /* check for given channel in selection list */
316 selchannel = ifport->in_channel;
319 if (selchannel->channel == channel || selchannel->channel == CHANNEL_FREE)
321 selchannel = selchannel->next;
326 /* exclusive channel requests must be in the list */
329 /* no exclusive channel */
332 add_trace("conclusion", NULL, "exclusively requested channel not in list");
334 return(-6); // channel unacceptable
336 /* get index for channel */
337 i = channel-1-(channel>=17);
338 if (i < 0 || i >= p_m_mISDNport->b_num || channel == 16)
340 add_trace("conclusion", NULL, "exclusively requested channel outside interface range");
342 return(-6); // channel unacceptable
345 if (p_m_mISDNport->b_port[i] == NULL)
347 add_trace("conclusion", NULL, "exclusively requested channel is busy");
349 return(-6); // channel unacceptable
352 /* requested channels in list will be used */
355 /* get index for channel */
356 i = channel-1-(channel>=17);
357 if (i < 0 || i >= p_m_mISDNport->b_num || channel == 16)
359 add_trace("info", NULL, "requested channel %d outside interface range", channel);
360 } else /* if inside range (else) check if available */
361 if (p_m_mISDNport->b_port[i] == NULL)
365 /* if channel is not available or not in list, it must be searched */
367 /* check for first free channel in list */
369 selchannel = ifport->in_channel;
372 switch(selchannel->channel)
374 case CHANNEL_FREE: /* free channel */
375 add_trace("hunting", "channel", "free");
376 if (p_m_mISDNport->b_reserved >= p_m_mISDNport->b_num)
377 break; /* all channel in use or reserverd */
380 while(i < p_m_mISDNport->b_num)
382 if (p_m_mISDNport->b_port[i] == NULL)
384 channel = i+1+(i>=15);
392 add_trace("hunting", "channel", "%d", selchannel->channel);
393 if (selchannel->channel<1 || selchannel->channel==16)
394 break; /* invalid channels */
395 i = selchannel->channel-1-(selchannel->channel>=17);
396 if (i >= p_m_mISDNport->b_num)
397 break; /* channel not in port */
398 if (p_m_mISDNport->b_port[i] == NULL)
400 channel = selchannel->channel;
406 break; /* found channel */
407 selchannel = selchannel->next;
411 add_trace("conclusion", NULL, "no channel available");
413 return(-6); // channel unacceptable
417 add_trace("conclusion", NULL, "channel available");
418 add_trace("connect", "channel", "%d", channel);
424 * handles all indications
426 /* CC_SETUP INDICATION */
427 void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
429 int calling_type, calling_plan, calling_present, calling_screen;
430 int called_type, called_plan;
431 int redir_type, redir_plan, redir_present, redir_screen, redir_reason;
432 int hlc_coding, hlc_presentation, hlc_interpretation, hlc_hlc, hlc_exthlc;
433 int bearer_coding, bearer_capability, bearer_mode, bearer_rate, bearer_multi, bearer_user;
434 int exclusive, channel;
436 unsigned char keypad[32] = "";
437 unsigned char useruser[128];
438 int useruser_len = 0, useruser_protocol;
439 class Endpoint *epoint;
440 struct lcr_msg *message;
442 /* process given callref */
443 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
444 add_trace("callref", "new", "0x%x", pid);
447 /* release in case the ID is already in use */
448 add_trace("error", NULL, "callref already in use");
450 l3m = create_l3msg();
451 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
452 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
453 add_trace("reason", NULL, "callref already in use");
455 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, pid, l3m);
456 new_state(PORT_STATE_RELEASE);
461 p_m_d_ces = pid >> 16;
464 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_IND, DIRECTION_IN);
465 dec_ie_calling_pn(l3m, &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id));
466 dec_ie_called_pn(l3m, &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
467 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
468 /* te-mode: CNIP (calling name identification presentation) */
470 dec_facility_centrex(l3m, (unsigned char *)p_callerinfo.name, sizeof(p_callerinfo.name));
471 dec_ie_useruser(l3m, &useruser_protocol, useruser, &useruser_len);
472 dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
473 dec_ie_redir_nr(l3m, &redir_type, &redir_plan, &redir_present, &redir_screen, &redir_reason, (unsigned char *)p_redirinfo.id, sizeof(p_redirinfo.id));
474 dec_ie_channel_id(l3m, &exclusive, &channel);
475 dec_ie_hlc(l3m, &hlc_coding, &hlc_interpretation, &hlc_presentation, &hlc_hlc, &hlc_exthlc);
476 dec_ie_bearer(l3m, &bearer_coding, &bearer_capability, &bearer_mode, &bearer_rate, &bearer_multi, &bearer_user);
477 dec_ie_display(l3m, (unsigned char *)p_dialinginfo.display, sizeof(p_dialinginfo.display));
480 /* if blocked, release call with MT_RELEASE_COMPLETE */
481 if (p_m_mISDNport->ifport->block)
483 l3m = create_l3msg();
484 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
485 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 27); /* temporary unavailable */
486 add_trace("reason", NULL, "port blocked");
488 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
489 new_state(PORT_STATE_RELEASE);
495 switch (calling_present)
498 p_callerinfo.present = INFO_PRESENT_RESTRICTED;
501 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
504 p_callerinfo.present = INFO_PRESENT_ALLOWED;
507 switch (calling_screen)
510 p_callerinfo.screen = INFO_SCREEN_USER;
513 p_callerinfo.screen = INFO_SCREEN_NETWORK;
516 switch (calling_type)
519 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
520 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
521 p_callerinfo.screen = INFO_SCREEN_NETWORK;
524 p_callerinfo.ntype = INFO_NTYPE_INTERNATIONAL;
527 p_callerinfo.ntype = INFO_NTYPE_NATIONAL;
530 p_callerinfo.ntype = INFO_NTYPE_SUBSCRIBER;
533 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
536 p_callerinfo.isdn_port = p_m_portnum;
537 SCPY(p_callerinfo.interface, p_m_mISDNport->ifport->interface->name);
539 /* dialing information */
540 SCAT(p_dialinginfo.id, (char *)keypad);
544 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
547 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
550 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
553 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
558 switch (redir_present)
561 p_redirinfo.present = INFO_PRESENT_RESTRICTED;
564 p_redirinfo.present = INFO_PRESENT_NOTAVAIL;
567 p_redirinfo.present = INFO_PRESENT_ALLOWED;
570 switch (redir_screen)
573 p_redirinfo.screen = INFO_SCREEN_USER;
576 p_redirinfo.screen = INFO_SCREEN_NETWORK;
579 switch (redir_reason)
582 p_redirinfo.reason = INFO_REDIR_BUSY;
585 p_redirinfo.reason = INFO_REDIR_NORESPONSE;
588 p_redirinfo.reason = INFO_REDIR_UNCONDITIONAL;
591 p_redirinfo.reason = INFO_REDIR_CALLDEFLECT;
594 p_redirinfo.reason = INFO_REDIR_OUTOFORDER;
597 p_redirinfo.reason = INFO_REDIR_UNKNOWN;
603 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
604 p_redirinfo.present = INFO_PRESENT_NULL; /* not redirecting */
605 p_redirinfo.reason = INFO_REDIR_UNKNOWN;
608 p_redirinfo.ntype = INFO_NTYPE_INTERNATIONAL;
611 p_redirinfo.ntype = INFO_NTYPE_NATIONAL;
614 p_redirinfo.ntype = INFO_NTYPE_SUBSCRIBER;
617 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
620 p_redirinfo.isdn_port = p_m_portnum;
622 /* bearer capability */
623 switch (bearer_capability)
626 p_capainfo.bearer_capa = INFO_BC_AUDIO;
627 bearer_user = (options.law=='a')?3:2;
630 p_capainfo.bearer_capa = bearer_capability;
636 p_capainfo.bearer_mode = INFO_BMODE_PACKET;
639 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
645 p_capainfo.bearer_info1 = INFO_INFO1_NONE;
648 p_capainfo.bearer_info1 = bearer_user + 0x80;
656 p_capainfo.hlc = INFO_HLC_NONE;
659 p_capainfo.hlc = hlc_hlc + 0x80;
665 p_capainfo.exthlc = INFO_HLC_NONE;
668 p_capainfo.exthlc = hlc_exthlc + 0x80;
672 /* set bchannel mode */
673 if (p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED
674 || p_capainfo.bearer_capa==INFO_BC_DATARESTRICTED
675 || p_capainfo.bearer_capa==INFO_BC_VIDEO)
676 p_capainfo.source_mode = B_MODE_HDLC;
678 p_capainfo.source_mode = B_MODE_TRANSPARENT;
679 p_m_b_mode = p_capainfo.source_mode;
682 ret = channel = hunt_bchannel(channel, exclusive);
687 ret = seize_bchannel(channel, 1);
692 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
693 * in response to the setup
695 l3m = create_l3msg();
696 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
697 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
699 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
700 new_state(PORT_STATE_RELEASE);
704 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
706 /* create endpoint */
708 FATAL("Incoming call but already got an endpoint.\n");
709 if (!(epoint = new Endpoint(p_serial, 0)))
710 FATAL("No memory for Endpoint instance\n");
711 if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 0))) //incoming
712 FATAL("No memory for Endpoint Application instance\n");
713 epointlist_new(epoint->ep_serial);
715 /* send setup message to endpoit */
716 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
717 message->param.setup.isdn_port = p_m_portnum;
718 message->param.setup.port_type = p_type;
719 // message->param.setup.dtmf = !p_m_mISDNport->ifport->nodtmf;
720 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
721 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
722 memcpy(&message->param.setup.redirinfo, &p_redirinfo, sizeof(struct redir_info));
723 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
724 memcpy(message->param.setup.useruser.data, &useruser, useruser_len);
725 message->param.setup.useruser.len = useruser_len;
726 message->param.setup.useruser.protocol = useruser_protocol;
727 message_put(message);
729 new_state(PORT_STATE_IN_SETUP);
732 /* CC_INFORMATION INDICATION */
733 void Pdss1::information_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
736 unsigned char keypad[32] = "", display[128] = "";
737 struct lcr_msg *message;
739 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_IND, DIRECTION_IN);
740 dec_ie_called_pn(l3m, &type, &plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
741 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
742 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
743 dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
746 SCAT(p_dialinginfo.id, (char *)keypad);
750 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
753 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
756 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
759 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
762 SCAT(p_dialinginfo.display, (char *)display);
763 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_INFORMATION);
764 memcpy(&message->param.information, &p_dialinginfo, sizeof(struct dialing_info));
765 message_put(message);
766 /* reset overlap timeout */
770 /* CC_SETUP_ACCNOWLEDGE INDICATION */
771 void Pdss1::setup_acknowledge_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
773 int exclusive, channel;
774 int coding, location, progress;
776 struct lcr_msg *message;
778 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_IND, DIRECTION_IN);
779 dec_ie_channel_id(l3m, &exclusive, &channel);
780 dec_ie_progress(l3m, &coding, &location, &progress);
783 /* process channel */
784 ret = received_first_reply_to_setup(cmd, channel, exclusive);
787 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
788 message->param.disconnectinfo.cause = -ret;
789 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
790 message_put(message);
791 new_state(PORT_STATE_RELEASE);
796 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_OVERLAP);
797 message_put(message);
799 new_state(PORT_STATE_OUT_OVERLAP);
802 /* CC_PROCEEDING INDICATION */
803 void Pdss1::proceeding_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
805 int exclusive, channel;
806 int coding, location, progress;
808 struct lcr_msg *message;
809 int notify = -1, type, plan, present;
812 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_IND, DIRECTION_IN);
813 dec_ie_channel_id(l3m, &exclusive, &channel);
814 dec_ie_progress(l3m, &coding, &location, &progress);
815 dec_ie_notify(l3m, ¬ify);
816 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
819 ret = received_first_reply_to_setup(cmd, channel, exclusive);
822 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
823 message->param.disconnectinfo.cause = -ret;
824 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
825 message_put(message);
826 new_state(PORT_STATE_RELEASE);
830 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
831 message_put(message);
833 new_state(PORT_STATE_OUT_PROCEEDING);
839 if (type >= 0 || notify)
841 if (!notify && type >= 0)
843 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
844 message->param.notifyinfo.notify = notify;
845 SCPY(message->param.notifyinfo.id, redir);
846 /* redirection number */
850 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
853 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
856 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
862 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
863 message->param.notifyinfo.present = INFO_PRESENT_NULL;
866 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
869 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
872 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
875 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
878 message->param.notifyinfo.isdn_port = p_m_portnum;
879 message_put(message);
883 /* CC_ALERTING INDICATION */
884 void Pdss1::alerting_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
886 int exclusive, channel;
887 int coding, location, progress;
889 struct lcr_msg *message;
890 int notify = -1, type, plan, present;
893 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_IND, DIRECTION_IN);
894 dec_ie_channel_id(l3m, &exclusive, &channel);
895 dec_ie_progress(l3m, &coding, &location, &progress);
896 dec_ie_notify(l3m, ¬ify);
897 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
900 /* process channel */
901 ret = received_first_reply_to_setup(cmd, channel, exclusive);
904 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
905 message->param.disconnectinfo.cause = -ret;
906 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
907 message_put(message);
908 new_state(PORT_STATE_RELEASE);
912 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ALERTING);
913 message_put(message);
915 new_state(PORT_STATE_OUT_ALERTING);
921 if (type >= 0 || notify)
923 if (!notify && type >= 0)
925 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
926 message->param.notifyinfo.notify = notify;
927 SCPY(message->param.notifyinfo.id, redir);
931 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
934 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
937 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
943 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
944 message->param.notifyinfo.present = INFO_PRESENT_NULL;
947 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
950 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
953 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
956 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
959 message->param.notifyinfo.isdn_port = p_m_portnum;
960 message_put(message);
964 /* CC_CONNECT INDICATION */
965 void Pdss1::connect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
967 int exclusive, channel;
968 int type, plan, present, screen;
970 struct lcr_msg *message;
973 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_IND, DIRECTION_IN);
974 dec_ie_channel_id(l3m, &exclusive, &channel);
975 dec_ie_connected_pn(l3m, &type, &plan, &present, &screen, (unsigned char *)p_connectinfo.id, sizeof(p_connectinfo.id));
976 dec_ie_display(l3m, (unsigned char *)p_connectinfo.display, sizeof(p_connectinfo.display));
977 /* te-mode: CONP (connected name identification presentation) */
979 dec_facility_centrex(l3m, (unsigned char *)p_connectinfo.name, sizeof(p_connectinfo.name));
983 bchannel_before = p_m_b_channel;
984 ret = received_first_reply_to_setup(cmd, channel, exclusive);
987 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
988 message->param.disconnectinfo.cause = -ret;
989 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
990 message_put(message);
991 new_state(PORT_STATE_RELEASE);
996 /* connect information */
1000 p_connectinfo.present = INFO_PRESENT_RESTRICTED;
1003 p_connectinfo.present = INFO_PRESENT_NOTAVAIL;
1006 p_connectinfo.present = INFO_PRESENT_ALLOWED;
1012 p_connectinfo.screen = INFO_SCREEN_USER;
1015 p_connectinfo.screen = INFO_SCREEN_NETWORK;
1021 p_connectinfo.present = INFO_PRESENT_NULL; /* no COLP info */
1022 p_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
1025 p_connectinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1028 p_connectinfo.ntype = INFO_NTYPE_NATIONAL;
1031 p_connectinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1034 p_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
1037 p_connectinfo.isdn_port = p_m_portnum;
1038 SCPY(p_connectinfo.interface, p_m_mISDNport->ifport->interface->name);
1040 /* only in nt-mode we send connect ack. in te-mode it is done by stack itself or optional */
1043 /* send connect acknowledge */
1044 l3m = create_l3msg();
1045 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_RES, DIRECTION_OUT);
1046 /* if we had no bchannel before, we send it now */
1047 if (!bchannel_before && p_m_b_channel)
1048 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1050 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT_ACKNOWLEDGE, p_m_d_l3id, l3m);
1053 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_CONNECT);
1054 memcpy(&message->param.connectinfo, &p_connectinfo, sizeof(struct connect_info));
1055 message_put(message);
1057 new_state(PORT_STATE_CONNECT);
1060 /* CC_DISCONNECT INDICATION */
1061 void Pdss1::disconnect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1063 int location, cause;
1064 int coding, proglocation, progress;
1065 struct lcr_msg *message;
1066 unsigned char display[128] = "";
1068 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1069 dec_ie_progress(l3m, &coding, &proglocation, &progress);
1070 dec_ie_cause(l3m, &location, &cause);
1071 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1077 /* release if remote sends us no tones */
1078 if (!p_m_mISDNport->earlyb)
1082 l3m = create_l3msg();
1083 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
1084 enc_ie_cause(l3m, location, cause); /* normal */
1085 add_trace("reason", NULL, "no remote patterns");
1087 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
1089 /* sending release to endpoint */
1090 if (location == LOCATION_PRIVATE_LOCAL)
1091 location = LOCATION_PRIVATE_REMOTE;
1094 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1095 message->param.disconnectinfo.cause = cause;
1096 message->param.disconnectinfo.location = location;
1097 SCAT(message->param.disconnectinfo.display, (char *)display);
1098 message_put(message);
1100 free_epointlist(p_epointlist);
1102 new_state(PORT_STATE_RELEASE);
1107 /* sending disconnect to active endpoint and release to inactive endpoints */
1108 if (location == LOCATION_PRIVATE_LOCAL)
1109 location = LOCATION_PRIVATE_REMOTE;
1110 if (ACTIVE_EPOINT(p_epointlist))
1112 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_DISCONNECT);
1113 message->param.disconnectinfo.location = location;
1114 message->param.disconnectinfo.cause = cause;
1115 SCAT(message->param.disconnectinfo.display, (char *)display);
1116 message_put(message);
1118 while(INACTIVE_EPOINT(p_epointlist))
1120 message = message_create(p_serial, INACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1121 message->param.disconnectinfo.location = location;
1122 message->param.disconnectinfo.cause = cause;
1123 SCAT(message->param.disconnectinfo.display, (char *)display);
1124 message_put(message);
1126 free_epointid(INACTIVE_EPOINT(p_epointlist));
1128 new_state(PORT_STATE_IN_DISCONNECT);
1131 /* CC_DISCONNECT INDICATION */
1132 void Pdss1::disconnect_ind_i(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1134 int location, cause;
1137 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1138 if (p_m_d_collect_cause > 0)
1140 add_trace("old-cause", "location", "%d", p_m_d_collect_location);
1141 add_trace("old-cause", "value", "%d", p_m_d_collect_cause);
1143 dec_ie_cause(l3m, &location, &cause);
1144 if (location == LOCATION_PRIVATE_LOCAL)
1145 location = LOCATION_PRIVATE_REMOTE;
1148 collect_cause(&p_m_d_collect_cause, &p_m_d_collect_location, cause, location);
1149 add_trace("new-cause", "location", "%d", p_m_d_collect_location);
1150 add_trace("new-cause", "value", "%d", p_m_d_collect_cause);
1155 /* CC_RELEASE INDICATION */
1156 void Pdss1::release_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1158 int location, cause;
1159 struct lcr_msg *message;
1160 unsigned char display[128] = "";
1162 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_IND, DIRECTION_IN);
1163 dec_ie_cause(l3m, &location, &cause);
1164 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1170 /* sending release to endpoint */
1171 if (location == LOCATION_PRIVATE_LOCAL)
1172 location = LOCATION_PRIVATE_REMOTE;
1175 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1176 message->param.disconnectinfo.cause = cause;
1177 message->param.disconnectinfo.location = location;
1178 SCAT(message->param.disconnectinfo.display, (char *)display);
1179 message_put(message);
1181 free_epointlist(p_epointlist);
1184 new_state(PORT_STATE_RELEASE);
1188 /* CC_RESTART INDICATION */
1189 void Pdss1::restart_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1191 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESTART_IND, DIRECTION_IN);
1194 // L3 process is not toucht. (not even by network stack)
1197 /* CC_RELEASE_COMPLETE INDICATION (a reject) */
1198 void Pdss1::release_complete_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1200 int location, cause;
1201 struct lcr_msg *message;
1203 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_IND, DIRECTION_IN);
1204 /* in case layer 2 is down during setup, we send cause 27 loc 5 */
1205 if (p_state == PORT_STATE_OUT_SETUP && p_m_mISDNport->l1link == 0)
1211 dec_ie_cause(l3m, &location, &cause);
1212 if (p_m_mISDNport->l1link < 0)
1213 add_trace("layer 1", NULL, "unknown");
1215 add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
1218 if (location == LOCATION_PRIVATE_LOCAL)
1219 location = LOCATION_PRIVATE_REMOTE;
1224 /* sending release to endpoint */
1227 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1228 message->param.disconnectinfo.cause = cause;
1229 message->param.disconnectinfo.location = location;
1230 message_put(message);
1232 free_epointlist(p_epointlist);
1235 new_state(PORT_STATE_RELEASE);
1240 void Pdss1::t312_timeout_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1242 // not required, release is performed with MT_FREE
1245 /* CC_NOTIFY INDICATION */
1246 void Pdss1::notify_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1248 struct lcr_msg *message;
1249 int notify, type, plan, present;
1250 unsigned char notifyid[sizeof(message->param.notifyinfo.id)];
1251 unsigned char display[128] = "";
1253 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_IND, DIRECTION_IN);
1254 dec_ie_notify(l3m, ¬ify);
1255 dec_ie_redir_dn(l3m, &type, &plan, &present, notifyid, sizeof(notifyid));
1256 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1259 if (!ACTIVE_EPOINT(p_epointlist))
1261 /* notification indicator */
1265 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1266 message->param.notifyinfo.notify = notify;
1267 SCPY(message->param.notifyinfo.id, (char *)notifyid);
1268 /* redirection number */
1272 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
1275 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
1278 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
1284 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1285 message->param.notifyinfo.present = INFO_PRESENT_NULL;
1288 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1291 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
1294 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1297 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1300 SCAT(message->param.notifyinfo.display, (char *)display);
1301 message->param.notifyinfo.isdn_port = p_m_portnum;
1302 message_put(message);
1306 /* CC_HOLD INDICATION */
1307 struct lcr_msg *message;
1308 void Pdss1::hold_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1310 // class Endpoint *epoint;
1312 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_IND, DIRECTION_IN);
1315 if (!ACTIVE_EPOINT(p_epointlist) || p_m_hold)
1317 l3m = create_l3msg();
1318 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_REJECT_REQ, DIRECTION_OUT);
1319 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */
1320 add_trace("reason", NULL, "no endpoint");
1322 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_REJECT, p_m_d_l3id, l3m);
1327 /* notify the hold of call */
1328 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1329 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_HOLD;
1330 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1331 message_put(message);
1333 /* deactivate bchannel */
1334 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (hold)", DIRECTION_NONE);
1335 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1339 /* set hold state */
1342 epoint = find_epoint_id(ACTIVE_EPOINT(p_epointlist));
1343 if (epoint && p_m_d_ntmode)
1345 p_m_timeout = p_settings.tout_hold;
1350 /* acknowledge hold */
1351 l3m = create_l3msg();
1352 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1354 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_ACKNOWLEDGE, p_m_d_l3id, l3m);
1358 /* CC_RETRIEVE INDICATION */
1359 void Pdss1::retrieve_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1361 struct lcr_msg *message;
1362 int channel, exclusive, cause;
1365 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_IND, DIRECTION_IN);
1366 dec_ie_channel_id(l3m, &exclusive, &channel);
1371 cause = 101; /* incompatible state */
1374 l3m = create_l3msg();
1375 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_REJECT_REQ, DIRECTION_OUT);
1376 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, cause);
1378 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_REJECT, p_m_d_l3id, l3m);
1383 /* notify the retrieve of call */
1384 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1385 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL;
1386 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1387 message_put(message);
1390 ret = channel = hunt_bchannel(channel, exclusive);
1395 ret = seize_bchannel(channel, 1);
1402 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1404 /* set hold state */
1408 /* acknowledge retrieve */
1409 l3m = create_l3msg();
1410 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1411 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1413 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_ACKNOWLEDGE, p_m_d_l3id, l3m);
1416 /* CC_SUSPEND INDICATION */
1417 void Pdss1::suspend_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1419 struct lcr_msg *message;
1420 class Endpoint *epoint;
1421 unsigned char callid[8];
1423 int ret = -31; /* normal, unspecified */
1425 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_IND, DIRECTION_IN);
1426 dec_ie_call_id(l3m, callid, &len);
1429 if (!ACTIVE_EPOINT(p_epointlist))
1432 l3m = create_l3msg();
1433 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_REJECT_REQ, DIRECTION_OUT);
1434 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1436 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_REJECT, p_m_d_l3id, l3m);
1443 /* check if call id is in use */
1444 epoint = epoint_first;
1447 if (epoint->ep_park)
1449 if (epoint->ep_park_len == len)
1450 if (!memcmp(epoint->ep_park_callid, callid, len))
1452 ret = -84; /* call id in use */
1456 epoint = epoint->next;
1459 /* notify the hold of call */
1460 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1461 message->param.notifyinfo.notify = INFO_NOTIFY_USER_SUSPENDED;
1462 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1463 message_put(message);
1465 /* deactivate bchannel */
1466 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (suspend)", DIRECTION_NONE);
1467 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1471 /* sending suspend to endpoint */
1472 while (p_epointlist)
1474 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_SUSPEND);
1475 memcpy(message->param.parkinfo.callid, callid, sizeof(message->param.parkinfo.callid));
1476 message->param.parkinfo.len = len;
1477 message_put(message);
1479 free_epointlist(p_epointlist);
1482 /* sending SUSPEND_ACKNOWLEDGE */
1483 l3m = create_l3msg();
1484 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1486 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_ACKNOWLEDGE, p_m_d_l3id, l3m);
1488 new_state(PORT_STATE_RELEASE);
1492 /* CC_RESUME INDICATION */
1493 void Pdss1::resume_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1495 unsigned char callid[8];
1497 int channel, exclusive;
1498 class Endpoint *epoint;
1499 struct lcr_msg *message;
1502 /* process given callref */
1503 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
1504 add_trace("callref", "new", "0x%x", pid);
1507 /* release is case the ID is already in use */
1508 add_trace("error", NULL, "callref already in use");
1510 l3m = create_l3msg();
1511 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1512 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
1513 add_trace("reason", NULL, "callref already in use");
1515 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, pid, l3m);
1516 new_state(PORT_STATE_RELEASE);
1521 p_m_d_ces = pid >> 16;
1524 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_IND, DIRECTION_IN);
1525 dec_ie_call_id(l3m, callid, &len);
1528 /* if blocked, release call */
1529 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);
1554 l3m = create_l3msg();
1555 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1556 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1558 add_trace("reason", NULL, "port blocked");
1560 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, p_m_d_l3id, l3m);
1561 new_state(PORT_STATE_RELEASE);
1565 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1567 /* create endpoint */
1569 FATAL("Incoming resume but already got an endpoint.\n");
1570 ret = -85; /* no call suspended */
1571 epoint = epoint_first;
1574 if (epoint->ep_park)
1576 ret = -83; /* suspended call exists, but this not */
1577 if (epoint->ep_park_len == len)
1578 if (!memcmp(epoint->ep_park_callid, callid, len))
1581 epoint = epoint->next;
1586 epointlist_new(epoint->ep_serial);
1587 if (!(epoint->portlist_new(p_serial, p_type, p_m_mISDNport->earlyb)))
1588 FATAL("No memory for portlist\n");
1589 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RESUME);
1590 message_put(message);
1592 /* notify the resume of call */
1593 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1594 message->param.notifyinfo.notify = INFO_NOTIFY_USER_RESUMED;
1595 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1596 message_put(message);
1598 /* sending RESUME_ACKNOWLEDGE */
1599 l3m = create_l3msg();
1600 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1601 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1603 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_ACKNOWLEDGE, p_m_d_l3id, l3m);
1605 new_state(PORT_STATE_CONNECT);
1609 /* CC_FACILITY INDICATION */
1610 void Pdss1::facility_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1612 unsigned char facil[256];
1614 struct lcr_msg *message;
1616 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_IND, DIRECTION_IN);
1617 dec_ie_facility(l3m, facil, &facil_len);
1624 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_FACILITY);
1625 message->param.facilityinfo.len = facil_len;
1626 memcpy(message->param.facilityinfo.data, facil, facil_len);
1627 message_put(message);
1632 * handler for isdn connections
1633 * incoming information are parsed and sent via message to the endpoint
1635 void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1644 PERROR("Pdss1(%s) timeout without cause.\n", p_name);
1647 if (l3m->cause[0] != 5)
1649 PERROR("Pdss1(%s) expecting timeout with timer diagnostic. (got len=%d)\n", p_name, l3m->cause[0]);
1652 timer = (l3m->cause[3]-'0')*100;
1653 timer += (l3m->cause[4]-'0')*10;
1654 timer += (l3m->cause[5]-'0');
1655 l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN);
1656 add_trace("timer", NULL, "%d", timer);
1659 t312_timeout_ind(cmd, pid, l3m);
1663 if (p_state != PORT_STATE_IDLE)
1665 setup_ind(cmd, pid, l3m);
1668 case MT_INFORMATION:
1669 information_ind(cmd, pid, l3m);
1672 case MT_SETUP_ACKNOWLEDGE:
1673 if (p_state != PORT_STATE_OUT_SETUP)
1675 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received setup_acknowledge, but we are not in outgoing setup state, IGNORING.\n", p_name);
1678 setup_acknowledge_ind(cmd, pid, l3m);
1681 case MT_CALL_PROCEEDING:
1682 if (p_state != PORT_STATE_OUT_SETUP
1683 && p_state != PORT_STATE_OUT_OVERLAP)
1685 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received proceeding, but we are not in outgoing setup OR overlap state, IGNORING.\n", p_name);
1688 proceeding_ind(cmd, pid, l3m);
1692 if (p_state != PORT_STATE_OUT_SETUP
1693 && p_state != PORT_STATE_OUT_OVERLAP
1694 && p_state != PORT_STATE_OUT_PROCEEDING)
1696 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding state, IGNORING.\n", p_name);
1699 alerting_ind(cmd, pid, l3m);
1703 if (p_state != PORT_STATE_OUT_SETUP
1704 && p_state != PORT_STATE_OUT_OVERLAP
1705 && p_state != PORT_STATE_OUT_PROCEEDING
1706 && p_state != PORT_STATE_OUT_ALERTING)
1708 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);
1711 connect_ind(cmd, pid, l3m);
1712 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)
1726 /* send pending notify message during connect-ack */
1727 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1728 message_free(p_m_d_notify_pending);
1729 p_m_d_notify_pending = NULL;
1734 disconnect_ind(cmd, pid, l3m);
1738 release_ind(cmd, pid, l3m);
1741 case MT_RELEASE_COMPLETE:
1742 release_complete_ind(cmd, pid, l3m);
1746 restart_ind(cmd, pid, l3m);
1750 notify_ind(cmd, pid, l3m);
1754 hold_ind(cmd, pid, l3m);
1758 retrieve_ind(cmd, pid, l3m);
1762 suspend_ind(cmd, pid, l3m);
1766 resume_ind(cmd, pid, l3m);
1770 facility_ind(cmd, pid, l3m);
1774 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_L3ID_IND, DIRECTION_IN);
1775 add_trace("callref", NULL, "0x%x", p_m_d_l3id);
1780 /* sending release to endpoint in case we still have an endpoint
1781 * this is because we don't get any response if a release_complete is received (or a release in release state)
1783 while(p_epointlist) // only if not already released
1785 struct lcr_msg *message;
1786 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1787 if (p_m_d_collect_cause)
1789 message->param.disconnectinfo.cause = p_m_d_collect_cause;
1790 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, 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)
1818 p_m_timeout = p_m_mISDNport->ifport->tout_dialing;
1821 if (state != p_state)
1823 if (state == PORT_STATE_IN_SETUP
1824 || state == PORT_STATE_OUT_SETUP
1825 || state == PORT_STATE_IN_OVERLAP
1826 || state == PORT_STATE_OUT_OVERLAP)
1828 p_m_timeout = p_m_mISDNport->ifport->tout_setup;
1831 if (state == PORT_STATE_IN_PROCEEDING
1832 || state == PORT_STATE_OUT_PROCEEDING)
1834 p_m_timeout = p_m_mISDNport->ifport->tout_proceeding;
1837 if (state == PORT_STATE_IN_ALERTING
1838 || state == PORT_STATE_OUT_ALERTING)
1840 p_m_timeout = p_m_mISDNport->ifport->tout_alerting;
1843 if (state == PORT_STATE_CONNECT
1844 || state == PORT_STATE_CONNECT_WAITING)
1848 if (state == PORT_STATE_IN_DISCONNECT
1849 || state == PORT_STATE_OUT_DISCONNECT)
1851 p_m_timeout = p_m_mISDNport->ifport->tout_disconnect;
1856 Port::new_state(state);
1863 int Pdss1::handler(void)
1867 if ((ret = PmISDN::handler()))
1870 /* handle destruction */
1871 if (p_m_delete && p_m_d_l3id==0)
1882 * handles all messages from endpoint
1884 /* MESSAGE_INFORMATION */
1885 void Pdss1::message_information(unsigned int epoint_id, int message_id, union parameter *param)
1889 if (param->information.id[0]) /* only if we have something to dial */
1891 l3m = create_l3msg();
1892 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1893 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)param->information.id);
1895 enc_ie_display(l3m, (unsigned char *)param->information.display);
1897 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1906 void Pdss1::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
1910 int plan, type, screen, present, reason;
1911 int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
1912 int channel, exclusive;
1913 struct epoint_list *epointlist;
1915 /* release if port is blocked */
1916 if (p_m_mISDNport->ifport->block)
1918 struct lcr_msg *message;
1920 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1921 message->param.disconnectinfo.cause = 27; // temp. unavail.
1922 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1923 message_put(message);
1924 new_state(PORT_STATE_RELEASE);
1929 /* copy setup infos to port */
1930 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
1931 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
1932 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
1933 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
1934 // SCPY(&p_m_tones_dir, param->setup.ext.tones_dir);
1935 /* screen outgoing caller id */
1936 do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_m_mISDNport->ifport->interface);
1938 /* only display at connect state: this case happens if endpoint is in connected mode */
1939 if (p_state==PORT_STATE_CONNECT)
1941 if (p_type!=PORT_TYPE_DSS1_NT_OUT
1942 && p_type!=PORT_TYPE_DSS1_NT_IN)
1944 if (p_callerinfo.display[0])
1946 /* sending information */
1947 l3m = create_l3msg();
1948 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1950 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
1952 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1957 /* attach only if not already */
1958 epointlist = p_epointlist;
1961 if (epointlist->epoint_id == epoint_id)
1963 epointlist = epointlist->next;
1966 epointlist_new(epoint_id);
1972 channel = p_m_b_channel;
1973 exclusive = p_m_b_exclusive;
1975 channel = CHANNEL_ANY;
1976 /* nt-port with no channel, not reserverd */
1977 if (!p_m_b_channel && !p_m_b_reserve && p_type==PORT_TYPE_DSS1_NT_OUT)
1978 channel = CHANNEL_NO;
1981 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT);
1982 /* see MT_ASSIGN notes at do_layer3() */
1984 ret = p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ASSIGN, 0, NULL);
1985 if (mt_assign_pid == 0 || ret < 0)
1987 struct lcr_msg *message;
1989 add_trace("callref", NULL, "no free id");
1991 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1992 message->param.disconnectinfo.cause = 47;
1993 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1994 message_put(message);
1995 new_state(PORT_STATE_RELEASE);
1999 p_m_d_l3id = mt_assign_pid;
2001 add_trace("callref", "new", "0x%x", p_m_d_l3id);
2004 /* preparing setup message */
2005 l3m = create_l3msg();
2006 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_REQ, DIRECTION_OUT);
2007 /* channel information */
2008 if (channel >= 0) /* it should */
2010 enc_ie_channel_id(l3m, exclusive, channel);
2012 /* caller information */
2014 switch (p_callerinfo.ntype)
2016 case INFO_NTYPE_INTERNATIONAL:
2019 case INFO_NTYPE_NATIONAL:
2022 case INFO_NTYPE_SUBSCRIBER:
2025 default: /* INFO_NTYPE_UNKNOWN */
2029 switch (p_callerinfo.screen)
2031 case INFO_SCREEN_USER:
2034 default: /* INFO_SCREEN_NETWORK */
2038 switch (p_callerinfo.present)
2040 case INFO_PRESENT_RESTRICTED:
2043 case INFO_PRESENT_NOTAVAIL:
2046 default: /* INFO_PRESENT_ALLOWED */
2051 enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id);
2052 /* dialing information */
2053 if (p_dialinginfo.id[0]) /* only if we have something to dial */
2055 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id);
2057 /* sending complete */
2058 if (p_dialinginfo.sending_complete)
2059 enc_ie_complete(l3m, 1);
2060 /* sending user-user */
2061 if (param->setup.useruser.len)
2063 enc_ie_useruser(l3m, param->setup.useruser.protocol, param->setup.useruser.data, param->setup.useruser.len);
2065 /* redirecting number */
2067 switch (p_redirinfo.ntype)
2069 case INFO_NTYPE_INTERNATIONAL:
2072 case INFO_NTYPE_NATIONAL:
2075 case INFO_NTYPE_SUBSCRIBER:
2078 default: /* INFO_NTYPE_UNKNOWN */
2082 switch (p_redirinfo.screen)
2084 case INFO_SCREEN_USER:
2087 default: /* INFO_SCREE_NETWORK */
2091 switch (p_redirinfo.reason)
2093 case INFO_REDIR_BUSY:
2096 case INFO_REDIR_NORESPONSE:
2099 case INFO_REDIR_UNCONDITIONAL:
2102 case INFO_REDIR_CALLDEFLECT:
2105 case INFO_REDIR_OUTOFORDER:
2108 default: /* INFO_REDIR_UNKNOWN */
2112 switch (p_redirinfo.present)
2114 case INFO_PRESENT_NULL: /* no redir at all */
2121 case INFO_PRESENT_RESTRICTED:
2124 case INFO_PRESENT_NOTAVAIL:
2127 default: /* INFO_PRESENT_ALLOWED */
2131 /* sending redirecting number only in ntmode */
2132 if (type >= 0 && p_m_d_ntmode)
2133 enc_ie_redir_nr(l3m, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
2134 /* bearer capability */
2135 //printf("hlc=%d\n",p_capainfo.hlc);
2137 capability = p_capainfo.bearer_capa;
2138 mode = p_capainfo.bearer_mode;
2139 rate = (mode==INFO_BMODE_CIRCUIT)?0x10:0x00;
2140 switch (p_capainfo.bearer_info1)
2142 case INFO_INFO1_NONE:
2146 user = p_capainfo.bearer_info1 & 0x7f;
2149 enc_ie_bearer(l3m, coding, capability, mode, rate, -1, user);
2156 hlc = p_capainfo.hlc & 0x7f;
2158 if (p_capainfo.exthlc)
2159 exthlc = p_capainfo.exthlc & 0x7f;
2160 enc_ie_hlc(l3m, coding, interpretation, presentation, hlc, exthlc);
2164 if (p_callerinfo.display[0] && p_m_d_ntmode)
2165 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
2166 /* nt-mode: CNIP (calling name identification presentation) */
2167 // if (p_callerinfo.name[0] && p_m_d_ntmode)
2168 // enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
2171 /* send setup message now */
2172 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP, p_m_d_l3id, l3m);
2174 new_state(PORT_STATE_OUT_SETUP);
2177 /* MESSAGE_FACILITY */
2178 void Pdss1::message_facility(unsigned int epoint_id, int message_id, union parameter *param)
2182 /* facility will not be sent to external lines */
2186 /* sending facility */
2187 l3m = create_l3msg();
2188 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
2189 enc_ie_facility(l3m, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len);
2191 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
2194 /* MESSAGE_NOTIFY */
2195 void Pdss1::message_notify(unsigned int epoint_id, int message_id, union parameter *param)
2199 int plan, type = -1, present;
2201 if (param->notifyinfo.notify>INFO_NOTIFY_NONE)
2202 notify = param->notifyinfo.notify & 0x7f;
2205 if (p_state != PORT_STATE_CONNECT)
2207 /* notify only allowed in active state */
2213 switch (param->notifyinfo.ntype)
2215 case INFO_NTYPE_INTERNATIONAL:
2218 case INFO_NTYPE_NATIONAL:
2221 case INFO_NTYPE_SUBSCRIBER:
2224 default: /* INFO_NTYPE_UNKNOWN */
2228 switch (param->notifyinfo.present)
2230 case INFO_PRESENT_NULL: /* no redir at all */
2235 case INFO_PRESENT_RESTRICTED:
2238 case INFO_PRESENT_NOTAVAIL:
2241 default: /* INFO_PRESENT_ALLOWED */
2247 if (notify<0 && !param->notifyinfo.display[0])
2249 /* nothing to notify, nothing to display */
2255 if (p_state!=PORT_STATE_CONNECT)
2257 /* queue notification */
2258 if (p_m_d_notify_pending)
2259 message_free(p_m_d_notify_pending);
2260 p_m_d_notify_pending = message_create(ACTIVE_EPOINT(p_epointlist), p_serial, EPOINT_TO_PORT, message_id);
2261 memcpy(&p_m_d_notify_pending->param, param, sizeof(union parameter));
2264 /* sending notification */
2265 l3m = create_l3msg();
2266 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
2267 enc_ie_notify(l3m, notify);
2268 /* sending redirection number only in ntmode */
2269 if (type >= 0 && p_m_d_ntmode)
2270 enc_ie_redir_dn(l3m, type, plan, present, (unsigned char *)param->notifyinfo.id);
2271 if (param->notifyinfo.display[0] && p_m_d_ntmode)
2272 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2274 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_NOTIFY, p_m_d_l3id, l3m);
2276 } else if (p_m_d_ntmode)
2278 /* sending information */
2279 l3m = create_l3msg();
2280 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2281 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2283 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2287 /* MESSAGE_OVERLAP */
2288 void Pdss1::message_overlap(unsigned int epoint_id, int message_id, union parameter *param)
2292 /* in case of sending complete, we proceed */
2293 if (p_dialinginfo.sending_complete)
2295 PDEBUG(DEBUG_ISDN, "sending proceeding instead of setup_acknowledge, because address is complete.\n");
2296 message_proceeding(epoint_id, message_id, param);
2300 /* sending setup_acknowledge */
2301 l3m = create_l3msg();
2302 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_REQ, DIRECTION_OUT);
2303 /* channel information */
2304 if (p_state == PORT_STATE_IN_SETUP)
2305 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2306 /* progress information */
2307 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2308 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2309 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2310 if (p_m_mISDNport->tones)
2311 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2313 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, l3m);
2315 new_state(PORT_STATE_IN_OVERLAP);
2318 /* MESSAGE_PROCEEDING */
2319 void Pdss1::message_proceeding(unsigned int epoint_id, int message_id, union parameter *param)
2323 /* sending proceeding */
2324 l3m = create_l3msg();
2325 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2326 /* channel information */
2327 if (p_state == PORT_STATE_IN_SETUP)
2328 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2329 /* progress information */
2330 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2331 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2332 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2333 if (p_m_mISDNport->tones)
2334 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2336 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2338 new_state(PORT_STATE_IN_PROCEEDING);
2341 /* MESSAGE_ALERTING */
2342 void Pdss1::message_alerting(unsigned int epoint_id, int message_id, union parameter *param)
2346 /* NT-MODE in setup state we must send PROCEEDING first */
2347 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2349 /* sending proceeding */
2350 l3m = create_l3msg();
2351 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2352 /* channel information */
2353 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2354 /* progress information */
2355 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2356 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2357 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2358 if (p_m_mISDNport->tones)
2359 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2361 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 /* sending alerting */
2366 l3m = create_l3msg();
2367 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_REQ, DIRECTION_OUT);
2368 /* channel information */
2369 if (p_state == PORT_STATE_IN_SETUP)
2370 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2371 /* progress information */
2372 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2373 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2374 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2375 if (p_m_mISDNport->tones)
2376 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2378 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ALERTING, p_m_d_l3id, l3m);
2380 new_state(PORT_STATE_IN_ALERTING);
2383 /* MESSAGE_CONNECT */
2384 void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parameter *param)
2387 int type, plan, present, screen;
2388 class Endpoint *epoint;
2390 /* NT-MODE in setup state we must send PROCEEDING first */
2391 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2393 /* sending proceeding */
2394 l3m = create_l3msg();
2395 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2396 /* channel information */
2397 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2399 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2400 new_state(PORT_STATE_IN_PROCEEDING);
2403 /* copy connected information */
2404 memcpy(&p_connectinfo, ¶m->connectinfo, sizeof(p_connectinfo));
2405 /* screen outgoing caller id */
2406 do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface);
2408 /* only display at connect state */
2409 if (p_state == PORT_STATE_CONNECT)
2410 if (p_connectinfo.display[0])
2412 /* sending information */
2413 l3m = create_l3msg();
2414 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2416 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2418 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2422 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)
2424 /* connect command only possible in setup, proceeding or alerting state */
2428 /* preparing connect message */
2429 l3m = create_l3msg();
2430 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_REQ, DIRECTION_OUT);
2431 /* connect information */
2433 switch (p_connectinfo.ntype)
2435 case INFO_NTYPE_INTERNATIONAL:
2438 case INFO_NTYPE_NATIONAL:
2441 case INFO_NTYPE_SUBSCRIBER:
2444 default: /* INFO_NTYPE_UNKNOWN */
2448 switch (param->connectinfo.screen)
2450 case INFO_SCREEN_USER:
2453 default: /* INFO_SCREE_NETWORK */
2457 switch (p_connectinfo.present)
2459 case INFO_PRESENT_NULL: /* no colp at all */
2465 case INFO_PRESENT_RESTRICTED:
2468 case INFO_PRESENT_NOTAVAIL:
2471 default: /* INFO_PRESENT_ALLOWED */
2476 enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
2478 if (p_connectinfo.display[0] && p_m_d_ntmode)
2479 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2480 /* nt-mode: CONP (connected name identification presentation) */
2481 // if (p_connectinfo.name[0] && p_m_d_ntmode)
2482 // enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
2486 epoint = find_epoint_id(epoint_id);
2487 enc_ie_date(l3m, now, p_settings.no_seconds);
2490 /* finally send message */
2491 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT, p_m_d_l3id, l3m);
2494 new_state(PORT_STATE_CONNECT);
2496 new_state(PORT_STATE_CONNECT_WAITING);
2500 /* MESSAGE_DISCONNECT */
2501 void Pdss1::message_disconnect(unsigned int epoint_id, int message_id, union parameter *param)
2504 struct lcr_msg *message;
2507 /* we reject during incoming setup when we have no tones. also if we are in outgoing setup state */
2508 // if ((p_state==PORT_STATE_IN_SETUP && !p_m_mISDNport->tones)
2509 if (/* ||*/ p_state==PORT_STATE_OUT_SETUP)
2511 /* sending release to endpoint */
2514 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
2515 memcpy(&message->param, param, sizeof(union parameter));
2516 message_put(message);
2518 free_epointlist(p_epointlist);
2520 /* sending release */
2521 l3m = create_l3msg();
2522 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
2524 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2526 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2527 new_state(PORT_STATE_RELEASE);
2532 /* workarround: NT-MODE in setup state we must send PROCEEDING first to make it work */
2533 if (p_state==PORT_STATE_IN_SETUP)
2535 /* sending proceeding */
2536 l3m = create_l3msg();
2537 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2538 /* channel information */
2539 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2540 /* progress information */
2541 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2542 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2543 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2544 if (p_m_mISDNport->tones)
2545 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2547 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2548 new_state(PORT_STATE_IN_PROCEEDING);
2551 /* sending disconnect */
2552 l3m = create_l3msg();
2553 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2554 /* progress information */
2555 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2556 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2557 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2558 if (p_m_mISDNport->tones)
2559 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2561 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2563 if (param->disconnectinfo.display[0])
2564 p = param->disconnectinfo.display;
2565 if (p) if (*p && p_m_d_ntmode)
2566 enc_ie_display(l3m, (unsigned char *)p);
2568 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2569 new_state(PORT_STATE_OUT_DISCONNECT);
2572 /* MESSAGE_RELEASE */
2573 void Pdss1::message_release(unsigned int epoint_id, int message_id, union parameter *param)
2576 class Endpoint *epoint;
2580 * we may only release during incoming disconnect state.
2581 * this means that the endpoint doesnt require audio anymore
2583 if (p_state == PORT_STATE_IN_DISCONNECT
2584 || p_state == PORT_STATE_OUT_DISCONNECT)
2586 /* sending release */
2587 l3m = create_l3msg();
2588 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2590 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2592 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
2593 new_state(PORT_STATE_RELEASE);
2595 free_epointid(epoint_id);
2596 // wait for callref to be released
2601 * if we are on incoming call setup, we may reject by sending a release_complete
2602 * also on outgoing call setup, we send a release complete, BUT this is not conform. (i don't know any other way)
2604 if (p_state==PORT_STATE_IN_SETUP
2605 || p_state==PORT_STATE_OUT_SETUP)
2607 //#warning remove me
2608 //PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
2609 /* sending release complete */
2610 l3m = create_l3msg();
2611 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2613 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2615 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2616 new_state(PORT_STATE_RELEASE);
2618 free_epointid(epoint_id);
2619 // wait for callref to be released
2624 wirklich erst proceeding?:
2625 /* NT-MODE in setup state we must send PROCEEDING first */
2626 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2628 CALL_PROCEEDING_t *proceeding;
2630 /* sending proceeding */
2631 l3m = create_l3msg();
2632 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2633 /* channel information */
2634 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2635 /* progress information */
2636 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2637 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2638 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2639 if (p_m_mISDNport->tones)
2640 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2642 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2646 /* sending disconnect */
2647 l3m = create_l3msg();
2648 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2649 /* progress information */
2650 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2651 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2652 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2653 if (p_m_mISDNport->tones)
2654 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2656 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2658 epoint = find_epoint_id(epoint_id);
2659 if (param->disconnectinfo.display[0])
2660 p = param->disconnectinfo.display;
2661 if (p) if (*p && p_m_d_ntmode)
2662 enc_ie_display(l3m, (unsigned char *)p);
2664 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2665 new_state(PORT_STATE_OUT_DISCONNECT);
2667 free_epointid(epoint_id);
2668 // wait for release and callref to be released
2669 //#warning remove me
2670 //PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
2675 * endpoint sends messages to the port
2677 int Pdss1::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
2679 struct lcr_msg *message;
2681 if (PmISDN::message_epoint(epoint_id, message_id, param))
2686 case MESSAGE_INFORMATION: /* overlap dialing */
2687 if (p_type==PORT_TYPE_DSS1_NT_OUT
2688 && p_state!=PORT_STATE_OUT_OVERLAP
2689 && p_state!=PORT_STATE_CONNECT
2690 && p_state!=PORT_STATE_OUT_DISCONNECT
2691 && p_state!=PORT_STATE_IN_DISCONNECT)
2695 if (p_type==PORT_TYPE_DSS1_TE_OUT
2696 && p_state!=PORT_STATE_OUT_OVERLAP
2697 && p_state!=PORT_STATE_OUT_PROCEEDING
2698 && p_state!=PORT_STATE_OUT_ALERTING
2699 && p_state!=PORT_STATE_CONNECT
2700 && p_state!=PORT_STATE_OUT_DISCONNECT
2701 && p_state!=PORT_STATE_IN_DISCONNECT)
2705 if ((p_type==PORT_TYPE_DSS1_NT_IN || p_type==PORT_TYPE_DSS1_TE_IN)
2706 && p_state!=PORT_STATE_IN_OVERLAP
2707 && p_state!=PORT_STATE_IN_PROCEEDING
2708 && p_state!=PORT_STATE_IN_ALERTING
2709 && p_state!=PORT_STATE_CONNECT
2710 && p_state!=PORT_STATE_CONNECT_WAITING
2711 && p_state!=PORT_STATE_OUT_DISCONNECT
2712 && p_state!=PORT_STATE_IN_DISCONNECT)
2716 message_information(epoint_id, message_id, param);
2719 case MESSAGE_SETUP: /* dial-out command received from epoint */
2720 if (p_state!=PORT_STATE_IDLE
2721 && p_state!=PORT_STATE_CONNECT)
2723 PERROR("Pdss1(%s) ignoring setup because isdn port is not in idle state (or connected for sending display info).\n", p_name);
2726 if (p_epointlist && p_state==PORT_STATE_IDLE)
2727 FATAL("Pdss1(%s): epoint pointer is set in idle state, how bad!!\n", p_name);
2728 message_setup(epoint_id, message_id, param);
2731 case MESSAGE_NOTIFY: /* display and notifications */
2732 message_notify(epoint_id, message_id, param);
2735 case MESSAGE_FACILITY: /* facility message */
2736 message_facility(epoint_id, message_id, param);
2739 case MESSAGE_OVERLAP: /* more information is needed */
2740 if (p_state!=PORT_STATE_IN_SETUP)
2744 message_overlap(epoint_id, message_id, param);
2747 case MESSAGE_PROCEEDING: /* call of endpoint is proceeding */
2748 if (p_state!=PORT_STATE_IN_SETUP
2749 && p_state!=PORT_STATE_IN_OVERLAP)
2753 message_proceeding(epoint_id, message_id, param);
2756 case MESSAGE_ALERTING: /* call of endpoint is ringing */
2757 if (p_state!=PORT_STATE_IN_SETUP
2758 && p_state!=PORT_STATE_IN_OVERLAP
2759 && p_state!=PORT_STATE_IN_PROCEEDING)
2763 message_alerting(epoint_id, message_id, param);
2766 case MESSAGE_CONNECT: /* call of endpoint is connected */
2767 if (p_state!=PORT_STATE_IN_SETUP
2768 && p_state!=PORT_STATE_IN_OVERLAP
2769 && p_state!=PORT_STATE_IN_PROCEEDING
2770 && p_state!=PORT_STATE_IN_ALERTING
2771 && !(p_state==PORT_STATE_CONNECT && p_m_d_ntmode))
2775 message_connect(epoint_id, message_id, param);
2778 case MESSAGE_DISCONNECT: /* call has been disconnected */
2779 if (p_state!=PORT_STATE_IN_SETUP
2780 && p_state!=PORT_STATE_IN_OVERLAP
2781 && p_state!=PORT_STATE_IN_PROCEEDING
2782 && p_state!=PORT_STATE_IN_ALERTING
2783 && p_state!=PORT_STATE_OUT_SETUP
2784 && p_state!=PORT_STATE_OUT_OVERLAP
2785 && p_state!=PORT_STATE_OUT_PROCEEDING
2786 && p_state!=PORT_STATE_OUT_ALERTING
2787 && p_state!=PORT_STATE_CONNECT
2788 && p_state!=PORT_STATE_CONNECT_WAITING)
2792 message_disconnect(epoint_id, message_id, param);
2795 case MESSAGE_RELEASE: /* release isdn port */
2796 if (p_state==PORT_STATE_RELEASE)
2800 message_release(epoint_id, message_id, param);
2804 PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message);
2813 * data from isdn-stack (layer-3) to pbx (port class)
2815 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
2821 PDEBUG(DEBUG_ISDN, "cmd(0x%x) pid(0x%x)\n", cmd, pid);
2825 PDEBUG(DEBUG_ISDN, "ignoring dummy process from phone.\n");
2829 /* find Port object of type ISDN */
2834 if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
2836 pdss1 = (class Pdss1 *)port;
2837 /* check out correct stack and id */
2838 if (pdss1->p_m_mISDNport == mISDNport)
2840 if (pdss1->p_m_d_l3id & MISDN_PID_CR_FLAG)
2842 /* local callref, so match value only */
2843 if ((pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == (pid & MISDN_PID_CRVAL_MASK))
2847 /* remote callref, ref + channel id */
2848 if (pdss1->p_m_d_l3id == pid)
2856 /* aktueller prozess */
2859 if (cmd == MT_ASSIGN)
2861 /* stack gives us new layer 3 id (during connect) */
2862 l1l2l3_trace_header(mISDNport, pdss1, L3_NEW_L3ID_IND, DIRECTION_IN);
2863 add_trace("callref", "old", "0x%x", pdss1->p_m_d_l3id);
2864 /* nt-library now gives us a new id via CC_SETUP_CONFIRM */
2865 if ((pdss1->p_m_d_l3id&MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER)
2866 PERROR(" strange setup-procid 0x%x\n", pdss1->p_m_d_l3id);
2867 pdss1->p_m_d_l3id = pid;
2868 if (port->p_state == PORT_STATE_CONNECT)
2869 pdss1->p_m_d_ces = pid >> 16;
2870 add_trace("callref", "new", "0x%x", pdss1->p_m_d_l3id);
2874 /* if process id is master process, but a child disconnects */
2875 if (mISDNport->ntmode
2876 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2877 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) == MISDN_PID_MASTER)
2879 if (cmd == MT_DISCONNECT
2880 || cmd == MT_RELEASE)
2882 /* send special indication for child disconnect */
2883 pdss1->disconnect_ind_i(cmd, pid, l3m);
2886 if (cmd == MT_RELEASE_COMPLETE)
2889 /* if we have child pid and got different child pid message, ignore */
2890 if (mISDNport->ntmode
2891 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2892 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2893 && pid != pdss1->p_m_d_l3id)
2896 /* process message */
2897 pdss1->message_isdn(cmd, pid, l3m);
2905 /* creating port object, transparent until setup with hdlc */
2906 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2907 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0, B_MODE_TRANSPARENT)))
2909 FATAL("Cannot create Port instance.\n");
2910 pdss1->message_isdn(cmd, pid, l3m);
2914 /* creating port object, transparent until setup with hdlc */
2915 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2916 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0, B_MODE_TRANSPARENT)))
2917 FATAL("Cannot create Port instance.\n");
2918 pdss1->message_isdn(cmd, pid, l3m);
2922 PDEBUG(DEBUG_ISDN, "unused call ref released (l3id=0x%x)\n", pid);
2925 case MT_RELEASE_COMPLETE:
2926 PERROR("must be ignored by stack, not sent to app\n");
2930 // facility als broadcast
2934 PERROR("unhandled message: cmd(0x%x) pid(0x%x)\n", cmd, pid);
2938 if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT)
2940 pdss1 = (class Pdss1 *)port;
2941 /* check out correct stack */
2942 if (pdss1->p_m_mISDNport == mISDNport)
2943 /* check out correct id */
2944 PERROR("unhandled message: pid=%x is not associated with port-dinfo=%x\n", pid, pdss1->p_m_d_l3id);
2956 * sending message that were queued during L1 activation
2957 * or releasing port if link is down
2959 void setup_queue(struct mISDNport *mISDNport, int link)
2963 struct lcr_msg *message;
2965 if (!mISDNport->ntmode)
2968 /* check all port objects for pending message */
2972 if ((port->p_type&PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
2974 pdss1 = (class Pdss1 *)port;
2975 if (pdss1->p_m_mISDNport == mISDNport)
2977 if (pdss1->p_m_d_queue)
2981 PDEBUG(DEBUG_ISDN, "the L1 became active, so we send queued message for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
2982 /* LAYER 1 is up, so we send */
2983 pdss1->message_setup(pdss1->p_m_d_queue->id_from, pdss1->p_m_d_queue->type, &pdss1->p_m_d_queue->param);
2984 message_free(pdss1->p_m_d_queue);
2985 pdss1->p_m_d_queue = NULL;
2988 PDEBUG(DEBUG_ISDN, "the L1 became NOT active, so we release port for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
2989 message = message_create(pdss1->p_serial, pdss1->p_m_d_queue->id_from, PORT_TO_EPOINT, MESSAGE_RELEASE);
2990 message->param.disconnectinfo.cause = 27;
2991 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
2992 message_put(message);
2993 pdss1->new_state(PORT_STATE_RELEASE);
2994 pdss1->p_m_delete = 1;