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);
463 dec_ie_display(l3m, (unsigned char *)p_dialinginfo.display, sizeof(p_dialinginfo.display));
466 /* if blocked, release call with MT_RELEASE_COMPLETE */
467 if (p_m_mISDNport->ifport->block)
469 l3m = create_l3msg();
470 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
471 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 27); /* temporary unavailable */
472 add_trace("reason", NULL, "port blocked");
474 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
475 new_state(PORT_STATE_RELEASE);
481 switch (calling_present)
484 p_callerinfo.present = INFO_PRESENT_RESTRICTED;
487 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
490 p_callerinfo.present = INFO_PRESENT_ALLOWED;
493 switch (calling_screen)
496 p_callerinfo.screen = INFO_SCREEN_USER;
499 p_callerinfo.screen = INFO_SCREEN_NETWORK;
502 switch (calling_type)
505 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
506 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
507 p_callerinfo.screen = INFO_SCREEN_NETWORK;
510 p_callerinfo.ntype = INFO_NTYPE_INTERNATIONAL;
513 p_callerinfo.ntype = INFO_NTYPE_NATIONAL;
516 p_callerinfo.ntype = INFO_NTYPE_SUBSCRIBER;
519 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
522 p_callerinfo.isdn_port = p_m_portnum;
523 SCPY(p_callerinfo.interface, p_m_mISDNport->ifport->interface->name);
525 /* dialing information */
526 SCAT(p_dialinginfo.id, (char *)keypad);
530 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
533 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
536 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
539 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
544 switch (redir_present)
547 p_redirinfo.present = INFO_PRESENT_RESTRICTED;
550 p_redirinfo.present = INFO_PRESENT_NOTAVAIL;
553 p_redirinfo.present = INFO_PRESENT_ALLOWED;
556 switch (redir_screen)
559 p_redirinfo.screen = INFO_SCREEN_USER;
562 p_redirinfo.screen = INFO_SCREEN_NETWORK;
565 switch (redir_reason)
568 p_redirinfo.reason = INFO_REDIR_BUSY;
571 p_redirinfo.reason = INFO_REDIR_NORESPONSE;
574 p_redirinfo.reason = INFO_REDIR_UNCONDITIONAL;
577 p_redirinfo.reason = INFO_REDIR_CALLDEFLECT;
580 p_redirinfo.reason = INFO_REDIR_OUTOFORDER;
583 p_redirinfo.reason = INFO_REDIR_UNKNOWN;
589 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
590 p_redirinfo.present = INFO_PRESENT_NULL; /* not redirecting */
591 p_redirinfo.reason = INFO_REDIR_UNKNOWN;
594 p_redirinfo.ntype = INFO_NTYPE_INTERNATIONAL;
597 p_redirinfo.ntype = INFO_NTYPE_NATIONAL;
600 p_redirinfo.ntype = INFO_NTYPE_SUBSCRIBER;
603 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
606 p_redirinfo.isdn_port = p_m_portnum;
608 /* bearer capability */
609 switch (bearer_capability)
612 p_capainfo.bearer_capa = INFO_BC_AUDIO;
613 bearer_user = (options.law=='a')?3:2;
616 p_capainfo.bearer_capa = bearer_capability;
622 p_capainfo.bearer_mode = INFO_BMODE_PACKET;
625 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
631 p_capainfo.bearer_info1 = INFO_INFO1_NONE;
634 p_capainfo.bearer_info1 = bearer_user + 0x80;
642 p_capainfo.hlc = INFO_HLC_NONE;
645 p_capainfo.hlc = hlc_hlc + 0x80;
651 p_capainfo.exthlc = INFO_HLC_NONE;
654 p_capainfo.exthlc = hlc_exthlc + 0x80;
659 ret = channel = hunt_bchannel(channel, exclusive);
664 ret = seize_bchannel(channel, 1);
669 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
670 * in response to the setup
672 l3m = create_l3msg();
673 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
674 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
676 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
677 new_state(PORT_STATE_RELEASE);
681 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
683 /* create endpoint */
685 FATAL("Incoming call but already got an endpoint.\n");
686 if (!(epoint = new Endpoint(p_serial, 0)))
687 FATAL("No memory for Endpoint instance\n");
688 if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 0))) //incoming
689 FATAL("No memory for Endpoint Application instance\n");
690 epointlist_new(epoint->ep_serial);
692 /* send setup message to endpoit */
693 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
694 message->param.setup.isdn_port = p_m_portnum;
695 message->param.setup.port_type = p_type;
696 // message->param.setup.dtmf = !p_m_mISDNport->ifport->nodtmf;
697 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
698 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
699 memcpy(&message->param.setup.redirinfo, &p_redirinfo, sizeof(struct redir_info));
700 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
701 memcpy(message->param.setup.useruser.data, &useruser, useruser_len);
702 message->param.setup.useruser.len = useruser_len;
703 message->param.setup.useruser.protocol = useruser_protocol;
704 message_put(message);
706 new_state(PORT_STATE_IN_SETUP);
709 /* CC_INFORMATION INDICATION */
710 void Pdss1::information_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
713 unsigned char keypad[32] = "", display[128] = "";
714 struct lcr_msg *message;
716 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_IND, DIRECTION_IN);
717 dec_ie_called_pn(l3m, &type, &plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
718 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
719 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
720 dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
723 SCAT(p_dialinginfo.id, (char *)keypad);
727 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
730 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
733 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
736 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
739 SCAT(p_dialinginfo.display, (char *)display);
740 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_INFORMATION);
741 memcpy(&message->param.information, &p_dialinginfo, sizeof(struct dialing_info));
742 message_put(message);
743 /* reset overlap timeout */
747 /* CC_SETUP_ACCNOWLEDGE INDICATION */
748 void Pdss1::setup_acknowledge_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
750 int exclusive, channel;
751 int coding, location, progress;
753 struct lcr_msg *message;
755 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_IND, DIRECTION_IN);
756 dec_ie_channel_id(l3m, &exclusive, &channel);
757 dec_ie_progress(l3m, &coding, &location, &progress);
760 /* process channel */
761 ret = received_first_reply_to_setup(cmd, channel, exclusive);
764 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
765 message->param.disconnectinfo.cause = -ret;
766 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
767 message_put(message);
768 new_state(PORT_STATE_RELEASE);
773 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_OVERLAP);
774 message_put(message);
776 new_state(PORT_STATE_OUT_OVERLAP);
779 /* CC_PROCEEDING INDICATION */
780 void Pdss1::proceeding_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
782 int exclusive, channel;
783 int coding, location, progress;
785 struct lcr_msg *message;
786 int notify = -1, type, plan, present;
789 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_IND, DIRECTION_IN);
790 dec_ie_channel_id(l3m, &exclusive, &channel);
791 dec_ie_progress(l3m, &coding, &location, &progress);
792 dec_ie_notify(l3m, ¬ify);
793 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
796 ret = received_first_reply_to_setup(cmd, channel, exclusive);
799 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
800 message->param.disconnectinfo.cause = -ret;
801 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
802 message_put(message);
803 new_state(PORT_STATE_RELEASE);
807 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
808 message_put(message);
810 new_state(PORT_STATE_OUT_PROCEEDING);
816 if (type >= 0 || notify)
818 if (!notify && type >= 0)
820 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
821 message->param.notifyinfo.notify = notify;
822 SCPY(message->param.notifyinfo.id, redir);
823 /* redirection number */
827 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
830 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
833 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
839 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
840 message->param.notifyinfo.present = INFO_PRESENT_NULL;
843 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
846 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
849 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
852 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
855 message->param.notifyinfo.isdn_port = p_m_portnum;
856 message_put(message);
860 /* CC_ALERTING INDICATION */
861 void Pdss1::alerting_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
863 int exclusive, channel;
864 int coding, location, progress;
866 struct lcr_msg *message;
867 int notify = -1, type, plan, present;
870 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_IND, DIRECTION_IN);
871 dec_ie_channel_id(l3m, &exclusive, &channel);
872 dec_ie_progress(l3m, &coding, &location, &progress);
873 dec_ie_notify(l3m, ¬ify);
874 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
877 /* process channel */
878 ret = received_first_reply_to_setup(cmd, channel, exclusive);
881 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
882 message->param.disconnectinfo.cause = -ret;
883 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
884 message_put(message);
885 new_state(PORT_STATE_RELEASE);
889 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ALERTING);
890 message_put(message);
892 new_state(PORT_STATE_OUT_ALERTING);
898 if (type >= 0 || notify)
900 if (!notify && type >= 0)
902 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
903 message->param.notifyinfo.notify = notify;
904 SCPY(message->param.notifyinfo.id, redir);
908 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
911 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
914 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
920 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
921 message->param.notifyinfo.present = INFO_PRESENT_NULL;
924 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
927 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
930 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
933 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
936 message->param.notifyinfo.isdn_port = p_m_portnum;
937 message_put(message);
941 /* CC_CONNECT INDICATION */
942 void Pdss1::connect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
944 int exclusive, channel;
945 int type, plan, present, screen;
947 struct lcr_msg *message;
950 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_IND, DIRECTION_IN);
951 dec_ie_channel_id(l3m, &exclusive, &channel);
952 dec_ie_connected_pn(l3m, &type, &plan, &present, &screen, (unsigned char *)p_connectinfo.id, sizeof(p_connectinfo.id));
953 dec_ie_display(l3m, (unsigned char *)p_connectinfo.display, sizeof(p_connectinfo.display));
954 /* te-mode: CONP (connected name identification presentation) */
956 dec_facility_centrex(l3m, (unsigned char *)p_connectinfo.name, sizeof(p_connectinfo.name));
960 bchannel_before = p_m_b_channel;
961 ret = received_first_reply_to_setup(cmd, channel, exclusive);
964 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
965 message->param.disconnectinfo.cause = -ret;
966 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
967 message_put(message);
968 new_state(PORT_STATE_RELEASE);
973 /* connect information */
977 p_connectinfo.present = INFO_PRESENT_RESTRICTED;
980 p_connectinfo.present = INFO_PRESENT_NOTAVAIL;
983 p_connectinfo.present = INFO_PRESENT_ALLOWED;
989 p_connectinfo.screen = INFO_SCREEN_USER;
992 p_connectinfo.screen = INFO_SCREEN_NETWORK;
998 p_connectinfo.present = INFO_PRESENT_NULL; /* no COLP info */
999 p_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
1002 p_connectinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1005 p_connectinfo.ntype = INFO_NTYPE_NATIONAL;
1008 p_connectinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1011 p_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
1014 p_connectinfo.isdn_port = p_m_portnum;
1015 SCPY(p_connectinfo.interface, p_m_mISDNport->ifport->interface->name);
1017 /* only in nt-mode we send connect ack. in te-mode it is done by stack itself or optional */
1020 /* send connect acknowledge */
1021 l3m = create_l3msg();
1022 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_RES, DIRECTION_OUT);
1023 /* if we had no bchannel before, we send it now */
1024 if (!bchannel_before && p_m_b_channel)
1025 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1027 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT_ACKNOWLEDGE, p_m_d_l3id, l3m);
1030 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_CONNECT);
1031 memcpy(&message->param.connectinfo, &p_connectinfo, sizeof(struct connect_info));
1032 message_put(message);
1034 new_state(PORT_STATE_CONNECT);
1037 /* CC_DISCONNECT INDICATION */
1038 void Pdss1::disconnect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1040 int location, cause;
1041 int coding, proglocation, progress;
1042 struct lcr_msg *message;
1043 unsigned char display[128] = "";
1045 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1046 dec_ie_progress(l3m, &coding, &proglocation, &progress);
1047 dec_ie_cause(l3m, &location, &cause);
1048 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1054 /* release if remote sends us no tones */
1055 if (!p_m_mISDNport->earlyb)
1059 l3m = create_l3msg();
1060 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
1061 enc_ie_cause(l3m, location, cause); /* normal */
1062 add_trace("reason", NULL, "no remote patterns");
1064 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
1066 /* sending release to endpoint */
1067 if (location == LOCATION_PRIVATE_LOCAL)
1068 location = LOCATION_PRIVATE_REMOTE;
1071 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1072 message->param.disconnectinfo.cause = cause;
1073 message->param.disconnectinfo.location = location;
1074 SCAT(message->param.disconnectinfo.display, (char *)display);
1075 message_put(message);
1077 free_epointlist(p_epointlist);
1079 new_state(PORT_STATE_RELEASE);
1084 /* sending disconnect to active endpoint and release to inactive endpoints */
1085 if (location == LOCATION_PRIVATE_LOCAL)
1086 location = LOCATION_PRIVATE_REMOTE;
1087 if (ACTIVE_EPOINT(p_epointlist))
1089 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_DISCONNECT);
1090 message->param.disconnectinfo.location = location;
1091 message->param.disconnectinfo.cause = cause;
1092 SCAT(message->param.disconnectinfo.display, (char *)display);
1093 message_put(message);
1095 while(INACTIVE_EPOINT(p_epointlist))
1097 message = message_create(p_serial, INACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1098 message->param.disconnectinfo.location = location;
1099 message->param.disconnectinfo.cause = cause;
1100 SCAT(message->param.disconnectinfo.display, (char *)display);
1101 message_put(message);
1103 free_epointid(INACTIVE_EPOINT(p_epointlist));
1105 new_state(PORT_STATE_IN_DISCONNECT);
1108 /* CC_DISCONNECT INDICATION */
1109 void Pdss1::disconnect_ind_i(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1111 int location, cause;
1114 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1115 if (p_m_d_collect_cause > 0)
1117 add_trace("old-cause", "location", "%d", p_m_d_collect_location);
1118 add_trace("old-cause", "value", "%d", p_m_d_collect_cause);
1120 dec_ie_cause(l3m, &location, &cause);
1121 if (location == LOCATION_PRIVATE_LOCAL)
1122 location = LOCATION_PRIVATE_REMOTE;
1125 collect_cause(&p_m_d_collect_cause, &p_m_d_collect_location, cause, location);
1126 add_trace("new-cause", "location", "%d", p_m_d_collect_location);
1127 add_trace("new-cause", "value", "%d", p_m_d_collect_cause);
1132 /* CC_RELEASE INDICATION */
1133 void Pdss1::release_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1135 int location, cause;
1136 struct lcr_msg *message;
1137 unsigned char display[128] = "";
1139 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_IND, DIRECTION_IN);
1140 dec_ie_cause(l3m, &location, &cause);
1141 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1147 /* sending release to endpoint */
1148 if (location == LOCATION_PRIVATE_LOCAL)
1149 location = LOCATION_PRIVATE_REMOTE;
1152 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1153 message->param.disconnectinfo.cause = cause;
1154 message->param.disconnectinfo.location = location;
1155 SCAT(message->param.disconnectinfo.display, (char *)display);
1156 message_put(message);
1158 free_epointlist(p_epointlist);
1161 new_state(PORT_STATE_RELEASE);
1165 /* CC_RESTART INDICATION */
1166 void Pdss1::restart_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1168 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESTART_IND, DIRECTION_IN);
1171 // L3 process is not toucht. (not even by network stack)
1174 /* CC_RELEASE_COMPLETE INDICATION (a reject) */
1175 void Pdss1::release_complete_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1177 int location, cause;
1178 struct lcr_msg *message;
1180 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_IND, DIRECTION_IN);
1181 /* in case layer 2 is down during setup, we send cause 27 loc 5 */
1182 if (p_state == PORT_STATE_OUT_SETUP && !p_m_mISDNport->l1link)
1188 dec_ie_cause(l3m, &location, &cause);
1189 add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
1192 if (location == LOCATION_PRIVATE_LOCAL)
1193 location = LOCATION_PRIVATE_REMOTE;
1198 /* sending release to endpoint */
1201 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1202 message->param.disconnectinfo.cause = cause;
1203 message->param.disconnectinfo.location = location;
1204 message_put(message);
1206 free_epointlist(p_epointlist);
1209 new_state(PORT_STATE_RELEASE);
1214 void Pdss1::t312_timeout_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1216 // not required, release is performed with MT_FREE
1219 /* CC_NOTIFY INDICATION */
1220 void Pdss1::notify_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1222 struct lcr_msg *message;
1223 int notify, type, plan, present;
1224 unsigned char notifyid[sizeof(message->param.notifyinfo.id)];
1225 unsigned char display[128] = "";
1227 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_IND, DIRECTION_IN);
1228 dec_ie_notify(l3m, ¬ify);
1229 dec_ie_redir_dn(l3m, &type, &plan, &present, notifyid, sizeof(notifyid));
1230 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1233 if (!ACTIVE_EPOINT(p_epointlist))
1235 /* notification indicator */
1239 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1240 message->param.notifyinfo.notify = notify;
1241 SCPY(message->param.notifyinfo.id, (char *)notifyid);
1242 /* redirection number */
1246 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
1249 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
1252 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
1258 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1259 message->param.notifyinfo.present = INFO_PRESENT_NULL;
1262 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1265 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
1268 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1271 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1274 SCAT(message->param.notifyinfo.display, (char *)display);
1275 message->param.notifyinfo.isdn_port = p_m_portnum;
1276 message_put(message);
1280 /* CC_HOLD INDICATION */
1281 struct lcr_msg *message;
1282 void Pdss1::hold_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1284 // class Endpoint *epoint;
1286 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_IND, DIRECTION_IN);
1289 if (!ACTIVE_EPOINT(p_epointlist) || p_m_hold)
1291 l3m = create_l3msg();
1292 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_REJECT_REQ, DIRECTION_OUT);
1293 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */
1294 add_trace("reason", NULL, "no endpoint");
1296 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_REJECT, p_m_d_l3id, l3m);
1301 /* notify the hold of call */
1302 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1303 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_HOLD;
1304 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1305 message_put(message);
1307 /* deactivate bchannel */
1308 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (hold)", DIRECTION_NONE);
1309 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1313 /* set hold state */
1316 epoint = find_epoint_id(ACTIVE_EPOINT(p_epointlist));
1317 if (epoint && p_m_d_ntmode)
1319 p_m_timeout = p_settings.tout_hold;
1324 /* acknowledge hold */
1325 l3m = create_l3msg();
1326 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1328 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_ACKNOWLEDGE, p_m_d_l3id, l3m);
1332 /* CC_RETRIEVE INDICATION */
1333 void Pdss1::retrieve_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1335 struct lcr_msg *message;
1336 int channel, exclusive, cause;
1339 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_IND, DIRECTION_IN);
1340 dec_ie_channel_id(l3m, &exclusive, &channel);
1345 cause = 101; /* incompatible state */
1348 l3m = create_l3msg();
1349 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_REJECT_REQ, DIRECTION_OUT);
1350 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, cause);
1352 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_REJECT, p_m_d_l3id, l3m);
1357 /* notify the retrieve of call */
1358 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1359 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL;
1360 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1361 message_put(message);
1364 ret = channel = hunt_bchannel(channel, exclusive);
1369 ret = seize_bchannel(channel, 1);
1376 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1378 /* set hold state */
1382 /* acknowledge retrieve */
1383 l3m = create_l3msg();
1384 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1385 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1387 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_ACKNOWLEDGE, p_m_d_l3id, l3m);
1390 /* CC_SUSPEND INDICATION */
1391 void Pdss1::suspend_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1393 struct lcr_msg *message;
1394 class Endpoint *epoint;
1395 unsigned char callid[8];
1397 int ret = -31; /* normal, unspecified */
1399 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_IND, DIRECTION_IN);
1400 dec_ie_call_id(l3m, callid, &len);
1403 if (!ACTIVE_EPOINT(p_epointlist))
1406 l3m = create_l3msg();
1407 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_REJECT_REQ, DIRECTION_OUT);
1408 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1410 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_REJECT, p_m_d_l3id, l3m);
1417 /* check if call id is in use */
1418 epoint = epoint_first;
1421 if (epoint->ep_park)
1423 if (epoint->ep_park_len == len)
1424 if (!memcmp(epoint->ep_park_callid, callid, len))
1426 ret = -84; /* call id in use */
1430 epoint = epoint->next;
1433 /* notify the hold of call */
1434 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1435 message->param.notifyinfo.notify = INFO_NOTIFY_USER_SUSPENDED;
1436 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1437 message_put(message);
1439 /* deactivate bchannel */
1440 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (suspend)", DIRECTION_NONE);
1441 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1445 /* sending suspend to endpoint */
1446 while (p_epointlist)
1448 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_SUSPEND);
1449 memcpy(message->param.parkinfo.callid, callid, sizeof(message->param.parkinfo.callid));
1450 message->param.parkinfo.len = len;
1451 message_put(message);
1453 free_epointlist(p_epointlist);
1456 /* sending SUSPEND_ACKNOWLEDGE */
1457 l3m = create_l3msg();
1458 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1460 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_ACKNOWLEDGE, p_m_d_l3id, l3m);
1462 new_state(PORT_STATE_RELEASE);
1466 /* CC_RESUME INDICATION */
1467 void Pdss1::resume_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1469 unsigned char callid[8];
1471 int channel, exclusive;
1472 class Endpoint *epoint;
1473 struct lcr_msg *message;
1476 /* process given callref */
1477 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
1478 add_trace("callref", "new", "0x%x", pid);
1481 /* release is case the ID is already in use */
1482 add_trace("error", NULL, "callref already in use");
1484 l3m = create_l3msg();
1485 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1486 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
1487 add_trace("reason", NULL, "callref already in use");
1489 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, pid, l3m);
1490 new_state(PORT_STATE_RELEASE);
1495 p_m_d_ces = pid >> 16;
1498 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_IND, DIRECTION_IN);
1499 dec_ie_call_id(l3m, callid, &len);
1502 /* if blocked, release call */
1503 if (p_m_mISDNport->ifport->block)
1512 /* channel_id (no channel is possible in message) */
1514 channel = -1; /* any channel */
1517 ret = channel = hunt_bchannel(channel, exclusive);
1522 ret = seize_bchannel(channel, 1);
1527 l3m = create_l3msg();
1528 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1529 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1531 add_trace("reason", NULL, "port blocked");
1533 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, p_m_d_l3id, l3m);
1534 new_state(PORT_STATE_RELEASE);
1538 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1540 /* create endpoint */
1542 FATAL("Incoming resume but already got an endpoint.\n");
1543 ret = -85; /* no call suspended */
1544 epoint = epoint_first;
1547 if (epoint->ep_park)
1549 ret = -83; /* suspended call exists, but this not */
1550 if (epoint->ep_park_len == len)
1551 if (!memcmp(epoint->ep_park_callid, callid, len))
1554 epoint = epoint->next;
1559 epointlist_new(epoint->ep_serial);
1560 if (!(epoint->portlist_new(p_serial, p_type, p_m_mISDNport->earlyb)))
1561 FATAL("No memory for portlist\n");
1562 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RESUME);
1563 message_put(message);
1565 /* notify the resume of call */
1566 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1567 message->param.notifyinfo.notify = INFO_NOTIFY_USER_RESUMED;
1568 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1569 message_put(message);
1571 /* sending RESUME_ACKNOWLEDGE */
1572 l3m = create_l3msg();
1573 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1574 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1576 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_ACKNOWLEDGE, p_m_d_l3id, l3m);
1578 new_state(PORT_STATE_CONNECT);
1582 /* CC_FACILITY INDICATION */
1583 void Pdss1::facility_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1585 unsigned char facil[256];
1587 struct lcr_msg *message;
1589 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_IND, DIRECTION_IN);
1590 dec_ie_facility(l3m, facil, &facil_len);
1597 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_FACILITY);
1598 message->param.facilityinfo.len = facil_len;
1599 memcpy(message->param.facilityinfo.data, facil, facil_len);
1600 message_put(message);
1605 * handler for isdn connections
1606 * incoming information are parsed and sent via message to the endpoint
1608 void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1617 PERROR("Pdss1(%s) timeout without cause.\n", p_name);
1620 if (l3m->cause[0] != 5)
1622 PERROR("Pdss1(%s) expecting timeout with timer diagnostic. (got len=%d)\n", p_name, l3m->cause[0]);
1625 timer = (l3m->cause[3]-'0')*100;
1626 timer += (l3m->cause[4]-'0')*10;
1627 timer += (l3m->cause[5]-'0');
1628 l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN);
1629 add_trace("timer", NULL, "%d", timer);
1632 t312_timeout_ind(cmd, pid, l3m);
1636 if (p_state != PORT_STATE_IDLE)
1638 setup_ind(cmd, pid, l3m);
1641 case MT_INFORMATION:
1642 information_ind(cmd, pid, l3m);
1645 case MT_SETUP_ACKNOWLEDGE:
1646 if (p_state != PORT_STATE_OUT_SETUP)
1648 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received setup_acknowledge, but we are not in outgoing setup state, IGNORING.\n", p_name);
1651 setup_acknowledge_ind(cmd, pid, l3m);
1654 case MT_CALL_PROCEEDING:
1655 if (p_state != PORT_STATE_OUT_SETUP
1656 && p_state != PORT_STATE_OUT_OVERLAP)
1658 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received proceeding, but we are not in outgoing setup OR overlap state, IGNORING.\n", p_name);
1661 proceeding_ind(cmd, pid, l3m);
1665 if (p_state != PORT_STATE_OUT_SETUP
1666 && p_state != PORT_STATE_OUT_OVERLAP
1667 && p_state != PORT_STATE_OUT_PROCEEDING)
1669 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding state, IGNORING.\n", p_name);
1672 alerting_ind(cmd, pid, l3m);
1676 if (p_state != PORT_STATE_OUT_SETUP
1677 && p_state != PORT_STATE_OUT_OVERLAP
1678 && p_state != PORT_STATE_OUT_PROCEEDING
1679 && p_state != PORT_STATE_OUT_ALERTING)
1681 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);
1684 connect_ind(cmd, pid, l3m);
1685 if (p_m_d_notify_pending)
1687 /* send pending notify message during connect */
1688 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1689 message_free(p_m_d_notify_pending);
1690 p_m_d_notify_pending = NULL;
1694 case MT_CONNECT_ACKNOWLEDGE:
1695 if (p_state == PORT_STATE_CONNECT_WAITING)
1696 new_state(PORT_STATE_CONNECT);
1697 if (p_m_d_notify_pending)
1699 /* send pending notify message during connect-ack */
1700 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1701 message_free(p_m_d_notify_pending);
1702 p_m_d_notify_pending = NULL;
1707 disconnect_ind(cmd, pid, l3m);
1711 release_ind(cmd, pid, l3m);
1714 case MT_RELEASE_COMPLETE:
1715 release_complete_ind(cmd, pid, l3m);
1719 restart_ind(cmd, pid, l3m);
1723 notify_ind(cmd, pid, l3m);
1727 hold_ind(cmd, pid, l3m);
1731 retrieve_ind(cmd, pid, l3m);
1735 suspend_ind(cmd, pid, l3m);
1739 resume_ind(cmd, pid, l3m);
1743 facility_ind(cmd, pid, l3m);
1747 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_L3ID_IND, DIRECTION_IN);
1748 add_trace("callref", NULL, "0x%x", p_m_d_l3id);
1753 /* sending release to endpoint in case we still have an endpoint
1754 * this is because we don't get any response if a release_complete is received (or a release in release state)
1756 while(p_epointlist) // only if not already released
1758 struct lcr_msg *message;
1759 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1760 if (p_m_d_collect_cause)
1762 message->param.disconnectinfo.cause = p_m_d_collect_cause;
1763 message->param.disconnectinfo.location = p_m_d_collect_location;
1766 message->param.disconnectinfo.cause = CAUSE_NOUSER;
1767 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1769 message_put(message);
1771 free_epointlist(p_epointlist);
1773 new_state(PORT_STATE_RELEASE);
1778 l1l2l3_trace_header(p_m_mISDNport, this, L3_UNKNOWN, DIRECTION_IN);
1779 add_trace("unhandled", "cmd", "0x%x", cmd);
1784 void Pdss1::new_state(int state)
1786 // class Endpoint *epoint;
1789 if (state == PORT_STATE_IN_OVERLAP)
1791 p_m_timeout = p_m_mISDNport->ifport->tout_dialing;
1794 if (state != p_state)
1796 if (state == PORT_STATE_IN_SETUP
1797 || state == PORT_STATE_OUT_SETUP
1798 || state == PORT_STATE_IN_OVERLAP
1799 || state == PORT_STATE_OUT_OVERLAP)
1801 p_m_timeout = p_m_mISDNport->ifport->tout_setup;
1804 if (state == PORT_STATE_IN_PROCEEDING
1805 || state == PORT_STATE_OUT_PROCEEDING)
1807 p_m_timeout = p_m_mISDNport->ifport->tout_proceeding;
1810 if (state == PORT_STATE_IN_ALERTING
1811 || state == PORT_STATE_OUT_ALERTING)
1813 p_m_timeout = p_m_mISDNport->ifport->tout_alerting;
1816 if (state == PORT_STATE_CONNECT
1817 || state == PORT_STATE_CONNECT_WAITING)
1821 if (state == PORT_STATE_IN_DISCONNECT
1822 || state == PORT_STATE_OUT_DISCONNECT)
1824 p_m_timeout = p_m_mISDNport->ifport->tout_disconnect;
1829 Port::new_state(state);
1836 int Pdss1::handler(void)
1840 if ((ret = PmISDN::handler()))
1843 /* handle destruction */
1844 if (p_m_delete && p_m_d_l3id==0)
1855 * handles all messages from endpoint
1857 /* MESSAGE_INFORMATION */
1858 void Pdss1::message_information(unsigned int epoint_id, int message_id, union parameter *param)
1862 if (param->information.id[0]) /* only if we have something to dial */
1864 l3m = create_l3msg();
1865 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1866 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)param->information.id);
1868 enc_ie_display(l3m, (unsigned char *)param->information.display);
1870 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1879 void Pdss1::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
1883 int plan, type, screen, present, reason;
1884 int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
1885 int channel, exclusive;
1886 struct epoint_list *epointlist;
1888 /* release if port is blocked */
1889 if (p_m_mISDNport->ifport->block)
1891 struct lcr_msg *message;
1893 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1894 message->param.disconnectinfo.cause = 27; // temp. unavail.
1895 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1896 message_put(message);
1897 new_state(PORT_STATE_RELEASE);
1902 /* copy setup infos to port */
1903 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
1904 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
1905 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
1906 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
1907 // SCPY(&p_m_tones_dir, param->setup.ext.tones_dir);
1908 /* screen outgoing caller id */
1909 do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_m_mISDNport->ifport->interface);
1911 /* only display at connect state: this case happens if endpoint is in connected mode */
1912 if (p_state==PORT_STATE_CONNECT)
1914 if (p_type!=PORT_TYPE_DSS1_NT_OUT
1915 && p_type!=PORT_TYPE_DSS1_NT_IN)
1917 if (p_callerinfo.display[0])
1919 /* sending information */
1920 l3m = create_l3msg();
1921 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1923 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
1925 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1930 /* attach only if not already */
1931 epointlist = p_epointlist;
1934 if (epointlist->epoint_id == epoint_id)
1936 epointlist = epointlist->next;
1939 epointlist_new(epoint_id);
1945 channel = p_m_b_channel;
1946 exclusive = p_m_b_exclusive;
1948 channel = CHANNEL_ANY;
1949 /* nt-port with no channel, not reserverd */
1950 if (!p_m_b_channel && !p_m_b_reserve && p_type==PORT_TYPE_DSS1_NT_OUT)
1951 channel = CHANNEL_NO;
1954 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT);
1955 /* see MT_ASSIGN notes at do_layer3() */
1957 ret = p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ASSIGN, 0, NULL);
1958 if (mt_assign_pid == 0 || ret < 0)
1960 struct lcr_msg *message;
1962 add_trace("callref", NULL, "no free id");
1964 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1965 message->param.disconnectinfo.cause = 47;
1966 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1967 message_put(message);
1968 new_state(PORT_STATE_RELEASE);
1972 p_m_d_l3id = mt_assign_pid;
1974 add_trace("callref", "new", "0x%x", p_m_d_l3id);
1977 /* preparing setup message */
1978 l3m = create_l3msg();
1979 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_REQ, DIRECTION_OUT);
1980 /* channel information */
1981 if (channel >= 0) /* it should */
1983 enc_ie_channel_id(l3m, exclusive, channel);
1985 /* caller information */
1987 switch (p_callerinfo.ntype)
1989 case INFO_NTYPE_INTERNATIONAL:
1992 case INFO_NTYPE_NATIONAL:
1995 case INFO_NTYPE_SUBSCRIBER:
1998 default: /* INFO_NTYPE_UNKNOWN */
2002 switch (p_callerinfo.screen)
2004 case INFO_SCREEN_USER:
2007 default: /* INFO_SCREEN_NETWORK */
2011 switch (p_callerinfo.present)
2013 case INFO_PRESENT_RESTRICTED:
2016 case INFO_PRESENT_NOTAVAIL:
2019 default: /* INFO_PRESENT_ALLOWED */
2024 enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id);
2025 /* dialing information */
2026 if (p_dialinginfo.id[0]) /* only if we have something to dial */
2028 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id);
2030 /* sending complete */
2031 if (p_dialinginfo.sending_complete)
2032 enc_ie_complete(l3m, 1);
2033 /* sending user-user */
2034 if (param->setup.useruser.len)
2036 enc_ie_useruser(l3m, param->setup.useruser.protocol, param->setup.useruser.data, param->setup.useruser.len);
2038 /* redirecting number */
2040 switch (p_redirinfo.ntype)
2042 case INFO_NTYPE_INTERNATIONAL:
2045 case INFO_NTYPE_NATIONAL:
2048 case INFO_NTYPE_SUBSCRIBER:
2051 default: /* INFO_NTYPE_UNKNOWN */
2055 switch (p_redirinfo.screen)
2057 case INFO_SCREEN_USER:
2060 default: /* INFO_SCREE_NETWORK */
2064 switch (p_redirinfo.reason)
2066 case INFO_REDIR_BUSY:
2069 case INFO_REDIR_NORESPONSE:
2072 case INFO_REDIR_UNCONDITIONAL:
2075 case INFO_REDIR_CALLDEFLECT:
2078 case INFO_REDIR_OUTOFORDER:
2081 default: /* INFO_REDIR_UNKNOWN */
2085 switch (p_redirinfo.present)
2087 case INFO_PRESENT_NULL: /* no redir at all */
2094 case INFO_PRESENT_RESTRICTED:
2097 case INFO_PRESENT_NOTAVAIL:
2100 default: /* INFO_PRESENT_ALLOWED */
2104 /* sending redirecting number only in ntmode */
2105 if (type >= 0 && p_m_d_ntmode)
2106 enc_ie_redir_nr(l3m, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
2107 /* bearer capability */
2108 //printf("hlc=%d\n",p_capainfo.hlc);
2110 capability = p_capainfo.bearer_capa;
2111 mode = p_capainfo.bearer_mode;
2112 rate = (mode==INFO_BMODE_CIRCUIT)?0x10:0x00;
2113 switch (p_capainfo.bearer_info1)
2115 case INFO_INFO1_NONE:
2119 user = p_capainfo.bearer_info1 & 0x7f;
2122 enc_ie_bearer(l3m, coding, capability, mode, rate, -1, user);
2129 hlc = p_capainfo.hlc & 0x7f;
2131 if (p_capainfo.exthlc)
2132 exthlc = p_capainfo.exthlc & 0x7f;
2133 enc_ie_hlc(l3m, coding, interpretation, presentation, hlc, exthlc);
2137 if (p_callerinfo.display[0] && p_m_d_ntmode)
2138 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
2139 /* nt-mode: CNIP (calling name identification presentation) */
2140 // if (p_callerinfo.name[0] && p_m_d_ntmode)
2141 // enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
2144 /* send setup message now */
2145 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP, p_m_d_l3id, l3m);
2147 new_state(PORT_STATE_OUT_SETUP);
2150 /* MESSAGE_FACILITY */
2151 void Pdss1::message_facility(unsigned int epoint_id, int message_id, union parameter *param)
2155 /* facility will not be sent to external lines */
2159 /* sending facility */
2160 l3m = create_l3msg();
2161 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
2162 enc_ie_facility(l3m, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len);
2164 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
2167 /* MESSAGE_NOTIFY */
2168 void Pdss1::message_notify(unsigned int epoint_id, int message_id, union parameter *param)
2172 int plan, type = -1, present;
2174 if (param->notifyinfo.notify>INFO_NOTIFY_NONE)
2175 notify = param->notifyinfo.notify & 0x7f;
2178 if (p_state != PORT_STATE_CONNECT)
2180 /* notify only allowed in active state */
2186 switch (param->notifyinfo.ntype)
2188 case INFO_NTYPE_INTERNATIONAL:
2191 case INFO_NTYPE_NATIONAL:
2194 case INFO_NTYPE_SUBSCRIBER:
2197 default: /* INFO_NTYPE_UNKNOWN */
2201 switch (param->notifyinfo.present)
2203 case INFO_PRESENT_NULL: /* no redir at all */
2208 case INFO_PRESENT_RESTRICTED:
2211 case INFO_PRESENT_NOTAVAIL:
2214 default: /* INFO_PRESENT_ALLOWED */
2220 if (notify<0 && !param->notifyinfo.display[0])
2222 /* nothing to notify, nothing to display */
2228 if (p_state!=PORT_STATE_CONNECT)
2230 /* queue notification */
2231 if (p_m_d_notify_pending)
2232 message_free(p_m_d_notify_pending);
2233 p_m_d_notify_pending = message_create(ACTIVE_EPOINT(p_epointlist), p_serial, EPOINT_TO_PORT, message_id);
2234 memcpy(&p_m_d_notify_pending->param, param, sizeof(union parameter));
2237 /* sending notification */
2238 l3m = create_l3msg();
2239 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
2240 enc_ie_notify(l3m, notify);
2241 /* sending redirection number only in ntmode */
2242 if (type >= 0 && p_m_d_ntmode)
2243 enc_ie_redir_dn(l3m, type, plan, present, (unsigned char *)param->notifyinfo.id);
2244 if (param->notifyinfo.display[0] && p_m_d_ntmode)
2245 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2247 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_NOTIFY, p_m_d_l3id, l3m);
2249 } else if (p_m_d_ntmode)
2251 /* sending information */
2252 l3m = create_l3msg();
2253 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2254 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2256 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2260 /* MESSAGE_OVERLAP */
2261 void Pdss1::message_overlap(unsigned int epoint_id, int message_id, union parameter *param)
2265 /* sending setup_acknowledge */
2266 l3m = create_l3msg();
2267 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_REQ, DIRECTION_OUT);
2268 /* channel information */
2269 if (p_state == PORT_STATE_IN_SETUP)
2270 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2271 /* progress information */
2272 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2273 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2274 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2275 if (p_m_mISDNport->tones)
2276 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2278 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, l3m);
2280 new_state(PORT_STATE_IN_OVERLAP);
2283 /* MESSAGE_PROCEEDING */
2284 void Pdss1::message_proceeding(unsigned int epoint_id, int message_id, union parameter *param)
2288 /* sending proceeding */
2289 l3m = create_l3msg();
2290 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2291 /* channel information */
2292 if (p_state == PORT_STATE_IN_SETUP)
2293 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2294 /* progress information */
2295 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2296 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2297 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2298 if (p_m_mISDNport->tones)
2299 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2301 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2303 new_state(PORT_STATE_IN_PROCEEDING);
2306 /* MESSAGE_ALERTING */
2307 void Pdss1::message_alerting(unsigned int epoint_id, int message_id, union parameter *param)
2311 /* NT-MODE in setup state we must send PROCEEDING first */
2312 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2314 /* sending proceeding */
2315 l3m = create_l3msg();
2316 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2317 /* channel information */
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_CALL_PROCEEDING, p_m_d_l3id, l3m);
2327 new_state(PORT_STATE_IN_PROCEEDING);
2330 /* sending alerting */
2331 l3m = create_l3msg();
2332 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_REQ, DIRECTION_OUT);
2333 /* channel information */
2334 if (p_state == PORT_STATE_IN_SETUP)
2335 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2336 /* progress information */
2337 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2338 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2339 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2340 if (p_m_mISDNport->tones)
2341 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2343 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ALERTING, p_m_d_l3id, l3m);
2345 new_state(PORT_STATE_IN_ALERTING);
2348 /* MESSAGE_CONNECT */
2349 void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parameter *param)
2352 int type, plan, present, screen;
2353 class Endpoint *epoint;
2355 /* NT-MODE in setup state we must send PROCEEDING first */
2356 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2358 /* sending proceeding */
2359 l3m = create_l3msg();
2360 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2361 /* channel information */
2362 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2364 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2365 new_state(PORT_STATE_IN_PROCEEDING);
2368 /* copy connected information */
2369 memcpy(&p_connectinfo, ¶m->connectinfo, sizeof(p_connectinfo));
2370 /* screen outgoing caller id */
2371 do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface);
2373 /* only display at connect state */
2374 if (p_state == PORT_STATE_CONNECT)
2375 if (p_connectinfo.display[0])
2377 /* sending information */
2378 l3m = create_l3msg();
2379 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2381 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2383 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2387 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)
2389 /* connect command only possible in setup, proceeding or alerting state */
2393 /* preparing connect message */
2394 l3m = create_l3msg();
2395 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_REQ, DIRECTION_OUT);
2396 /* connect information */
2398 switch (p_connectinfo.ntype)
2400 case INFO_NTYPE_INTERNATIONAL:
2403 case INFO_NTYPE_NATIONAL:
2406 case INFO_NTYPE_SUBSCRIBER:
2409 default: /* INFO_NTYPE_UNKNOWN */
2413 switch (param->connectinfo.screen)
2415 case INFO_SCREEN_USER:
2418 default: /* INFO_SCREE_NETWORK */
2422 switch (p_connectinfo.present)
2424 case INFO_PRESENT_NULL: /* no colp at all */
2430 case INFO_PRESENT_RESTRICTED:
2433 case INFO_PRESENT_NOTAVAIL:
2436 default: /* INFO_PRESENT_ALLOWED */
2441 enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
2443 if (p_connectinfo.display[0] && p_m_d_ntmode)
2444 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2445 /* nt-mode: CONP (connected name identification presentation) */
2446 // if (p_connectinfo.name[0] && p_m_d_ntmode)
2447 // enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
2451 epoint = find_epoint_id(epoint_id);
2452 enc_ie_date(l3m, now, p_settings.no_seconds);
2455 /* finally send message */
2456 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT, p_m_d_l3id, l3m);
2459 new_state(PORT_STATE_CONNECT);
2461 new_state(PORT_STATE_CONNECT_WAITING);
2465 /* MESSAGE_DISCONNECT */
2466 void Pdss1::message_disconnect(unsigned int epoint_id, int message_id, union parameter *param)
2469 struct lcr_msg *message;
2472 /* we reject during incoming setup when we have no tones. also if we are in outgoing setup state */
2473 // if ((p_state==PORT_STATE_IN_SETUP && !p_m_mISDNport->tones)
2474 if (/* ||*/ p_state==PORT_STATE_OUT_SETUP)
2476 /* sending release to endpoint */
2479 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
2480 memcpy(&message->param, param, sizeof(union parameter));
2481 message_put(message);
2483 free_epointlist(p_epointlist);
2485 /* sending release */
2486 l3m = create_l3msg();
2487 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
2489 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2491 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2492 new_state(PORT_STATE_RELEASE);
2497 /* workarround: NT-MODE in setup state we must send PROCEEDING first to make it work */
2498 if (p_state==PORT_STATE_IN_SETUP)
2500 /* sending proceeding */
2501 l3m = create_l3msg();
2502 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2503 /* channel information */
2504 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2505 /* progress information */
2506 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2507 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2508 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2509 if (p_m_mISDNport->tones)
2510 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2512 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2513 new_state(PORT_STATE_IN_PROCEEDING);
2516 /* sending disconnect */
2517 l3m = create_l3msg();
2518 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2519 /* progress information */
2520 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2521 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2522 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2523 if (p_m_mISDNport->tones)
2524 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2526 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2528 if (param->disconnectinfo.display[0])
2529 p = param->disconnectinfo.display;
2530 if (p) if (*p && p_m_d_ntmode)
2531 enc_ie_display(l3m, (unsigned char *)p);
2533 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2534 new_state(PORT_STATE_OUT_DISCONNECT);
2537 /* MESSAGE_RELEASE */
2538 void Pdss1::message_release(unsigned int epoint_id, int message_id, union parameter *param)
2541 class Endpoint *epoint;
2545 * we may only release during incoming disconnect state.
2546 * this means that the endpoint doesnt require audio anymore
2548 if (p_state == PORT_STATE_IN_DISCONNECT
2549 || p_state == PORT_STATE_OUT_DISCONNECT)
2551 /* sending release */
2552 l3m = create_l3msg();
2553 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2555 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2557 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
2558 new_state(PORT_STATE_RELEASE);
2560 free_epointid(epoint_id);
2561 // wait for callref to be released
2566 * if we are on incoming call setup, we may reject by sending a release_complete
2567 * also on outgoing call setup, we send a release complete, BUT this is not conform. (i don't know any other way)
2569 if (p_state==PORT_STATE_IN_SETUP
2570 || p_state==PORT_STATE_OUT_SETUP)
2572 //#warning remove me
2573 //PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
2574 /* sending release complete */
2575 l3m = create_l3msg();
2576 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2578 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2580 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2581 new_state(PORT_STATE_RELEASE);
2583 free_epointid(epoint_id);
2584 // wait for callref to be released
2589 wirklich erst proceeding?:
2590 /* NT-MODE in setup state we must send PROCEEDING first */
2591 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2593 CALL_PROCEEDING_t *proceeding;
2595 /* sending proceeding */
2596 l3m = create_l3msg();
2597 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2598 /* channel information */
2599 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2600 /* progress information */
2601 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2602 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2603 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2604 if (p_m_mISDNport->tones)
2605 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2607 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2611 /* sending disconnect */
2612 l3m = create_l3msg();
2613 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2614 /* progress information */
2615 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2616 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2617 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2618 if (p_m_mISDNport->tones)
2619 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2621 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2623 epoint = find_epoint_id(epoint_id);
2624 if (param->disconnectinfo.display[0])
2625 p = param->disconnectinfo.display;
2626 if (p) if (*p && p_m_d_ntmode)
2627 enc_ie_display(l3m, (unsigned char *)p);
2629 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2630 new_state(PORT_STATE_OUT_DISCONNECT);
2632 free_epointid(epoint_id);
2633 // wait for release and callref to be released
2634 //#warning remove me
2635 //PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
2640 * endpoint sends messages to the port
2642 int Pdss1::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
2644 struct lcr_msg *message;
2646 if (PmISDN::message_epoint(epoint_id, message_id, param))
2651 case MESSAGE_INFORMATION: /* overlap dialing */
2652 if (p_type==PORT_TYPE_DSS1_NT_OUT
2653 && p_state!=PORT_STATE_OUT_OVERLAP
2654 && p_state!=PORT_STATE_CONNECT
2655 && p_state!=PORT_STATE_OUT_DISCONNECT
2656 && p_state!=PORT_STATE_IN_DISCONNECT)
2660 if (p_type==PORT_TYPE_DSS1_TE_OUT
2661 && p_state!=PORT_STATE_OUT_OVERLAP
2662 && p_state!=PORT_STATE_OUT_PROCEEDING
2663 && p_state!=PORT_STATE_OUT_ALERTING
2664 && p_state!=PORT_STATE_CONNECT
2665 && p_state!=PORT_STATE_OUT_DISCONNECT
2666 && p_state!=PORT_STATE_IN_DISCONNECT)
2670 if ((p_type==PORT_TYPE_DSS1_NT_IN || p_type==PORT_TYPE_DSS1_TE_IN)
2671 && p_state!=PORT_STATE_IN_OVERLAP
2672 && p_state!=PORT_STATE_IN_PROCEEDING
2673 && p_state!=PORT_STATE_IN_ALERTING
2674 && p_state!=PORT_STATE_CONNECT
2675 && p_state!=PORT_STATE_CONNECT_WAITING
2676 && p_state!=PORT_STATE_OUT_DISCONNECT
2677 && p_state!=PORT_STATE_IN_DISCONNECT)
2681 message_information(epoint_id, message_id, param);
2684 case MESSAGE_SETUP: /* dial-out command received from epoint */
2685 if (p_state!=PORT_STATE_IDLE
2686 && p_state!=PORT_STATE_CONNECT)
2688 PERROR("Pdss1(%s) ignoring setup because isdn port is not in idle state (or connected for sending display info).\n", p_name);
2691 if (p_epointlist && p_state==PORT_STATE_IDLE)
2692 FATAL("Pdss1(%s): epoint pointer is set in idle state, how bad!!\n", p_name);
2693 message_setup(epoint_id, message_id, param);
2696 case MESSAGE_NOTIFY: /* display and notifications */
2697 message_notify(epoint_id, message_id, param);
2700 case MESSAGE_FACILITY: /* facility message */
2701 message_facility(epoint_id, message_id, param);
2704 case MESSAGE_OVERLAP: /* more information is needed */
2705 if (p_state!=PORT_STATE_IN_SETUP)
2709 message_overlap(epoint_id, message_id, param);
2712 case MESSAGE_PROCEEDING: /* call of endpoint is proceeding */
2713 if (p_state!=PORT_STATE_IN_SETUP
2714 && p_state!=PORT_STATE_IN_OVERLAP)
2718 message_proceeding(epoint_id, message_id, param);
2721 case MESSAGE_ALERTING: /* call of endpoint is ringing */
2722 if (p_state!=PORT_STATE_IN_SETUP
2723 && p_state!=PORT_STATE_IN_OVERLAP
2724 && p_state!=PORT_STATE_IN_PROCEEDING)
2728 message_alerting(epoint_id, message_id, param);
2731 case MESSAGE_CONNECT: /* call of endpoint is connected */
2732 if (p_state!=PORT_STATE_IN_SETUP
2733 && p_state!=PORT_STATE_IN_OVERLAP
2734 && p_state!=PORT_STATE_IN_PROCEEDING
2735 && p_state!=PORT_STATE_IN_ALERTING
2736 && !(p_state==PORT_STATE_CONNECT && p_m_d_ntmode))
2740 message_connect(epoint_id, message_id, param);
2743 case MESSAGE_DISCONNECT: /* call has been disconnected */
2744 if (p_state!=PORT_STATE_IN_SETUP
2745 && p_state!=PORT_STATE_IN_OVERLAP
2746 && p_state!=PORT_STATE_IN_PROCEEDING
2747 && p_state!=PORT_STATE_IN_ALERTING
2748 && p_state!=PORT_STATE_OUT_SETUP
2749 && p_state!=PORT_STATE_OUT_OVERLAP
2750 && p_state!=PORT_STATE_OUT_PROCEEDING
2751 && p_state!=PORT_STATE_OUT_ALERTING
2752 && p_state!=PORT_STATE_CONNECT
2753 && p_state!=PORT_STATE_CONNECT_WAITING)
2757 message_disconnect(epoint_id, message_id, param);
2760 case MESSAGE_RELEASE: /* release isdn port */
2761 if (p_state==PORT_STATE_RELEASE)
2765 message_release(epoint_id, message_id, param);
2769 PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message);
2778 * data from isdn-stack (layer-3) to pbx (port class)
2780 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
2786 PDEBUG(DEBUG_ISDN, "cmd(0x%x) pid(0x%x)\n", cmd, pid);
2790 PDEBUG(DEBUG_ISDN, "ignoring dummy process from phone.\n");
2794 /* find Port object of type ISDN */
2799 if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
2801 pdss1 = (class Pdss1 *)port;
2802 /* check out correct stack and id */
2803 if (pdss1->p_m_mISDNport == mISDNport)
2805 if (pdss1->p_m_d_l3id & MISDN_PID_CR_FLAG)
2807 /* local callref, so match value only */
2808 if ((pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == (pid & MISDN_PID_CRVAL_MASK))
2812 /* remote callref, ref + channel id */
2813 if (pdss1->p_m_d_l3id == pid)
2821 /* aktueller prozess */
2824 if (cmd == MT_ASSIGN)
2826 /* stack gives us new layer 3 id (during connect) */
2827 l1l2l3_trace_header(mISDNport, pdss1, L3_NEW_L3ID_IND, DIRECTION_IN);
2828 add_trace("callref", "old", "0x%x", pdss1->p_m_d_l3id);
2829 /* nt-library now gives us a new id via CC_SETUP_CONFIRM */
2830 if ((pdss1->p_m_d_l3id&MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER)
2831 PERROR(" strange setup-procid 0x%x\n", pdss1->p_m_d_l3id);
2832 pdss1->p_m_d_l3id = pid;
2833 if (port->p_state == PORT_STATE_CONNECT)
2834 pdss1->p_m_d_ces = pid >> 16;
2835 add_trace("callref", "new", "0x%x", pdss1->p_m_d_l3id);
2839 /* if process id is master process, but a child disconnects */
2840 if (mISDNport->ntmode
2841 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2842 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) == MISDN_PID_MASTER)
2844 if (cmd == MT_DISCONNECT
2845 || cmd == MT_RELEASE)
2847 /* send special indication for child disconnect */
2848 pdss1->disconnect_ind_i(cmd, pid, l3m);
2851 if (cmd == MT_RELEASE_COMPLETE)
2854 /* if we have child pid and got different child pid message, ignore */
2855 if (mISDNport->ntmode
2856 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2857 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2858 && pid != pdss1->p_m_d_l3id)
2861 /* process message */
2862 pdss1->message_isdn(cmd, pid, l3m);
2870 /* creating port object */
2871 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2872 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0)))
2874 FATAL("Cannot create Port instance.\n");
2875 pdss1->message_isdn(cmd, pid, l3m);
2879 /* creating port object */
2880 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2881 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0)))
2882 FATAL("Cannot create Port instance.\n");
2883 pdss1->message_isdn(cmd, pid, l3m);
2887 PDEBUG(DEBUG_ISDN, "unused call ref released (l3id=0x%x)\n", pid);
2890 case MT_RELEASE_COMPLETE:
2891 PERROR("must be ignored by stack, not sent to app\n");
2895 // facility als broadcast
2899 PERROR("unhandled message: cmd(0x%x) pid(0x%x)\n", cmd, pid);
2903 if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT)
2905 pdss1 = (class Pdss1 *)port;
2906 /* check out correct stack */
2907 if (pdss1->p_m_mISDNport == mISDNport)
2908 /* check out correct id */
2909 PERROR("unhandled message: pid=%x is not associated with port-dinfo=%x\n", pid, pdss1->p_m_d_l3id);
2921 * sending message that were queued during L1 activation
2922 * or releasing port if link is down
2924 void setup_queue(struct mISDNport *mISDNport, int link)
2928 struct lcr_msg *message;
2930 if (!mISDNport->ntmode)
2933 /* check all port objects for pending message */
2937 if ((port->p_type&PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
2939 pdss1 = (class Pdss1 *)port;
2940 if (pdss1->p_m_mISDNport == mISDNport)
2942 if (pdss1->p_m_d_queue)
2946 PDEBUG(DEBUG_ISDN, "the L1 became active, so we send queued message for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
2947 /* LAYER 1 is up, so we send */
2948 pdss1->message_setup(pdss1->p_m_d_queue->id_from, pdss1->p_m_d_queue->type, &pdss1->p_m_d_queue->param);
2949 message_free(pdss1->p_m_d_queue);
2950 pdss1->p_m_d_queue = NULL;
2953 PDEBUG(DEBUG_ISDN, "the L1 became NOT active, so we release port for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
2954 message = message_create(pdss1->p_serial, pdss1->p_m_d_queue->id_from, PORT_TO_EPOINT, MESSAGE_RELEASE);
2955 message->param.disconnectinfo.cause = 27;
2956 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
2957 message_put(message);
2958 pdss1->new_state(PORT_STATE_RELEASE);
2959 pdss1->p_m_delete = 1;