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)
1202 dec_ie_cause(l3m, &location, &cause);
1203 add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
1206 if (location == LOCATION_PRIVATE_LOCAL)
1207 location = LOCATION_PRIVATE_REMOTE;
1212 /* sending release to endpoint */
1215 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1216 message->param.disconnectinfo.cause = cause;
1217 message->param.disconnectinfo.location = location;
1218 message_put(message);
1220 free_epointlist(p_epointlist);
1223 new_state(PORT_STATE_RELEASE);
1228 void Pdss1::t312_timeout_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1230 // not required, release is performed with MT_FREE
1233 /* CC_NOTIFY INDICATION */
1234 void Pdss1::notify_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1236 struct lcr_msg *message;
1237 int notify, type, plan, present;
1238 unsigned char notifyid[sizeof(message->param.notifyinfo.id)];
1239 unsigned char display[128] = "";
1241 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_IND, DIRECTION_IN);
1242 dec_ie_notify(l3m, ¬ify);
1243 dec_ie_redir_dn(l3m, &type, &plan, &present, notifyid, sizeof(notifyid));
1244 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1247 if (!ACTIVE_EPOINT(p_epointlist))
1249 /* notification indicator */
1253 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1254 message->param.notifyinfo.notify = notify;
1255 SCPY(message->param.notifyinfo.id, (char *)notifyid);
1256 /* redirection number */
1260 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
1263 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
1266 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
1272 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1273 message->param.notifyinfo.present = INFO_PRESENT_NULL;
1276 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1279 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
1282 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1285 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1288 SCAT(message->param.notifyinfo.display, (char *)display);
1289 message->param.notifyinfo.isdn_port = p_m_portnum;
1290 message_put(message);
1294 /* CC_HOLD INDICATION */
1295 struct lcr_msg *message;
1296 void Pdss1::hold_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1298 // class Endpoint *epoint;
1300 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_IND, DIRECTION_IN);
1303 if (!ACTIVE_EPOINT(p_epointlist) || p_m_hold)
1305 l3m = create_l3msg();
1306 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_REJECT_REQ, DIRECTION_OUT);
1307 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */
1308 add_trace("reason", NULL, "no endpoint");
1310 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_REJECT, p_m_d_l3id, l3m);
1315 /* notify the hold of call */
1316 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1317 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_HOLD;
1318 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1319 message_put(message);
1321 /* deactivate bchannel */
1322 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (hold)", DIRECTION_NONE);
1323 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1327 /* set hold state */
1330 epoint = find_epoint_id(ACTIVE_EPOINT(p_epointlist));
1331 if (epoint && p_m_d_ntmode)
1333 p_m_timeout = p_settings.tout_hold;
1338 /* acknowledge hold */
1339 l3m = create_l3msg();
1340 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1342 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_ACKNOWLEDGE, p_m_d_l3id, l3m);
1346 /* CC_RETRIEVE INDICATION */
1347 void Pdss1::retrieve_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1349 struct lcr_msg *message;
1350 int channel, exclusive, cause;
1353 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_IND, DIRECTION_IN);
1354 dec_ie_channel_id(l3m, &exclusive, &channel);
1359 cause = 101; /* incompatible state */
1362 l3m = create_l3msg();
1363 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_REJECT_REQ, DIRECTION_OUT);
1364 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, cause);
1366 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_REJECT, p_m_d_l3id, l3m);
1371 /* notify the retrieve of call */
1372 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1373 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL;
1374 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1375 message_put(message);
1378 ret = channel = hunt_bchannel(channel, exclusive);
1383 ret = seize_bchannel(channel, 1);
1390 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1392 /* set hold state */
1396 /* acknowledge retrieve */
1397 l3m = create_l3msg();
1398 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1399 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1401 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_ACKNOWLEDGE, p_m_d_l3id, l3m);
1404 /* CC_SUSPEND INDICATION */
1405 void Pdss1::suspend_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1407 struct lcr_msg *message;
1408 class Endpoint *epoint;
1409 unsigned char callid[8];
1411 int ret = -31; /* normal, unspecified */
1413 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_IND, DIRECTION_IN);
1414 dec_ie_call_id(l3m, callid, &len);
1417 if (!ACTIVE_EPOINT(p_epointlist))
1420 l3m = create_l3msg();
1421 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_REJECT_REQ, DIRECTION_OUT);
1422 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1424 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_REJECT, p_m_d_l3id, l3m);
1431 /* check if call id is in use */
1432 epoint = epoint_first;
1435 if (epoint->ep_park)
1437 if (epoint->ep_park_len == len)
1438 if (!memcmp(epoint->ep_park_callid, callid, len))
1440 ret = -84; /* call id in use */
1444 epoint = epoint->next;
1447 /* notify the hold of call */
1448 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1449 message->param.notifyinfo.notify = INFO_NOTIFY_USER_SUSPENDED;
1450 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1451 message_put(message);
1453 /* deactivate bchannel */
1454 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (suspend)", DIRECTION_NONE);
1455 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1459 /* sending suspend to endpoint */
1460 while (p_epointlist)
1462 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_SUSPEND);
1463 memcpy(message->param.parkinfo.callid, callid, sizeof(message->param.parkinfo.callid));
1464 message->param.parkinfo.len = len;
1465 message_put(message);
1467 free_epointlist(p_epointlist);
1470 /* sending SUSPEND_ACKNOWLEDGE */
1471 l3m = create_l3msg();
1472 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1474 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_ACKNOWLEDGE, p_m_d_l3id, l3m);
1476 new_state(PORT_STATE_RELEASE);
1480 /* CC_RESUME INDICATION */
1481 void Pdss1::resume_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1483 unsigned char callid[8];
1485 int channel, exclusive;
1486 class Endpoint *epoint;
1487 struct lcr_msg *message;
1490 /* process given callref */
1491 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
1492 add_trace("callref", "new", "0x%x", pid);
1495 /* release is case the ID is already in use */
1496 add_trace("error", NULL, "callref already in use");
1498 l3m = create_l3msg();
1499 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1500 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
1501 add_trace("reason", NULL, "callref already in use");
1503 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, pid, l3m);
1504 new_state(PORT_STATE_RELEASE);
1509 p_m_d_ces = pid >> 16;
1512 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_IND, DIRECTION_IN);
1513 dec_ie_call_id(l3m, callid, &len);
1516 /* if blocked, release call */
1517 if (p_m_mISDNport->ifport->block)
1526 /* channel_id (no channel is possible in message) */
1528 channel = -1; /* any channel */
1531 ret = channel = hunt_bchannel(channel, exclusive);
1536 ret = seize_bchannel(channel, 1);
1541 l3m = create_l3msg();
1542 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1543 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1545 add_trace("reason", NULL, "port blocked");
1547 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, p_m_d_l3id, l3m);
1548 new_state(PORT_STATE_RELEASE);
1552 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1554 /* create endpoint */
1556 FATAL("Incoming resume but already got an endpoint.\n");
1557 ret = -85; /* no call suspended */
1558 epoint = epoint_first;
1561 if (epoint->ep_park)
1563 ret = -83; /* suspended call exists, but this not */
1564 if (epoint->ep_park_len == len)
1565 if (!memcmp(epoint->ep_park_callid, callid, len))
1568 epoint = epoint->next;
1573 epointlist_new(epoint->ep_serial);
1574 if (!(epoint->portlist_new(p_serial, p_type, p_m_mISDNport->earlyb)))
1575 FATAL("No memory for portlist\n");
1576 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RESUME);
1577 message_put(message);
1579 /* notify the resume of call */
1580 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1581 message->param.notifyinfo.notify = INFO_NOTIFY_USER_RESUMED;
1582 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1583 message_put(message);
1585 /* sending RESUME_ACKNOWLEDGE */
1586 l3m = create_l3msg();
1587 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1588 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1590 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_ACKNOWLEDGE, p_m_d_l3id, l3m);
1592 new_state(PORT_STATE_CONNECT);
1596 /* CC_FACILITY INDICATION */
1597 void Pdss1::facility_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1599 unsigned char facil[256];
1601 struct lcr_msg *message;
1603 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_IND, DIRECTION_IN);
1604 dec_ie_facility(l3m, facil, &facil_len);
1611 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_FACILITY);
1612 message->param.facilityinfo.len = facil_len;
1613 memcpy(message->param.facilityinfo.data, facil, facil_len);
1614 message_put(message);
1619 * handler for isdn connections
1620 * incoming information are parsed and sent via message to the endpoint
1622 void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1631 PERROR("Pdss1(%s) timeout without cause.\n", p_name);
1634 if (l3m->cause[0] != 5)
1636 PERROR("Pdss1(%s) expecting timeout with timer diagnostic. (got len=%d)\n", p_name, l3m->cause[0]);
1639 timer = (l3m->cause[3]-'0')*100;
1640 timer += (l3m->cause[4]-'0')*10;
1641 timer += (l3m->cause[5]-'0');
1642 l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN);
1643 add_trace("timer", NULL, "%d", timer);
1646 t312_timeout_ind(cmd, pid, l3m);
1650 if (p_state != PORT_STATE_IDLE)
1652 setup_ind(cmd, pid, l3m);
1655 case MT_INFORMATION:
1656 information_ind(cmd, pid, l3m);
1659 case MT_SETUP_ACKNOWLEDGE:
1660 if (p_state != PORT_STATE_OUT_SETUP)
1662 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received setup_acknowledge, but we are not in outgoing setup state, IGNORING.\n", p_name);
1665 setup_acknowledge_ind(cmd, pid, l3m);
1668 case MT_CALL_PROCEEDING:
1669 if (p_state != PORT_STATE_OUT_SETUP
1670 && p_state != PORT_STATE_OUT_OVERLAP)
1672 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received proceeding, but we are not in outgoing setup OR overlap state, IGNORING.\n", p_name);
1675 proceeding_ind(cmd, pid, l3m);
1679 if (p_state != PORT_STATE_OUT_SETUP
1680 && p_state != PORT_STATE_OUT_OVERLAP
1681 && p_state != PORT_STATE_OUT_PROCEEDING)
1683 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding state, IGNORING.\n", p_name);
1686 alerting_ind(cmd, pid, l3m);
1690 if (p_state != PORT_STATE_OUT_SETUP
1691 && p_state != PORT_STATE_OUT_OVERLAP
1692 && p_state != PORT_STATE_OUT_PROCEEDING
1693 && p_state != PORT_STATE_OUT_ALERTING)
1695 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);
1698 connect_ind(cmd, pid, l3m);
1699 if (p_m_d_notify_pending)
1701 /* send pending notify message during connect */
1702 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1703 message_free(p_m_d_notify_pending);
1704 p_m_d_notify_pending = NULL;
1708 case MT_CONNECT_ACKNOWLEDGE:
1709 if (p_state == PORT_STATE_CONNECT_WAITING)
1710 new_state(PORT_STATE_CONNECT);
1711 if (p_m_d_notify_pending)
1713 /* send pending notify message during connect-ack */
1714 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1715 message_free(p_m_d_notify_pending);
1716 p_m_d_notify_pending = NULL;
1721 disconnect_ind(cmd, pid, l3m);
1725 release_ind(cmd, pid, l3m);
1728 case MT_RELEASE_COMPLETE:
1729 release_complete_ind(cmd, pid, l3m);
1733 restart_ind(cmd, pid, l3m);
1737 notify_ind(cmd, pid, l3m);
1741 hold_ind(cmd, pid, l3m);
1745 retrieve_ind(cmd, pid, l3m);
1749 suspend_ind(cmd, pid, l3m);
1753 resume_ind(cmd, pid, l3m);
1757 facility_ind(cmd, pid, l3m);
1761 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_L3ID_IND, DIRECTION_IN);
1762 add_trace("callref", NULL, "0x%x", p_m_d_l3id);
1767 /* sending release to endpoint in case we still have an endpoint
1768 * this is because we don't get any response if a release_complete is received (or a release in release state)
1770 while(p_epointlist) // only if not already released
1772 struct lcr_msg *message;
1773 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1774 if (p_m_d_collect_cause)
1776 message->param.disconnectinfo.cause = p_m_d_collect_cause;
1777 message->param.disconnectinfo.location = p_m_d_collect_location;
1780 message->param.disconnectinfo.cause = CAUSE_NOUSER;
1781 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1783 message_put(message);
1785 free_epointlist(p_epointlist);
1787 new_state(PORT_STATE_RELEASE);
1792 l1l2l3_trace_header(p_m_mISDNport, this, L3_UNKNOWN, DIRECTION_IN);
1793 add_trace("unhandled", "cmd", "0x%x", cmd);
1798 void Pdss1::new_state(int state)
1800 // class Endpoint *epoint;
1803 if (state == PORT_STATE_IN_OVERLAP)
1805 p_m_timeout = p_m_mISDNport->ifport->tout_dialing;
1808 if (state != p_state)
1810 if (state == PORT_STATE_IN_SETUP
1811 || state == PORT_STATE_OUT_SETUP
1812 || state == PORT_STATE_IN_OVERLAP
1813 || state == PORT_STATE_OUT_OVERLAP)
1815 p_m_timeout = p_m_mISDNport->ifport->tout_setup;
1818 if (state == PORT_STATE_IN_PROCEEDING
1819 || state == PORT_STATE_OUT_PROCEEDING)
1821 p_m_timeout = p_m_mISDNport->ifport->tout_proceeding;
1824 if (state == PORT_STATE_IN_ALERTING
1825 || state == PORT_STATE_OUT_ALERTING)
1827 p_m_timeout = p_m_mISDNport->ifport->tout_alerting;
1830 if (state == PORT_STATE_CONNECT
1831 || state == PORT_STATE_CONNECT_WAITING)
1835 if (state == PORT_STATE_IN_DISCONNECT
1836 || state == PORT_STATE_OUT_DISCONNECT)
1838 p_m_timeout = p_m_mISDNport->ifport->tout_disconnect;
1843 Port::new_state(state);
1850 int Pdss1::handler(void)
1854 if ((ret = PmISDN::handler()))
1857 /* handle destruction */
1858 if (p_m_delete && p_m_d_l3id==0)
1869 * handles all messages from endpoint
1871 /* MESSAGE_INFORMATION */
1872 void Pdss1::message_information(unsigned int epoint_id, int message_id, union parameter *param)
1876 if (param->information.id[0]) /* only if we have something to dial */
1878 l3m = create_l3msg();
1879 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1880 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)param->information.id);
1882 enc_ie_display(l3m, (unsigned char *)param->information.display);
1884 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1893 void Pdss1::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
1897 int plan, type, screen, present, reason;
1898 int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
1899 int channel, exclusive;
1900 struct epoint_list *epointlist;
1902 /* release if port is blocked */
1903 if (p_m_mISDNport->ifport->block)
1905 struct lcr_msg *message;
1907 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1908 message->param.disconnectinfo.cause = 27; // temp. unavail.
1909 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1910 message_put(message);
1911 new_state(PORT_STATE_RELEASE);
1916 /* copy setup infos to port */
1917 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
1918 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
1919 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
1920 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
1921 // SCPY(&p_m_tones_dir, param->setup.ext.tones_dir);
1922 /* screen outgoing caller id */
1923 do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_m_mISDNport->ifport->interface);
1925 /* only display at connect state: this case happens if endpoint is in connected mode */
1926 if (p_state==PORT_STATE_CONNECT)
1928 if (p_type!=PORT_TYPE_DSS1_NT_OUT
1929 && p_type!=PORT_TYPE_DSS1_NT_IN)
1931 if (p_callerinfo.display[0])
1933 /* sending information */
1934 l3m = create_l3msg();
1935 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1937 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
1939 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1944 /* attach only if not already */
1945 epointlist = p_epointlist;
1948 if (epointlist->epoint_id == epoint_id)
1950 epointlist = epointlist->next;
1953 epointlist_new(epoint_id);
1959 channel = p_m_b_channel;
1960 exclusive = p_m_b_exclusive;
1962 channel = CHANNEL_ANY;
1963 /* nt-port with no channel, not reserverd */
1964 if (!p_m_b_channel && !p_m_b_reserve && p_type==PORT_TYPE_DSS1_NT_OUT)
1965 channel = CHANNEL_NO;
1968 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT);
1969 /* see MT_ASSIGN notes at do_layer3() */
1971 ret = p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ASSIGN, 0, NULL);
1972 if (mt_assign_pid == 0 || ret < 0)
1974 struct lcr_msg *message;
1976 add_trace("callref", NULL, "no free id");
1978 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1979 message->param.disconnectinfo.cause = 47;
1980 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1981 message_put(message);
1982 new_state(PORT_STATE_RELEASE);
1986 p_m_d_l3id = mt_assign_pid;
1988 add_trace("callref", "new", "0x%x", p_m_d_l3id);
1991 /* preparing setup message */
1992 l3m = create_l3msg();
1993 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_REQ, DIRECTION_OUT);
1994 /* channel information */
1995 if (channel >= 0) /* it should */
1997 enc_ie_channel_id(l3m, exclusive, channel);
1999 /* caller information */
2001 switch (p_callerinfo.ntype)
2003 case INFO_NTYPE_INTERNATIONAL:
2006 case INFO_NTYPE_NATIONAL:
2009 case INFO_NTYPE_SUBSCRIBER:
2012 default: /* INFO_NTYPE_UNKNOWN */
2016 switch (p_callerinfo.screen)
2018 case INFO_SCREEN_USER:
2021 default: /* INFO_SCREEN_NETWORK */
2025 switch (p_callerinfo.present)
2027 case INFO_PRESENT_RESTRICTED:
2030 case INFO_PRESENT_NOTAVAIL:
2033 default: /* INFO_PRESENT_ALLOWED */
2038 enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id);
2039 /* dialing information */
2040 if (p_dialinginfo.id[0]) /* only if we have something to dial */
2042 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id);
2044 /* sending complete */
2045 if (p_dialinginfo.sending_complete)
2046 enc_ie_complete(l3m, 1);
2047 /* sending user-user */
2048 if (param->setup.useruser.len)
2050 enc_ie_useruser(l3m, param->setup.useruser.protocol, param->setup.useruser.data, param->setup.useruser.len);
2052 /* redirecting number */
2054 switch (p_redirinfo.ntype)
2056 case INFO_NTYPE_INTERNATIONAL:
2059 case INFO_NTYPE_NATIONAL:
2062 case INFO_NTYPE_SUBSCRIBER:
2065 default: /* INFO_NTYPE_UNKNOWN */
2069 switch (p_redirinfo.screen)
2071 case INFO_SCREEN_USER:
2074 default: /* INFO_SCREE_NETWORK */
2078 switch (p_redirinfo.reason)
2080 case INFO_REDIR_BUSY:
2083 case INFO_REDIR_NORESPONSE:
2086 case INFO_REDIR_UNCONDITIONAL:
2089 case INFO_REDIR_CALLDEFLECT:
2092 case INFO_REDIR_OUTOFORDER:
2095 default: /* INFO_REDIR_UNKNOWN */
2099 switch (p_redirinfo.present)
2101 case INFO_PRESENT_NULL: /* no redir at all */
2108 case INFO_PRESENT_RESTRICTED:
2111 case INFO_PRESENT_NOTAVAIL:
2114 default: /* INFO_PRESENT_ALLOWED */
2118 /* sending redirecting number only in ntmode */
2119 if (type >= 0 && p_m_d_ntmode)
2120 enc_ie_redir_nr(l3m, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
2121 /* bearer capability */
2122 //printf("hlc=%d\n",p_capainfo.hlc);
2124 capability = p_capainfo.bearer_capa;
2125 mode = p_capainfo.bearer_mode;
2126 rate = (mode==INFO_BMODE_CIRCUIT)?0x10:0x00;
2127 switch (p_capainfo.bearer_info1)
2129 case INFO_INFO1_NONE:
2133 user = p_capainfo.bearer_info1 & 0x7f;
2136 enc_ie_bearer(l3m, coding, capability, mode, rate, -1, user);
2143 hlc = p_capainfo.hlc & 0x7f;
2145 if (p_capainfo.exthlc)
2146 exthlc = p_capainfo.exthlc & 0x7f;
2147 enc_ie_hlc(l3m, coding, interpretation, presentation, hlc, exthlc);
2151 if (p_callerinfo.display[0] && p_m_d_ntmode)
2152 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
2153 /* nt-mode: CNIP (calling name identification presentation) */
2154 // if (p_callerinfo.name[0] && p_m_d_ntmode)
2155 // enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
2158 /* send setup message now */
2159 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP, p_m_d_l3id, l3m);
2161 new_state(PORT_STATE_OUT_SETUP);
2164 /* MESSAGE_FACILITY */
2165 void Pdss1::message_facility(unsigned int epoint_id, int message_id, union parameter *param)
2169 /* facility will not be sent to external lines */
2173 /* sending facility */
2174 l3m = create_l3msg();
2175 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
2176 enc_ie_facility(l3m, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len);
2178 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
2181 /* MESSAGE_NOTIFY */
2182 void Pdss1::message_notify(unsigned int epoint_id, int message_id, union parameter *param)
2186 int plan, type = -1, present;
2188 if (param->notifyinfo.notify>INFO_NOTIFY_NONE)
2189 notify = param->notifyinfo.notify & 0x7f;
2192 if (p_state != PORT_STATE_CONNECT)
2194 /* notify only allowed in active state */
2200 switch (param->notifyinfo.ntype)
2202 case INFO_NTYPE_INTERNATIONAL:
2205 case INFO_NTYPE_NATIONAL:
2208 case INFO_NTYPE_SUBSCRIBER:
2211 default: /* INFO_NTYPE_UNKNOWN */
2215 switch (param->notifyinfo.present)
2217 case INFO_PRESENT_NULL: /* no redir at all */
2222 case INFO_PRESENT_RESTRICTED:
2225 case INFO_PRESENT_NOTAVAIL:
2228 default: /* INFO_PRESENT_ALLOWED */
2234 if (notify<0 && !param->notifyinfo.display[0])
2236 /* nothing to notify, nothing to display */
2242 if (p_state!=PORT_STATE_CONNECT)
2244 /* queue notification */
2245 if (p_m_d_notify_pending)
2246 message_free(p_m_d_notify_pending);
2247 p_m_d_notify_pending = message_create(ACTIVE_EPOINT(p_epointlist), p_serial, EPOINT_TO_PORT, message_id);
2248 memcpy(&p_m_d_notify_pending->param, param, sizeof(union parameter));
2251 /* sending notification */
2252 l3m = create_l3msg();
2253 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
2254 enc_ie_notify(l3m, notify);
2255 /* sending redirection number only in ntmode */
2256 if (type >= 0 && p_m_d_ntmode)
2257 enc_ie_redir_dn(l3m, type, plan, present, (unsigned char *)param->notifyinfo.id);
2258 if (param->notifyinfo.display[0] && p_m_d_ntmode)
2259 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2261 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_NOTIFY, p_m_d_l3id, l3m);
2263 } else if (p_m_d_ntmode)
2265 /* sending information */
2266 l3m = create_l3msg();
2267 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2268 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2270 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2274 /* MESSAGE_OVERLAP */
2275 void Pdss1::message_overlap(unsigned int epoint_id, int message_id, union parameter *param)
2279 /* in case of sending complete, we proceed */
2280 if (p_dialinginfo.sending_complete)
2282 PDEBUG(DEBUG_ISDN, "sending proceeding instead of setup_acknowledge, because address is complete.\n");
2283 message_proceeding(epoint_id, message_id, param);
2287 /* sending setup_acknowledge */
2288 l3m = create_l3msg();
2289 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_REQ, DIRECTION_OUT);
2290 /* channel information */
2291 if (p_state == PORT_STATE_IN_SETUP)
2292 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2293 /* progress information */
2294 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2295 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2296 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2297 if (p_m_mISDNport->tones)
2298 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2300 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, l3m);
2302 new_state(PORT_STATE_IN_OVERLAP);
2305 /* MESSAGE_PROCEEDING */
2306 void Pdss1::message_proceeding(unsigned int epoint_id, int message_id, union parameter *param)
2310 /* sending proceeding */
2311 l3m = create_l3msg();
2312 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2313 /* channel information */
2314 if (p_state == PORT_STATE_IN_SETUP)
2315 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2316 /* progress information */
2317 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2318 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2319 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2320 if (p_m_mISDNport->tones)
2321 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2323 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2325 new_state(PORT_STATE_IN_PROCEEDING);
2328 /* MESSAGE_ALERTING */
2329 void Pdss1::message_alerting(unsigned int epoint_id, int message_id, union parameter *param)
2333 /* NT-MODE in setup state we must send PROCEEDING first */
2334 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2336 /* sending proceeding */
2337 l3m = create_l3msg();
2338 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2339 /* channel information */
2340 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2341 /* progress information */
2342 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2343 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2344 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2345 if (p_m_mISDNport->tones)
2346 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2348 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2349 new_state(PORT_STATE_IN_PROCEEDING);
2352 /* sending alerting */
2353 l3m = create_l3msg();
2354 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_REQ, DIRECTION_OUT);
2355 /* channel information */
2356 if (p_state == PORT_STATE_IN_SETUP)
2357 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2358 /* progress information */
2359 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2360 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2361 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2362 if (p_m_mISDNport->tones)
2363 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2365 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ALERTING, p_m_d_l3id, l3m);
2367 new_state(PORT_STATE_IN_ALERTING);
2370 /* MESSAGE_CONNECT */
2371 void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parameter *param)
2374 int type, plan, present, screen;
2375 class Endpoint *epoint;
2377 /* NT-MODE in setup state we must send PROCEEDING first */
2378 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2380 /* sending proceeding */
2381 l3m = create_l3msg();
2382 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2383 /* channel information */
2384 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2386 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2387 new_state(PORT_STATE_IN_PROCEEDING);
2390 /* copy connected information */
2391 memcpy(&p_connectinfo, ¶m->connectinfo, sizeof(p_connectinfo));
2392 /* screen outgoing caller id */
2393 do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface);
2395 /* only display at connect state */
2396 if (p_state == PORT_STATE_CONNECT)
2397 if (p_connectinfo.display[0])
2399 /* sending information */
2400 l3m = create_l3msg();
2401 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2403 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2405 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2409 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)
2411 /* connect command only possible in setup, proceeding or alerting state */
2415 /* preparing connect message */
2416 l3m = create_l3msg();
2417 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_REQ, DIRECTION_OUT);
2418 /* connect information */
2420 switch (p_connectinfo.ntype)
2422 case INFO_NTYPE_INTERNATIONAL:
2425 case INFO_NTYPE_NATIONAL:
2428 case INFO_NTYPE_SUBSCRIBER:
2431 default: /* INFO_NTYPE_UNKNOWN */
2435 switch (param->connectinfo.screen)
2437 case INFO_SCREEN_USER:
2440 default: /* INFO_SCREE_NETWORK */
2444 switch (p_connectinfo.present)
2446 case INFO_PRESENT_NULL: /* no colp at all */
2452 case INFO_PRESENT_RESTRICTED:
2455 case INFO_PRESENT_NOTAVAIL:
2458 default: /* INFO_PRESENT_ALLOWED */
2463 enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
2465 if (p_connectinfo.display[0] && p_m_d_ntmode)
2466 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2467 /* nt-mode: CONP (connected name identification presentation) */
2468 // if (p_connectinfo.name[0] && p_m_d_ntmode)
2469 // enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
2473 epoint = find_epoint_id(epoint_id);
2474 enc_ie_date(l3m, now, p_settings.no_seconds);
2477 /* finally send message */
2478 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT, p_m_d_l3id, l3m);
2481 new_state(PORT_STATE_CONNECT);
2483 new_state(PORT_STATE_CONNECT_WAITING);
2487 /* MESSAGE_DISCONNECT */
2488 void Pdss1::message_disconnect(unsigned int epoint_id, int message_id, union parameter *param)
2491 struct lcr_msg *message;
2494 /* we reject during incoming setup when we have no tones. also if we are in outgoing setup state */
2495 // if ((p_state==PORT_STATE_IN_SETUP && !p_m_mISDNport->tones)
2496 if (/* ||*/ p_state==PORT_STATE_OUT_SETUP)
2498 /* sending release to endpoint */
2501 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
2502 memcpy(&message->param, param, sizeof(union parameter));
2503 message_put(message);
2505 free_epointlist(p_epointlist);
2507 /* sending release */
2508 l3m = create_l3msg();
2509 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
2511 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2513 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2514 new_state(PORT_STATE_RELEASE);
2519 /* workarround: NT-MODE in setup state we must send PROCEEDING first to make it work */
2520 if (p_state==PORT_STATE_IN_SETUP)
2522 /* sending proceeding */
2523 l3m = create_l3msg();
2524 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2525 /* channel information */
2526 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2527 /* progress information */
2528 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2529 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2530 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2531 if (p_m_mISDNport->tones)
2532 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2534 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2535 new_state(PORT_STATE_IN_PROCEEDING);
2538 /* sending disconnect */
2539 l3m = create_l3msg();
2540 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2541 /* progress information */
2542 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2543 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2544 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2545 if (p_m_mISDNport->tones)
2546 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2548 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2550 if (param->disconnectinfo.display[0])
2551 p = param->disconnectinfo.display;
2552 if (p) if (*p && p_m_d_ntmode)
2553 enc_ie_display(l3m, (unsigned char *)p);
2555 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2556 new_state(PORT_STATE_OUT_DISCONNECT);
2559 /* MESSAGE_RELEASE */
2560 void Pdss1::message_release(unsigned int epoint_id, int message_id, union parameter *param)
2563 class Endpoint *epoint;
2567 * we may only release during incoming disconnect state.
2568 * this means that the endpoint doesnt require audio anymore
2570 if (p_state == PORT_STATE_IN_DISCONNECT
2571 || p_state == PORT_STATE_OUT_DISCONNECT)
2573 /* sending release */
2574 l3m = create_l3msg();
2575 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2577 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2579 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
2580 new_state(PORT_STATE_RELEASE);
2582 free_epointid(epoint_id);
2583 // wait for callref to be released
2588 * if we are on incoming call setup, we may reject by sending a release_complete
2589 * also on outgoing call setup, we send a release complete, BUT this is not conform. (i don't know any other way)
2591 if (p_state==PORT_STATE_IN_SETUP
2592 || p_state==PORT_STATE_OUT_SETUP)
2594 //#warning remove me
2595 //PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
2596 /* sending release complete */
2597 l3m = create_l3msg();
2598 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2600 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2602 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2603 new_state(PORT_STATE_RELEASE);
2605 free_epointid(epoint_id);
2606 // wait for callref to be released
2611 wirklich erst proceeding?:
2612 /* NT-MODE in setup state we must send PROCEEDING first */
2613 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2615 CALL_PROCEEDING_t *proceeding;
2617 /* sending proceeding */
2618 l3m = create_l3msg();
2619 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2620 /* channel information */
2621 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2622 /* progress information */
2623 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2624 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2625 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2626 if (p_m_mISDNport->tones)
2627 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2629 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2633 /* sending disconnect */
2634 l3m = create_l3msg();
2635 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2636 /* progress information */
2637 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2638 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2639 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2640 if (p_m_mISDNport->tones)
2641 enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
2643 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2645 epoint = find_epoint_id(epoint_id);
2646 if (param->disconnectinfo.display[0])
2647 p = param->disconnectinfo.display;
2648 if (p) if (*p && p_m_d_ntmode)
2649 enc_ie_display(l3m, (unsigned char *)p);
2651 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2652 new_state(PORT_STATE_OUT_DISCONNECT);
2654 free_epointid(epoint_id);
2655 // wait for release and callref to be released
2656 //#warning remove me
2657 //PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
2662 * endpoint sends messages to the port
2664 int Pdss1::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
2666 struct lcr_msg *message;
2668 if (PmISDN::message_epoint(epoint_id, message_id, param))
2673 case MESSAGE_INFORMATION: /* overlap dialing */
2674 if (p_type==PORT_TYPE_DSS1_NT_OUT
2675 && p_state!=PORT_STATE_OUT_OVERLAP
2676 && p_state!=PORT_STATE_CONNECT
2677 && p_state!=PORT_STATE_OUT_DISCONNECT
2678 && p_state!=PORT_STATE_IN_DISCONNECT)
2682 if (p_type==PORT_TYPE_DSS1_TE_OUT
2683 && p_state!=PORT_STATE_OUT_OVERLAP
2684 && p_state!=PORT_STATE_OUT_PROCEEDING
2685 && p_state!=PORT_STATE_OUT_ALERTING
2686 && p_state!=PORT_STATE_CONNECT
2687 && p_state!=PORT_STATE_OUT_DISCONNECT
2688 && p_state!=PORT_STATE_IN_DISCONNECT)
2692 if ((p_type==PORT_TYPE_DSS1_NT_IN || p_type==PORT_TYPE_DSS1_TE_IN)
2693 && p_state!=PORT_STATE_IN_OVERLAP
2694 && p_state!=PORT_STATE_IN_PROCEEDING
2695 && p_state!=PORT_STATE_IN_ALERTING
2696 && p_state!=PORT_STATE_CONNECT
2697 && p_state!=PORT_STATE_CONNECT_WAITING
2698 && p_state!=PORT_STATE_OUT_DISCONNECT
2699 && p_state!=PORT_STATE_IN_DISCONNECT)
2703 message_information(epoint_id, message_id, param);
2706 case MESSAGE_SETUP: /* dial-out command received from epoint */
2707 if (p_state!=PORT_STATE_IDLE
2708 && p_state!=PORT_STATE_CONNECT)
2710 PERROR("Pdss1(%s) ignoring setup because isdn port is not in idle state (or connected for sending display info).\n", p_name);
2713 if (p_epointlist && p_state==PORT_STATE_IDLE)
2714 FATAL("Pdss1(%s): epoint pointer is set in idle state, how bad!!\n", p_name);
2715 message_setup(epoint_id, message_id, param);
2718 case MESSAGE_NOTIFY: /* display and notifications */
2719 message_notify(epoint_id, message_id, param);
2722 case MESSAGE_FACILITY: /* facility message */
2723 message_facility(epoint_id, message_id, param);
2726 case MESSAGE_OVERLAP: /* more information is needed */
2727 if (p_state!=PORT_STATE_IN_SETUP)
2731 message_overlap(epoint_id, message_id, param);
2734 case MESSAGE_PROCEEDING: /* call of endpoint is proceeding */
2735 if (p_state!=PORT_STATE_IN_SETUP
2736 && p_state!=PORT_STATE_IN_OVERLAP)
2740 message_proceeding(epoint_id, message_id, param);
2743 case MESSAGE_ALERTING: /* call of endpoint is ringing */
2744 if (p_state!=PORT_STATE_IN_SETUP
2745 && p_state!=PORT_STATE_IN_OVERLAP
2746 && p_state!=PORT_STATE_IN_PROCEEDING)
2750 message_alerting(epoint_id, message_id, param);
2753 case MESSAGE_CONNECT: /* call of endpoint is connected */
2754 if (p_state!=PORT_STATE_IN_SETUP
2755 && p_state!=PORT_STATE_IN_OVERLAP
2756 && p_state!=PORT_STATE_IN_PROCEEDING
2757 && p_state!=PORT_STATE_IN_ALERTING
2758 && !(p_state==PORT_STATE_CONNECT && p_m_d_ntmode))
2762 message_connect(epoint_id, message_id, param);
2765 case MESSAGE_DISCONNECT: /* call has been disconnected */
2766 if (p_state!=PORT_STATE_IN_SETUP
2767 && p_state!=PORT_STATE_IN_OVERLAP
2768 && p_state!=PORT_STATE_IN_PROCEEDING
2769 && p_state!=PORT_STATE_IN_ALERTING
2770 && p_state!=PORT_STATE_OUT_SETUP
2771 && p_state!=PORT_STATE_OUT_OVERLAP
2772 && p_state!=PORT_STATE_OUT_PROCEEDING
2773 && p_state!=PORT_STATE_OUT_ALERTING
2774 && p_state!=PORT_STATE_CONNECT
2775 && p_state!=PORT_STATE_CONNECT_WAITING)
2779 message_disconnect(epoint_id, message_id, param);
2782 case MESSAGE_RELEASE: /* release isdn port */
2783 if (p_state==PORT_STATE_RELEASE)
2787 message_release(epoint_id, message_id, param);
2791 PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message);
2800 * data from isdn-stack (layer-3) to pbx (port class)
2802 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
2808 PDEBUG(DEBUG_ISDN, "cmd(0x%x) pid(0x%x)\n", cmd, pid);
2812 PDEBUG(DEBUG_ISDN, "ignoring dummy process from phone.\n");
2816 /* find Port object of type ISDN */
2821 if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
2823 pdss1 = (class Pdss1 *)port;
2824 /* check out correct stack and id */
2825 if (pdss1->p_m_mISDNport == mISDNport)
2827 if (pdss1->p_m_d_l3id & MISDN_PID_CR_FLAG)
2829 /* local callref, so match value only */
2830 if ((pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == (pid & MISDN_PID_CRVAL_MASK))
2834 /* remote callref, ref + channel id */
2835 if (pdss1->p_m_d_l3id == pid)
2843 /* aktueller prozess */
2846 if (cmd == MT_ASSIGN)
2848 /* stack gives us new layer 3 id (during connect) */
2849 l1l2l3_trace_header(mISDNport, pdss1, L3_NEW_L3ID_IND, DIRECTION_IN);
2850 add_trace("callref", "old", "0x%x", pdss1->p_m_d_l3id);
2851 /* nt-library now gives us a new id via CC_SETUP_CONFIRM */
2852 if ((pdss1->p_m_d_l3id&MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER)
2853 PERROR(" strange setup-procid 0x%x\n", pdss1->p_m_d_l3id);
2854 pdss1->p_m_d_l3id = pid;
2855 if (port->p_state == PORT_STATE_CONNECT)
2856 pdss1->p_m_d_ces = pid >> 16;
2857 add_trace("callref", "new", "0x%x", pdss1->p_m_d_l3id);
2861 /* if process id is master process, but a child disconnects */
2862 if (mISDNport->ntmode
2863 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2864 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) == MISDN_PID_MASTER)
2866 if (cmd == MT_DISCONNECT
2867 || cmd == MT_RELEASE)
2869 /* send special indication for child disconnect */
2870 pdss1->disconnect_ind_i(cmd, pid, l3m);
2873 if (cmd == MT_RELEASE_COMPLETE)
2876 /* if we have child pid and got different child pid message, ignore */
2877 if (mISDNport->ntmode
2878 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2879 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2880 && pid != pdss1->p_m_d_l3id)
2883 /* process message */
2884 pdss1->message_isdn(cmd, pid, l3m);
2892 /* creating port object */
2893 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2894 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0)))
2896 FATAL("Cannot create Port instance.\n");
2897 pdss1->message_isdn(cmd, pid, l3m);
2901 /* creating port object */
2902 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2903 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0)))
2904 FATAL("Cannot create Port instance.\n");
2905 pdss1->message_isdn(cmd, pid, l3m);
2909 PDEBUG(DEBUG_ISDN, "unused call ref released (l3id=0x%x)\n", pid);
2912 case MT_RELEASE_COMPLETE:
2913 PERROR("must be ignored by stack, not sent to app\n");
2917 // facility als broadcast
2921 PERROR("unhandled message: cmd(0x%x) pid(0x%x)\n", cmd, pid);
2925 if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT)
2927 pdss1 = (class Pdss1 *)port;
2928 /* check out correct stack */
2929 if (pdss1->p_m_mISDNport == mISDNport)
2930 /* check out correct id */
2931 PERROR("unhandled message: pid=%x is not associated with port-dinfo=%x\n", pid, pdss1->p_m_d_l3id);
2943 * sending message that were queued during L1 activation
2944 * or releasing port if link is down
2946 void setup_queue(struct mISDNport *mISDNport, int link)
2950 struct lcr_msg *message;
2952 if (!mISDNport->ntmode)
2955 /* check all port objects for pending message */
2959 if ((port->p_type&PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
2961 pdss1 = (class Pdss1 *)port;
2962 if (pdss1->p_m_mISDNport == mISDNport)
2964 if (pdss1->p_m_d_queue)
2968 PDEBUG(DEBUG_ISDN, "the L1 became active, so we send queued message for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
2969 /* LAYER 1 is up, so we send */
2970 pdss1->message_setup(pdss1->p_m_d_queue->id_from, pdss1->p_m_d_queue->type, &pdss1->p_m_d_queue->param);
2971 message_free(pdss1->p_m_d_queue);
2972 pdss1->p_m_d_queue = NULL;
2975 PDEBUG(DEBUG_ISDN, "the L1 became NOT active, so we release port for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
2976 message = message_create(pdss1->p_serial, pdss1->p_m_d_queue->id_from, PORT_TO_EPOINT, MESSAGE_RELEASE);
2977 message->param.disconnectinfo.cause = 27;
2978 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
2979 message_put(message);
2980 pdss1->new_state(PORT_STATE_RELEASE);
2981 pdss1->p_m_delete = 1;