1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
10 \*****************************************************************************/
15 #include <sys/socket.h>
19 extern unsigned long 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 long 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_RELEASE_COMPLETE INDICATION (a reject) */
1154 void Pdss1::release_complete_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1156 int location, cause;
1157 struct lcr_msg *message;
1159 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_IND, DIRECTION_IN);
1160 /* in case layer 2 is down during setup, we send cause 27 loc 5 */
1161 if (p_state == PORT_STATE_OUT_SETUP && !p_m_mISDNport->l1link)
1167 dec_ie_cause(l3m, &location, &cause);
1168 add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
1171 if (location == LOCATION_PRIVATE_LOCAL)
1172 location = LOCATION_PRIVATE_REMOTE;
1177 /* sending release to endpoint */
1180 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1181 message->param.disconnectinfo.cause = cause;
1182 message->param.disconnectinfo.location = location;
1183 message_put(message);
1185 free_epointlist(p_epointlist);
1188 new_state(PORT_STATE_RELEASE);
1193 void Pdss1::t312_timeout_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1195 // not required, release is performed with MT_FREE
1198 /* CC_NOTIFY INDICATION */
1199 void Pdss1::notify_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1201 struct lcr_msg *message;
1202 int notify, type, plan, present;
1203 unsigned char notifyid[sizeof(message->param.notifyinfo.id)];
1205 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_IND, DIRECTION_IN);
1206 dec_ie_notify(l3m, ¬ify);
1207 dec_ie_redir_dn(l3m, &type, &plan, &present, notifyid, sizeof(notifyid));
1210 if (!ACTIVE_EPOINT(p_epointlist))
1212 /* notification indicator */
1216 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1217 message->param.notifyinfo.notify = notify;
1218 SCPY(message->param.notifyinfo.id, (char *)notifyid);
1219 /* redirection number */
1223 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
1226 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
1229 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
1235 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1236 message->param.notifyinfo.present = INFO_PRESENT_NULL;
1239 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1242 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
1245 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1248 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1251 message->param.notifyinfo.isdn_port = p_m_portnum;
1252 message_put(message);
1256 /* CC_HOLD INDICATION */
1257 struct lcr_msg *message;
1258 void Pdss1::hold_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1260 // class Endpoint *epoint;
1262 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_IND, DIRECTION_IN);
1265 if (!ACTIVE_EPOINT(p_epointlist) || p_m_hold)
1267 l3m = create_l3msg();
1268 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_REJECT_REQ, DIRECTION_OUT);
1269 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */
1270 add_trace("reason", NULL, "no endpoint");
1272 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_REJECT, p_m_d_l3id, l3m);
1277 /* notify the hold of call */
1278 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1279 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_HOLD;
1280 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1281 message_put(message);
1283 /* deactivate bchannel */
1284 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (hold)", DIRECTION_NONE);
1285 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1289 /* set hold state */
1292 epoint = find_epoint_id(ACTIVE_EPOINT(p_epointlist));
1293 if (epoint && p_m_d_ntmode)
1295 p_m_timeout = p_settings.tout_hold;
1300 /* acknowledge hold */
1301 l3m = create_l3msg();
1302 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1304 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_ACKNOWLEDGE, p_m_d_l3id, l3m);
1308 /* CC_RETRIEVE INDICATION */
1309 void Pdss1::retrieve_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1311 struct lcr_msg *message;
1312 int channel, exclusive, cause;
1315 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_IND, DIRECTION_IN);
1316 dec_ie_channel_id(l3m, &exclusive, &channel);
1321 cause = 101; /* incompatible state */
1324 l3m = create_l3msg();
1325 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_REJECT_REQ, DIRECTION_OUT);
1326 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, cause);
1328 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_REJECT, p_m_d_l3id, l3m);
1333 /* notify the retrieve of call */
1334 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1335 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL;
1336 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1337 message_put(message);
1340 ret = channel = hunt_bchannel(channel, exclusive);
1345 ret = seize_bchannel(channel, 1);
1352 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1354 /* set hold state */
1358 /* acknowledge retrieve */
1359 l3m = create_l3msg();
1360 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1361 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1363 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_ACKNOWLEDGE, p_m_d_l3id, l3m);
1366 /* CC_SUSPEND INDICATION */
1367 void Pdss1::suspend_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1369 struct lcr_msg *message;
1370 class Endpoint *epoint;
1371 unsigned char callid[8];
1373 int ret = -31; /* normal, unspecified */
1375 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_IND, DIRECTION_IN);
1376 dec_ie_call_id(l3m, callid, &len);
1379 if (!ACTIVE_EPOINT(p_epointlist))
1382 l3m = create_l3msg();
1383 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_REJECT_REQ, DIRECTION_OUT);
1384 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1386 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_REJECT, p_m_d_l3id, l3m);
1393 /* check if call id is in use */
1394 epoint = epoint_first;
1397 if (epoint->ep_park)
1399 if (epoint->ep_park_len == len)
1400 if (!memcmp(epoint->ep_park_callid, callid, len))
1402 ret = -84; /* call id in use */
1406 epoint = epoint->next;
1409 /* notify the hold of call */
1410 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1411 message->param.notifyinfo.notify = INFO_NOTIFY_USER_SUSPENDED;
1412 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1413 message_put(message);
1415 /* deactivate bchannel */
1416 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (suspend)", DIRECTION_NONE);
1417 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1421 /* sending suspend to endpoint */
1422 while (p_epointlist)
1424 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_SUSPEND);
1425 memcpy(message->param.parkinfo.callid, callid, sizeof(message->param.parkinfo.callid));
1426 message->param.parkinfo.len = len;
1427 message_put(message);
1429 free_epointlist(p_epointlist);
1432 /* sending SUSPEND_ACKNOWLEDGE */
1433 l3m = create_l3msg();
1434 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1436 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_ACKNOWLEDGE, p_m_d_l3id, l3m);
1438 new_state(PORT_STATE_RELEASE);
1442 /* CC_RESUME INDICATION */
1443 void Pdss1::resume_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1445 unsigned char callid[8];
1447 int channel, exclusive;
1448 class Endpoint *epoint;
1449 struct lcr_msg *message;
1452 /* process given callref */
1453 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
1454 add_trace("callref", "new", "0x%x", pid);
1457 /* release is case the ID is already in use */
1458 add_trace("error", NULL, "callref already in use");
1460 l3m = create_l3msg();
1461 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1462 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
1463 add_trace("reason", NULL, "callref already in use");
1465 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, pid, l3m);
1466 new_state(PORT_STATE_RELEASE);
1471 p_m_d_ces = pid >> 16;
1474 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_IND, DIRECTION_IN);
1475 dec_ie_call_id(l3m, callid, &len);
1478 /* if blocked, release call */
1479 if (p_m_mISDNport->ifport->block)
1488 /* channel_id (no channel is possible in message) */
1490 channel = -1; /* any channel */
1493 ret = channel = hunt_bchannel(channel, exclusive);
1498 ret = seize_bchannel(channel, 1);
1503 l3m = create_l3msg();
1504 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1505 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1507 add_trace("reason", NULL, "port blocked");
1509 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, p_m_d_l3id, l3m);
1510 new_state(PORT_STATE_RELEASE);
1514 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1516 /* create endpoint */
1518 FATAL("Incoming resume but already got an endpoint.\n");
1519 ret = -85; /* no call suspended */
1520 epoint = epoint_first;
1523 if (epoint->ep_park)
1525 ret = -83; /* suspended call exists, but this not */
1526 if (epoint->ep_park_len == len)
1527 if (!memcmp(epoint->ep_park_callid, callid, len))
1530 epoint = epoint->next;
1535 epointlist_new(epoint->ep_serial);
1536 if (!(epoint->portlist_new(p_serial, p_type, p_m_mISDNport->earlyb)))
1537 FATAL("No memory for portlist\n");
1538 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RESUME);
1539 message_put(message);
1541 /* notify the resume of call */
1542 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1543 message->param.notifyinfo.notify = INFO_NOTIFY_USER_RESUMED;
1544 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1545 message_put(message);
1547 /* sending RESUME_ACKNOWLEDGE */
1548 l3m = create_l3msg();
1549 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1550 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1552 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_ACKNOWLEDGE, p_m_d_l3id, l3m);
1554 new_state(PORT_STATE_CONNECT);
1558 /* CC_FACILITY INDICATION */
1559 void Pdss1::facility_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1561 unsigned char facil[256];
1563 struct lcr_msg *message;
1565 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_IND, DIRECTION_IN);
1566 dec_ie_facility(l3m, facil, &facil_len);
1573 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_FACILITY);
1574 message->param.facilityinfo.len = facil_len;
1575 memcpy(message->param.facilityinfo.data, facil, facil_len);
1576 message_put(message);
1581 * handler for isdn connections
1582 * incoming information are parsed and sent via message to the endpoint
1584 void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1593 PERROR("Pdss1(%s) timeout without cause.\n", p_name);
1596 if (l3m->cause[0] != 5)
1598 PERROR("Pdss1(%s) expecting timeout with timer diagnostic. (got len=%d)\n", p_name, l3m->cause[0]);
1601 timer = (l3m->cause[3]-'0')*100;
1602 timer += (l3m->cause[4]-'0')*10;
1603 timer += (l3m->cause[5]-'0');
1604 l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN);
1605 add_trace("timer", NULL, "%d", timer);
1608 t312_timeout_ind(cmd, pid, l3m);
1612 if (p_state != PORT_STATE_IDLE)
1614 setup_ind(cmd, pid, l3m);
1617 case MT_INFORMATION:
1618 information_ind(cmd, pid, l3m);
1621 case MT_SETUP_ACKNOWLEDGE:
1622 if (p_state != PORT_STATE_OUT_SETUP)
1624 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received setup_acknowledge, but we are not in outgoing setup state, IGNORING.\n", p_name);
1627 setup_acknowledge_ind(cmd, pid, l3m);
1630 case MT_CALL_PROCEEDING:
1631 if (p_state != PORT_STATE_OUT_SETUP
1632 && p_state != PORT_STATE_OUT_OVERLAP)
1634 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received proceeding, but we are not in outgoing setup OR overlap state, IGNORING.\n", p_name);
1637 proceeding_ind(cmd, pid, l3m);
1641 if (p_state != PORT_STATE_OUT_SETUP
1642 && p_state != PORT_STATE_OUT_OVERLAP
1643 && p_state != PORT_STATE_OUT_PROCEEDING)
1645 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding state, IGNORING.\n", p_name);
1648 alerting_ind(cmd, pid, l3m);
1652 if (p_state != PORT_STATE_OUT_SETUP
1653 && p_state != PORT_STATE_OUT_OVERLAP
1654 && p_state != PORT_STATE_OUT_PROCEEDING
1655 && p_state != PORT_STATE_OUT_ALERTING)
1657 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);
1660 connect_ind(cmd, pid, l3m);
1661 if (p_m_d_notify_pending)
1663 /* send pending notify message during connect */
1664 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1665 message_free(p_m_d_notify_pending);
1666 p_m_d_notify_pending = NULL;
1670 case MT_CONNECT_ACKNOWLEDGE:
1671 if (p_state == PORT_STATE_CONNECT_WAITING)
1672 new_state(PORT_STATE_CONNECT);
1673 if (p_m_d_notify_pending)
1675 /* send pending notify message during connect-ack */
1676 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1677 message_free(p_m_d_notify_pending);
1678 p_m_d_notify_pending = NULL;
1683 disconnect_ind(cmd, pid, l3m);
1687 release_ind(cmd, pid, l3m);
1690 case MT_RELEASE_COMPLETE:
1691 release_complete_ind(cmd, pid, l3m);
1695 notify_ind(cmd, pid, l3m);
1699 hold_ind(cmd, pid, l3m);
1703 retrieve_ind(cmd, pid, l3m);
1707 suspend_ind(cmd, pid, l3m);
1711 resume_ind(cmd, pid, l3m);
1715 facility_ind(cmd, pid, l3m);
1719 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_L3ID_IND, DIRECTION_IN);
1720 add_trace("callref", NULL, "0x%x", p_m_d_l3id);
1725 /* sending release to endpoint in case we still have an endpoint
1726 * this is because we don't get any response if a release_complete is received (or a release in release state)
1728 while(p_epointlist) // only if not already released
1730 struct lcr_msg *message;
1731 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1732 if (p_m_d_collect_cause)
1734 message->param.disconnectinfo.cause = p_m_d_collect_cause;
1735 message->param.disconnectinfo.location = p_m_d_collect_location;
1738 message->param.disconnectinfo.cause = CAUSE_NOUSER;
1739 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1741 message_put(message);
1743 free_epointlist(p_epointlist);
1745 new_state(PORT_STATE_RELEASE);
1750 l1l2l3_trace_header(p_m_mISDNport, this, L3_UNKNOWN, DIRECTION_IN);
1751 add_trace("unhandled", "cmd", "0x%x", cmd);
1756 void Pdss1::new_state(int state)
1758 // class Endpoint *epoint;
1761 if (state == PORT_STATE_IN_OVERLAP)
1763 p_m_timeout = p_m_mISDNport->ifport->tout_dialing;
1766 if (state != p_state)
1768 if (state == PORT_STATE_IN_SETUP
1769 || state == PORT_STATE_OUT_SETUP
1770 || state == PORT_STATE_IN_OVERLAP
1771 || state == PORT_STATE_OUT_OVERLAP)
1773 p_m_timeout = p_m_mISDNport->ifport->tout_setup;
1776 if (state == PORT_STATE_IN_PROCEEDING
1777 || state == PORT_STATE_OUT_PROCEEDING)
1779 p_m_timeout = p_m_mISDNport->ifport->tout_proceeding;
1782 if (state == PORT_STATE_IN_ALERTING
1783 || state == PORT_STATE_OUT_ALERTING)
1785 p_m_timeout = p_m_mISDNport->ifport->tout_alerting;
1788 if (state == PORT_STATE_CONNECT
1789 || state == PORT_STATE_CONNECT_WAITING)
1793 if (state == PORT_STATE_IN_DISCONNECT
1794 || state == PORT_STATE_OUT_DISCONNECT)
1796 p_m_timeout = p_m_mISDNport->ifport->tout_disconnect;
1801 Port::new_state(state);
1808 int Pdss1::handler(void)
1812 if ((ret = PmISDN::handler()))
1815 /* handle destruction */
1816 if (p_m_delete && p_m_d_l3id==0)
1827 * handles all messages from endpoint
1829 /* MESSAGE_INFORMATION */
1830 void Pdss1::message_information(unsigned long epoint_id, int message_id, union parameter *param)
1834 if (param->information.id[0]) /* only if we have something to dial */
1836 l3m = create_l3msg();
1837 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1838 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)param->information.id);
1840 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1849 void Pdss1::message_setup(unsigned long epoint_id, int message_id, union parameter *param)
1853 int plan, type, screen, present, reason;
1854 int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
1855 int channel, exclusive;
1856 struct epoint_list *epointlist;
1858 /* release if port is blocked */
1859 if (p_m_mISDNport->ifport->block)
1861 struct lcr_msg *message;
1863 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1864 message->param.disconnectinfo.cause = 27; // temp. unavail.
1865 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1866 message_put(message);
1867 new_state(PORT_STATE_RELEASE);
1872 /* copy setup infos to port */
1873 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
1874 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
1875 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
1876 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
1877 // SCPY(&p_m_tones_dir, param->setup.ext.tones_dir);
1878 /* screen outgoing caller id */
1879 do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_m_mISDNport->ifport->interface);
1881 /* only display at connect state: this case happens if endpoint is in connected mode */
1882 if (p_state==PORT_STATE_CONNECT)
1884 if (p_type!=PORT_TYPE_DSS1_NT_OUT
1885 && p_type!=PORT_TYPE_DSS1_NT_IN)
1887 if (p_callerinfo.display[0])
1889 /* sending information */
1890 l3m = create_l3msg();
1891 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1893 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
1895 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1900 /* attach only if not already */
1901 epointlist = p_epointlist;
1904 if (epointlist->epoint_id == epoint_id)
1906 epointlist = epointlist->next;
1909 epointlist_new(epoint_id);
1915 channel = p_m_b_channel;
1916 exclusive = p_m_b_exclusive;
1918 channel = CHANNEL_ANY;
1919 /* nt-port with no channel, not reserverd */
1920 if (!p_m_b_channel && !p_m_b_reserve && p_type==PORT_TYPE_DSS1_NT_OUT)
1921 channel = CHANNEL_NO;
1924 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT);
1925 /* see MT_ASSIGN notes at do_layer3() */
1927 ret = p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ASSIGN, 0, NULL);
1928 if (mt_assign_pid == 0 || ret < 0)
1930 struct lcr_msg *message;
1932 add_trace("callref", NULL, "no free id");
1934 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1935 message->param.disconnectinfo.cause = 47;
1936 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1937 message_put(message);
1938 new_state(PORT_STATE_RELEASE);
1942 p_m_d_l3id = mt_assign_pid;
1944 add_trace("callref", "new", "0x%x", p_m_d_l3id);
1947 /* preparing setup message */
1948 l3m = create_l3msg();
1949 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_REQ, DIRECTION_OUT);
1950 /* channel information */
1951 if (channel >= 0) /* it should */
1953 enc_ie_channel_id(l3m, exclusive, channel);
1955 /* caller information */
1957 switch (p_callerinfo.ntype)
1959 case INFO_NTYPE_INTERNATIONAL:
1962 case INFO_NTYPE_NATIONAL:
1965 case INFO_NTYPE_SUBSCRIBER:
1968 default: /* INFO_NTYPE_UNKNOWN */
1972 switch (p_callerinfo.screen)
1974 case INFO_SCREEN_USER:
1977 default: /* INFO_SCREEN_NETWORK */
1981 switch (p_callerinfo.present)
1983 case INFO_PRESENT_RESTRICTED:
1986 case INFO_PRESENT_NOTAVAIL:
1989 default: /* INFO_PRESENT_ALLOWED */
1994 enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id);
1995 /* dialing information */
1996 if (p_dialinginfo.id[0]) /* only if we have something to dial */
1998 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id);
2000 /* sending complete */
2001 if (p_dialinginfo.sending_complete)
2002 enc_ie_complete(l3m, 1);
2003 /* sending user-user */
2004 if (param->setup.useruser.len)
2006 enc_ie_useruser(l3m, param->setup.useruser.protocol, param->setup.useruser.data, param->setup.useruser.len);
2008 /* redirecting number */
2010 switch (p_redirinfo.ntype)
2012 case INFO_NTYPE_INTERNATIONAL:
2015 case INFO_NTYPE_NATIONAL:
2018 case INFO_NTYPE_SUBSCRIBER:
2021 default: /* INFO_NTYPE_UNKNOWN */
2025 switch (p_redirinfo.screen)
2027 case INFO_SCREEN_USER:
2030 default: /* INFO_SCREE_NETWORK */
2034 switch (p_redirinfo.reason)
2036 case INFO_REDIR_BUSY:
2039 case INFO_REDIR_NORESPONSE:
2042 case INFO_REDIR_UNCONDITIONAL:
2045 case INFO_REDIR_CALLDEFLECT:
2048 case INFO_REDIR_OUTOFORDER:
2051 default: /* INFO_REDIR_UNKNOWN */
2055 switch (p_redirinfo.present)
2057 case INFO_PRESENT_NULL: /* no redir at all */
2064 case INFO_PRESENT_RESTRICTED:
2067 case INFO_PRESENT_NOTAVAIL:
2070 default: /* INFO_PRESENT_ALLOWED */
2074 /* sending redirecting number only in ntmode */
2075 if (type >= 0 && p_m_d_ntmode)
2076 enc_ie_redir_nr(l3m, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
2077 /* bearer capability */
2078 //printf("hlc=%d\n",p_capainfo.hlc);
2080 capability = p_capainfo.bearer_capa;
2081 mode = p_capainfo.bearer_mode;
2082 rate = (mode==INFO_BMODE_CIRCUIT)?0x10:0x00;
2083 switch (p_capainfo.bearer_info1)
2085 case INFO_INFO1_NONE:
2089 user = p_capainfo.bearer_info1 & 0x7f;
2092 enc_ie_bearer(l3m, coding, capability, mode, rate, -1, user);
2099 hlc = p_capainfo.hlc & 0x7f;
2101 if (p_capainfo.exthlc)
2102 exthlc = p_capainfo.exthlc & 0x7f;
2103 enc_ie_hlc(l3m, coding, interpretation, presentation, hlc, exthlc);
2107 if (p_callerinfo.display[0] && p_m_d_ntmode)
2108 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
2109 /* nt-mode: CNIP (calling name identification presentation) */
2110 // if (p_callerinfo.name[0] && p_m_d_ntmode)
2111 // enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
2114 /* send setup message now */
2115 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP, p_m_d_l3id, l3m);
2117 new_state(PORT_STATE_OUT_SETUP);
2120 /* MESSAGE_FACILITY */
2121 void Pdss1::message_facility(unsigned long epoint_id, int message_id, union parameter *param)
2125 /* facility will not be sent to external lines */
2129 /* sending facility */
2130 l3m = create_l3msg();
2131 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
2132 enc_ie_facility(l3m, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len);
2134 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
2137 /* MESSAGE_NOTIFY */
2138 void Pdss1::message_notify(unsigned long epoint_id, int message_id, union parameter *param)
2142 int plan, type = -1, present;
2144 if (param->notifyinfo.notify>INFO_NOTIFY_NONE)
2145 notify = param->notifyinfo.notify & 0x7f;
2148 if (p_state != PORT_STATE_CONNECT)
2150 /* notify only allowed in active state */
2156 switch (param->notifyinfo.ntype)
2158 case INFO_NTYPE_INTERNATIONAL:
2161 case INFO_NTYPE_NATIONAL:
2164 case INFO_NTYPE_SUBSCRIBER:
2167 default: /* INFO_NTYPE_UNKNOWN */
2171 switch (param->notifyinfo.present)
2173 case INFO_PRESENT_NULL: /* no redir at all */
2178 case INFO_PRESENT_RESTRICTED:
2181 case INFO_PRESENT_NOTAVAIL:
2184 default: /* INFO_PRESENT_ALLOWED */
2190 if (notify<0 && !param->notifyinfo.display[0])
2192 /* nothing to notify, nothing to display */
2198 if (p_state!=PORT_STATE_CONNECT)
2200 /* queue notification */
2201 if (p_m_d_notify_pending)
2202 message_free(p_m_d_notify_pending);
2203 p_m_d_notify_pending = message_create(ACTIVE_EPOINT(p_epointlist), p_serial, EPOINT_TO_PORT, message_id);
2204 memcpy(&p_m_d_notify_pending->param, param, sizeof(union parameter));
2207 /* sending notification */
2208 l3m = create_l3msg();
2209 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
2210 enc_ie_notify(l3m, notify);
2211 /* sending redirection number only in ntmode */
2212 if (type >= 0 && p_m_d_ntmode)
2213 enc_ie_redir_dn(l3m, type, plan, present, (unsigned char *)param->notifyinfo.id);
2214 if (param->notifyinfo.display[0] && p_m_d_ntmode)
2215 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2217 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_NOTIFY, p_m_d_l3id, l3m);
2219 } else if (p_m_d_ntmode)
2221 /* sending information */
2222 l3m = create_l3msg();
2223 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2224 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2226 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2230 /* MESSAGE_OVERLAP */
2231 void Pdss1::message_overlap(unsigned long epoint_id, int message_id, union parameter *param)
2235 /* sending setup_acknowledge */
2236 l3m = create_l3msg();
2237 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_REQ, DIRECTION_OUT);
2238 /* channel information */
2239 if (p_state == PORT_STATE_IN_SETUP)
2240 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2241 /* progress information */
2242 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2243 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2244 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2245 if (p_m_mISDNport->tones)
2246 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2248 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, l3m);
2250 new_state(PORT_STATE_IN_OVERLAP);
2253 /* MESSAGE_PROCEEDING */
2254 void Pdss1::message_proceeding(unsigned long epoint_id, int message_id, union parameter *param)
2258 /* sending proceeding */
2259 l3m = create_l3msg();
2260 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2261 /* channel information */
2262 if (p_state == PORT_STATE_IN_SETUP)
2263 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2264 /* progress information */
2265 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2266 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2267 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2268 if (p_m_mISDNport->tones)
2269 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2271 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2273 new_state(PORT_STATE_IN_PROCEEDING);
2276 /* MESSAGE_ALERTING */
2277 void Pdss1::message_alerting(unsigned long epoint_id, int message_id, union parameter *param)
2281 /* NT-MODE in setup state we must send PROCEEDING first */
2282 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2284 /* sending proceeding */
2285 l3m = create_l3msg();
2286 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2287 /* channel information */
2288 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2289 /* progress information */
2290 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2291 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2292 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2293 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2295 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2296 new_state(PORT_STATE_IN_PROCEEDING);
2299 /* sending alerting */
2300 l3m = create_l3msg();
2301 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_REQ, DIRECTION_OUT);
2302 /* channel information */
2303 if (p_state == PORT_STATE_IN_SETUP)
2304 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2305 /* progress information */
2306 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2307 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2308 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2309 if (p_m_mISDNport->tones)
2310 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2312 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ALERTING, p_m_d_l3id, l3m);
2314 new_state(PORT_STATE_IN_ALERTING);
2317 /* MESSAGE_CONNECT */
2318 void Pdss1::message_connect(unsigned long epoint_id, int message_id, union parameter *param)
2321 int type, plan, present, screen;
2322 class Endpoint *epoint;
2324 /* NT-MODE in setup state we must send PROCEEDING first */
2325 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2327 /* sending proceeding */
2328 l3m = create_l3msg();
2329 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2330 /* channel information */
2331 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2332 // /* progress information */
2333 // if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2334 // || p_capainfo.bearer_capa==INFO_BC_AUDIO
2335 // || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2336 // enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2338 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2339 new_state(PORT_STATE_IN_PROCEEDING);
2342 /* copy connected information */
2343 memcpy(&p_connectinfo, ¶m->connectinfo, sizeof(p_connectinfo));
2344 /* screen outgoing caller id */
2345 do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface);
2347 /* only display at connect state */
2348 if (p_state == PORT_STATE_CONNECT)
2349 if (p_connectinfo.display[0])
2351 /* sending information */
2352 l3m = create_l3msg();
2353 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2355 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2357 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2361 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)
2363 /* connect command only possible in setup, proceeding or alerting state */
2367 /* preparing connect message */
2368 l3m = create_l3msg();
2369 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_REQ, DIRECTION_OUT);
2370 /* connect information */
2372 switch (p_connectinfo.ntype)
2374 case INFO_NTYPE_INTERNATIONAL:
2377 case INFO_NTYPE_NATIONAL:
2380 case INFO_NTYPE_SUBSCRIBER:
2383 default: /* INFO_NTYPE_UNKNOWN */
2387 switch (param->connectinfo.screen)
2389 case INFO_SCREEN_USER:
2392 default: /* INFO_SCREE_NETWORK */
2396 switch (p_connectinfo.present)
2398 case INFO_PRESENT_NULL: /* no colp at all */
2404 case INFO_PRESENT_RESTRICTED:
2407 case INFO_PRESENT_NOTAVAIL:
2410 default: /* INFO_PRESENT_ALLOWED */
2415 enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
2417 if (p_connectinfo.display[0] && p_m_d_ntmode)
2418 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2419 /* nt-mode: CONP (connected name identification presentation) */
2420 // if (p_connectinfo.name[0] && p_m_d_ntmode)
2421 // enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
2425 epoint = find_epoint_id(epoint_id);
2426 enc_ie_date(l3m, now, p_settings.no_seconds);
2429 /* finally send message */
2430 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT, p_m_d_l3id, l3m);
2433 new_state(PORT_STATE_CONNECT);
2435 new_state(PORT_STATE_CONNECT_WAITING);
2439 /* MESSAGE_DISCONNECT */
2440 void Pdss1::message_disconnect(unsigned long epoint_id, int message_id, union parameter *param)
2443 struct lcr_msg *message;
2446 /* we reject during incoming setup when we have no tones. also if we are in outgoing setup state */
2447 // if ((p_state==PORT_STATE_IN_SETUP && !p_m_mISDNport->tones)
2448 if (/* ||*/ p_state==PORT_STATE_OUT_SETUP)
2450 /* sending release to endpoint */
2453 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
2454 memcpy(&message->param, param, sizeof(union parameter));
2455 message_put(message);
2457 free_epointlist(p_epointlist);
2459 /* sending release */
2460 l3m = create_l3msg();
2461 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
2463 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2465 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2466 new_state(PORT_STATE_RELEASE);
2471 /* workarround: NT-MODE in setup state we must send PROCEEDING first to make it work */
2472 if (p_state==PORT_STATE_IN_SETUP)
2474 /* sending proceeding */
2475 l3m = create_l3msg();
2476 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2477 /* channel information */
2478 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2479 /* progress information */
2480 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2481 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2482 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2483 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2485 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2486 new_state(PORT_STATE_IN_PROCEEDING);
2489 /* sending disconnect */
2490 l3m = create_l3msg();
2491 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2492 /* progress information */
2493 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2494 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2495 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2496 if (p_m_mISDNport->tones)
2497 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2499 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2501 if (param->disconnectinfo.display[0])
2502 p = param->disconnectinfo.display;
2503 if (p) if (*p && p_m_d_ntmode)
2504 enc_ie_display(l3m, (unsigned char *)p);
2506 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2507 new_state(PORT_STATE_OUT_DISCONNECT);
2510 /* MESSAGE_RELEASE */
2511 void Pdss1::message_release(unsigned long epoint_id, int message_id, union parameter *param)
2514 class Endpoint *epoint;
2518 * we may only release during incoming disconnect state.
2519 * this means that the endpoint doesnt require audio anymore
2521 if (p_state == PORT_STATE_IN_DISCONNECT
2522 || p_state == PORT_STATE_OUT_DISCONNECT)
2524 /* sending release */
2525 l3m = create_l3msg();
2526 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2528 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2530 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
2531 new_state(PORT_STATE_RELEASE);
2533 free_epointid(epoint_id);
2534 // wait for callref to be released
2539 * if we are on incoming call setup, we may reject by sending a release_complete
2540 * also on outgoing call setup, we send a release complete, BUT this is not conform. (i don't know any other way)
2542 if (p_state==PORT_STATE_IN_SETUP
2543 || p_state==PORT_STATE_OUT_SETUP)
2544 // // NOTE: a bug in mISDNuser (see disconnect_req_out !!!)
2545 // || p_state==PORT_STATE_OUT_DISCO)
2547 //#warning remove me
2548 //PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
2549 /* sending release complete */
2550 l3m = create_l3msg();
2551 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2553 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2555 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2556 new_state(PORT_STATE_RELEASE);
2558 free_epointid(epoint_id);
2559 // wait for callref to be released
2564 wirklich erst proceeding?:
2565 /* NT-MODE in setup state we must send PROCEEDING first */
2566 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2568 CALL_PROCEEDING_t *proceeding;
2570 /* sending proceeding */
2571 l3m = create_l3msg();
2572 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2573 /* channel information */
2574 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2575 /* progress information */
2576 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2577 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2578 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2579 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2581 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2585 /* sending disconnect */
2586 l3m = create_l3msg();
2587 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2588 /* progress information */
2589 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2590 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2591 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2592 if (p_m_mISDNport->tones)
2593 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2595 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2597 epoint = find_epoint_id(epoint_id);
2598 if (param->disconnectinfo.display[0])
2599 p = param->disconnectinfo.display;
2600 if (p) if (*p && p_m_d_ntmode)
2601 enc_ie_display(l3m, (unsigned char *)p);
2603 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2604 new_state(PORT_STATE_OUT_DISCONNECT);
2606 free_epointid(epoint_id);
2607 // wait for release and callref to be released
2608 //#warning remove me
2609 //PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
2614 * endpoint sends messages to the port
2616 int Pdss1::message_epoint(unsigned long epoint_id, int message_id, union parameter *param)
2618 struct lcr_msg *message;
2620 if (PmISDN::message_epoint(epoint_id, message_id, param))
2625 case MESSAGE_INFORMATION: /* overlap dialing */
2626 if (p_type==PORT_TYPE_DSS1_NT_OUT
2627 && p_state!=PORT_STATE_OUT_OVERLAP
2628 && p_state!=PORT_STATE_CONNECT
2629 && p_state!=PORT_STATE_OUT_DISCONNECT
2630 && p_state!=PORT_STATE_IN_DISCONNECT)
2634 if (p_type==PORT_TYPE_DSS1_TE_OUT
2635 && p_state!=PORT_STATE_OUT_OVERLAP
2636 && p_state!=PORT_STATE_OUT_PROCEEDING
2637 && p_state!=PORT_STATE_OUT_ALERTING
2638 && p_state!=PORT_STATE_CONNECT
2639 && p_state!=PORT_STATE_OUT_DISCONNECT
2640 && p_state!=PORT_STATE_IN_DISCONNECT)
2644 if ((p_type==PORT_TYPE_DSS1_NT_IN || p_type==PORT_TYPE_DSS1_TE_IN)
2645 && p_state!=PORT_STATE_IN_OVERLAP
2646 && p_state!=PORT_STATE_IN_PROCEEDING
2647 && p_state!=PORT_STATE_IN_ALERTING
2648 && p_state!=PORT_STATE_CONNECT
2649 && p_state!=PORT_STATE_CONNECT_WAITING
2650 && p_state!=PORT_STATE_OUT_DISCONNECT
2651 && p_state!=PORT_STATE_IN_DISCONNECT)
2655 message_information(epoint_id, message_id, param);
2658 case MESSAGE_SETUP: /* dial-out command received from epoint */
2659 if (p_state!=PORT_STATE_IDLE
2660 && p_state!=PORT_STATE_CONNECT)
2662 PERROR("Pdss1(%s) ignoring setup because isdn port is not in idle state (or connected for sending display info).\n", p_name);
2665 if (p_epointlist && p_state==PORT_STATE_IDLE)
2666 FATAL("Pdss1(%s): epoint pointer is set in idle state, how bad!!\n", p_name);
2667 message_setup(epoint_id, message_id, param);
2670 case MESSAGE_NOTIFY: /* display and notifications */
2671 message_notify(epoint_id, message_id, param);
2674 case MESSAGE_FACILITY: /* facility message */
2675 message_facility(epoint_id, message_id, param);
2678 case MESSAGE_OVERLAP: /* more information is needed */
2679 if (p_state!=PORT_STATE_IN_SETUP)
2683 message_overlap(epoint_id, message_id, param);
2686 case MESSAGE_PROCEEDING: /* call of endpoint is proceeding */
2687 if (p_state!=PORT_STATE_IN_SETUP
2688 && p_state!=PORT_STATE_IN_OVERLAP)
2692 message_proceeding(epoint_id, message_id, param);
2695 case MESSAGE_ALERTING: /* call of endpoint is ringing */
2696 if (p_state!=PORT_STATE_IN_SETUP
2697 && p_state!=PORT_STATE_IN_OVERLAP
2698 && p_state!=PORT_STATE_IN_PROCEEDING)
2702 message_alerting(epoint_id, message_id, param);
2705 case MESSAGE_CONNECT: /* call of endpoint is connected */
2706 if (p_state!=PORT_STATE_IN_SETUP
2707 && p_state!=PORT_STATE_IN_OVERLAP
2708 && p_state!=PORT_STATE_IN_PROCEEDING
2709 && p_state!=PORT_STATE_IN_ALERTING
2710 && !(p_state==PORT_STATE_CONNECT && p_m_d_ntmode))
2714 message_connect(epoint_id, message_id, param);
2717 case MESSAGE_DISCONNECT: /* call has been disconnected */
2718 if (p_state!=PORT_STATE_IN_SETUP
2719 && p_state!=PORT_STATE_IN_OVERLAP
2720 && p_state!=PORT_STATE_IN_PROCEEDING
2721 && p_state!=PORT_STATE_IN_ALERTING
2722 && p_state!=PORT_STATE_OUT_SETUP
2723 && p_state!=PORT_STATE_OUT_OVERLAP
2724 && p_state!=PORT_STATE_OUT_PROCEEDING
2725 && p_state!=PORT_STATE_OUT_ALERTING
2726 && p_state!=PORT_STATE_CONNECT
2727 && p_state!=PORT_STATE_CONNECT_WAITING)
2731 message_disconnect(epoint_id, message_id, param);
2734 case MESSAGE_RELEASE: /* release isdn port */
2735 if (p_state==PORT_STATE_RELEASE)
2739 message_release(epoint_id, message_id, param);
2743 PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message);
2752 * data from isdn-stack (layer-3) to pbx (port class)
2754 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
2760 PDEBUG(DEBUG_ISDN, "cmd(0x%x) pid(0x%x)\n", cmd, pid);
2764 PDEBUG(DEBUG_ISDN, "ignoring dummy process from phone.\n");
2768 /* find Port object of type ISDN */
2773 if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
2775 pdss1 = (class Pdss1 *)port;
2776 /* check out correct stack and id */
2777 if (pdss1->p_m_mISDNport == mISDNport)
2779 if (pdss1->p_m_d_l3id & MISDN_PID_CR_FLAG)
2781 /* local callref, so match value only */
2782 if ((pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == (pid & MISDN_PID_CRVAL_MASK))
2786 /* remote callref, ref + channel id */
2787 if (pdss1->p_m_d_l3id == pid)
2795 /* aktueller prozess */
2798 if (cmd == MT_ASSIGN)
2800 /* stack gives us new layer 3 id (during connect) */
2801 l1l2l3_trace_header(mISDNport, pdss1, L3_NEW_L3ID_IND, DIRECTION_IN);
2802 add_trace("callref", "old", "0x%x", pdss1->p_m_d_l3id);
2803 /* nt-library now gives us a new id via CC_SETUP_CONFIRM */
2804 if ((pdss1->p_m_d_l3id&MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER)
2805 PERROR(" strange setup-procid 0x%x\n", pdss1->p_m_d_l3id);
2806 pdss1->p_m_d_l3id = pid;
2807 if (port->p_state == PORT_STATE_CONNECT)
2808 pdss1->p_m_d_ces = pid >> 16;
2809 add_trace("callref", "new", "0x%x", pdss1->p_m_d_l3id);
2813 /* if process id is master process, but a child disconnects */
2814 if (mISDNport->ntmode
2815 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2816 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) == MISDN_PID_MASTER)
2818 if (cmd == MT_DISCONNECT
2819 || cmd == MT_RELEASE)
2821 /* send special indication for child disconnect */
2822 pdss1->disconnect_ind_i(cmd, pid, l3m);
2825 if (cmd == MT_RELEASE_COMPLETE)
2828 /* if we have child pid and got different child pid message, ignore */
2829 if (mISDNport->ntmode
2830 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2831 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2832 && pid != pdss1->p_m_d_l3id)
2835 /* process message */
2836 pdss1->message_isdn(cmd, pid, l3m);
2844 /* creating port object */
2845 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2846 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0)))
2848 FATAL("Cannot create Port instance.\n");
2849 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)))
2856 FATAL("Cannot create Port instance.\n");
2857 pdss1->message_isdn(cmd, pid, l3m);
2861 PDEBUG(DEBUG_ISDN, "unused call ref released (l3id=0x%x)\n", pid);
2864 case MT_RELEASE_COMPLETE:
2865 PERROR("must be ignored by stack, not sent to app\n");
2869 // facility als broadcast
2873 PERROR("unhandled message: cmd(0x%x) pid(0x%x)\n", cmd, pid);
2877 if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT)
2879 pdss1 = (class Pdss1 *)port;
2880 /* check out correct stack */
2881 if (pdss1->p_m_mISDNport == mISDNport)
2882 /* check out correct id */
2883 PERROR("unhandled message: pid=%x is not associated with port-dinfo=%x\n", pid, pdss1->p_m_d_l3id);
2895 * sending message that were queued during L1 activation
2896 * or releasing port if link is down
2898 void setup_queue(struct mISDNport *mISDNport, int link)
2902 struct lcr_msg *message;
2904 if (!mISDNport->ntmode)
2907 /* check all port objects for pending message */
2911 if ((port->p_type&PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
2913 pdss1 = (class Pdss1 *)port;
2914 if (pdss1->p_m_mISDNport == mISDNport)
2916 if (pdss1->p_m_d_queue)
2920 PDEBUG(DEBUG_ISDN, "the L1 became active, so we send queued message for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
2921 /* LAYER 1 is up, so we send */
2922 pdss1->message_setup(pdss1->p_m_d_queue->id_from, pdss1->p_m_d_queue->type, &pdss1->p_m_d_queue->param);
2923 message_free(pdss1->p_m_d_queue);
2924 pdss1->p_m_d_queue = NULL;
2927 PDEBUG(DEBUG_ISDN, "the L1 became NOT active, so we release port for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
2928 message = message_create(pdss1->p_serial, pdss1->p_m_d_queue->id_from, PORT_TO_EPOINT, MESSAGE_RELEASE);
2929 message->param.disconnectinfo.cause = 27;
2930 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
2931 message_put(message);
2932 pdss1->new_state(PORT_STATE_RELEASE);
2933 pdss1->p_m_delete = 1;