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) : PmISDN(type, mISDNport, portname, settings, channel, exclusive)
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 */
331 add_trace("conclusion", NULL, "exclusively requested channel not in list");
333 return(-6); // channel unacceptable
335 i = selchannel->channel-1-(selchannel->channel>=17);
336 if (p_m_mISDNport->b_port[i] == NULL)
338 add_trace("conclusion", NULL, "exclusively requested channel is busy");
340 return(-6); // channel unacceptable
343 /* requested channels in list will be used */
346 i = selchannel->channel-1-(selchannel->channel>=17);
347 if (p_m_mISDNport->b_port[i] == NULL)
351 /* if channel is not available or not in list, it must be searched */
353 /* check for first free channel in list */
355 selchannel = ifport->in_channel;
358 switch(selchannel->channel)
360 case CHANNEL_FREE: /* free channel */
361 add_trace("hunting", "channel", "free");
362 if (p_m_mISDNport->b_reserved >= p_m_mISDNport->b_num)
363 break; /* all channel in use or reserverd */
366 while(i < p_m_mISDNport->b_num)
368 if (p_m_mISDNport->b_port[i] == NULL)
370 channel = i+1+(i>=15);
378 add_trace("hunting", "channel", "%d", selchannel->channel);
379 if (selchannel->channel<1 || selchannel->channel==16)
380 break; /* invalid channels */
381 i = selchannel->channel-1-(selchannel->channel>=17);
382 if (i >= p_m_mISDNport->b_num)
383 break; /* channel not in port */
384 if (p_m_mISDNport->b_port[i] == NULL)
386 channel = selchannel->channel;
392 break; /* found channel */
393 selchannel = selchannel->next;
397 add_trace("conclusion", NULL, "no channel available");
399 return(-6); // channel unacceptable
403 add_trace("conclusion", NULL, "channel available");
404 add_trace("connect", "channel", "%d", channel);
410 * handles all indications
412 /* CC_SETUP INDICATION */
413 void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
415 int calling_type, calling_plan, calling_present, calling_screen;
416 int called_type, called_plan;
417 int redir_type, redir_plan, redir_present, redir_screen, redir_reason;
418 int hlc_coding, hlc_presentation, hlc_interpretation, hlc_hlc, hlc_exthlc;
419 int bearer_coding, bearer_capability, bearer_mode, bearer_rate, bearer_multi, bearer_user;
420 int exclusive, channel;
422 unsigned char keypad[32] = "";
423 unsigned char useruser[128];
424 int useruser_len = 0, useruser_protocol;
425 class Endpoint *epoint;
426 struct lcr_msg *message;
428 /* process given callref */
429 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
430 add_trace("callref", "new", "0x%x", pid);
433 /* release in case the ID is already in use */
434 add_trace("error", NULL, "callref already in use");
436 l3m = create_l3msg();
437 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
438 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
439 add_trace("reason", NULL, "callref already in use");
441 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, pid, l3m);
442 new_state(PORT_STATE_RELEASE);
447 p_m_d_ces = pid >> 16;
450 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_IND, DIRECTION_IN);
451 dec_ie_calling_pn(l3m, &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id));
452 dec_ie_called_pn(l3m, &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
453 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
454 /* te-mode: CNIP (calling name identification presentation) */
456 dec_facility_centrex(l3m, (unsigned char *)p_callerinfo.name, sizeof(p_callerinfo.name));
457 dec_ie_useruser(l3m, &useruser_protocol, useruser, &useruser_len);
458 dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
459 dec_ie_redir_nr(l3m, &redir_type, &redir_plan, &redir_present, &redir_screen, &redir_reason, (unsigned char *)p_redirinfo.id, sizeof(p_redirinfo.id));
460 dec_ie_channel_id(l3m, &exclusive, &channel);
461 dec_ie_hlc(l3m, &hlc_coding, &hlc_interpretation, &hlc_presentation, &hlc_hlc, &hlc_exthlc);
462 dec_ie_bearer(l3m, &bearer_coding, &bearer_capability, &bearer_mode, &bearer_rate, &bearer_multi, &bearer_user);
465 /* if blocked, release call with MT_RELEASE_COMPLETE */
466 if (p_m_mISDNport->ifport->block)
468 l3m = create_l3msg();
469 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
470 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 27); /* temporary unavailable */
471 add_trace("reason", NULL, "port blocked");
473 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
474 new_state(PORT_STATE_RELEASE);
480 switch (calling_present)
483 p_callerinfo.present = INFO_PRESENT_RESTRICTED;
486 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
489 p_callerinfo.present = INFO_PRESENT_ALLOWED;
492 switch (calling_screen)
495 p_callerinfo.screen = INFO_SCREEN_USER;
498 p_callerinfo.screen = INFO_SCREEN_NETWORK;
501 switch (calling_type)
504 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
505 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
506 p_callerinfo.screen = INFO_SCREEN_NETWORK;
509 p_callerinfo.ntype = INFO_NTYPE_INTERNATIONAL;
512 p_callerinfo.ntype = INFO_NTYPE_NATIONAL;
515 p_callerinfo.ntype = INFO_NTYPE_SUBSCRIBER;
518 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
521 p_callerinfo.isdn_port = p_m_portnum;
522 SCPY(p_callerinfo.interface, p_m_mISDNport->ifport->interface->name);
524 /* dialing information */
525 SCAT(p_dialinginfo.id, (char *)keypad);
529 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
532 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
535 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
538 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
543 switch (redir_present)
546 p_redirinfo.present = INFO_PRESENT_RESTRICTED;
549 p_redirinfo.present = INFO_PRESENT_NOTAVAIL;
552 p_redirinfo.present = INFO_PRESENT_ALLOWED;
555 switch (redir_screen)
558 p_redirinfo.screen = INFO_SCREEN_USER;
561 p_redirinfo.screen = INFO_SCREEN_NETWORK;
564 switch (redir_reason)
567 p_redirinfo.reason = INFO_REDIR_BUSY;
570 p_redirinfo.reason = INFO_REDIR_NORESPONSE;
573 p_redirinfo.reason = INFO_REDIR_UNCONDITIONAL;
576 p_redirinfo.reason = INFO_REDIR_CALLDEFLECT;
579 p_redirinfo.reason = INFO_REDIR_OUTOFORDER;
582 p_redirinfo.reason = INFO_REDIR_UNKNOWN;
588 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
589 p_redirinfo.present = INFO_PRESENT_NULL; /* not redirecting */
590 p_redirinfo.reason = INFO_REDIR_UNKNOWN;
593 p_redirinfo.ntype = INFO_NTYPE_INTERNATIONAL;
596 p_redirinfo.ntype = INFO_NTYPE_NATIONAL;
599 p_redirinfo.ntype = INFO_NTYPE_SUBSCRIBER;
602 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
605 p_redirinfo.isdn_port = p_m_portnum;
607 /* bearer capability */
608 switch (bearer_capability)
611 p_capainfo.bearer_capa = INFO_BC_AUDIO;
612 bearer_user = (options.law=='a')?3:2;
615 p_capainfo.bearer_capa = bearer_capability;
621 p_capainfo.bearer_mode = INFO_BMODE_PACKET;
624 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
630 p_capainfo.bearer_info1 = INFO_INFO1_NONE;
633 p_capainfo.bearer_info1 = bearer_user + 0x80;
641 p_capainfo.hlc = INFO_HLC_NONE;
644 p_capainfo.hlc = hlc_hlc + 0x80;
650 p_capainfo.exthlc = INFO_HLC_NONE;
653 p_capainfo.exthlc = hlc_exthlc + 0x80;
658 ret = channel = hunt_bchannel(channel, exclusive);
663 ret = seize_bchannel(channel, 1);
668 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
669 * in response to the setup
671 l3m = create_l3msg();
672 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
673 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
675 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
676 new_state(PORT_STATE_RELEASE);
680 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
682 /* create endpoint */
684 FATAL("Incoming call but already got an endpoint.\n");
685 if (!(epoint = new Endpoint(p_serial, 0)))
686 FATAL("No memory for Endpoint instance\n");
687 if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 0))) //incoming
688 FATAL("No memory for Endpoint Application instance\n");
689 epointlist_new(epoint->ep_serial);
691 /* send setup message to endpoit */
692 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
693 message->param.setup.isdn_port = p_m_portnum;
694 message->param.setup.port_type = p_type;
695 // message->param.setup.dtmf = !p_m_mISDNport->ifport->nodtmf;
696 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
697 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
698 memcpy(&message->param.setup.redirinfo, &p_redirinfo, sizeof(struct redir_info));
699 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
700 memcpy(message->param.setup.useruser.data, &useruser, useruser_len);
701 message->param.setup.useruser.len = useruser_len;
702 message->param.setup.useruser.protocol = useruser_protocol;
703 message_put(message);
705 new_state(PORT_STATE_IN_SETUP);
708 /* CC_INFORMATION INDICATION */
709 void Pdss1::information_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
712 unsigned char keypad[32] = "";
713 struct lcr_msg *message;
715 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_IND, DIRECTION_IN);
716 dec_ie_called_pn(l3m, &type, &plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
717 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
718 dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
721 SCAT(p_dialinginfo.id, (char *)keypad);
725 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
728 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
731 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
734 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
737 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_INFORMATION);
738 memcpy(&message->param.information, &p_dialinginfo, sizeof(struct dialing_info));
739 message_put(message);
740 /* reset overlap timeout */
744 /* CC_SETUP_ACCNOWLEDGE INDICATION */
745 void Pdss1::setup_acknowledge_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
747 int exclusive, channel;
748 int coding, location, progress;
750 struct lcr_msg *message;
752 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_IND, DIRECTION_IN);
753 dec_ie_channel_id(l3m, &exclusive, &channel);
754 dec_ie_progress(l3m, &coding, &location, &progress);
757 /* process channel */
758 ret = received_first_reply_to_setup(cmd, channel, exclusive);
761 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
762 message->param.disconnectinfo.cause = -ret;
763 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
764 message_put(message);
765 new_state(PORT_STATE_RELEASE);
770 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_OVERLAP);
771 message_put(message);
773 new_state(PORT_STATE_OUT_OVERLAP);
776 /* CC_PROCEEDING INDICATION */
777 void Pdss1::proceeding_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
779 int exclusive, channel;
780 int coding, location, progress;
782 struct lcr_msg *message;
783 int notify = -1, type, plan, present;
786 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_IND, DIRECTION_IN);
787 dec_ie_channel_id(l3m, &exclusive, &channel);
788 dec_ie_progress(l3m, &coding, &location, &progress);
789 dec_ie_notify(l3m, ¬ify);
790 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
793 ret = received_first_reply_to_setup(cmd, channel, exclusive);
796 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
797 message->param.disconnectinfo.cause = -ret;
798 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
799 message_put(message);
800 new_state(PORT_STATE_RELEASE);
804 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
805 message_put(message);
807 new_state(PORT_STATE_OUT_PROCEEDING);
813 if (type >= 0 || notify)
815 if (!notify && type >= 0)
817 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
818 message->param.notifyinfo.notify = notify;
819 SCPY(message->param.notifyinfo.id, redir);
820 /* redirection number */
824 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
827 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
830 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
836 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
837 message->param.notifyinfo.present = INFO_PRESENT_NULL;
840 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
843 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
846 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
849 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
852 message->param.notifyinfo.isdn_port = p_m_portnum;
853 message_put(message);
857 /* CC_ALERTING INDICATION */
858 void Pdss1::alerting_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
860 int exclusive, channel;
861 int coding, location, progress;
863 struct lcr_msg *message;
864 int notify = -1, type, plan, present;
867 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_IND, DIRECTION_IN);
868 dec_ie_channel_id(l3m, &exclusive, &channel);
869 dec_ie_progress(l3m, &coding, &location, &progress);
870 dec_ie_notify(l3m, ¬ify);
871 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
874 /* process channel */
875 ret = received_first_reply_to_setup(cmd, channel, exclusive);
878 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
879 message->param.disconnectinfo.cause = -ret;
880 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
881 message_put(message);
882 new_state(PORT_STATE_RELEASE);
886 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ALERTING);
887 message_put(message);
889 new_state(PORT_STATE_OUT_ALERTING);
895 if (type >= 0 || notify)
897 if (!notify && type >= 0)
899 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
900 message->param.notifyinfo.notify = notify;
901 SCPY(message->param.notifyinfo.id, redir);
905 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
908 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
911 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
917 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
918 message->param.notifyinfo.present = INFO_PRESENT_NULL;
921 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
924 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
927 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
930 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
933 message->param.notifyinfo.isdn_port = p_m_portnum;
934 message_put(message);
938 /* CC_CONNECT INDICATION */
939 void Pdss1::connect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
941 int exclusive, channel;
942 int type, plan, present, screen;
944 struct lcr_msg *message;
947 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_IND, DIRECTION_IN);
948 dec_ie_channel_id(l3m, &exclusive, &channel);
949 dec_ie_connected_pn(l3m, &type, &plan, &present, &screen, (unsigned char *)p_connectinfo.id, sizeof(p_connectinfo.id));
950 /* te-mode: CONP (connected name identification presentation) */
952 dec_facility_centrex(l3m, (unsigned char *)p_connectinfo.name, sizeof(p_connectinfo.name));
956 bchannel_before = p_m_b_channel;
957 ret = received_first_reply_to_setup(cmd, channel, exclusive);
960 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
961 message->param.disconnectinfo.cause = -ret;
962 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
963 message_put(message);
964 new_state(PORT_STATE_RELEASE);
969 /* connect information */
973 p_connectinfo.present = INFO_PRESENT_RESTRICTED;
976 p_connectinfo.present = INFO_PRESENT_NOTAVAIL;
979 p_connectinfo.present = INFO_PRESENT_ALLOWED;
985 p_connectinfo.screen = INFO_SCREEN_USER;
988 p_connectinfo.screen = INFO_SCREEN_NETWORK;
994 p_connectinfo.present = INFO_PRESENT_NULL; /* no COLP info */
995 p_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
998 p_connectinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1001 p_connectinfo.ntype = INFO_NTYPE_NATIONAL;
1004 p_connectinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1007 p_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
1010 p_connectinfo.isdn_port = p_m_portnum;
1011 SCPY(p_connectinfo.interface, p_m_mISDNport->ifport->interface->name);
1013 /* only in nt-mode we send connect ack. in te-mode it is done by stack itself or optional */
1016 /* send connect acknowledge */
1017 l3m = create_l3msg();
1018 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_RES, DIRECTION_OUT);
1019 /* if we had no bchannel before, we send it now */
1020 if (!bchannel_before && p_m_b_channel)
1021 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1023 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT_ACKNOWLEDGE, p_m_d_l3id, l3m);
1026 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_CONNECT);
1027 memcpy(&message->param.connectinfo, &p_connectinfo, sizeof(struct connect_info));
1028 message_put(message);
1030 new_state(PORT_STATE_CONNECT);
1033 /* CC_DISCONNECT INDICATION */
1034 void Pdss1::disconnect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1036 int location, cause;
1037 int coding, proglocation, progress;
1038 struct lcr_msg *message;
1040 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1041 dec_ie_progress(l3m, &coding, &proglocation, &progress);
1042 dec_ie_cause(l3m, &location, &cause);
1048 /* release if remote sends us no tones */
1049 if (!p_m_mISDNport->earlyb)
1053 l3m = create_l3msg();
1054 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
1055 enc_ie_cause(l3m, location, cause); /* normal */
1056 add_trace("reason", NULL, "no remote patterns");
1058 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
1060 /* sending release to endpoint */
1061 if (location == LOCATION_PRIVATE_LOCAL)
1062 location = LOCATION_PRIVATE_REMOTE;
1065 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1066 message->param.disconnectinfo.cause = cause;
1067 message->param.disconnectinfo.location = location;
1068 message_put(message);
1070 free_epointlist(p_epointlist);
1072 new_state(PORT_STATE_RELEASE);
1077 /* sending disconnect to active endpoint and release to inactive endpoints */
1078 if (location == LOCATION_PRIVATE_LOCAL)
1079 location = LOCATION_PRIVATE_REMOTE;
1080 if (ACTIVE_EPOINT(p_epointlist))
1082 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_DISCONNECT);
1083 message->param.disconnectinfo.location = location;
1084 message->param.disconnectinfo.cause = cause;
1085 message_put(message);
1087 while(INACTIVE_EPOINT(p_epointlist))
1089 message = message_create(p_serial, INACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1090 message->param.disconnectinfo.location = location;
1091 message->param.disconnectinfo.cause = cause;
1092 message_put(message);
1094 free_epointid(INACTIVE_EPOINT(p_epointlist));
1096 new_state(PORT_STATE_IN_DISCONNECT);
1099 /* CC_DISCONNECT INDICATION */
1100 void Pdss1::disconnect_ind_i(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1102 int location, cause;
1105 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1106 if (p_m_d_collect_cause > 0)
1108 add_trace("old-cause", "location", "%d", p_m_d_collect_location);
1109 add_trace("old-cause", "value", "%d", p_m_d_collect_cause);
1111 dec_ie_cause(l3m, &location, &cause);
1112 if (location == LOCATION_PRIVATE_LOCAL)
1113 location = LOCATION_PRIVATE_REMOTE;
1116 collect_cause(&p_m_d_collect_cause, &p_m_d_collect_location, cause, location);
1117 add_trace("new-cause", "location", "%d", p_m_d_collect_location);
1118 add_trace("new-cause", "value", "%d", p_m_d_collect_cause);
1123 /* CC_RELEASE INDICATION */
1124 void Pdss1::release_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1126 int location, cause;
1127 struct lcr_msg *message;
1129 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_IND, DIRECTION_IN);
1130 dec_ie_cause(l3m, &location, &cause);
1136 /* sending release to endpoint */
1137 if (location == LOCATION_PRIVATE_LOCAL)
1138 location = LOCATION_PRIVATE_REMOTE;
1141 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1142 message->param.disconnectinfo.cause = cause;
1143 message->param.disconnectinfo.location = location;
1144 message_put(message);
1146 free_epointlist(p_epointlist);
1149 new_state(PORT_STATE_RELEASE);
1153 /* CC_RESTART INDICATION */
1154 void Pdss1::restart_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1156 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESTART_IND, DIRECTION_IN);
1159 // L3 process is not toucht. (not even by network stack)
1162 /* CC_RELEASE_COMPLETE INDICATION (a reject) */
1163 void Pdss1::release_complete_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1165 int location, cause;
1166 struct lcr_msg *message;
1168 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_IND, DIRECTION_IN);
1169 /* in case layer 2 is down during setup, we send cause 27 loc 5 */
1170 if (p_state == PORT_STATE_OUT_SETUP && !p_m_mISDNport->l1link)
1176 dec_ie_cause(l3m, &location, &cause);
1177 add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
1180 if (location == LOCATION_PRIVATE_LOCAL)
1181 location = LOCATION_PRIVATE_REMOTE;
1186 /* sending release to endpoint */
1189 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1190 message->param.disconnectinfo.cause = cause;
1191 message->param.disconnectinfo.location = location;
1192 message_put(message);
1194 free_epointlist(p_epointlist);
1197 new_state(PORT_STATE_RELEASE);
1202 void Pdss1::t312_timeout_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1204 // not required, release is performed with MT_FREE
1207 /* CC_NOTIFY INDICATION */
1208 void Pdss1::notify_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1210 struct lcr_msg *message;
1211 int notify, type, plan, present;
1212 unsigned char notifyid[sizeof(message->param.notifyinfo.id)];
1214 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_IND, DIRECTION_IN);
1215 dec_ie_notify(l3m, ¬ify);
1216 dec_ie_redir_dn(l3m, &type, &plan, &present, notifyid, sizeof(notifyid));
1219 if (!ACTIVE_EPOINT(p_epointlist))
1221 /* notification indicator */
1225 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1226 message->param.notifyinfo.notify = notify;
1227 SCPY(message->param.notifyinfo.id, (char *)notifyid);
1228 /* redirection number */
1232 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
1235 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
1238 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
1244 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1245 message->param.notifyinfo.present = INFO_PRESENT_NULL;
1248 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1251 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
1254 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1257 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1260 message->param.notifyinfo.isdn_port = p_m_portnum;
1261 message_put(message);
1265 /* CC_HOLD INDICATION */
1266 struct lcr_msg *message;
1267 void Pdss1::hold_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1269 // class Endpoint *epoint;
1271 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_IND, DIRECTION_IN);
1274 if (!ACTIVE_EPOINT(p_epointlist) || p_m_hold)
1276 l3m = create_l3msg();
1277 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_REJECT_REQ, DIRECTION_OUT);
1278 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */
1279 add_trace("reason", NULL, "no endpoint");
1281 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_REJECT, p_m_d_l3id, l3m);
1286 /* notify the hold of call */
1287 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1288 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_HOLD;
1289 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1290 message_put(message);
1292 /* deactivate bchannel */
1293 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (hold)", DIRECTION_NONE);
1294 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1298 /* set hold state */
1301 epoint = find_epoint_id(ACTIVE_EPOINT(p_epointlist));
1302 if (epoint && p_m_d_ntmode)
1304 p_m_timeout = p_settings.tout_hold;
1309 /* acknowledge hold */
1310 l3m = create_l3msg();
1311 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1313 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_ACKNOWLEDGE, p_m_d_l3id, l3m);
1317 /* CC_RETRIEVE INDICATION */
1318 void Pdss1::retrieve_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1320 struct lcr_msg *message;
1321 int channel, exclusive, cause;
1324 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_IND, DIRECTION_IN);
1325 dec_ie_channel_id(l3m, &exclusive, &channel);
1330 cause = 101; /* incompatible state */
1333 l3m = create_l3msg();
1334 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_REJECT_REQ, DIRECTION_OUT);
1335 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, cause);
1337 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_REJECT, p_m_d_l3id, l3m);
1342 /* notify the retrieve of call */
1343 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1344 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL;
1345 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1346 message_put(message);
1349 ret = channel = hunt_bchannel(channel, exclusive);
1354 ret = seize_bchannel(channel, 1);
1361 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1363 /* set hold state */
1367 /* acknowledge retrieve */
1368 l3m = create_l3msg();
1369 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1370 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1372 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_ACKNOWLEDGE, p_m_d_l3id, l3m);
1375 /* CC_SUSPEND INDICATION */
1376 void Pdss1::suspend_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1378 struct lcr_msg *message;
1379 class Endpoint *epoint;
1380 unsigned char callid[8];
1382 int ret = -31; /* normal, unspecified */
1384 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_IND, DIRECTION_IN);
1385 dec_ie_call_id(l3m, callid, &len);
1388 if (!ACTIVE_EPOINT(p_epointlist))
1391 l3m = create_l3msg();
1392 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_REJECT_REQ, DIRECTION_OUT);
1393 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1395 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_REJECT, p_m_d_l3id, l3m);
1402 /* check if call id is in use */
1403 epoint = epoint_first;
1406 if (epoint->ep_park)
1408 if (epoint->ep_park_len == len)
1409 if (!memcmp(epoint->ep_park_callid, callid, len))
1411 ret = -84; /* call id in use */
1415 epoint = epoint->next;
1418 /* notify the hold of call */
1419 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1420 message->param.notifyinfo.notify = INFO_NOTIFY_USER_SUSPENDED;
1421 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1422 message_put(message);
1424 /* deactivate bchannel */
1425 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (suspend)", DIRECTION_NONE);
1426 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1430 /* sending suspend to endpoint */
1431 while (p_epointlist)
1433 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_SUSPEND);
1434 memcpy(message->param.parkinfo.callid, callid, sizeof(message->param.parkinfo.callid));
1435 message->param.parkinfo.len = len;
1436 message_put(message);
1438 free_epointlist(p_epointlist);
1441 /* sending SUSPEND_ACKNOWLEDGE */
1442 l3m = create_l3msg();
1443 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1445 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_ACKNOWLEDGE, p_m_d_l3id, l3m);
1447 new_state(PORT_STATE_RELEASE);
1451 /* CC_RESUME INDICATION */
1452 void Pdss1::resume_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1454 unsigned char callid[8];
1456 int channel, exclusive;
1457 class Endpoint *epoint;
1458 struct lcr_msg *message;
1461 /* process given callref */
1462 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
1463 add_trace("callref", "new", "0x%x", pid);
1466 /* release is case the ID is already in use */
1467 add_trace("error", NULL, "callref already in use");
1469 l3m = create_l3msg();
1470 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1471 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
1472 add_trace("reason", NULL, "callref already in use");
1474 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, pid, l3m);
1475 new_state(PORT_STATE_RELEASE);
1480 p_m_d_ces = pid >> 16;
1483 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_IND, DIRECTION_IN);
1484 dec_ie_call_id(l3m, callid, &len);
1487 /* if blocked, release call */
1488 if (p_m_mISDNport->ifport->block)
1497 /* channel_id (no channel is possible in message) */
1499 channel = -1; /* any channel */
1502 ret = channel = hunt_bchannel(channel, exclusive);
1507 ret = seize_bchannel(channel, 1);
1512 l3m = create_l3msg();
1513 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1514 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1516 add_trace("reason", NULL, "port blocked");
1518 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, p_m_d_l3id, l3m);
1519 new_state(PORT_STATE_RELEASE);
1523 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1525 /* create endpoint */
1527 FATAL("Incoming resume but already got an endpoint.\n");
1528 ret = -85; /* no call suspended */
1529 epoint = epoint_first;
1532 if (epoint->ep_park)
1534 ret = -83; /* suspended call exists, but this not */
1535 if (epoint->ep_park_len == len)
1536 if (!memcmp(epoint->ep_park_callid, callid, len))
1539 epoint = epoint->next;
1544 epointlist_new(epoint->ep_serial);
1545 if (!(epoint->portlist_new(p_serial, p_type, p_m_mISDNport->earlyb)))
1546 FATAL("No memory for portlist\n");
1547 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RESUME);
1548 message_put(message);
1550 /* notify the resume of call */
1551 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1552 message->param.notifyinfo.notify = INFO_NOTIFY_USER_RESUMED;
1553 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1554 message_put(message);
1556 /* sending RESUME_ACKNOWLEDGE */
1557 l3m = create_l3msg();
1558 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1559 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1561 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_ACKNOWLEDGE, p_m_d_l3id, l3m);
1563 new_state(PORT_STATE_CONNECT);
1567 /* CC_FACILITY INDICATION */
1568 void Pdss1::facility_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1570 unsigned char facil[256];
1572 struct lcr_msg *message;
1574 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_IND, DIRECTION_IN);
1575 dec_ie_facility(l3m, facil, &facil_len);
1582 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_FACILITY);
1583 message->param.facilityinfo.len = facil_len;
1584 memcpy(message->param.facilityinfo.data, facil, facil_len);
1585 message_put(message);
1590 * handler for isdn connections
1591 * incoming information are parsed and sent via message to the endpoint
1593 void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1602 PERROR("Pdss1(%s) timeout without cause.\n", p_name);
1605 if (l3m->cause[0] != 5)
1607 PERROR("Pdss1(%s) expecting timeout with timer diagnostic. (got len=%d)\n", p_name, l3m->cause[0]);
1610 timer = (l3m->cause[3]-'0')*100;
1611 timer += (l3m->cause[4]-'0')*10;
1612 timer += (l3m->cause[5]-'0');
1613 l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN);
1614 add_trace("timer", NULL, "%d", timer);
1617 t312_timeout_ind(cmd, pid, l3m);
1621 if (p_state != PORT_STATE_IDLE)
1623 setup_ind(cmd, pid, l3m);
1626 case MT_INFORMATION:
1627 information_ind(cmd, pid, l3m);
1630 case MT_SETUP_ACKNOWLEDGE:
1631 if (p_state != PORT_STATE_OUT_SETUP)
1633 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received setup_acknowledge, but we are not in outgoing setup state, IGNORING.\n", p_name);
1636 setup_acknowledge_ind(cmd, pid, l3m);
1639 case MT_CALL_PROCEEDING:
1640 if (p_state != PORT_STATE_OUT_SETUP
1641 && p_state != PORT_STATE_OUT_OVERLAP)
1643 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received proceeding, but we are not in outgoing setup OR overlap state, IGNORING.\n", p_name);
1646 proceeding_ind(cmd, pid, l3m);
1650 if (p_state != PORT_STATE_OUT_SETUP
1651 && p_state != PORT_STATE_OUT_OVERLAP
1652 && p_state != PORT_STATE_OUT_PROCEEDING)
1654 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding state, IGNORING.\n", p_name);
1657 alerting_ind(cmd, pid, l3m);
1661 if (p_state != PORT_STATE_OUT_SETUP
1662 && p_state != PORT_STATE_OUT_OVERLAP
1663 && p_state != PORT_STATE_OUT_PROCEEDING
1664 && p_state != PORT_STATE_OUT_ALERTING)
1666 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);
1669 connect_ind(cmd, pid, l3m);
1670 if (p_m_d_notify_pending)
1672 /* send pending notify message during connect */
1673 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1674 message_free(p_m_d_notify_pending);
1675 p_m_d_notify_pending = NULL;
1679 case MT_CONNECT_ACKNOWLEDGE:
1680 if (p_state == PORT_STATE_CONNECT_WAITING)
1681 new_state(PORT_STATE_CONNECT);
1682 if (p_m_d_notify_pending)
1684 /* send pending notify message during connect-ack */
1685 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1686 message_free(p_m_d_notify_pending);
1687 p_m_d_notify_pending = NULL;
1692 disconnect_ind(cmd, pid, l3m);
1696 release_ind(cmd, pid, l3m);
1699 case MT_RELEASE_COMPLETE:
1700 release_complete_ind(cmd, pid, l3m);
1704 restart_ind(cmd, pid, l3m);
1708 notify_ind(cmd, pid, l3m);
1712 hold_ind(cmd, pid, l3m);
1716 retrieve_ind(cmd, pid, l3m);
1720 suspend_ind(cmd, pid, l3m);
1724 resume_ind(cmd, pid, l3m);
1728 facility_ind(cmd, pid, l3m);
1732 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_L3ID_IND, DIRECTION_IN);
1733 add_trace("callref", NULL, "0x%x", p_m_d_l3id);
1738 /* sending release to endpoint in case we still have an endpoint
1739 * this is because we don't get any response if a release_complete is received (or a release in release state)
1741 while(p_epointlist) // only if not already released
1743 struct lcr_msg *message;
1744 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1745 if (p_m_d_collect_cause)
1747 message->param.disconnectinfo.cause = p_m_d_collect_cause;
1748 message->param.disconnectinfo.location = p_m_d_collect_location;
1751 message->param.disconnectinfo.cause = CAUSE_NOUSER;
1752 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1754 message_put(message);
1756 free_epointlist(p_epointlist);
1758 new_state(PORT_STATE_RELEASE);
1763 l1l2l3_trace_header(p_m_mISDNport, this, L3_UNKNOWN, DIRECTION_IN);
1764 add_trace("unhandled", "cmd", "0x%x", cmd);
1769 void Pdss1::new_state(int state)
1771 // class Endpoint *epoint;
1774 if (state == PORT_STATE_IN_OVERLAP)
1776 p_m_timeout = p_m_mISDNport->ifport->tout_dialing;
1779 if (state != p_state)
1781 if (state == PORT_STATE_IN_SETUP
1782 || state == PORT_STATE_OUT_SETUP
1783 || state == PORT_STATE_IN_OVERLAP
1784 || state == PORT_STATE_OUT_OVERLAP)
1786 p_m_timeout = p_m_mISDNport->ifport->tout_setup;
1789 if (state == PORT_STATE_IN_PROCEEDING
1790 || state == PORT_STATE_OUT_PROCEEDING)
1792 p_m_timeout = p_m_mISDNport->ifport->tout_proceeding;
1795 if (state == PORT_STATE_IN_ALERTING
1796 || state == PORT_STATE_OUT_ALERTING)
1798 p_m_timeout = p_m_mISDNport->ifport->tout_alerting;
1801 if (state == PORT_STATE_CONNECT
1802 || state == PORT_STATE_CONNECT_WAITING)
1806 if (state == PORT_STATE_IN_DISCONNECT
1807 || state == PORT_STATE_OUT_DISCONNECT)
1809 p_m_timeout = p_m_mISDNport->ifport->tout_disconnect;
1814 Port::new_state(state);
1821 int Pdss1::handler(void)
1825 if ((ret = PmISDN::handler()))
1828 /* handle destruction */
1829 if (p_m_delete && p_m_d_l3id==0)
1840 * handles all messages from endpoint
1842 /* MESSAGE_INFORMATION */
1843 void Pdss1::message_information(unsigned int epoint_id, int message_id, union parameter *param)
1847 if (param->information.id[0]) /* only if we have something to dial */
1849 l3m = create_l3msg();
1850 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1851 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)param->information.id);
1853 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1862 void Pdss1::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
1866 int plan, type, screen, present, reason;
1867 int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
1868 int channel, exclusive;
1869 struct epoint_list *epointlist;
1871 /* release if port is blocked */
1872 if (p_m_mISDNport->ifport->block)
1874 struct lcr_msg *message;
1876 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1877 message->param.disconnectinfo.cause = 27; // temp. unavail.
1878 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1879 message_put(message);
1880 new_state(PORT_STATE_RELEASE);
1885 /* copy setup infos to port */
1886 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
1887 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
1888 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
1889 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
1890 // SCPY(&p_m_tones_dir, param->setup.ext.tones_dir);
1891 /* screen outgoing caller id */
1892 do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_m_mISDNport->ifport->interface);
1894 /* only display at connect state: this case happens if endpoint is in connected mode */
1895 if (p_state==PORT_STATE_CONNECT)
1897 if (p_type!=PORT_TYPE_DSS1_NT_OUT
1898 && p_type!=PORT_TYPE_DSS1_NT_IN)
1900 if (p_callerinfo.display[0])
1902 /* sending information */
1903 l3m = create_l3msg();
1904 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1906 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
1908 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1913 /* attach only if not already */
1914 epointlist = p_epointlist;
1917 if (epointlist->epoint_id == epoint_id)
1919 epointlist = epointlist->next;
1922 epointlist_new(epoint_id);
1928 channel = p_m_b_channel;
1929 exclusive = p_m_b_exclusive;
1931 channel = CHANNEL_ANY;
1932 /* nt-port with no channel, not reserverd */
1933 if (!p_m_b_channel && !p_m_b_reserve && p_type==PORT_TYPE_DSS1_NT_OUT)
1934 channel = CHANNEL_NO;
1937 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT);
1938 /* see MT_ASSIGN notes at do_layer3() */
1940 ret = p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ASSIGN, 0, NULL);
1941 if (mt_assign_pid == 0 || ret < 0)
1943 struct lcr_msg *message;
1945 add_trace("callref", NULL, "no free id");
1947 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1948 message->param.disconnectinfo.cause = 47;
1949 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1950 message_put(message);
1951 new_state(PORT_STATE_RELEASE);
1955 p_m_d_l3id = mt_assign_pid;
1957 add_trace("callref", "new", "0x%x", p_m_d_l3id);
1960 /* preparing setup message */
1961 l3m = create_l3msg();
1962 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_REQ, DIRECTION_OUT);
1963 /* channel information */
1964 if (channel >= 0) /* it should */
1966 enc_ie_channel_id(l3m, exclusive, channel);
1968 /* caller information */
1970 switch (p_callerinfo.ntype)
1972 case INFO_NTYPE_INTERNATIONAL:
1975 case INFO_NTYPE_NATIONAL:
1978 case INFO_NTYPE_SUBSCRIBER:
1981 default: /* INFO_NTYPE_UNKNOWN */
1985 switch (p_callerinfo.screen)
1987 case INFO_SCREEN_USER:
1990 default: /* INFO_SCREEN_NETWORK */
1994 switch (p_callerinfo.present)
1996 case INFO_PRESENT_RESTRICTED:
1999 case INFO_PRESENT_NOTAVAIL:
2002 default: /* INFO_PRESENT_ALLOWED */
2007 enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id);
2008 /* dialing information */
2009 if (p_dialinginfo.id[0]) /* only if we have something to dial */
2011 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id);
2013 /* sending complete */
2014 if (p_dialinginfo.sending_complete)
2015 enc_ie_complete(l3m, 1);
2016 /* sending user-user */
2017 if (param->setup.useruser.len)
2019 enc_ie_useruser(l3m, param->setup.useruser.protocol, param->setup.useruser.data, param->setup.useruser.len);
2021 /* redirecting number */
2023 switch (p_redirinfo.ntype)
2025 case INFO_NTYPE_INTERNATIONAL:
2028 case INFO_NTYPE_NATIONAL:
2031 case INFO_NTYPE_SUBSCRIBER:
2034 default: /* INFO_NTYPE_UNKNOWN */
2038 switch (p_redirinfo.screen)
2040 case INFO_SCREEN_USER:
2043 default: /* INFO_SCREE_NETWORK */
2047 switch (p_redirinfo.reason)
2049 case INFO_REDIR_BUSY:
2052 case INFO_REDIR_NORESPONSE:
2055 case INFO_REDIR_UNCONDITIONAL:
2058 case INFO_REDIR_CALLDEFLECT:
2061 case INFO_REDIR_OUTOFORDER:
2064 default: /* INFO_REDIR_UNKNOWN */
2068 switch (p_redirinfo.present)
2070 case INFO_PRESENT_NULL: /* no redir at all */
2077 case INFO_PRESENT_RESTRICTED:
2080 case INFO_PRESENT_NOTAVAIL:
2083 default: /* INFO_PRESENT_ALLOWED */
2087 /* sending redirecting number only in ntmode */
2088 if (type >= 0 && p_m_d_ntmode)
2089 enc_ie_redir_nr(l3m, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
2090 /* bearer capability */
2091 //printf("hlc=%d\n",p_capainfo.hlc);
2093 capability = p_capainfo.bearer_capa;
2094 mode = p_capainfo.bearer_mode;
2095 rate = (mode==INFO_BMODE_CIRCUIT)?0x10:0x00;
2096 switch (p_capainfo.bearer_info1)
2098 case INFO_INFO1_NONE:
2102 user = p_capainfo.bearer_info1 & 0x7f;
2105 enc_ie_bearer(l3m, coding, capability, mode, rate, -1, user);
2112 hlc = p_capainfo.hlc & 0x7f;
2114 if (p_capainfo.exthlc)
2115 exthlc = p_capainfo.exthlc & 0x7f;
2116 enc_ie_hlc(l3m, coding, interpretation, presentation, hlc, exthlc);
2120 if (p_callerinfo.display[0] && p_m_d_ntmode)
2121 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
2122 /* nt-mode: CNIP (calling name identification presentation) */
2123 // if (p_callerinfo.name[0] && p_m_d_ntmode)
2124 // enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
2127 /* send setup message now */
2128 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP, p_m_d_l3id, l3m);
2130 new_state(PORT_STATE_OUT_SETUP);
2133 /* MESSAGE_FACILITY */
2134 void Pdss1::message_facility(unsigned int epoint_id, int message_id, union parameter *param)
2138 /* facility will not be sent to external lines */
2142 /* sending facility */
2143 l3m = create_l3msg();
2144 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
2145 enc_ie_facility(l3m, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len);
2147 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
2150 /* MESSAGE_NOTIFY */
2151 void Pdss1::message_notify(unsigned int epoint_id, int message_id, union parameter *param)
2155 int plan, type = -1, present;
2157 if (param->notifyinfo.notify>INFO_NOTIFY_NONE)
2158 notify = param->notifyinfo.notify & 0x7f;
2161 if (p_state != PORT_STATE_CONNECT)
2163 /* notify only allowed in active state */
2169 switch (param->notifyinfo.ntype)
2171 case INFO_NTYPE_INTERNATIONAL:
2174 case INFO_NTYPE_NATIONAL:
2177 case INFO_NTYPE_SUBSCRIBER:
2180 default: /* INFO_NTYPE_UNKNOWN */
2184 switch (param->notifyinfo.present)
2186 case INFO_PRESENT_NULL: /* no redir at all */
2191 case INFO_PRESENT_RESTRICTED:
2194 case INFO_PRESENT_NOTAVAIL:
2197 default: /* INFO_PRESENT_ALLOWED */
2203 if (notify<0 && !param->notifyinfo.display[0])
2205 /* nothing to notify, nothing to display */
2211 if (p_state!=PORT_STATE_CONNECT)
2213 /* queue notification */
2214 if (p_m_d_notify_pending)
2215 message_free(p_m_d_notify_pending);
2216 p_m_d_notify_pending = message_create(ACTIVE_EPOINT(p_epointlist), p_serial, EPOINT_TO_PORT, message_id);
2217 memcpy(&p_m_d_notify_pending->param, param, sizeof(union parameter));
2220 /* sending notification */
2221 l3m = create_l3msg();
2222 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
2223 enc_ie_notify(l3m, notify);
2224 /* sending redirection number only in ntmode */
2225 if (type >= 0 && p_m_d_ntmode)
2226 enc_ie_redir_dn(l3m, type, plan, present, (unsigned char *)param->notifyinfo.id);
2227 if (param->notifyinfo.display[0] && p_m_d_ntmode)
2228 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2230 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_NOTIFY, p_m_d_l3id, l3m);
2232 } else if (p_m_d_ntmode)
2234 /* sending information */
2235 l3m = create_l3msg();
2236 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2237 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2239 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2243 /* MESSAGE_OVERLAP */
2244 void Pdss1::message_overlap(unsigned int epoint_id, int message_id, union parameter *param)
2248 /* sending setup_acknowledge */
2249 l3m = create_l3msg();
2250 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_REQ, DIRECTION_OUT);
2251 /* channel information */
2252 if (p_state == PORT_STATE_IN_SETUP)
2253 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2254 /* progress information */
2255 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2256 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2257 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2258 if (p_m_mISDNport->tones)
2259 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2261 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, l3m);
2263 new_state(PORT_STATE_IN_OVERLAP);
2266 /* MESSAGE_PROCEEDING */
2267 void Pdss1::message_proceeding(unsigned int epoint_id, int message_id, union parameter *param)
2271 /* sending proceeding */
2272 l3m = create_l3msg();
2273 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2274 /* channel information */
2275 if (p_state == PORT_STATE_IN_SETUP)
2276 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2277 /* progress information */
2278 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2279 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2280 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2281 if (p_m_mISDNport->tones)
2282 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2284 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2286 new_state(PORT_STATE_IN_PROCEEDING);
2289 /* MESSAGE_ALERTING */
2290 void Pdss1::message_alerting(unsigned int epoint_id, int message_id, union parameter *param)
2294 /* NT-MODE in setup state we must send PROCEEDING first */
2295 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2297 /* sending proceeding */
2298 l3m = create_l3msg();
2299 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2300 /* channel information */
2301 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2302 /* progress information */
2303 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2304 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2305 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2306 if (p_m_mISDNport->tones)
2307 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2309 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2310 new_state(PORT_STATE_IN_PROCEEDING);
2313 /* sending alerting */
2314 l3m = create_l3msg();
2315 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_REQ, DIRECTION_OUT);
2316 /* channel information */
2317 if (p_state == PORT_STATE_IN_SETUP)
2318 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2319 /* progress information */
2320 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2321 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2322 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2323 if (p_m_mISDNport->tones)
2324 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2326 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ALERTING, p_m_d_l3id, l3m);
2328 new_state(PORT_STATE_IN_ALERTING);
2331 /* MESSAGE_CONNECT */
2332 void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parameter *param)
2335 int type, plan, present, screen;
2336 class Endpoint *epoint;
2338 /* NT-MODE in setup state we must send PROCEEDING first */
2339 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2341 /* sending proceeding */
2342 l3m = create_l3msg();
2343 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2344 /* channel information */
2345 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2347 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2348 new_state(PORT_STATE_IN_PROCEEDING);
2351 /* copy connected information */
2352 memcpy(&p_connectinfo, ¶m->connectinfo, sizeof(p_connectinfo));
2353 /* screen outgoing caller id */
2354 do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface);
2356 /* only display at connect state */
2357 if (p_state == PORT_STATE_CONNECT)
2358 if (p_connectinfo.display[0])
2360 /* sending information */
2361 l3m = create_l3msg();
2362 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2364 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2366 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2370 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)
2372 /* connect command only possible in setup, proceeding or alerting state */
2376 /* preparing connect message */
2377 l3m = create_l3msg();
2378 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_REQ, DIRECTION_OUT);
2379 /* connect information */
2381 switch (p_connectinfo.ntype)
2383 case INFO_NTYPE_INTERNATIONAL:
2386 case INFO_NTYPE_NATIONAL:
2389 case INFO_NTYPE_SUBSCRIBER:
2392 default: /* INFO_NTYPE_UNKNOWN */
2396 switch (param->connectinfo.screen)
2398 case INFO_SCREEN_USER:
2401 default: /* INFO_SCREE_NETWORK */
2405 switch (p_connectinfo.present)
2407 case INFO_PRESENT_NULL: /* no colp at all */
2413 case INFO_PRESENT_RESTRICTED:
2416 case INFO_PRESENT_NOTAVAIL:
2419 default: /* INFO_PRESENT_ALLOWED */
2424 enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
2426 if (p_connectinfo.display[0] && p_m_d_ntmode)
2427 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2428 /* nt-mode: CONP (connected name identification presentation) */
2429 // if (p_connectinfo.name[0] && p_m_d_ntmode)
2430 // enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
2434 epoint = find_epoint_id(epoint_id);
2435 enc_ie_date(l3m, now, p_settings.no_seconds);
2438 /* finally send message */
2439 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT, p_m_d_l3id, l3m);
2442 new_state(PORT_STATE_CONNECT);
2444 new_state(PORT_STATE_CONNECT_WAITING);
2448 /* MESSAGE_DISCONNECT */
2449 void Pdss1::message_disconnect(unsigned int epoint_id, int message_id, union parameter *param)
2452 struct lcr_msg *message;
2455 /* we reject during incoming setup when we have no tones. also if we are in outgoing setup state */
2456 // if ((p_state==PORT_STATE_IN_SETUP && !p_m_mISDNport->tones)
2457 if (/* ||*/ p_state==PORT_STATE_OUT_SETUP)
2459 /* sending release to endpoint */
2462 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
2463 memcpy(&message->param, param, sizeof(union parameter));
2464 message_put(message);
2466 free_epointlist(p_epointlist);
2468 /* sending release */
2469 l3m = create_l3msg();
2470 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
2472 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2474 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2475 new_state(PORT_STATE_RELEASE);
2480 /* workarround: NT-MODE in setup state we must send PROCEEDING first to make it work */
2481 if (p_state==PORT_STATE_IN_SETUP)
2483 /* sending proceeding */
2484 l3m = create_l3msg();
2485 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2486 /* channel information */
2487 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2488 /* progress information */
2489 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2490 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2491 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2492 if (p_m_mISDNport->tones)
2493 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2495 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2496 new_state(PORT_STATE_IN_PROCEEDING);
2499 /* sending disconnect */
2500 l3m = create_l3msg();
2501 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2502 /* progress information */
2503 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2504 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2505 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2506 if (p_m_mISDNport->tones)
2507 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2509 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2511 if (param->disconnectinfo.display[0])
2512 p = param->disconnectinfo.display;
2513 if (p) if (*p && p_m_d_ntmode)
2514 enc_ie_display(l3m, (unsigned char *)p);
2516 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2517 new_state(PORT_STATE_OUT_DISCONNECT);
2520 /* MESSAGE_RELEASE */
2521 void Pdss1::message_release(unsigned int epoint_id, int message_id, union parameter *param)
2524 class Endpoint *epoint;
2528 * we may only release during incoming disconnect state.
2529 * this means that the endpoint doesnt require audio anymore
2531 if (p_state == PORT_STATE_IN_DISCONNECT
2532 || p_state == PORT_STATE_OUT_DISCONNECT)
2534 /* sending release */
2535 l3m = create_l3msg();
2536 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2538 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2540 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
2541 new_state(PORT_STATE_RELEASE);
2543 free_epointid(epoint_id);
2544 // wait for callref to be released
2549 * if we are on incoming call setup, we may reject by sending a release_complete
2550 * also on outgoing call setup, we send a release complete, BUT this is not conform. (i don't know any other way)
2552 if (p_state==PORT_STATE_IN_SETUP
2553 || p_state==PORT_STATE_OUT_SETUP)
2555 //#warning remove me
2556 //PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
2557 /* sending release complete */
2558 l3m = create_l3msg();
2559 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2561 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2563 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2564 new_state(PORT_STATE_RELEASE);
2566 free_epointid(epoint_id);
2567 // wait for callref to be released
2572 wirklich erst proceeding?:
2573 /* NT-MODE in setup state we must send PROCEEDING first */
2574 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2576 CALL_PROCEEDING_t *proceeding;
2578 /* sending proceeding */
2579 l3m = create_l3msg();
2580 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2581 /* channel information */
2582 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2583 /* progress information */
2584 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2585 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2586 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2587 if (p_m_mISDNport->tones)
2588 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2590 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2594 /* sending disconnect */
2595 l3m = create_l3msg();
2596 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2597 /* progress information */
2598 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2599 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2600 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2601 if (p_m_mISDNport->tones)
2602 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2604 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2606 epoint = find_epoint_id(epoint_id);
2607 if (param->disconnectinfo.display[0])
2608 p = param->disconnectinfo.display;
2609 if (p) if (*p && p_m_d_ntmode)
2610 enc_ie_display(l3m, (unsigned char *)p);
2612 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2613 new_state(PORT_STATE_OUT_DISCONNECT);
2615 free_epointid(epoint_id);
2616 // wait for release and callref to be released
2617 //#warning remove me
2618 //PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
2623 * endpoint sends messages to the port
2625 int Pdss1::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
2627 struct lcr_msg *message;
2629 if (PmISDN::message_epoint(epoint_id, message_id, param))
2634 case MESSAGE_INFORMATION: /* overlap dialing */
2635 if (p_type==PORT_TYPE_DSS1_NT_OUT
2636 && p_state!=PORT_STATE_OUT_OVERLAP
2637 && p_state!=PORT_STATE_CONNECT
2638 && p_state!=PORT_STATE_OUT_DISCONNECT
2639 && p_state!=PORT_STATE_IN_DISCONNECT)
2643 if (p_type==PORT_TYPE_DSS1_TE_OUT
2644 && p_state!=PORT_STATE_OUT_OVERLAP
2645 && p_state!=PORT_STATE_OUT_PROCEEDING
2646 && p_state!=PORT_STATE_OUT_ALERTING
2647 && p_state!=PORT_STATE_CONNECT
2648 && p_state!=PORT_STATE_OUT_DISCONNECT
2649 && p_state!=PORT_STATE_IN_DISCONNECT)
2653 if ((p_type==PORT_TYPE_DSS1_NT_IN || p_type==PORT_TYPE_DSS1_TE_IN)
2654 && p_state!=PORT_STATE_IN_OVERLAP
2655 && p_state!=PORT_STATE_IN_PROCEEDING
2656 && p_state!=PORT_STATE_IN_ALERTING
2657 && p_state!=PORT_STATE_CONNECT
2658 && p_state!=PORT_STATE_CONNECT_WAITING
2659 && p_state!=PORT_STATE_OUT_DISCONNECT
2660 && p_state!=PORT_STATE_IN_DISCONNECT)
2664 message_information(epoint_id, message_id, param);
2667 case MESSAGE_SETUP: /* dial-out command received from epoint */
2668 if (p_state!=PORT_STATE_IDLE
2669 && p_state!=PORT_STATE_CONNECT)
2671 PERROR("Pdss1(%s) ignoring setup because isdn port is not in idle state (or connected for sending display info).\n", p_name);
2674 if (p_epointlist && p_state==PORT_STATE_IDLE)
2675 FATAL("Pdss1(%s): epoint pointer is set in idle state, how bad!!\n", p_name);
2676 message_setup(epoint_id, message_id, param);
2679 case MESSAGE_NOTIFY: /* display and notifications */
2680 message_notify(epoint_id, message_id, param);
2683 case MESSAGE_FACILITY: /* facility message */
2684 message_facility(epoint_id, message_id, param);
2687 case MESSAGE_OVERLAP: /* more information is needed */
2688 if (p_state!=PORT_STATE_IN_SETUP)
2692 message_overlap(epoint_id, message_id, param);
2695 case MESSAGE_PROCEEDING: /* call of endpoint is proceeding */
2696 if (p_state!=PORT_STATE_IN_SETUP
2697 && p_state!=PORT_STATE_IN_OVERLAP)
2701 message_proceeding(epoint_id, message_id, param);
2704 case MESSAGE_ALERTING: /* call of endpoint is ringing */
2705 if (p_state!=PORT_STATE_IN_SETUP
2706 && p_state!=PORT_STATE_IN_OVERLAP
2707 && p_state!=PORT_STATE_IN_PROCEEDING)
2711 message_alerting(epoint_id, message_id, param);
2714 case MESSAGE_CONNECT: /* call of endpoint is connected */
2715 if (p_state!=PORT_STATE_IN_SETUP
2716 && p_state!=PORT_STATE_IN_OVERLAP
2717 && p_state!=PORT_STATE_IN_PROCEEDING
2718 && p_state!=PORT_STATE_IN_ALERTING
2719 && !(p_state==PORT_STATE_CONNECT && p_m_d_ntmode))
2723 message_connect(epoint_id, message_id, param);
2726 case MESSAGE_DISCONNECT: /* call has been disconnected */
2727 if (p_state!=PORT_STATE_IN_SETUP
2728 && p_state!=PORT_STATE_IN_OVERLAP
2729 && p_state!=PORT_STATE_IN_PROCEEDING
2730 && p_state!=PORT_STATE_IN_ALERTING
2731 && p_state!=PORT_STATE_OUT_SETUP
2732 && p_state!=PORT_STATE_OUT_OVERLAP
2733 && p_state!=PORT_STATE_OUT_PROCEEDING
2734 && p_state!=PORT_STATE_OUT_ALERTING
2735 && p_state!=PORT_STATE_CONNECT
2736 && p_state!=PORT_STATE_CONNECT_WAITING)
2740 message_disconnect(epoint_id, message_id, param);
2743 case MESSAGE_RELEASE: /* release isdn port */
2744 if (p_state==PORT_STATE_RELEASE)
2748 message_release(epoint_id, message_id, param);
2752 PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message);
2761 * data from isdn-stack (layer-3) to pbx (port class)
2763 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
2769 PDEBUG(DEBUG_ISDN, "cmd(0x%x) pid(0x%x)\n", cmd, pid);
2773 PDEBUG(DEBUG_ISDN, "ignoring dummy process from phone.\n");
2777 /* find Port object of type ISDN */
2782 if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
2784 pdss1 = (class Pdss1 *)port;
2785 /* check out correct stack and id */
2786 if (pdss1->p_m_mISDNport == mISDNport)
2788 if (pdss1->p_m_d_l3id & MISDN_PID_CR_FLAG)
2790 /* local callref, so match value only */
2791 if ((pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == (pid & MISDN_PID_CRVAL_MASK))
2795 /* remote callref, ref + channel id */
2796 if (pdss1->p_m_d_l3id == pid)
2804 /* aktueller prozess */
2807 if (cmd == MT_ASSIGN)
2809 /* stack gives us new layer 3 id (during connect) */
2810 l1l2l3_trace_header(mISDNport, pdss1, L3_NEW_L3ID_IND, DIRECTION_IN);
2811 add_trace("callref", "old", "0x%x", pdss1->p_m_d_l3id);
2812 /* nt-library now gives us a new id via CC_SETUP_CONFIRM */
2813 if ((pdss1->p_m_d_l3id&MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER)
2814 PERROR(" strange setup-procid 0x%x\n", pdss1->p_m_d_l3id);
2815 pdss1->p_m_d_l3id = pid;
2816 if (port->p_state == PORT_STATE_CONNECT)
2817 pdss1->p_m_d_ces = pid >> 16;
2818 add_trace("callref", "new", "0x%x", pdss1->p_m_d_l3id);
2822 /* if process id is master process, but a child disconnects */
2823 if (mISDNport->ntmode
2824 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2825 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) == MISDN_PID_MASTER)
2827 if (cmd == MT_DISCONNECT
2828 || cmd == MT_RELEASE)
2830 /* send special indication for child disconnect */
2831 pdss1->disconnect_ind_i(cmd, pid, l3m);
2834 if (cmd == MT_RELEASE_COMPLETE)
2837 /* if we have child pid and got different child pid message, ignore */
2838 if (mISDNport->ntmode
2839 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2840 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2841 && pid != pdss1->p_m_d_l3id)
2844 /* process message */
2845 pdss1->message_isdn(cmd, pid, l3m);
2853 /* creating port object */
2854 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2855 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0)))
2857 FATAL("Cannot create Port instance.\n");
2858 pdss1->message_isdn(cmd, pid, l3m);
2862 /* creating port object */
2863 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2864 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0)))
2865 FATAL("Cannot create Port instance.\n");
2866 pdss1->message_isdn(cmd, pid, l3m);
2870 PDEBUG(DEBUG_ISDN, "unused call ref released (l3id=0x%x)\n", pid);
2873 case MT_RELEASE_COMPLETE:
2874 PERROR("must be ignored by stack, not sent to app\n");
2878 // facility als broadcast
2882 PERROR("unhandled message: cmd(0x%x) pid(0x%x)\n", cmd, pid);
2886 if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT)
2888 pdss1 = (class Pdss1 *)port;
2889 /* check out correct stack */
2890 if (pdss1->p_m_mISDNport == mISDNport)
2891 /* check out correct id */
2892 PERROR("unhandled message: pid=%x is not associated with port-dinfo=%x\n", pid, pdss1->p_m_d_l3id);
2904 * sending message that were queued during L1 activation
2905 * or releasing port if link is down
2907 void setup_queue(struct mISDNport *mISDNport, int link)
2911 struct lcr_msg *message;
2913 if (!mISDNport->ntmode)
2916 /* check all port objects for pending message */
2920 if ((port->p_type&PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
2922 pdss1 = (class Pdss1 *)port;
2923 if (pdss1->p_m_mISDNport == mISDNport)
2925 if (pdss1->p_m_d_queue)
2929 PDEBUG(DEBUG_ISDN, "the L1 became active, so we send queued message for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
2930 /* LAYER 1 is up, so we send */
2931 pdss1->message_setup(pdss1->p_m_d_queue->id_from, pdss1->p_m_d_queue->type, &pdss1->p_m_d_queue->param);
2932 message_free(pdss1->p_m_d_queue);
2933 pdss1->p_m_d_queue = NULL;
2936 PDEBUG(DEBUG_ISDN, "the L1 became NOT active, so we release port for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
2937 message = message_create(pdss1->p_serial, pdss1->p_m_d_queue->id_from, PORT_TO_EPOINT, MESSAGE_RELEASE);
2938 message->param.disconnectinfo.cause = 27;
2939 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
2940 message_put(message);
2941 pdss1->new_state(PORT_STATE_RELEASE);
2942 pdss1->p_m_delete = 1;