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 */
329 /* no exclusive channel */
332 add_trace("conclusion", NULL, "exclusively requested channel not in list");
334 return(-6); // channel unacceptable
336 /* get index for channel */
337 i = channel-1-(channel>=17);
338 if (i < 0 || i >= p_m_mISDNport->b_num || channel == 16)
340 add_trace("conclusion", NULL, "exclusively requested channel outside interface range");
342 return(-6); // channel unacceptable
345 if (p_m_mISDNport->b_port[i] == NULL)
347 add_trace("conclusion", NULL, "exclusively requested channel is busy");
349 return(-6); // channel unacceptable
352 /* requested channels in list will be used */
355 /* get index for channel */
356 i = channel-1-(channel>=17);
357 if (i < 0 || i >= p_m_mISDNport->b_num || channel == 16)
359 add_trace("info", NULL, "requested channel %d outside interface range", channel);
360 } else /* if inside range (else) check if available */
361 if (p_m_mISDNport->b_port[i] == NULL)
365 /* if channel is not available or not in list, it must be searched */
367 /* check for first free channel in list */
369 selchannel = ifport->in_channel;
372 switch(selchannel->channel)
374 case CHANNEL_FREE: /* free channel */
375 add_trace("hunting", "channel", "free");
376 if (p_m_mISDNport->b_reserved >= p_m_mISDNport->b_num)
377 break; /* all channel in use or reserverd */
380 while(i < p_m_mISDNport->b_num)
382 if (p_m_mISDNport->b_port[i] == NULL)
384 channel = i+1+(i>=15);
392 add_trace("hunting", "channel", "%d", selchannel->channel);
393 if (selchannel->channel<1 || selchannel->channel==16)
394 break; /* invalid channels */
395 i = selchannel->channel-1-(selchannel->channel>=17);
396 if (i >= p_m_mISDNport->b_num)
397 break; /* channel not in port */
398 if (p_m_mISDNport->b_port[i] == NULL)
400 channel = selchannel->channel;
406 break; /* found channel */
407 selchannel = selchannel->next;
411 add_trace("conclusion", NULL, "no channel available");
413 return(-6); // channel unacceptable
417 add_trace("conclusion", NULL, "channel available");
418 add_trace("connect", "channel", "%d", channel);
424 * handles all indications
426 /* CC_SETUP INDICATION */
427 void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
429 int calling_type, calling_plan, calling_present, calling_screen;
430 int called_type, called_plan;
431 int redir_type, redir_plan, redir_present, redir_screen, redir_reason;
432 int hlc_coding, hlc_presentation, hlc_interpretation, hlc_hlc, hlc_exthlc;
433 int bearer_coding, bearer_capability, bearer_mode, bearer_rate, bearer_multi, bearer_user;
434 int exclusive, channel;
436 unsigned char keypad[32] = "";
437 unsigned char useruser[128];
438 int useruser_len = 0, useruser_protocol;
439 class Endpoint *epoint;
440 struct lcr_msg *message;
442 /* process given callref */
443 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
444 add_trace("callref", "new", "0x%x", pid);
447 /* release in case the ID is already in use */
448 add_trace("error", NULL, "callref already in use");
450 l3m = create_l3msg();
451 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
452 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
453 add_trace("reason", NULL, "callref already in use");
455 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, pid, l3m);
456 new_state(PORT_STATE_RELEASE);
461 p_m_d_ces = pid >> 16;
464 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_IND, DIRECTION_IN);
465 dec_ie_calling_pn(l3m, &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id));
466 dec_ie_called_pn(l3m, &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
467 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
468 /* te-mode: CNIP (calling name identification presentation) */
470 dec_facility_centrex(l3m, (unsigned char *)p_callerinfo.name, sizeof(p_callerinfo.name));
471 dec_ie_useruser(l3m, &useruser_protocol, useruser, &useruser_len);
472 dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
473 dec_ie_redir_nr(l3m, &redir_type, &redir_plan, &redir_present, &redir_screen, &redir_reason, (unsigned char *)p_redirinfo.id, sizeof(p_redirinfo.id));
474 dec_ie_channel_id(l3m, &exclusive, &channel);
475 dec_ie_hlc(l3m, &hlc_coding, &hlc_interpretation, &hlc_presentation, &hlc_hlc, &hlc_exthlc);
476 dec_ie_bearer(l3m, &bearer_coding, &bearer_capability, &bearer_mode, &bearer_rate, &bearer_multi, &bearer_user);
477 dec_ie_display(l3m, (unsigned char *)p_dialinginfo.display, sizeof(p_dialinginfo.display));
480 /* if blocked, release call with MT_RELEASE_COMPLETE */
481 if (p_m_mISDNport->ifport->block)
483 l3m = create_l3msg();
484 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
485 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 27); /* temporary unavailable */
486 add_trace("reason", NULL, "port blocked");
488 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
489 new_state(PORT_STATE_RELEASE);
495 switch (calling_present)
498 p_callerinfo.present = INFO_PRESENT_RESTRICTED;
501 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
504 p_callerinfo.present = INFO_PRESENT_ALLOWED;
507 switch (calling_screen)
510 p_callerinfo.screen = INFO_SCREEN_USER;
513 p_callerinfo.screen = INFO_SCREEN_NETWORK;
516 switch (calling_type)
519 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
520 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
521 p_callerinfo.screen = INFO_SCREEN_NETWORK;
524 p_callerinfo.ntype = INFO_NTYPE_INTERNATIONAL;
527 p_callerinfo.ntype = INFO_NTYPE_NATIONAL;
530 p_callerinfo.ntype = INFO_NTYPE_SUBSCRIBER;
533 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
536 p_callerinfo.isdn_port = p_m_portnum;
537 SCPY(p_callerinfo.interface, p_m_mISDNport->ifport->interface->name);
539 /* dialing information */
540 SCAT(p_dialinginfo.id, (char *)keypad);
544 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
547 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
550 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
553 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
558 switch (redir_present)
561 p_redirinfo.present = INFO_PRESENT_RESTRICTED;
564 p_redirinfo.present = INFO_PRESENT_NOTAVAIL;
567 p_redirinfo.present = INFO_PRESENT_ALLOWED;
570 switch (redir_screen)
573 p_redirinfo.screen = INFO_SCREEN_USER;
576 p_redirinfo.screen = INFO_SCREEN_NETWORK;
579 switch (redir_reason)
582 p_redirinfo.reason = INFO_REDIR_BUSY;
585 p_redirinfo.reason = INFO_REDIR_NORESPONSE;
588 p_redirinfo.reason = INFO_REDIR_UNCONDITIONAL;
591 p_redirinfo.reason = INFO_REDIR_CALLDEFLECT;
594 p_redirinfo.reason = INFO_REDIR_OUTOFORDER;
597 p_redirinfo.reason = INFO_REDIR_UNKNOWN;
603 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
604 p_redirinfo.present = INFO_PRESENT_NULL; /* not redirecting */
605 p_redirinfo.reason = INFO_REDIR_UNKNOWN;
608 p_redirinfo.ntype = INFO_NTYPE_INTERNATIONAL;
611 p_redirinfo.ntype = INFO_NTYPE_NATIONAL;
614 p_redirinfo.ntype = INFO_NTYPE_SUBSCRIBER;
617 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
620 p_redirinfo.isdn_port = p_m_portnum;
622 /* bearer capability */
623 switch (bearer_capability)
626 p_capainfo.bearer_capa = INFO_BC_AUDIO;
627 bearer_user = (options.law=='a')?3:2;
630 p_capainfo.bearer_capa = bearer_capability;
636 p_capainfo.bearer_mode = INFO_BMODE_PACKET;
639 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
645 p_capainfo.bearer_info1 = INFO_INFO1_NONE;
648 p_capainfo.bearer_info1 = bearer_user + 0x80;
656 p_capainfo.hlc = INFO_HLC_NONE;
659 p_capainfo.hlc = hlc_hlc + 0x80;
665 p_capainfo.exthlc = INFO_HLC_NONE;
668 p_capainfo.exthlc = hlc_exthlc + 0x80;
673 ret = channel = hunt_bchannel(channel, exclusive);
678 ret = seize_bchannel(channel, 1);
683 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
684 * in response to the setup
686 l3m = create_l3msg();
687 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
688 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
690 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
691 new_state(PORT_STATE_RELEASE);
695 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
697 /* create endpoint */
699 FATAL("Incoming call but already got an endpoint.\n");
700 if (!(epoint = new Endpoint(p_serial, 0)))
701 FATAL("No memory for Endpoint instance\n");
702 if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 0))) //incoming
703 FATAL("No memory for Endpoint Application instance\n");
704 epointlist_new(epoint->ep_serial);
706 /* send setup message to endpoit */
707 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
708 message->param.setup.isdn_port = p_m_portnum;
709 message->param.setup.port_type = p_type;
710 // message->param.setup.dtmf = !p_m_mISDNport->ifport->nodtmf;
711 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
712 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
713 memcpy(&message->param.setup.redirinfo, &p_redirinfo, sizeof(struct redir_info));
714 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
715 memcpy(message->param.setup.useruser.data, &useruser, useruser_len);
716 message->param.setup.useruser.len = useruser_len;
717 message->param.setup.useruser.protocol = useruser_protocol;
718 message_put(message);
720 new_state(PORT_STATE_IN_SETUP);
723 /* CC_INFORMATION INDICATION */
724 void Pdss1::information_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
727 unsigned char keypad[32] = "", display[128] = "";
728 struct lcr_msg *message;
730 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_IND, DIRECTION_IN);
731 dec_ie_called_pn(l3m, &type, &plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
732 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
733 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
734 dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
737 SCAT(p_dialinginfo.id, (char *)keypad);
741 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
744 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
747 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
750 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
753 SCAT(p_dialinginfo.display, (char *)display);
754 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_INFORMATION);
755 memcpy(&message->param.information, &p_dialinginfo, sizeof(struct dialing_info));
756 message_put(message);
757 /* reset overlap timeout */
761 /* CC_SETUP_ACCNOWLEDGE INDICATION */
762 void Pdss1::setup_acknowledge_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
764 int exclusive, channel;
765 int coding, location, progress;
767 struct lcr_msg *message;
769 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_IND, DIRECTION_IN);
770 dec_ie_channel_id(l3m, &exclusive, &channel);
771 dec_ie_progress(l3m, &coding, &location, &progress);
774 /* process channel */
775 ret = received_first_reply_to_setup(cmd, channel, exclusive);
778 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
779 message->param.disconnectinfo.cause = -ret;
780 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
781 message_put(message);
782 new_state(PORT_STATE_RELEASE);
787 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_OVERLAP);
788 message_put(message);
790 new_state(PORT_STATE_OUT_OVERLAP);
793 /* CC_PROCEEDING INDICATION */
794 void Pdss1::proceeding_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
796 int exclusive, channel;
797 int coding, location, progress;
799 struct lcr_msg *message;
800 int notify = -1, type, plan, present;
803 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_IND, DIRECTION_IN);
804 dec_ie_channel_id(l3m, &exclusive, &channel);
805 dec_ie_progress(l3m, &coding, &location, &progress);
806 dec_ie_notify(l3m, ¬ify);
807 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
810 ret = received_first_reply_to_setup(cmd, channel, exclusive);
813 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
814 message->param.disconnectinfo.cause = -ret;
815 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
816 message_put(message);
817 new_state(PORT_STATE_RELEASE);
821 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
822 message_put(message);
824 new_state(PORT_STATE_OUT_PROCEEDING);
830 if (type >= 0 || notify)
832 if (!notify && type >= 0)
834 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
835 message->param.notifyinfo.notify = notify;
836 SCPY(message->param.notifyinfo.id, redir);
837 /* redirection number */
841 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
844 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
847 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
853 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
854 message->param.notifyinfo.present = INFO_PRESENT_NULL;
857 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
860 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
863 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
866 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
869 message->param.notifyinfo.isdn_port = p_m_portnum;
870 message_put(message);
874 /* CC_ALERTING INDICATION */
875 void Pdss1::alerting_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
877 int exclusive, channel;
878 int coding, location, progress;
880 struct lcr_msg *message;
881 int notify = -1, type, plan, present;
884 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_IND, DIRECTION_IN);
885 dec_ie_channel_id(l3m, &exclusive, &channel);
886 dec_ie_progress(l3m, &coding, &location, &progress);
887 dec_ie_notify(l3m, ¬ify);
888 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
891 /* process channel */
892 ret = received_first_reply_to_setup(cmd, channel, exclusive);
895 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
896 message->param.disconnectinfo.cause = -ret;
897 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
898 message_put(message);
899 new_state(PORT_STATE_RELEASE);
903 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ALERTING);
904 message_put(message);
906 new_state(PORT_STATE_OUT_ALERTING);
912 if (type >= 0 || notify)
914 if (!notify && type >= 0)
916 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
917 message->param.notifyinfo.notify = notify;
918 SCPY(message->param.notifyinfo.id, redir);
922 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
925 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
928 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
934 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
935 message->param.notifyinfo.present = INFO_PRESENT_NULL;
938 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
941 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
944 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
947 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
950 message->param.notifyinfo.isdn_port = p_m_portnum;
951 message_put(message);
955 /* CC_CONNECT INDICATION */
956 void Pdss1::connect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
958 int exclusive, channel;
959 int type, plan, present, screen;
961 struct lcr_msg *message;
964 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_IND, DIRECTION_IN);
965 dec_ie_channel_id(l3m, &exclusive, &channel);
966 dec_ie_connected_pn(l3m, &type, &plan, &present, &screen, (unsigned char *)p_connectinfo.id, sizeof(p_connectinfo.id));
967 dec_ie_display(l3m, (unsigned char *)p_connectinfo.display, sizeof(p_connectinfo.display));
968 /* te-mode: CONP (connected name identification presentation) */
970 dec_facility_centrex(l3m, (unsigned char *)p_connectinfo.name, sizeof(p_connectinfo.name));
974 bchannel_before = p_m_b_channel;
975 ret = received_first_reply_to_setup(cmd, channel, exclusive);
978 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
979 message->param.disconnectinfo.cause = -ret;
980 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
981 message_put(message);
982 new_state(PORT_STATE_RELEASE);
987 /* connect information */
991 p_connectinfo.present = INFO_PRESENT_RESTRICTED;
994 p_connectinfo.present = INFO_PRESENT_NOTAVAIL;
997 p_connectinfo.present = INFO_PRESENT_ALLOWED;
1003 p_connectinfo.screen = INFO_SCREEN_USER;
1006 p_connectinfo.screen = INFO_SCREEN_NETWORK;
1012 p_connectinfo.present = INFO_PRESENT_NULL; /* no COLP info */
1013 p_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
1016 p_connectinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1019 p_connectinfo.ntype = INFO_NTYPE_NATIONAL;
1022 p_connectinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1025 p_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
1028 p_connectinfo.isdn_port = p_m_portnum;
1029 SCPY(p_connectinfo.interface, p_m_mISDNport->ifport->interface->name);
1031 /* only in nt-mode we send connect ack. in te-mode it is done by stack itself or optional */
1034 /* send connect acknowledge */
1035 l3m = create_l3msg();
1036 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_RES, DIRECTION_OUT);
1037 /* if we had no bchannel before, we send it now */
1038 if (!bchannel_before && p_m_b_channel)
1039 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1041 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT_ACKNOWLEDGE, p_m_d_l3id, l3m);
1044 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_CONNECT);
1045 memcpy(&message->param.connectinfo, &p_connectinfo, sizeof(struct connect_info));
1046 message_put(message);
1048 new_state(PORT_STATE_CONNECT);
1051 /* CC_DISCONNECT INDICATION */
1052 void Pdss1::disconnect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1054 int location, cause;
1055 int coding, proglocation, progress;
1056 struct lcr_msg *message;
1057 unsigned char display[128] = "";
1059 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1060 dec_ie_progress(l3m, &coding, &proglocation, &progress);
1061 dec_ie_cause(l3m, &location, &cause);
1062 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1068 /* release if remote sends us no tones */
1069 if (!p_m_mISDNport->earlyb)
1073 l3m = create_l3msg();
1074 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
1075 enc_ie_cause(l3m, location, cause); /* normal */
1076 add_trace("reason", NULL, "no remote patterns");
1078 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
1080 /* sending release to endpoint */
1081 if (location == LOCATION_PRIVATE_LOCAL)
1082 location = LOCATION_PRIVATE_REMOTE;
1085 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1086 message->param.disconnectinfo.cause = cause;
1087 message->param.disconnectinfo.location = location;
1088 SCAT(message->param.disconnectinfo.display, (char *)display);
1089 message_put(message);
1091 free_epointlist(p_epointlist);
1093 new_state(PORT_STATE_RELEASE);
1098 /* sending disconnect to active endpoint and release to inactive endpoints */
1099 if (location == LOCATION_PRIVATE_LOCAL)
1100 location = LOCATION_PRIVATE_REMOTE;
1101 if (ACTIVE_EPOINT(p_epointlist))
1103 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_DISCONNECT);
1104 message->param.disconnectinfo.location = location;
1105 message->param.disconnectinfo.cause = cause;
1106 SCAT(message->param.disconnectinfo.display, (char *)display);
1107 message_put(message);
1109 while(INACTIVE_EPOINT(p_epointlist))
1111 message = message_create(p_serial, INACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1112 message->param.disconnectinfo.location = location;
1113 message->param.disconnectinfo.cause = cause;
1114 SCAT(message->param.disconnectinfo.display, (char *)display);
1115 message_put(message);
1117 free_epointid(INACTIVE_EPOINT(p_epointlist));
1119 new_state(PORT_STATE_IN_DISCONNECT);
1122 /* CC_DISCONNECT INDICATION */
1123 void Pdss1::disconnect_ind_i(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1125 int location, cause;
1128 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1129 if (p_m_d_collect_cause > 0)
1131 add_trace("old-cause", "location", "%d", p_m_d_collect_location);
1132 add_trace("old-cause", "value", "%d", p_m_d_collect_cause);
1134 dec_ie_cause(l3m, &location, &cause);
1135 if (location == LOCATION_PRIVATE_LOCAL)
1136 location = LOCATION_PRIVATE_REMOTE;
1139 collect_cause(&p_m_d_collect_cause, &p_m_d_collect_location, cause, location);
1140 add_trace("new-cause", "location", "%d", p_m_d_collect_location);
1141 add_trace("new-cause", "value", "%d", p_m_d_collect_cause);
1146 /* CC_RELEASE INDICATION */
1147 void Pdss1::release_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1149 int location, cause;
1150 struct lcr_msg *message;
1151 unsigned char display[128] = "";
1153 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_IND, DIRECTION_IN);
1154 dec_ie_cause(l3m, &location, &cause);
1155 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1161 /* sending release to endpoint */
1162 if (location == LOCATION_PRIVATE_LOCAL)
1163 location = LOCATION_PRIVATE_REMOTE;
1166 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1167 message->param.disconnectinfo.cause = cause;
1168 message->param.disconnectinfo.location = location;
1169 SCAT(message->param.disconnectinfo.display, (char *)display);
1170 message_put(message);
1172 free_epointlist(p_epointlist);
1175 new_state(PORT_STATE_RELEASE);
1179 /* CC_RESTART INDICATION */
1180 void Pdss1::restart_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1182 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESTART_IND, DIRECTION_IN);
1185 // L3 process is not toucht. (not even by network stack)
1188 /* CC_RELEASE_COMPLETE INDICATION (a reject) */
1189 void Pdss1::release_complete_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1191 int location, cause;
1192 struct lcr_msg *message;
1194 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_IND, DIRECTION_IN);
1195 /* in case layer 2 is down during setup, we send cause 27 loc 5 */
1196 if (p_state == PORT_STATE_OUT_SETUP && p_m_mISDNport->l1link == 0)
1202 dec_ie_cause(l3m, &location, &cause);
1203 if (p_m_mISDNport->l1link < 0)
1204 add_trace("layer 1", NULL, "unknown");
1206 add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
1209 if (location == LOCATION_PRIVATE_LOCAL)
1210 location = LOCATION_PRIVATE_REMOTE;
1215 /* sending release to endpoint */
1218 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1219 message->param.disconnectinfo.cause = cause;
1220 message->param.disconnectinfo.location = location;
1221 message_put(message);
1223 free_epointlist(p_epointlist);
1226 new_state(PORT_STATE_RELEASE);
1231 void Pdss1::t312_timeout_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1233 // not required, release is performed with MT_FREE
1236 /* CC_NOTIFY INDICATION */
1237 void Pdss1::notify_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1239 struct lcr_msg *message;
1240 int notify, type, plan, present;
1241 unsigned char notifyid[sizeof(message->param.notifyinfo.id)];
1242 unsigned char display[128] = "";
1244 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_IND, DIRECTION_IN);
1245 dec_ie_notify(l3m, ¬ify);
1246 dec_ie_redir_dn(l3m, &type, &plan, &present, notifyid, sizeof(notifyid));
1247 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1250 if (!ACTIVE_EPOINT(p_epointlist))
1252 /* notification indicator */
1256 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1257 message->param.notifyinfo.notify = notify;
1258 SCPY(message->param.notifyinfo.id, (char *)notifyid);
1259 /* redirection number */
1263 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
1266 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
1269 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
1275 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1276 message->param.notifyinfo.present = INFO_PRESENT_NULL;
1279 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1282 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
1285 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1288 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1291 SCAT(message->param.notifyinfo.display, (char *)display);
1292 message->param.notifyinfo.isdn_port = p_m_portnum;
1293 message_put(message);
1297 /* CC_HOLD INDICATION */
1298 struct lcr_msg *message;
1299 void Pdss1::hold_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1301 // class Endpoint *epoint;
1303 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_IND, DIRECTION_IN);
1306 if (!ACTIVE_EPOINT(p_epointlist) || p_m_hold)
1308 l3m = create_l3msg();
1309 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_REJECT_REQ, DIRECTION_OUT);
1310 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */
1311 add_trace("reason", NULL, "no endpoint");
1313 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_REJECT, p_m_d_l3id, l3m);
1318 /* notify the hold of call */
1319 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1320 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_HOLD;
1321 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1322 message_put(message);
1324 /* deactivate bchannel */
1325 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (hold)", DIRECTION_NONE);
1326 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1330 /* set hold state */
1333 epoint = find_epoint_id(ACTIVE_EPOINT(p_epointlist));
1334 if (epoint && p_m_d_ntmode)
1336 p_m_timeout = p_settings.tout_hold;
1341 /* acknowledge hold */
1342 l3m = create_l3msg();
1343 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1345 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_ACKNOWLEDGE, p_m_d_l3id, l3m);
1349 /* CC_RETRIEVE INDICATION */
1350 void Pdss1::retrieve_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1352 struct lcr_msg *message;
1353 int channel, exclusive, cause;
1356 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_IND, DIRECTION_IN);
1357 dec_ie_channel_id(l3m, &exclusive, &channel);
1362 cause = 101; /* incompatible state */
1365 l3m = create_l3msg();
1366 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_REJECT_REQ, DIRECTION_OUT);
1367 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, cause);
1369 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_REJECT, p_m_d_l3id, l3m);
1374 /* notify the retrieve of call */
1375 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1376 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL;
1377 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1378 message_put(message);
1381 ret = channel = hunt_bchannel(channel, exclusive);
1386 ret = seize_bchannel(channel, 1);
1393 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1395 /* set hold state */
1399 /* acknowledge retrieve */
1400 l3m = create_l3msg();
1401 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1402 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1404 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_ACKNOWLEDGE, p_m_d_l3id, l3m);
1407 /* CC_SUSPEND INDICATION */
1408 void Pdss1::suspend_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1410 struct lcr_msg *message;
1411 class Endpoint *epoint;
1412 unsigned char callid[8];
1414 int ret = -31; /* normal, unspecified */
1416 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_IND, DIRECTION_IN);
1417 dec_ie_call_id(l3m, callid, &len);
1420 if (!ACTIVE_EPOINT(p_epointlist))
1423 l3m = create_l3msg();
1424 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_REJECT_REQ, DIRECTION_OUT);
1425 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1427 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_REJECT, p_m_d_l3id, l3m);
1434 /* check if call id is in use */
1435 epoint = epoint_first;
1438 if (epoint->ep_park)
1440 if (epoint->ep_park_len == len)
1441 if (!memcmp(epoint->ep_park_callid, callid, len))
1443 ret = -84; /* call id in use */
1447 epoint = epoint->next;
1450 /* notify the hold of call */
1451 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1452 message->param.notifyinfo.notify = INFO_NOTIFY_USER_SUSPENDED;
1453 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1454 message_put(message);
1456 /* deactivate bchannel */
1457 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (suspend)", DIRECTION_NONE);
1458 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1462 /* sending suspend to endpoint */
1463 while (p_epointlist)
1465 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_SUSPEND);
1466 memcpy(message->param.parkinfo.callid, callid, sizeof(message->param.parkinfo.callid));
1467 message->param.parkinfo.len = len;
1468 message_put(message);
1470 free_epointlist(p_epointlist);
1473 /* sending SUSPEND_ACKNOWLEDGE */
1474 l3m = create_l3msg();
1475 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1477 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_ACKNOWLEDGE, p_m_d_l3id, l3m);
1479 new_state(PORT_STATE_RELEASE);
1483 /* CC_RESUME INDICATION */
1484 void Pdss1::resume_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1486 unsigned char callid[8];
1488 int channel, exclusive;
1489 class Endpoint *epoint;
1490 struct lcr_msg *message;
1493 /* process given callref */
1494 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
1495 add_trace("callref", "new", "0x%x", pid);
1498 /* release is case the ID is already in use */
1499 add_trace("error", NULL, "callref already in use");
1501 l3m = create_l3msg();
1502 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1503 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
1504 add_trace("reason", NULL, "callref already in use");
1506 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, pid, l3m);
1507 new_state(PORT_STATE_RELEASE);
1512 p_m_d_ces = pid >> 16;
1515 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_IND, DIRECTION_IN);
1516 dec_ie_call_id(l3m, callid, &len);
1519 /* if blocked, release call */
1520 if (p_m_mISDNport->ifport->block)
1529 /* channel_id (no channel is possible in message) */
1531 channel = -1; /* any channel */
1534 ret = channel = hunt_bchannel(channel, exclusive);
1539 ret = seize_bchannel(channel, 1);
1544 l3m = create_l3msg();
1545 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1546 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1548 add_trace("reason", NULL, "port blocked");
1550 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, p_m_d_l3id, l3m);
1551 new_state(PORT_STATE_RELEASE);
1555 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1557 /* create endpoint */
1559 FATAL("Incoming resume but already got an endpoint.\n");
1560 ret = -85; /* no call suspended */
1561 epoint = epoint_first;
1564 if (epoint->ep_park)
1566 ret = -83; /* suspended call exists, but this not */
1567 if (epoint->ep_park_len == len)
1568 if (!memcmp(epoint->ep_park_callid, callid, len))
1571 epoint = epoint->next;
1576 epointlist_new(epoint->ep_serial);
1577 if (!(epoint->portlist_new(p_serial, p_type, p_m_mISDNport->earlyb)))
1578 FATAL("No memory for portlist\n");
1579 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RESUME);
1580 message_put(message);
1582 /* notify the resume of call */
1583 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1584 message->param.notifyinfo.notify = INFO_NOTIFY_USER_RESUMED;
1585 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1586 message_put(message);
1588 /* sending RESUME_ACKNOWLEDGE */
1589 l3m = create_l3msg();
1590 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1591 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1593 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_ACKNOWLEDGE, p_m_d_l3id, l3m);
1595 new_state(PORT_STATE_CONNECT);
1599 /* CC_FACILITY INDICATION */
1600 void Pdss1::facility_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1602 unsigned char facil[256];
1604 struct lcr_msg *message;
1606 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_IND, DIRECTION_IN);
1607 dec_ie_facility(l3m, facil, &facil_len);
1614 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_FACILITY);
1615 message->param.facilityinfo.len = facil_len;
1616 memcpy(message->param.facilityinfo.data, facil, facil_len);
1617 message_put(message);
1622 * handler for isdn connections
1623 * incoming information are parsed and sent via message to the endpoint
1625 void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1634 PERROR("Pdss1(%s) timeout without cause.\n", p_name);
1637 if (l3m->cause[0] != 5)
1639 PERROR("Pdss1(%s) expecting timeout with timer diagnostic. (got len=%d)\n", p_name, l3m->cause[0]);
1642 timer = (l3m->cause[3]-'0')*100;
1643 timer += (l3m->cause[4]-'0')*10;
1644 timer += (l3m->cause[5]-'0');
1645 l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN);
1646 add_trace("timer", NULL, "%d", timer);
1649 t312_timeout_ind(cmd, pid, l3m);
1653 if (p_state != PORT_STATE_IDLE)
1655 setup_ind(cmd, pid, l3m);
1658 case MT_INFORMATION:
1659 information_ind(cmd, pid, l3m);
1662 case MT_SETUP_ACKNOWLEDGE:
1663 if (p_state != PORT_STATE_OUT_SETUP)
1665 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received setup_acknowledge, but we are not in outgoing setup state, IGNORING.\n", p_name);
1668 setup_acknowledge_ind(cmd, pid, l3m);
1671 case MT_CALL_PROCEEDING:
1672 if (p_state != PORT_STATE_OUT_SETUP
1673 && p_state != PORT_STATE_OUT_OVERLAP)
1675 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received proceeding, but we are not in outgoing setup OR overlap state, IGNORING.\n", p_name);
1678 proceeding_ind(cmd, pid, l3m);
1682 if (p_state != PORT_STATE_OUT_SETUP
1683 && p_state != PORT_STATE_OUT_OVERLAP
1684 && p_state != PORT_STATE_OUT_PROCEEDING)
1686 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding state, IGNORING.\n", p_name);
1689 alerting_ind(cmd, pid, l3m);
1693 if (p_state != PORT_STATE_OUT_SETUP
1694 && p_state != PORT_STATE_OUT_OVERLAP
1695 && p_state != PORT_STATE_OUT_PROCEEDING
1696 && p_state != PORT_STATE_OUT_ALERTING)
1698 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);
1701 connect_ind(cmd, pid, l3m);
1702 if (p_m_d_notify_pending)
1704 /* send pending notify message during connect */
1705 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1706 message_free(p_m_d_notify_pending);
1707 p_m_d_notify_pending = NULL;
1711 case MT_CONNECT_ACKNOWLEDGE:
1712 if (p_state == PORT_STATE_CONNECT_WAITING)
1713 new_state(PORT_STATE_CONNECT);
1714 if (p_m_d_notify_pending)
1716 /* send pending notify message during connect-ack */
1717 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1718 message_free(p_m_d_notify_pending);
1719 p_m_d_notify_pending = NULL;
1724 disconnect_ind(cmd, pid, l3m);
1728 release_ind(cmd, pid, l3m);
1731 case MT_RELEASE_COMPLETE:
1732 release_complete_ind(cmd, pid, l3m);
1736 restart_ind(cmd, pid, l3m);
1740 notify_ind(cmd, pid, l3m);
1744 hold_ind(cmd, pid, l3m);
1748 retrieve_ind(cmd, pid, l3m);
1752 suspend_ind(cmd, pid, l3m);
1756 resume_ind(cmd, pid, l3m);
1760 facility_ind(cmd, pid, l3m);
1764 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_L3ID_IND, DIRECTION_IN);
1765 add_trace("callref", NULL, "0x%x", p_m_d_l3id);
1770 /* sending release to endpoint in case we still have an endpoint
1771 * this is because we don't get any response if a release_complete is received (or a release in release state)
1773 while(p_epointlist) // only if not already released
1775 struct lcr_msg *message;
1776 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1777 if (p_m_d_collect_cause)
1779 message->param.disconnectinfo.cause = p_m_d_collect_cause;
1780 message->param.disconnectinfo.location = p_m_d_collect_location;
1783 message->param.disconnectinfo.cause = CAUSE_NOUSER;
1784 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1786 message_put(message);
1788 free_epointlist(p_epointlist);
1790 new_state(PORT_STATE_RELEASE);
1795 l1l2l3_trace_header(p_m_mISDNport, this, L3_UNKNOWN, DIRECTION_IN);
1796 add_trace("unhandled", "cmd", "0x%x", cmd);
1801 void Pdss1::new_state(int state)
1803 // class Endpoint *epoint;
1806 if (state == PORT_STATE_IN_OVERLAP)
1808 p_m_timeout = p_m_mISDNport->ifport->tout_dialing;
1811 if (state != p_state)
1813 if (state == PORT_STATE_IN_SETUP
1814 || state == PORT_STATE_OUT_SETUP
1815 || state == PORT_STATE_IN_OVERLAP
1816 || state == PORT_STATE_OUT_OVERLAP)
1818 p_m_timeout = p_m_mISDNport->ifport->tout_setup;
1821 if (state == PORT_STATE_IN_PROCEEDING
1822 || state == PORT_STATE_OUT_PROCEEDING)
1824 p_m_timeout = p_m_mISDNport->ifport->tout_proceeding;
1827 if (state == PORT_STATE_IN_ALERTING
1828 || state == PORT_STATE_OUT_ALERTING)
1830 p_m_timeout = p_m_mISDNport->ifport->tout_alerting;
1833 if (state == PORT_STATE_CONNECT
1834 || state == PORT_STATE_CONNECT_WAITING)
1838 if (state == PORT_STATE_IN_DISCONNECT
1839 || state == PORT_STATE_OUT_DISCONNECT)
1841 p_m_timeout = p_m_mISDNport->ifport->tout_disconnect;
1846 Port::new_state(state);
1853 int Pdss1::handler(void)
1857 if ((ret = PmISDN::handler()))
1860 /* handle destruction */
1861 if (p_m_delete && p_m_d_l3id==0)
1872 * handles all messages from endpoint
1874 /* MESSAGE_INFORMATION */
1875 void Pdss1::message_information(unsigned int epoint_id, int message_id, union parameter *param)
1879 if (param->information.id[0]) /* only if we have something to dial */
1881 l3m = create_l3msg();
1882 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1883 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)param->information.id);
1885 enc_ie_display(l3m, (unsigned char *)param->information.display);
1887 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1896 void Pdss1::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
1900 int plan, type, screen, present, reason;
1901 int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
1902 int channel, exclusive;
1903 struct epoint_list *epointlist;
1905 /* release if port is blocked */
1906 if (p_m_mISDNport->ifport->block)
1908 struct lcr_msg *message;
1910 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1911 message->param.disconnectinfo.cause = 27; // temp. unavail.
1912 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1913 message_put(message);
1914 new_state(PORT_STATE_RELEASE);
1919 /* copy setup infos to port */
1920 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
1921 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
1922 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
1923 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
1924 // SCPY(&p_m_tones_dir, param->setup.ext.tones_dir);
1925 /* screen outgoing caller id */
1926 do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_m_mISDNport->ifport->interface);
1928 /* only display at connect state: this case happens if endpoint is in connected mode */
1929 if (p_state==PORT_STATE_CONNECT)
1931 if (p_type!=PORT_TYPE_DSS1_NT_OUT
1932 && p_type!=PORT_TYPE_DSS1_NT_IN)
1934 if (p_callerinfo.display[0])
1936 /* sending information */
1937 l3m = create_l3msg();
1938 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1940 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
1942 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1947 /* attach only if not already */
1948 epointlist = p_epointlist;
1951 if (epointlist->epoint_id == epoint_id)
1953 epointlist = epointlist->next;
1956 epointlist_new(epoint_id);
1962 channel = p_m_b_channel;
1963 exclusive = p_m_b_exclusive;
1965 channel = CHANNEL_ANY;
1966 /* nt-port with no channel, not reserverd */
1967 if (!p_m_b_channel && !p_m_b_reserve && p_type==PORT_TYPE_DSS1_NT_OUT)
1968 channel = CHANNEL_NO;
1971 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT);
1972 /* see MT_ASSIGN notes at do_layer3() */
1974 ret = p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ASSIGN, 0, NULL);
1975 if (mt_assign_pid == 0 || ret < 0)
1977 struct lcr_msg *message;
1979 add_trace("callref", NULL, "no free id");
1981 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1982 message->param.disconnectinfo.cause = 47;
1983 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1984 message_put(message);
1985 new_state(PORT_STATE_RELEASE);
1989 p_m_d_l3id = mt_assign_pid;
1991 add_trace("callref", "new", "0x%x", p_m_d_l3id);
1994 /* preparing setup message */
1995 l3m = create_l3msg();
1996 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_REQ, DIRECTION_OUT);
1997 /* channel information */
1998 if (channel >= 0) /* it should */
2000 enc_ie_channel_id(l3m, exclusive, channel);
2002 /* caller information */
2004 switch (p_callerinfo.ntype)
2006 case INFO_NTYPE_INTERNATIONAL:
2009 case INFO_NTYPE_NATIONAL:
2012 case INFO_NTYPE_SUBSCRIBER:
2015 default: /* INFO_NTYPE_UNKNOWN */
2019 switch (p_callerinfo.screen)
2021 case INFO_SCREEN_USER:
2024 default: /* INFO_SCREEN_NETWORK */
2028 switch (p_callerinfo.present)
2030 case INFO_PRESENT_RESTRICTED:
2033 case INFO_PRESENT_NOTAVAIL:
2036 default: /* INFO_PRESENT_ALLOWED */
2041 enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id);
2042 /* dialing information */
2043 if (p_dialinginfo.id[0]) /* only if we have something to dial */
2045 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id);
2047 /* sending complete */
2048 if (p_dialinginfo.sending_complete)
2049 enc_ie_complete(l3m, 1);
2050 /* sending user-user */
2051 if (param->setup.useruser.len)
2053 enc_ie_useruser(l3m, param->setup.useruser.protocol, param->setup.useruser.data, param->setup.useruser.len);
2055 /* redirecting number */
2057 switch (p_redirinfo.ntype)
2059 case INFO_NTYPE_INTERNATIONAL:
2062 case INFO_NTYPE_NATIONAL:
2065 case INFO_NTYPE_SUBSCRIBER:
2068 default: /* INFO_NTYPE_UNKNOWN */
2072 switch (p_redirinfo.screen)
2074 case INFO_SCREEN_USER:
2077 default: /* INFO_SCREE_NETWORK */
2081 switch (p_redirinfo.reason)
2083 case INFO_REDIR_BUSY:
2086 case INFO_REDIR_NORESPONSE:
2089 case INFO_REDIR_UNCONDITIONAL:
2092 case INFO_REDIR_CALLDEFLECT:
2095 case INFO_REDIR_OUTOFORDER:
2098 default: /* INFO_REDIR_UNKNOWN */
2102 switch (p_redirinfo.present)
2104 case INFO_PRESENT_NULL: /* no redir at all */
2111 case INFO_PRESENT_RESTRICTED:
2114 case INFO_PRESENT_NOTAVAIL:
2117 default: /* INFO_PRESENT_ALLOWED */
2121 /* sending redirecting number only in ntmode */
2122 if (type >= 0 && p_m_d_ntmode)
2123 enc_ie_redir_nr(l3m, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
2124 /* bearer capability */
2125 //printf("hlc=%d\n",p_capainfo.hlc);
2127 capability = p_capainfo.bearer_capa;
2128 mode = p_capainfo.bearer_mode;
2129 rate = (mode==INFO_BMODE_CIRCUIT)?0x10:0x00;
2130 switch (p_capainfo.bearer_info1)
2132 case INFO_INFO1_NONE:
2136 user = p_capainfo.bearer_info1 & 0x7f;
2139 enc_ie_bearer(l3m, coding, capability, mode, rate, -1, user);
2146 hlc = p_capainfo.hlc & 0x7f;
2148 if (p_capainfo.exthlc)
2149 exthlc = p_capainfo.exthlc & 0x7f;
2150 enc_ie_hlc(l3m, coding, interpretation, presentation, hlc, exthlc);
2154 if (p_callerinfo.display[0] && p_m_d_ntmode)
2155 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
2156 /* nt-mode: CNIP (calling name identification presentation) */
2157 // if (p_callerinfo.name[0] && p_m_d_ntmode)
2158 // enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
2161 /* send setup message now */
2162 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP, p_m_d_l3id, l3m);
2164 new_state(PORT_STATE_OUT_SETUP);
2167 /* MESSAGE_FACILITY */
2168 void Pdss1::message_facility(unsigned int epoint_id, int message_id, union parameter *param)
2172 /* facility will not be sent to external lines */
2176 /* sending facility */
2177 l3m = create_l3msg();
2178 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
2179 enc_ie_facility(l3m, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len);
2181 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
2184 /* MESSAGE_NOTIFY */
2185 void Pdss1::message_notify(unsigned int epoint_id, int message_id, union parameter *param)
2189 int plan, type = -1, present;
2191 if (param->notifyinfo.notify>INFO_NOTIFY_NONE)
2192 notify = param->notifyinfo.notify & 0x7f;
2195 if (p_state != PORT_STATE_CONNECT)
2197 /* notify only allowed in active state */
2203 switch (param->notifyinfo.ntype)
2205 case INFO_NTYPE_INTERNATIONAL:
2208 case INFO_NTYPE_NATIONAL:
2211 case INFO_NTYPE_SUBSCRIBER:
2214 default: /* INFO_NTYPE_UNKNOWN */
2218 switch (param->notifyinfo.present)
2220 case INFO_PRESENT_NULL: /* no redir at all */
2225 case INFO_PRESENT_RESTRICTED:
2228 case INFO_PRESENT_NOTAVAIL:
2231 default: /* INFO_PRESENT_ALLOWED */
2237 if (notify<0 && !param->notifyinfo.display[0])
2239 /* nothing to notify, nothing to display */
2245 if (p_state!=PORT_STATE_CONNECT)
2247 /* queue notification */
2248 if (p_m_d_notify_pending)
2249 message_free(p_m_d_notify_pending);
2250 p_m_d_notify_pending = message_create(ACTIVE_EPOINT(p_epointlist), p_serial, EPOINT_TO_PORT, message_id);
2251 memcpy(&p_m_d_notify_pending->param, param, sizeof(union parameter));
2254 /* sending notification */
2255 l3m = create_l3msg();
2256 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
2257 enc_ie_notify(l3m, notify);
2258 /* sending redirection number only in ntmode */
2259 if (type >= 0 && p_m_d_ntmode)
2260 enc_ie_redir_dn(l3m, type, plan, present, (unsigned char *)param->notifyinfo.id);
2261 if (param->notifyinfo.display[0] && p_m_d_ntmode)
2262 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2264 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_NOTIFY, p_m_d_l3id, l3m);
2266 } else if (p_m_d_ntmode)
2268 /* sending information */
2269 l3m = create_l3msg();
2270 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2271 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2273 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2277 /* MESSAGE_OVERLAP */
2278 void Pdss1::message_overlap(unsigned int epoint_id, int message_id, union parameter *param)
2282 /* in case of sending complete, we proceed */
2283 if (p_dialinginfo.sending_complete)
2285 PDEBUG(DEBUG_ISDN, "sending proceeding instead of setup_acknowledge, because address is complete.\n");
2286 message_proceeding(epoint_id, message_id, param);
2290 /* sending setup_acknowledge */
2291 l3m = create_l3msg();
2292 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_REQ, DIRECTION_OUT);
2293 /* channel information */
2294 if (p_state == PORT_STATE_IN_SETUP)
2295 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2296 /* progress information */
2297 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2298 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2299 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2300 if (p_m_mISDNport->tones)
2301 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2303 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, l3m);
2305 new_state(PORT_STATE_IN_OVERLAP);
2308 /* MESSAGE_PROCEEDING */
2309 void Pdss1::message_proceeding(unsigned int epoint_id, int message_id, union parameter *param)
2313 /* sending proceeding */
2314 l3m = create_l3msg();
2315 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2316 /* channel information */
2317 if (p_state == PORT_STATE_IN_SETUP)
2318 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2319 /* progress information */
2320 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2321 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2322 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2323 if (p_m_mISDNport->tones)
2324 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2326 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2328 new_state(PORT_STATE_IN_PROCEEDING);
2331 /* MESSAGE_ALERTING */
2332 void Pdss1::message_alerting(unsigned int epoint_id, int message_id, union parameter *param)
2336 /* NT-MODE in setup state we must send PROCEEDING first */
2337 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2339 /* sending proceeding */
2340 l3m = create_l3msg();
2341 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2342 /* channel information */
2343 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2344 /* progress information */
2345 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2346 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2347 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2348 if (p_m_mISDNport->tones)
2349 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2351 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2352 new_state(PORT_STATE_IN_PROCEEDING);
2355 /* sending alerting */
2356 l3m = create_l3msg();
2357 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_REQ, DIRECTION_OUT);
2358 /* channel information */
2359 if (p_state == PORT_STATE_IN_SETUP)
2360 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2361 /* progress information */
2362 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2363 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2364 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2365 if (p_m_mISDNport->tones)
2366 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2368 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ALERTING, p_m_d_l3id, l3m);
2370 new_state(PORT_STATE_IN_ALERTING);
2373 /* MESSAGE_CONNECT */
2374 void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parameter *param)
2377 int type, plan, present, screen;
2378 class Endpoint *epoint;
2380 /* NT-MODE in setup state we must send PROCEEDING first */
2381 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2383 /* sending proceeding */
2384 l3m = create_l3msg();
2385 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2386 /* channel information */
2387 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2389 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2390 new_state(PORT_STATE_IN_PROCEEDING);
2393 /* copy connected information */
2394 memcpy(&p_connectinfo, ¶m->connectinfo, sizeof(p_connectinfo));
2395 /* screen outgoing caller id */
2396 do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface);
2398 /* only display at connect state */
2399 if (p_state == PORT_STATE_CONNECT)
2400 if (p_connectinfo.display[0])
2402 /* sending information */
2403 l3m = create_l3msg();
2404 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2406 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2408 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2412 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)
2414 /* connect command only possible in setup, proceeding or alerting state */
2418 /* preparing connect message */
2419 l3m = create_l3msg();
2420 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_REQ, DIRECTION_OUT);
2421 /* connect information */
2423 switch (p_connectinfo.ntype)
2425 case INFO_NTYPE_INTERNATIONAL:
2428 case INFO_NTYPE_NATIONAL:
2431 case INFO_NTYPE_SUBSCRIBER:
2434 default: /* INFO_NTYPE_UNKNOWN */
2438 switch (param->connectinfo.screen)
2440 case INFO_SCREEN_USER:
2443 default: /* INFO_SCREE_NETWORK */
2447 switch (p_connectinfo.present)
2449 case INFO_PRESENT_NULL: /* no colp at all */
2455 case INFO_PRESENT_RESTRICTED:
2458 case INFO_PRESENT_NOTAVAIL:
2461 default: /* INFO_PRESENT_ALLOWED */
2466 enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
2468 if (p_connectinfo.display[0] && p_m_d_ntmode)
2469 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2470 /* nt-mode: CONP (connected name identification presentation) */
2471 // if (p_connectinfo.name[0] && p_m_d_ntmode)
2472 // enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
2476 epoint = find_epoint_id(epoint_id);
2477 enc_ie_date(l3m, now, p_settings.no_seconds);
2480 /* finally send message */
2481 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT, p_m_d_l3id, l3m);
2484 new_state(PORT_STATE_CONNECT);
2486 new_state(PORT_STATE_CONNECT_WAITING);
2490 /* MESSAGE_DISCONNECT */
2491 void Pdss1::message_disconnect(unsigned int epoint_id, int message_id, union parameter *param)
2494 struct lcr_msg *message;
2497 /* we reject during incoming setup when we have no tones. also if we are in outgoing setup state */
2498 // if ((p_state==PORT_STATE_IN_SETUP && !p_m_mISDNport->tones)
2499 if (/* ||*/ p_state==PORT_STATE_OUT_SETUP)
2501 /* sending release to endpoint */
2504 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
2505 memcpy(&message->param, param, sizeof(union parameter));
2506 message_put(message);
2508 free_epointlist(p_epointlist);
2510 /* sending release */
2511 l3m = create_l3msg();
2512 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
2514 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2516 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2517 new_state(PORT_STATE_RELEASE);
2522 /* workarround: NT-MODE in setup state we must send PROCEEDING first to make it work */
2523 if (p_state==PORT_STATE_IN_SETUP)
2525 /* sending proceeding */
2526 l3m = create_l3msg();
2527 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2528 /* channel information */
2529 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2530 /* progress information */
2531 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2532 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2533 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2534 if (p_m_mISDNport->tones)
2535 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2537 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2538 new_state(PORT_STATE_IN_PROCEEDING);
2541 /* sending disconnect */
2542 l3m = create_l3msg();
2543 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2544 /* progress information */
2545 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2546 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2547 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2548 if (p_m_mISDNport->tones)
2549 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2551 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2553 if (param->disconnectinfo.display[0])
2554 p = param->disconnectinfo.display;
2555 if (p) if (*p && p_m_d_ntmode)
2556 enc_ie_display(l3m, (unsigned char *)p);
2558 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2559 new_state(PORT_STATE_OUT_DISCONNECT);
2562 /* MESSAGE_RELEASE */
2563 void Pdss1::message_release(unsigned int epoint_id, int message_id, union parameter *param)
2566 class Endpoint *epoint;
2570 * we may only release during incoming disconnect state.
2571 * this means that the endpoint doesnt require audio anymore
2573 if (p_state == PORT_STATE_IN_DISCONNECT
2574 || p_state == PORT_STATE_OUT_DISCONNECT)
2576 /* sending release */
2577 l3m = create_l3msg();
2578 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2580 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2582 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
2583 new_state(PORT_STATE_RELEASE);
2585 free_epointid(epoint_id);
2586 // wait for callref to be released
2591 * if we are on incoming call setup, we may reject by sending a release_complete
2592 * also on outgoing call setup, we send a release complete, BUT this is not conform. (i don't know any other way)
2594 if (p_state==PORT_STATE_IN_SETUP
2595 || p_state==PORT_STATE_OUT_SETUP)
2597 //#warning remove me
2598 //PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
2599 /* sending release complete */
2600 l3m = create_l3msg();
2601 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2603 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2605 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2606 new_state(PORT_STATE_RELEASE);
2608 free_epointid(epoint_id);
2609 // wait for callref to be released
2614 wirklich erst proceeding?:
2615 /* NT-MODE in setup state we must send PROCEEDING first */
2616 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2618 CALL_PROCEEDING_t *proceeding;
2620 /* sending proceeding */
2621 l3m = create_l3msg();
2622 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2623 /* channel information */
2624 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2625 /* progress information */
2626 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2627 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2628 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2629 if (p_m_mISDNport->tones)
2630 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2632 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2636 /* sending disconnect */
2637 l3m = create_l3msg();
2638 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2639 /* progress information */
2640 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2641 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2642 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2643 if (p_m_mISDNport->tones)
2644 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2646 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2648 epoint = find_epoint_id(epoint_id);
2649 if (param->disconnectinfo.display[0])
2650 p = param->disconnectinfo.display;
2651 if (p) if (*p && p_m_d_ntmode)
2652 enc_ie_display(l3m, (unsigned char *)p);
2654 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2655 new_state(PORT_STATE_OUT_DISCONNECT);
2657 free_epointid(epoint_id);
2658 // wait for release and callref to be released
2659 //#warning remove me
2660 //PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
2665 * endpoint sends messages to the port
2667 int Pdss1::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
2669 struct lcr_msg *message;
2671 if (PmISDN::message_epoint(epoint_id, message_id, param))
2676 case MESSAGE_INFORMATION: /* overlap dialing */
2677 if (p_type==PORT_TYPE_DSS1_NT_OUT
2678 && p_state!=PORT_STATE_OUT_OVERLAP
2679 && p_state!=PORT_STATE_CONNECT
2680 && p_state!=PORT_STATE_OUT_DISCONNECT
2681 && p_state!=PORT_STATE_IN_DISCONNECT)
2685 if (p_type==PORT_TYPE_DSS1_TE_OUT
2686 && p_state!=PORT_STATE_OUT_OVERLAP
2687 && p_state!=PORT_STATE_OUT_PROCEEDING
2688 && p_state!=PORT_STATE_OUT_ALERTING
2689 && p_state!=PORT_STATE_CONNECT
2690 && p_state!=PORT_STATE_OUT_DISCONNECT
2691 && p_state!=PORT_STATE_IN_DISCONNECT)
2695 if ((p_type==PORT_TYPE_DSS1_NT_IN || p_type==PORT_TYPE_DSS1_TE_IN)
2696 && p_state!=PORT_STATE_IN_OVERLAP
2697 && p_state!=PORT_STATE_IN_PROCEEDING
2698 && p_state!=PORT_STATE_IN_ALERTING
2699 && p_state!=PORT_STATE_CONNECT
2700 && p_state!=PORT_STATE_CONNECT_WAITING
2701 && p_state!=PORT_STATE_OUT_DISCONNECT
2702 && p_state!=PORT_STATE_IN_DISCONNECT)
2706 message_information(epoint_id, message_id, param);
2709 case MESSAGE_SETUP: /* dial-out command received from epoint */
2710 if (p_state!=PORT_STATE_IDLE
2711 && p_state!=PORT_STATE_CONNECT)
2713 PERROR("Pdss1(%s) ignoring setup because isdn port is not in idle state (or connected for sending display info).\n", p_name);
2716 if (p_epointlist && p_state==PORT_STATE_IDLE)
2717 FATAL("Pdss1(%s): epoint pointer is set in idle state, how bad!!\n", p_name);
2718 message_setup(epoint_id, message_id, param);
2721 case MESSAGE_NOTIFY: /* display and notifications */
2722 message_notify(epoint_id, message_id, param);
2725 case MESSAGE_FACILITY: /* facility message */
2726 message_facility(epoint_id, message_id, param);
2729 case MESSAGE_OVERLAP: /* more information is needed */
2730 if (p_state!=PORT_STATE_IN_SETUP)
2734 message_overlap(epoint_id, message_id, param);
2737 case MESSAGE_PROCEEDING: /* call of endpoint is proceeding */
2738 if (p_state!=PORT_STATE_IN_SETUP
2739 && p_state!=PORT_STATE_IN_OVERLAP)
2743 message_proceeding(epoint_id, message_id, param);
2746 case MESSAGE_ALERTING: /* call of endpoint is ringing */
2747 if (p_state!=PORT_STATE_IN_SETUP
2748 && p_state!=PORT_STATE_IN_OVERLAP
2749 && p_state!=PORT_STATE_IN_PROCEEDING)
2753 message_alerting(epoint_id, message_id, param);
2756 case MESSAGE_CONNECT: /* call of endpoint is connected */
2757 if (p_state!=PORT_STATE_IN_SETUP
2758 && p_state!=PORT_STATE_IN_OVERLAP
2759 && p_state!=PORT_STATE_IN_PROCEEDING
2760 && p_state!=PORT_STATE_IN_ALERTING
2761 && !(p_state==PORT_STATE_CONNECT && p_m_d_ntmode))
2765 message_connect(epoint_id, message_id, param);
2768 case MESSAGE_DISCONNECT: /* call has been disconnected */
2769 if (p_state!=PORT_STATE_IN_SETUP
2770 && p_state!=PORT_STATE_IN_OVERLAP
2771 && p_state!=PORT_STATE_IN_PROCEEDING
2772 && p_state!=PORT_STATE_IN_ALERTING
2773 && p_state!=PORT_STATE_OUT_SETUP
2774 && p_state!=PORT_STATE_OUT_OVERLAP
2775 && p_state!=PORT_STATE_OUT_PROCEEDING
2776 && p_state!=PORT_STATE_OUT_ALERTING
2777 && p_state!=PORT_STATE_CONNECT
2778 && p_state!=PORT_STATE_CONNECT_WAITING)
2782 message_disconnect(epoint_id, message_id, param);
2785 case MESSAGE_RELEASE: /* release isdn port */
2786 if (p_state==PORT_STATE_RELEASE)
2790 message_release(epoint_id, message_id, param);
2794 PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message);
2803 * data from isdn-stack (layer-3) to pbx (port class)
2805 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
2811 PDEBUG(DEBUG_ISDN, "cmd(0x%x) pid(0x%x)\n", cmd, pid);
2815 PDEBUG(DEBUG_ISDN, "ignoring dummy process from phone.\n");
2819 /* find Port object of type ISDN */
2824 if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
2826 pdss1 = (class Pdss1 *)port;
2827 /* check out correct stack and id */
2828 if (pdss1->p_m_mISDNport == mISDNport)
2830 if (pdss1->p_m_d_l3id & MISDN_PID_CR_FLAG)
2832 /* local callref, so match value only */
2833 if ((pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == (pid & MISDN_PID_CRVAL_MASK))
2837 /* remote callref, ref + channel id */
2838 if (pdss1->p_m_d_l3id == pid)
2846 /* aktueller prozess */
2849 if (cmd == MT_ASSIGN)
2851 /* stack gives us new layer 3 id (during connect) */
2852 l1l2l3_trace_header(mISDNport, pdss1, L3_NEW_L3ID_IND, DIRECTION_IN);
2853 add_trace("callref", "old", "0x%x", pdss1->p_m_d_l3id);
2854 /* nt-library now gives us a new id via CC_SETUP_CONFIRM */
2855 if ((pdss1->p_m_d_l3id&MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER)
2856 PERROR(" strange setup-procid 0x%x\n", pdss1->p_m_d_l3id);
2857 pdss1->p_m_d_l3id = pid;
2858 if (port->p_state == PORT_STATE_CONNECT)
2859 pdss1->p_m_d_ces = pid >> 16;
2860 add_trace("callref", "new", "0x%x", pdss1->p_m_d_l3id);
2864 /* if process id is master process, but a child disconnects */
2865 if (mISDNport->ntmode
2866 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2867 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) == MISDN_PID_MASTER)
2869 if (cmd == MT_DISCONNECT
2870 || cmd == MT_RELEASE)
2872 /* send special indication for child disconnect */
2873 pdss1->disconnect_ind_i(cmd, pid, l3m);
2876 if (cmd == MT_RELEASE_COMPLETE)
2879 /* if we have child pid and got different child pid message, ignore */
2880 if (mISDNport->ntmode
2881 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2882 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2883 && pid != pdss1->p_m_d_l3id)
2886 /* process message */
2887 pdss1->message_isdn(cmd, pid, l3m);
2895 /* creating port object */
2896 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2897 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0)))
2899 FATAL("Cannot create Port instance.\n");
2900 pdss1->message_isdn(cmd, pid, l3m);
2904 /* creating port object */
2905 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2906 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0)))
2907 FATAL("Cannot create Port instance.\n");
2908 pdss1->message_isdn(cmd, pid, l3m);
2912 PDEBUG(DEBUG_ISDN, "unused call ref released (l3id=0x%x)\n", pid);
2915 case MT_RELEASE_COMPLETE:
2916 PERROR("must be ignored by stack, not sent to app\n");
2920 // facility als broadcast
2924 PERROR("unhandled message: cmd(0x%x) pid(0x%x)\n", cmd, pid);
2928 if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT)
2930 pdss1 = (class Pdss1 *)port;
2931 /* check out correct stack */
2932 if (pdss1->p_m_mISDNport == mISDNport)
2933 /* check out correct id */
2934 PERROR("unhandled message: pid=%x is not associated with port-dinfo=%x\n", pid, pdss1->p_m_d_l3id);
2946 * sending message that were queued during L1 activation
2947 * or releasing port if link is down
2949 void setup_queue(struct mISDNport *mISDNport, int link)
2953 struct lcr_msg *message;
2955 if (!mISDNport->ntmode)
2958 /* check all port objects for pending message */
2962 if ((port->p_type&PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
2964 pdss1 = (class Pdss1 *)port;
2965 if (pdss1->p_m_mISDNport == mISDNport)
2967 if (pdss1->p_m_d_queue)
2971 PDEBUG(DEBUG_ISDN, "the L1 became active, so we send queued message for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
2972 /* LAYER 1 is up, so we send */
2973 pdss1->message_setup(pdss1->p_m_d_queue->id_from, pdss1->p_m_d_queue->type, &pdss1->p_m_d_queue->param);
2974 message_free(pdss1->p_m_d_queue);
2975 pdss1->p_m_d_queue = NULL;
2978 PDEBUG(DEBUG_ISDN, "the L1 became NOT active, so we release port for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
2979 message = message_create(pdss1->p_serial, pdss1->p_m_d_queue->id_from, PORT_TO_EPOINT, MESSAGE_RELEASE);
2980 message->param.disconnectinfo.cause = 27;
2981 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
2982 message_put(message);
2983 pdss1->new_state(PORT_STATE_RELEASE);
2984 pdss1->p_m_delete = 1;