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, int mode) : PmISDN(type, mISDNport, portname, settings, channel, exclusive, mode)
28 p_callerinfo.itype = (mISDNport->ifport->interface->extension)?INFO_ITYPE_ISDN_EXTENSION:INFO_ITYPE_ISDN;
29 p_m_d_ntmode = mISDNport->ntmode;
30 p_m_d_tespecial = mISDNport->tespecial;
34 p_m_d_notify_pending = NULL;
35 p_m_d_collect_cause = 0;
36 p_m_d_collect_location = 0;
38 PDEBUG(DEBUG_ISDN, "Created new mISDNPort(%s). Currently %d objects use, %s%s port #%d\n", portname, mISDNport->use, (mISDNport->ntmode)?"NT":"TE", (mISDNport->tespecial)?" (special)":"", p_m_portnum);
47 /* remove queued message */
49 message_free(p_m_d_queue);
51 if (p_m_d_notify_pending)
52 message_free(p_m_d_notify_pending);
57 * create layer 3 message
59 static struct l3_msg *create_l3msg(void)
67 FATAL("Cannot allocate memory, system overloaded.\n");
68 exit(0); // make gcc happy
72 * if we received a first reply to the setup message,
73 * we will check if we have now channel information
74 * return: <0: error, call is released, -cause is given
75 * 0: ok, nothing to do
77 int Pdss1::received_first_reply_to_setup(unsigned int cmd, int channel, int exclusive)
82 /* correct exclusive to 0, if no explicit channel was given */
83 if (exclusive<0 || channel<=0)
87 if (p_m_b_channel && p_m_b_exclusive)
89 /*** we gave an exclusive channel (or if we are done) ***/
91 /* if not first reply, we are done */
92 if (p_state != PORT_STATE_OUT_SETUP)
95 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
96 add_trace("channel", "request", "%d (forced)", p_m_b_channel);
97 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
99 /* if give channel not accepted or not equal */
100 if (channel!=-1 && p_m_b_channel!=channel)
102 add_trace("conclusion", NULL, "forced channel not accepted");
108 add_trace("conclusion", NULL, "channel was accepted");
109 add_trace("connect", "channel", "%d", p_m_b_channel);
112 /* activate our exclusive channel */
113 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
117 /*** we gave a non-exclusive channel ***/
119 /* if not first reply, we are done */
120 if (p_state != PORT_STATE_OUT_SETUP)
123 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
124 add_trace("channel", "request", "%d (suggest)", p_m_b_channel);
125 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
127 /* if channel was accepted as given */
128 if (channel==-1 || p_m_b_channel==channel)
130 add_trace("conclusion", NULL, "channel was accepted as given");
131 add_trace("connect", "channel", "%d", p_m_b_channel);
133 p_m_b_exclusive = 1; // we are done
134 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
138 /* if channel value is faulty */
141 add_trace("conclusion", NULL, "illegal reply");
143 ret = -111; // protocol error
147 /* if channel was not accepted, try to get it */
148 ret = seize_bchannel(channel, 1); // exclusively
149 add_trace("channel", "available", ret<0?"no":"yes");
152 add_trace("conclusion", NULL, "replied channel not available");
156 add_trace("conclusion", NULL, "replied channel accepted");
157 add_trace("connect", "channel", "%d", p_m_b_channel);
160 /* activate channel given by remote */
161 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
165 /*** we sent 'any channel acceptable' ***/
167 /* if not first reply, we are done */
168 if (p_state != PORT_STATE_OUT_SETUP)
171 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
172 add_trace("channel", "request", "any");
173 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
174 /* if no channel was replied */
177 add_trace("conclusion", NULL, "no channel, protocol error");
179 ret = -111; // protocol error
183 /* we will see, if our received channel is available */
184 ret = seize_bchannel(channel, 1); // exclusively
185 add_trace("channel", "available", ret<0?"no":"yes");
188 add_trace("conclusion", NULL, "replied channel not available");
192 add_trace("conclusion", NULL, "replied channel accepted");
193 add_trace("connect", "channel", "%d", p_m_b_channel);
196 /* activate channel given by remote */
197 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
200 /*** we sent 'no channel available' ***/
202 /* if not the first reply, but a connect, we are forced */
203 if (cmd==MT_CONNECT && p_state!=PORT_STATE_OUT_SETUP)
205 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (connect)", DIRECTION_NONE);
206 add_trace("channel", "request", "no-channel");
207 add_trace("channel", "reply", (channel>=0)?"%d%s":"(none)", channel, exclusive?" (forced)":"");
210 goto use_from_connect;
212 ret = seize_bchannel(CHANNEL_ANY, 0); // any channel
213 add_trace("channel", "available", ret<0?"no":"yes");
216 add_trace("conclusion", NULL, "no channel available during call-waiting");
220 add_trace("conclusion", NULL, "using channel %d", p_m_b_channel);
221 add_trace("connect", "channel", "%d", p_m_b_channel);
223 p_m_b_exclusive = 1; // we are done
225 /* activate channel given by remote */
226 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
230 /* if not first reply, we are done */
231 if (p_state != PORT_STATE_OUT_SETUP)
234 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
235 add_trace("channel", "request", "no-channel");
236 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
237 /* if first reply has no channel, we are done */
240 add_trace("conclusion", NULL, "no channel until connect");
245 /* we will see, if our received channel is available */
247 ret = seize_bchannel(channel, exclusive);
248 add_trace("channel", "available", ret<0?"no":"yes");
251 add_trace("conclusion", NULL, "replied channel not available");
255 add_trace("conclusion", NULL, "replied channel accepted");
256 add_trace("connect", "channel", "%d", p_m_b_channel);
258 p_m_b_exclusive = 1; // we are done
260 /* activate channel given by remote */
261 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
267 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
268 * in response to the setup reply
270 l3m = create_l3msg();
271 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
272 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
274 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
275 new_state(PORT_STATE_RELEASE);
277 return(-34); /* to epoint: no channel available */
282 * hunt bchannel for incoming setup or retrieve or resume
284 int Pdss1::hunt_bchannel(int channel, int exclusive)
286 struct select_channel *selchannel;
287 struct interface_port *ifport = p_m_mISDNport->ifport;
290 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (setup)", DIRECTION_NONE);
293 if (channel == CHANNEL_NO)
294 add_trace("channel", "request", "no-channel");
296 add_trace("channel", "request", (channel>0)?"%d%s":"any", channel, exclusive?" (forced)":"");
297 if (channel==CHANNEL_NO && p_type==PORT_TYPE_DSS1_TE_IN)
299 add_trace("conclusion", NULL, "incoming call-waiting not supported for TE-mode");
301 return(-6); // channel unacceptable
303 if (channel <= 0) /* not given, no channel, whatever.. */
304 channel = CHANNEL_ANY; /* any channel */
305 add_trace("channel", "reserved", "%d", p_m_mISDNport->b_reserved);
306 if (p_m_mISDNport->b_reserved >= p_m_mISDNport->b_num) // of out chan..
308 add_trace("conclusion", NULL, "all channels are reserved");
310 return(-34); // no channel
312 if (channel == CHANNEL_ANY)
316 /* check for given channel in selection list */
317 selchannel = ifport->in_channel;
320 if (selchannel->channel == channel || selchannel->channel == CHANNEL_FREE)
322 selchannel = selchannel->next;
327 /* exclusive channel requests must be in the list */
330 /* no exclusive channel */
333 add_trace("conclusion", NULL, "exclusively requested channel not in list");
335 return(-6); // channel unacceptable
337 /* get index for channel */
338 i = channel-1-(channel>=17);
339 if (i < 0 || i >= p_m_mISDNport->b_num || channel == 16)
341 add_trace("conclusion", NULL, "exclusively requested channel outside interface range");
343 return(-6); // channel unacceptable
346 if (p_m_mISDNport->b_port[i] == NULL)
348 add_trace("conclusion", NULL, "exclusively requested channel is busy");
350 return(-6); // channel unacceptable
353 /* requested channels in list will be used */
356 /* get index for channel */
357 i = channel-1-(channel>=17);
358 if (i < 0 || i >= p_m_mISDNport->b_num || channel == 16)
360 add_trace("info", NULL, "requested channel %d outside interface range", channel);
361 } else /* if inside range (else) check if available */
362 if (p_m_mISDNport->b_port[i] == NULL)
366 /* if channel is not available or not in list, it must be searched */
368 /* check for first free channel in list */
370 selchannel = ifport->in_channel;
373 switch(selchannel->channel)
375 case CHANNEL_FREE: /* free channel */
376 add_trace("hunting", "channel", "free");
377 if (p_m_mISDNport->b_reserved >= p_m_mISDNport->b_num)
378 break; /* all channel in use or reserverd */
381 while(i < p_m_mISDNport->b_num)
383 if (p_m_mISDNport->b_port[i] == NULL)
385 channel = i+1+(i>=15);
393 add_trace("hunting", "channel", "%d", selchannel->channel);
394 if (selchannel->channel<1 || selchannel->channel==16)
395 break; /* invalid channels */
396 i = selchannel->channel-1-(selchannel->channel>=17);
397 if (i >= p_m_mISDNport->b_num)
398 break; /* channel not in port */
399 if (p_m_mISDNport->b_port[i] == NULL)
401 channel = selchannel->channel;
407 break; /* found channel */
408 selchannel = selchannel->next;
412 add_trace("conclusion", NULL, "no channel available");
414 return(-6); // channel unacceptable
418 add_trace("conclusion", NULL, "channel available");
419 add_trace("connect", "channel", "%d", channel);
425 * handles all indications
427 /* CC_SETUP INDICATION */
428 void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
430 int calling_type, calling_plan, calling_present, calling_screen;
431 int called_type, called_plan;
432 int redir_type, redir_plan, redir_present, redir_screen, redir_reason;
433 int hlc_coding, hlc_presentation, hlc_interpretation, hlc_hlc, hlc_exthlc;
434 int bearer_coding, bearer_capability, bearer_mode, bearer_rate, bearer_multi, bearer_user;
435 int exclusive, channel;
437 unsigned char keypad[32] = "";
438 unsigned char useruser[128];
439 int useruser_len = 0, useruser_protocol;
440 class Endpoint *epoint;
441 struct lcr_msg *message;
443 /* process given callref */
444 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
445 add_trace("callref", "new", "0x%x", pid);
448 /* release in case the ID is already in use */
449 add_trace("error", NULL, "callref already in use");
451 l3m = create_l3msg();
452 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
453 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
454 add_trace("reason", NULL, "callref already in use");
456 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, pid, l3m);
457 new_state(PORT_STATE_RELEASE);
462 p_m_d_ces = pid >> 16;
465 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_IND, DIRECTION_IN);
466 dec_ie_calling_pn(l3m, &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id));
467 dec_ie_called_pn(l3m, &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
468 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
469 /* 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;
672 /* set bchannel mode */
673 if (p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED
674 || p_capainfo.bearer_capa==INFO_BC_DATARESTRICTED
675 || p_capainfo.bearer_capa==INFO_BC_VIDEO)
676 p_capainfo.source_mode = B_MODE_HDLC;
678 p_capainfo.source_mode = B_MODE_TRANSPARENT;
679 p_m_b_mode = p_capainfo.source_mode;
682 ret = channel = hunt_bchannel(channel, exclusive);
687 ret = seize_bchannel(channel, 1);
692 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
693 * in response to the setup
695 l3m = create_l3msg();
696 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
697 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
699 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
700 new_state(PORT_STATE_RELEASE);
704 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
706 /* create endpoint */
708 FATAL("Incoming call but already got an endpoint.\n");
709 if (!(epoint = new Endpoint(p_serial, 0)))
710 FATAL("No memory for Endpoint instance\n");
711 if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 0))) //incoming
712 FATAL("No memory for Endpoint Application instance\n");
713 epointlist_new(epoint->ep_serial);
715 /* send setup message to endpoit */
716 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
717 message->param.setup.isdn_port = p_m_portnum;
718 message->param.setup.port_type = p_type;
719 // message->param.setup.dtmf = !p_m_mISDNport->ifport->nodtmf;
720 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
721 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
722 memcpy(&message->param.setup.redirinfo, &p_redirinfo, sizeof(struct redir_info));
723 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
724 memcpy(message->param.setup.useruser.data, &useruser, useruser_len);
725 message->param.setup.useruser.len = useruser_len;
726 message->param.setup.useruser.protocol = useruser_protocol;
727 message_put(message);
729 new_state(PORT_STATE_IN_SETUP);
732 /* CC_INFORMATION INDICATION */
733 void Pdss1::information_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
736 unsigned char keypad[32] = "", display[128] = "";
737 struct lcr_msg *message;
739 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_IND, DIRECTION_IN);
740 dec_ie_called_pn(l3m, &type, &plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
741 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
742 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
743 dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
746 SCAT(p_dialinginfo.id, (char *)keypad);
750 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
753 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
756 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
759 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
762 SCAT(p_dialinginfo.display, (char *)display);
763 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_INFORMATION);
764 memcpy(&message->param.information, &p_dialinginfo, sizeof(struct dialing_info));
765 message_put(message);
766 /* reset overlap timeout */
770 /* CC_SETUP_ACCNOWLEDGE INDICATION */
771 void Pdss1::setup_acknowledge_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
773 int exclusive, channel;
774 int coding, location, progress;
776 struct lcr_msg *message;
778 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_IND, DIRECTION_IN);
779 dec_ie_channel_id(l3m, &exclusive, &channel);
780 dec_ie_progress(l3m, &coding, &location, &progress);
783 /* process channel */
784 ret = received_first_reply_to_setup(cmd, channel, exclusive);
787 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
788 message->param.disconnectinfo.cause = -ret;
789 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
790 message_put(message);
791 new_state(PORT_STATE_RELEASE);
796 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_OVERLAP);
797 message_put(message);
799 new_state(PORT_STATE_OUT_OVERLAP);
802 /* CC_PROCEEDING INDICATION */
803 void Pdss1::proceeding_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
805 int exclusive, channel;
806 int coding, location, progress;
808 struct lcr_msg *message;
809 int notify = -1, type, plan, present;
812 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_IND, DIRECTION_IN);
813 dec_ie_channel_id(l3m, &exclusive, &channel);
814 dec_ie_progress(l3m, &coding, &location, &progress);
815 dec_ie_notify(l3m, ¬ify);
816 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
819 ret = received_first_reply_to_setup(cmd, channel, exclusive);
822 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
823 message->param.disconnectinfo.cause = -ret;
824 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
825 message_put(message);
826 new_state(PORT_STATE_RELEASE);
830 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
831 message_put(message);
833 new_state(PORT_STATE_OUT_PROCEEDING);
839 if (type >= 0 || notify)
841 if (!notify && type >= 0)
843 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
844 message->param.notifyinfo.notify = notify;
845 SCPY(message->param.notifyinfo.id, redir);
846 /* redirection number */
850 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
853 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
856 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
862 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
863 message->param.notifyinfo.present = INFO_PRESENT_NULL;
866 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
869 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
872 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
875 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
878 message->param.notifyinfo.isdn_port = p_m_portnum;
879 message_put(message);
883 /* CC_ALERTING INDICATION */
884 void Pdss1::alerting_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
886 int exclusive, channel;
887 int coding, location, progress;
889 struct lcr_msg *message;
890 int notify = -1, type, plan, present;
893 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_IND, DIRECTION_IN);
894 dec_ie_channel_id(l3m, &exclusive, &channel);
895 dec_ie_progress(l3m, &coding, &location, &progress);
896 dec_ie_notify(l3m, ¬ify);
897 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
900 /* process channel */
901 ret = received_first_reply_to_setup(cmd, channel, exclusive);
904 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
905 message->param.disconnectinfo.cause = -ret;
906 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
907 message_put(message);
908 new_state(PORT_STATE_RELEASE);
912 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ALERTING);
913 message_put(message);
915 new_state(PORT_STATE_OUT_ALERTING);
921 if (type >= 0 || notify)
923 if (!notify && type >= 0)
925 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
926 message->param.notifyinfo.notify = notify;
927 SCPY(message->param.notifyinfo.id, redir);
931 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
934 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
937 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
943 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
944 message->param.notifyinfo.present = INFO_PRESENT_NULL;
947 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
950 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
953 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
956 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
959 message->param.notifyinfo.isdn_port = p_m_portnum;
960 message_put(message);
964 /* CC_CONNECT INDICATION */
965 void Pdss1::connect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
967 int exclusive, channel;
968 int type, plan, present, screen;
970 struct lcr_msg *message;
973 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_IND, DIRECTION_IN);
974 dec_ie_channel_id(l3m, &exclusive, &channel);
975 dec_ie_connected_pn(l3m, &type, &plan, &present, &screen, (unsigned char *)p_connectinfo.id, sizeof(p_connectinfo.id));
976 dec_ie_display(l3m, (unsigned char *)p_connectinfo.display, sizeof(p_connectinfo.display));
977 /* te-mode: CONP (connected name identification presentation) */
978 dec_facility_centrex(l3m, (unsigned char *)p_connectinfo.name, sizeof(p_connectinfo.name));
982 bchannel_before = p_m_b_channel;
983 ret = received_first_reply_to_setup(cmd, channel, exclusive);
986 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
987 message->param.disconnectinfo.cause = -ret;
988 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
989 message_put(message);
990 new_state(PORT_STATE_RELEASE);
995 /* connect information */
999 p_connectinfo.present = INFO_PRESENT_RESTRICTED;
1002 p_connectinfo.present = INFO_PRESENT_NOTAVAIL;
1005 p_connectinfo.present = INFO_PRESENT_ALLOWED;
1011 p_connectinfo.screen = INFO_SCREEN_USER;
1014 p_connectinfo.screen = INFO_SCREEN_NETWORK;
1020 p_connectinfo.present = INFO_PRESENT_NULL; /* no COLP info */
1021 p_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
1024 p_connectinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1027 p_connectinfo.ntype = INFO_NTYPE_NATIONAL;
1030 p_connectinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1033 p_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
1036 p_connectinfo.isdn_port = p_m_portnum;
1037 SCPY(p_connectinfo.interface, p_m_mISDNport->ifport->interface->name);
1039 /* only in nt-mode we send connect ack. in te-mode it is done by stack itself or optional */
1042 /* send connect acknowledge */
1043 l3m = create_l3msg();
1044 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_RES, DIRECTION_OUT);
1045 /* if we had no bchannel before, we send it now */
1046 if (!bchannel_before && p_m_b_channel)
1047 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1049 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT_ACKNOWLEDGE, p_m_d_l3id, l3m);
1052 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_CONNECT);
1053 memcpy(&message->param.connectinfo, &p_connectinfo, sizeof(struct connect_info));
1054 message_put(message);
1056 new_state(PORT_STATE_CONNECT);
1059 /* CC_DISCONNECT INDICATION */
1060 void Pdss1::disconnect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1062 int location, cause;
1063 int coding, proglocation, progress;
1064 struct lcr_msg *message;
1065 unsigned char display[128] = "";
1067 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1068 dec_ie_progress(l3m, &coding, &proglocation, &progress);
1069 dec_ie_cause(l3m, &location, &cause);
1070 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1076 /* release if remote sends us no tones */
1077 if (!p_m_mISDNport->earlyb)
1081 l3m = create_l3msg();
1082 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
1083 enc_ie_cause(l3m, location, cause); /* normal */
1084 add_trace("reason", NULL, "no remote patterns");
1086 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
1088 /* sending release to endpoint */
1089 if (location == LOCATION_PRIVATE_LOCAL)
1090 location = LOCATION_PRIVATE_REMOTE;
1093 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1094 message->param.disconnectinfo.cause = cause;
1095 message->param.disconnectinfo.location = location;
1096 SCAT(message->param.disconnectinfo.display, (char *)display);
1097 message_put(message);
1099 free_epointlist(p_epointlist);
1101 new_state(PORT_STATE_RELEASE);
1106 /* sending disconnect to active endpoint and release to inactive endpoints */
1107 if (location == LOCATION_PRIVATE_LOCAL)
1108 location = LOCATION_PRIVATE_REMOTE;
1109 if (ACTIVE_EPOINT(p_epointlist))
1111 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_DISCONNECT);
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 while(INACTIVE_EPOINT(p_epointlist))
1119 message = message_create(p_serial, INACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1120 message->param.disconnectinfo.location = location;
1121 message->param.disconnectinfo.cause = cause;
1122 SCAT(message->param.disconnectinfo.display, (char *)display);
1123 message_put(message);
1125 free_epointid(INACTIVE_EPOINT(p_epointlist));
1127 new_state(PORT_STATE_IN_DISCONNECT);
1130 /* CC_DISCONNECT INDICATION */
1131 void Pdss1::disconnect_ind_i(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1133 int location, cause;
1136 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1137 if (p_m_d_collect_cause > 0)
1139 add_trace("old-cause", "location", "%d", p_m_d_collect_location);
1140 add_trace("old-cause", "value", "%d", p_m_d_collect_cause);
1142 dec_ie_cause(l3m, &location, &cause);
1143 if (location == LOCATION_PRIVATE_LOCAL)
1144 location = LOCATION_PRIVATE_REMOTE;
1147 collect_cause(&p_m_d_collect_cause, &p_m_d_collect_location, cause, location);
1148 add_trace("new-cause", "location", "%d", p_m_d_collect_location);
1149 add_trace("new-cause", "value", "%d", p_m_d_collect_cause);
1154 /* CC_RELEASE INDICATION */
1155 void Pdss1::release_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1157 int location, cause;
1158 struct lcr_msg *message;
1159 unsigned char display[128] = "";
1161 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_IND, DIRECTION_IN);
1162 dec_ie_cause(l3m, &location, &cause);
1163 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1169 /* sending release to endpoint */
1170 if (location == LOCATION_PRIVATE_LOCAL)
1171 location = LOCATION_PRIVATE_REMOTE;
1174 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1175 message->param.disconnectinfo.cause = cause;
1176 message->param.disconnectinfo.location = location;
1177 SCAT(message->param.disconnectinfo.display, (char *)display);
1178 message_put(message);
1180 free_epointlist(p_epointlist);
1183 new_state(PORT_STATE_RELEASE);
1187 /* CC_RESTART INDICATION */
1188 void Pdss1::restart_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1190 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESTART_IND, DIRECTION_IN);
1193 // L3 process is not toucht. (not even by network stack)
1196 /* CC_RELEASE_COMPLETE INDICATION (a reject) */
1197 void Pdss1::release_complete_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1199 int location, cause;
1200 struct lcr_msg *message;
1202 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_IND, DIRECTION_IN);
1203 /* in case layer 2 is down during setup, we send cause 27 loc 5 */
1204 if (p_state == PORT_STATE_OUT_SETUP && p_m_mISDNport->l1link == 0)
1210 dec_ie_cause(l3m, &location, &cause);
1211 if (p_m_mISDNport->l1link < 0)
1212 add_trace("layer 1", NULL, "unknown");
1214 add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
1217 if (location == LOCATION_PRIVATE_LOCAL)
1218 location = LOCATION_PRIVATE_REMOTE;
1223 /* sending release to endpoint */
1226 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1227 message->param.disconnectinfo.cause = cause;
1228 message->param.disconnectinfo.location = location;
1229 message_put(message);
1231 free_epointlist(p_epointlist);
1234 new_state(PORT_STATE_RELEASE);
1239 void Pdss1::t312_timeout_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1241 // not required, release is performed with MT_FREE
1244 /* CC_NOTIFY INDICATION */
1245 void Pdss1::notify_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1247 struct lcr_msg *message;
1248 int notify, type, plan, present;
1249 unsigned char notifyid[sizeof(message->param.notifyinfo.id)];
1250 unsigned char display[128] = "";
1252 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_IND, DIRECTION_IN);
1253 dec_ie_notify(l3m, ¬ify);
1254 dec_ie_redir_dn(l3m, &type, &plan, &present, notifyid, sizeof(notifyid));
1255 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1258 if (!ACTIVE_EPOINT(p_epointlist))
1260 /* notification indicator */
1264 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1265 message->param.notifyinfo.notify = notify;
1266 SCPY(message->param.notifyinfo.id, (char *)notifyid);
1267 /* redirection number */
1271 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
1274 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
1277 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
1283 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1284 message->param.notifyinfo.present = INFO_PRESENT_NULL;
1287 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1290 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
1293 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1296 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1299 SCAT(message->param.notifyinfo.display, (char *)display);
1300 message->param.notifyinfo.isdn_port = p_m_portnum;
1301 message_put(message);
1305 /* CC_HOLD INDICATION */
1306 struct lcr_msg *message;
1307 void Pdss1::hold_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1309 // class Endpoint *epoint;
1311 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_IND, DIRECTION_IN);
1314 if (!ACTIVE_EPOINT(p_epointlist) || p_m_hold)
1316 l3m = create_l3msg();
1317 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_REJECT_REQ, DIRECTION_OUT);
1318 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */
1319 add_trace("reason", NULL, "no endpoint");
1321 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_REJECT, p_m_d_l3id, l3m);
1326 /* notify the hold of call */
1327 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1328 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_HOLD;
1329 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1330 message_put(message);
1332 /* deactivate bchannel */
1333 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (hold)", DIRECTION_NONE);
1334 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1338 /* set hold state */
1341 epoint = find_epoint_id(ACTIVE_EPOINT(p_epointlist));
1342 if (epoint && p_m_d_ntmode)
1344 p_m_timeout = p_settings.tout_hold;
1349 /* acknowledge hold */
1350 l3m = create_l3msg();
1351 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1353 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_ACKNOWLEDGE, p_m_d_l3id, l3m);
1357 /* CC_RETRIEVE INDICATION */
1358 void Pdss1::retrieve_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1360 struct lcr_msg *message;
1361 int channel, exclusive, cause;
1364 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_IND, DIRECTION_IN);
1365 dec_ie_channel_id(l3m, &exclusive, &channel);
1370 cause = 101; /* incompatible state */
1373 l3m = create_l3msg();
1374 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_REJECT_REQ, DIRECTION_OUT);
1375 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, cause);
1377 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_REJECT, p_m_d_l3id, l3m);
1382 /* notify the retrieve of call */
1383 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1384 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL;
1385 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1386 message_put(message);
1389 ret = channel = hunt_bchannel(channel, exclusive);
1394 ret = seize_bchannel(channel, 1);
1401 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1403 /* set hold state */
1407 /* acknowledge retrieve */
1408 l3m = create_l3msg();
1409 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1410 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1412 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_ACKNOWLEDGE, p_m_d_l3id, l3m);
1415 /* CC_SUSPEND INDICATION */
1416 void Pdss1::suspend_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1418 struct lcr_msg *message;
1419 class Endpoint *epoint;
1420 unsigned char callid[8];
1422 int ret = -31; /* normal, unspecified */
1424 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_IND, DIRECTION_IN);
1425 dec_ie_call_id(l3m, callid, &len);
1428 if (!ACTIVE_EPOINT(p_epointlist))
1431 l3m = create_l3msg();
1432 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_REJECT_REQ, DIRECTION_OUT);
1433 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1435 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_REJECT, p_m_d_l3id, l3m);
1442 /* check if call id is in use */
1443 epoint = epoint_first;
1446 if (epoint->ep_park)
1448 if (epoint->ep_park_len == len)
1449 if (!memcmp(epoint->ep_park_callid, callid, len))
1451 ret = -84; /* call id in use */
1455 epoint = epoint->next;
1458 /* notify the hold of call */
1459 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1460 message->param.notifyinfo.notify = INFO_NOTIFY_USER_SUSPENDED;
1461 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1462 message_put(message);
1464 /* deactivate bchannel */
1465 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (suspend)", DIRECTION_NONE);
1466 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1470 /* sending suspend to endpoint */
1471 while (p_epointlist)
1473 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_SUSPEND);
1474 memcpy(message->param.parkinfo.callid, callid, sizeof(message->param.parkinfo.callid));
1475 message->param.parkinfo.len = len;
1476 message_put(message);
1478 free_epointlist(p_epointlist);
1481 /* sending SUSPEND_ACKNOWLEDGE */
1482 l3m = create_l3msg();
1483 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1485 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_ACKNOWLEDGE, p_m_d_l3id, l3m);
1487 new_state(PORT_STATE_RELEASE);
1491 /* CC_RESUME INDICATION */
1492 void Pdss1::resume_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1494 unsigned char callid[8];
1496 int channel, exclusive;
1497 class Endpoint *epoint;
1498 struct lcr_msg *message;
1501 /* process given callref */
1502 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
1503 add_trace("callref", "new", "0x%x", pid);
1506 /* release is case the ID is already in use */
1507 add_trace("error", NULL, "callref already in use");
1509 l3m = create_l3msg();
1510 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1511 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
1512 add_trace("reason", NULL, "callref already in use");
1514 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, pid, l3m);
1515 new_state(PORT_STATE_RELEASE);
1520 p_m_d_ces = pid >> 16;
1523 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_IND, DIRECTION_IN);
1524 dec_ie_call_id(l3m, callid, &len);
1527 /* if blocked, release call */
1528 if (p_m_mISDNport->ifport->block)
1537 /* channel_id (no channel is possible in message) */
1539 channel = -1; /* any channel */
1542 ret = channel = hunt_bchannel(channel, exclusive);
1546 // mode (if hdlc parked) to be done. never mind, this is almost never requested
1548 ret = seize_bchannel(channel, 1);
1553 l3m = create_l3msg();
1554 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1555 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1557 add_trace("reason", NULL, "port blocked");
1559 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, p_m_d_l3id, l3m);
1560 new_state(PORT_STATE_RELEASE);
1564 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1566 /* create endpoint */
1568 FATAL("Incoming resume but already got an endpoint.\n");
1569 ret = -85; /* no call suspended */
1570 epoint = epoint_first;
1573 if (epoint->ep_park)
1575 ret = -83; /* suspended call exists, but this not */
1576 if (epoint->ep_park_len == len)
1577 if (!memcmp(epoint->ep_park_callid, callid, len))
1580 epoint = epoint->next;
1585 epointlist_new(epoint->ep_serial);
1586 if (!(epoint->portlist_new(p_serial, p_type, p_m_mISDNport->earlyb)))
1587 FATAL("No memory for portlist\n");
1588 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RESUME);
1589 message_put(message);
1591 /* notify the resume of call */
1592 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1593 message->param.notifyinfo.notify = INFO_NOTIFY_USER_RESUMED;
1594 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1595 message_put(message);
1597 /* sending RESUME_ACKNOWLEDGE */
1598 l3m = create_l3msg();
1599 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1600 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1602 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_ACKNOWLEDGE, p_m_d_l3id, l3m);
1604 new_state(PORT_STATE_CONNECT);
1608 /* CC_FACILITY INDICATION */
1609 void Pdss1::facility_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1611 unsigned char facil[256];
1613 struct lcr_msg *message;
1615 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_IND, DIRECTION_IN);
1616 dec_ie_facility(l3m, facil, &facil_len);
1623 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_FACILITY);
1624 message->param.facilityinfo.len = facil_len;
1625 memcpy(message->param.facilityinfo.data, facil, facil_len);
1626 message_put(message);
1631 * handler for isdn connections
1632 * incoming information are parsed and sent via message to the endpoint
1634 void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1643 PERROR("Pdss1(%s) timeout without cause.\n", p_name);
1646 if (l3m->cause[0] != 5)
1648 PERROR("Pdss1(%s) expecting timeout with timer diagnostic. (got len=%d)\n", p_name, l3m->cause[0]);
1651 timer = (l3m->cause[3]-'0')*100;
1652 timer += (l3m->cause[4]-'0')*10;
1653 timer += (l3m->cause[5]-'0');
1654 l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN);
1655 add_trace("timer", NULL, "%d", timer);
1658 t312_timeout_ind(cmd, pid, l3m);
1662 if (p_state != PORT_STATE_IDLE)
1664 setup_ind(cmd, pid, l3m);
1667 case MT_INFORMATION:
1668 information_ind(cmd, pid, l3m);
1671 case MT_SETUP_ACKNOWLEDGE:
1672 if (p_state != PORT_STATE_OUT_SETUP)
1674 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received setup_acknowledge, but we are not in outgoing setup state, IGNORING.\n", p_name);
1677 setup_acknowledge_ind(cmd, pid, l3m);
1680 case MT_CALL_PROCEEDING:
1681 if (p_state != PORT_STATE_OUT_SETUP
1682 && p_state != PORT_STATE_OUT_OVERLAP)
1684 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received proceeding, but we are not in outgoing setup OR overlap state, IGNORING.\n", p_name);
1687 proceeding_ind(cmd, pid, l3m);
1691 if (p_state != PORT_STATE_OUT_SETUP
1692 && p_state != PORT_STATE_OUT_OVERLAP
1693 && p_state != PORT_STATE_OUT_PROCEEDING)
1695 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding state, IGNORING.\n", p_name);
1698 alerting_ind(cmd, pid, l3m);
1702 if (p_state != PORT_STATE_OUT_SETUP
1703 && p_state != PORT_STATE_OUT_OVERLAP
1704 && p_state != PORT_STATE_OUT_PROCEEDING
1705 && p_state != PORT_STATE_OUT_ALERTING)
1707 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);
1710 connect_ind(cmd, pid, l3m);
1711 if (p_m_d_notify_pending)
1713 /* send pending notify message during connect */
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;
1720 case MT_CONNECT_ACKNOWLEDGE:
1721 if (p_state == PORT_STATE_CONNECT_WAITING)
1722 new_state(PORT_STATE_CONNECT);
1723 if (p_m_d_notify_pending)
1725 /* send pending notify message during connect-ack */
1726 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1727 message_free(p_m_d_notify_pending);
1728 p_m_d_notify_pending = NULL;
1733 disconnect_ind(cmd, pid, l3m);
1737 release_ind(cmd, pid, l3m);
1740 case MT_RELEASE_COMPLETE:
1741 release_complete_ind(cmd, pid, l3m);
1745 restart_ind(cmd, pid, l3m);
1749 notify_ind(cmd, pid, l3m);
1753 hold_ind(cmd, pid, l3m);
1757 retrieve_ind(cmd, pid, l3m);
1761 suspend_ind(cmd, pid, l3m);
1765 resume_ind(cmd, pid, l3m);
1769 facility_ind(cmd, pid, l3m);
1773 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_L3ID_IND, DIRECTION_IN);
1774 add_trace("callref", NULL, "0x%x", p_m_d_l3id);
1779 /* sending release to endpoint in case we still have an endpoint
1780 * this is because we don't get any response if a release_complete is received (or a release in release state)
1782 while(p_epointlist) // only if not already released
1784 struct lcr_msg *message;
1785 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1786 if (p_m_d_collect_cause)
1788 message->param.disconnectinfo.cause = p_m_d_collect_cause;
1789 message->param.disconnectinfo.location = p_m_d_collect_location;
1792 message->param.disconnectinfo.cause = CAUSE_NOUSER;
1793 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1795 message_put(message);
1797 free_epointlist(p_epointlist);
1799 new_state(PORT_STATE_RELEASE);
1804 l1l2l3_trace_header(p_m_mISDNport, this, L3_UNKNOWN, DIRECTION_IN);
1805 add_trace("unhandled", "cmd", "0x%x", cmd);
1810 void Pdss1::new_state(int state)
1812 // class Endpoint *epoint;
1815 if (state == PORT_STATE_IN_OVERLAP)
1817 p_m_timeout = p_m_mISDNport->ifport->tout_dialing;
1820 if (state != p_state)
1822 if (state == PORT_STATE_IN_SETUP
1823 || state == PORT_STATE_OUT_SETUP
1824 || state == PORT_STATE_IN_OVERLAP
1825 || state == PORT_STATE_OUT_OVERLAP)
1827 p_m_timeout = p_m_mISDNport->ifport->tout_setup;
1830 if (state == PORT_STATE_IN_PROCEEDING
1831 || state == PORT_STATE_OUT_PROCEEDING)
1833 p_m_timeout = p_m_mISDNport->ifport->tout_proceeding;
1836 if (state == PORT_STATE_IN_ALERTING
1837 || state == PORT_STATE_OUT_ALERTING)
1839 p_m_timeout = p_m_mISDNport->ifport->tout_alerting;
1842 if (state == PORT_STATE_CONNECT
1843 || state == PORT_STATE_CONNECT_WAITING)
1847 if (state == PORT_STATE_IN_DISCONNECT
1848 || state == PORT_STATE_OUT_DISCONNECT)
1850 p_m_timeout = p_m_mISDNport->ifport->tout_disconnect;
1855 Port::new_state(state);
1862 int Pdss1::handler(void)
1866 if ((ret = PmISDN::handler()))
1869 /* handle destruction */
1870 if (p_m_delete && p_m_d_l3id==0)
1881 * handles all messages from endpoint
1883 /* MESSAGE_INFORMATION */
1884 void Pdss1::message_information(unsigned int epoint_id, int message_id, union parameter *param)
1888 if (param->information.id[0]) /* only if we have something to dial */
1890 l3m = create_l3msg();
1891 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1892 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)param->information.id);
1893 if (p_m_d_ntmode || p_m_d_tespecial)
1894 enc_ie_display(l3m, (unsigned char *)param->information.display);
1896 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1905 void Pdss1::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
1909 int plan, type, screen, present, reason;
1910 int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
1911 int channel, exclusive;
1912 struct epoint_list *epointlist;
1914 /* release if port is blocked */
1915 if (p_m_mISDNport->ifport->block)
1917 struct lcr_msg *message;
1919 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1920 message->param.disconnectinfo.cause = 27; // temp. unavail.
1921 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1922 message_put(message);
1923 new_state(PORT_STATE_RELEASE);
1928 /* copy setup infos to port */
1929 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
1930 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
1931 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
1932 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
1933 // SCPY(&p_m_tones_dir, param->setup.ext.tones_dir);
1934 /* screen outgoing caller id */
1935 do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_m_mISDNport->ifport->interface);
1937 /* only display at connect state: this case happens if endpoint is in connected mode */
1938 if (p_state==PORT_STATE_CONNECT)
1940 if (p_type!=PORT_TYPE_DSS1_NT_OUT
1941 && p_type!=PORT_TYPE_DSS1_NT_IN)
1943 if (p_callerinfo.display[0])
1945 /* sending information */
1946 l3m = create_l3msg();
1947 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1948 if (p_m_d_ntmode || p_m_d_tespecial)
1949 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
1951 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1956 /* attach only if not already */
1957 epointlist = p_epointlist;
1960 if (epointlist->epoint_id == epoint_id)
1962 epointlist = epointlist->next;
1965 epointlist_new(epoint_id);
1971 channel = p_m_b_channel;
1972 exclusive = p_m_b_exclusive;
1974 channel = CHANNEL_ANY;
1975 /* nt-port with no channel, not reserverd */
1976 if (!p_m_b_channel && !p_m_b_reserve && p_type==PORT_TYPE_DSS1_NT_OUT)
1977 channel = CHANNEL_NO;
1980 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT);
1981 /* see MT_ASSIGN notes at do_layer3() */
1983 ret = p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ASSIGN, 0, NULL);
1984 if (mt_assign_pid == 0 || ret < 0)
1986 struct lcr_msg *message;
1988 add_trace("callref", NULL, "no free id");
1990 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1991 message->param.disconnectinfo.cause = 47;
1992 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1993 message_put(message);
1994 new_state(PORT_STATE_RELEASE);
1998 p_m_d_l3id = mt_assign_pid;
2000 add_trace("callref", "new", "0x%x", p_m_d_l3id);
2003 /* preparing setup message */
2004 l3m = create_l3msg();
2005 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_REQ, DIRECTION_OUT);
2006 /* channel information */
2007 if (channel >= 0) /* it should */
2009 enc_ie_channel_id(l3m, exclusive, channel);
2011 /* caller information */
2013 switch (p_callerinfo.ntype)
2015 case INFO_NTYPE_INTERNATIONAL:
2018 case INFO_NTYPE_NATIONAL:
2021 case INFO_NTYPE_SUBSCRIBER:
2024 default: /* INFO_NTYPE_UNKNOWN */
2028 switch (p_callerinfo.screen)
2030 case INFO_SCREEN_USER:
2033 default: /* INFO_SCREEN_NETWORK */
2037 switch (p_callerinfo.present)
2039 case INFO_PRESENT_RESTRICTED:
2042 case INFO_PRESENT_NOTAVAIL:
2045 default: /* INFO_PRESENT_ALLOWED */
2050 enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id);
2051 /* dialing information */
2052 if (p_dialinginfo.id[0]) /* only if we have something to dial */
2054 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id);
2056 /* sending complete */
2057 if (p_dialinginfo.sending_complete)
2058 enc_ie_complete(l3m, 1);
2059 /* sending user-user */
2060 if (param->setup.useruser.len)
2062 enc_ie_useruser(l3m, param->setup.useruser.protocol, param->setup.useruser.data, param->setup.useruser.len);
2064 /* redirecting number */
2066 switch (p_redirinfo.ntype)
2068 case INFO_NTYPE_INTERNATIONAL:
2071 case INFO_NTYPE_NATIONAL:
2074 case INFO_NTYPE_SUBSCRIBER:
2077 default: /* INFO_NTYPE_UNKNOWN */
2081 switch (p_redirinfo.screen)
2083 case INFO_SCREEN_USER:
2086 default: /* INFO_SCREE_NETWORK */
2090 switch (p_redirinfo.reason)
2092 case INFO_REDIR_BUSY:
2095 case INFO_REDIR_NORESPONSE:
2098 case INFO_REDIR_UNCONDITIONAL:
2101 case INFO_REDIR_CALLDEFLECT:
2104 case INFO_REDIR_OUTOFORDER:
2107 default: /* INFO_REDIR_UNKNOWN */
2111 switch (p_redirinfo.present)
2113 case INFO_PRESENT_NULL: /* no redir at all */
2120 case INFO_PRESENT_RESTRICTED:
2123 case INFO_PRESENT_NOTAVAIL:
2126 default: /* INFO_PRESENT_ALLOWED */
2130 /* sending redirecting number only in ntmode */
2131 if (type >= 0 && (p_m_d_ntmode || p_m_d_tespecial))
2132 enc_ie_redir_nr(l3m, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
2133 /* bearer capability */
2134 //printf("hlc=%d\n",p_capainfo.hlc);
2136 capability = p_capainfo.bearer_capa;
2137 mode = p_capainfo.bearer_mode;
2138 rate = (mode==INFO_BMODE_CIRCUIT)?0x10:0x00;
2139 switch (p_capainfo.bearer_info1)
2141 case INFO_INFO1_NONE:
2145 user = p_capainfo.bearer_info1 & 0x7f;
2148 enc_ie_bearer(l3m, coding, capability, mode, rate, -1, user);
2155 hlc = p_capainfo.hlc & 0x7f;
2157 if (p_capainfo.exthlc)
2158 exthlc = p_capainfo.exthlc & 0x7f;
2159 enc_ie_hlc(l3m, coding, interpretation, presentation, hlc, exthlc);
2163 if (p_callerinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2164 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
2165 /* nt-mode: CNIP (calling name identification presentation) */
2166 // if (p_callerinfo.name[0] && (p_m_d_ntmode || p_m_d_tespecial))
2167 // enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
2170 /* send setup message now */
2171 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP, p_m_d_l3id, l3m);
2173 new_state(PORT_STATE_OUT_SETUP);
2176 /* MESSAGE_FACILITY */
2177 void Pdss1::message_facility(unsigned int epoint_id, int message_id, union parameter *param)
2181 /* facility will not be sent to external lines */
2182 if (!p_m_d_ntmode && !p_m_d_tespecial)
2185 /* sending facility */
2186 l3m = create_l3msg();
2187 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
2188 enc_ie_facility(l3m, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len);
2190 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
2193 /* MESSAGE_NOTIFY */
2194 void Pdss1::message_notify(unsigned int epoint_id, int message_id, union parameter *param)
2198 int plan, type = -1, present;
2200 if (param->notifyinfo.notify>INFO_NOTIFY_NONE)
2201 notify = param->notifyinfo.notify & 0x7f;
2204 if (p_state != PORT_STATE_CONNECT)
2206 /* notify only allowed in active state */
2212 switch (param->notifyinfo.ntype)
2214 case INFO_NTYPE_INTERNATIONAL:
2217 case INFO_NTYPE_NATIONAL:
2220 case INFO_NTYPE_SUBSCRIBER:
2223 default: /* INFO_NTYPE_UNKNOWN */
2227 switch (param->notifyinfo.present)
2229 case INFO_PRESENT_NULL: /* no redir at all */
2234 case INFO_PRESENT_RESTRICTED:
2237 case INFO_PRESENT_NOTAVAIL:
2240 default: /* INFO_PRESENT_ALLOWED */
2246 if (notify<0 && !param->notifyinfo.display[0])
2248 /* nothing to notify, nothing to display */
2254 if (p_state!=PORT_STATE_CONNECT)
2256 /* queue notification */
2257 if (p_m_d_notify_pending)
2258 message_free(p_m_d_notify_pending);
2259 p_m_d_notify_pending = message_create(ACTIVE_EPOINT(p_epointlist), p_serial, EPOINT_TO_PORT, message_id);
2260 memcpy(&p_m_d_notify_pending->param, param, sizeof(union parameter));
2263 /* sending notification */
2264 l3m = create_l3msg();
2265 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
2266 enc_ie_notify(l3m, notify);
2267 /* sending redirection number only in ntmode */
2268 if (type >= 0 && (p_m_d_ntmode || p_m_d_tespecial))
2269 enc_ie_redir_dn(l3m, type, plan, present, (unsigned char *)param->notifyinfo.id);
2270 if (param->notifyinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2271 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2273 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_NOTIFY, p_m_d_l3id, l3m);
2275 } else if (p_m_d_ntmode || p_m_d_tespecial)
2277 /* sending information */
2278 l3m = create_l3msg();
2279 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2280 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2282 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2286 /* MESSAGE_OVERLAP */
2287 void Pdss1::message_overlap(unsigned int epoint_id, int message_id, union parameter *param)
2291 /* in case of sending complete, we proceed */
2292 if (p_dialinginfo.sending_complete)
2294 PDEBUG(DEBUG_ISDN, "sending proceeding instead of setup_acknowledge, because address is complete.\n");
2295 message_proceeding(epoint_id, message_id, param);
2299 /* sending setup_acknowledge */
2300 l3m = create_l3msg();
2301 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_REQ, DIRECTION_OUT);
2302 /* channel information */
2303 if (p_state == PORT_STATE_IN_SETUP)
2304 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2305 /* progress information */
2306 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2307 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2308 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2309 if (p_m_mISDNport->tones)
2310 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2312 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, l3m);
2314 new_state(PORT_STATE_IN_OVERLAP);
2317 /* MESSAGE_PROCEEDING */
2318 void Pdss1::message_proceeding(unsigned int epoint_id, int message_id, union parameter *param)
2322 /* sending proceeding */
2323 l3m = create_l3msg();
2324 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2325 /* channel information */
2326 if (p_state == PORT_STATE_IN_SETUP)
2327 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2328 /* progress information */
2329 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2330 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2331 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2332 if (p_m_mISDNport->tones)
2333 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2335 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2337 new_state(PORT_STATE_IN_PROCEEDING);
2340 /* MESSAGE_ALERTING */
2341 void Pdss1::message_alerting(unsigned int epoint_id, int message_id, union parameter *param)
2345 /* NT-MODE in setup state we must send PROCEEDING first */
2346 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2348 /* sending proceeding */
2349 l3m = create_l3msg();
2350 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2351 /* channel information */
2352 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2353 /* progress information */
2354 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2355 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2356 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2357 if (p_m_mISDNport->tones)
2358 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2360 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2361 new_state(PORT_STATE_IN_PROCEEDING);
2364 /* sending alerting */
2365 l3m = create_l3msg();
2366 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_REQ, DIRECTION_OUT);
2367 /* channel information */
2368 if (p_state == PORT_STATE_IN_SETUP)
2369 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2370 /* progress information */
2371 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2372 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2373 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2374 if (p_m_mISDNport->tones)
2375 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2377 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ALERTING, p_m_d_l3id, l3m);
2379 new_state(PORT_STATE_IN_ALERTING);
2382 /* MESSAGE_CONNECT */
2383 void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parameter *param)
2386 int type, plan, present, screen;
2387 class Endpoint *epoint;
2389 /* NT-MODE in setup state we must send PROCEEDING first */
2390 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2392 /* sending proceeding */
2393 l3m = create_l3msg();
2394 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2395 /* channel information */
2396 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2398 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2399 new_state(PORT_STATE_IN_PROCEEDING);
2402 /* copy connected information */
2403 memcpy(&p_connectinfo, ¶m->connectinfo, sizeof(p_connectinfo));
2404 /* screen outgoing caller id */
2405 do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface);
2407 /* only display at connect state */
2408 if (p_state == PORT_STATE_CONNECT)
2409 if (p_connectinfo.display[0])
2411 /* sending information */
2412 l3m = create_l3msg();
2413 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2414 if (p_m_d_ntmode || p_m_d_tespecial)
2415 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2417 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2421 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)
2423 /* connect command only possible in setup, proceeding or alerting state */
2427 /* preparing connect message */
2428 l3m = create_l3msg();
2429 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_REQ, DIRECTION_OUT);
2430 /* connect information */
2432 switch (p_connectinfo.ntype)
2434 case INFO_NTYPE_INTERNATIONAL:
2437 case INFO_NTYPE_NATIONAL:
2440 case INFO_NTYPE_SUBSCRIBER:
2443 default: /* INFO_NTYPE_UNKNOWN */
2447 switch (param->connectinfo.screen)
2449 case INFO_SCREEN_USER:
2452 default: /* INFO_SCREE_NETWORK */
2456 switch (p_connectinfo.present)
2458 case INFO_PRESENT_NULL: /* no colp at all */
2464 case INFO_PRESENT_RESTRICTED:
2467 case INFO_PRESENT_NOTAVAIL:
2470 default: /* INFO_PRESENT_ALLOWED */
2475 enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
2477 if (p_connectinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2478 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2479 /* nt-mode: CONP (connected name identification presentation) */
2480 // if (p_connectinfo.name[0] && (p_m_d_ntmode || p_m_d_tespecial))
2481 // enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
2483 if (p_m_d_ntmode || p_m_d_tespecial)
2485 epoint = find_epoint_id(epoint_id);
2486 enc_ie_date(l3m, now, p_settings.no_seconds);
2489 /* finally send message */
2490 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT, p_m_d_l3id, l3m);
2493 new_state(PORT_STATE_CONNECT);
2495 new_state(PORT_STATE_CONNECT_WAITING);
2499 /* MESSAGE_DISCONNECT */
2500 void Pdss1::message_disconnect(unsigned int epoint_id, int message_id, union parameter *param)
2503 struct lcr_msg *message;
2506 /* we reject during incoming setup when we have no tones. also if we are in outgoing setup state */
2507 // if ((p_state==PORT_STATE_IN_SETUP && !p_m_mISDNport->tones)
2508 if (/* ||*/ p_state==PORT_STATE_OUT_SETUP)
2510 /* sending release to endpoint */
2513 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
2514 memcpy(&message->param, param, sizeof(union parameter));
2515 message_put(message);
2517 free_epointlist(p_epointlist);
2519 /* sending release */
2520 l3m = create_l3msg();
2521 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
2523 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2525 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2526 new_state(PORT_STATE_RELEASE);
2531 /* workarround: NT-MODE in setup state we must send PROCEEDING first to make it work */
2532 if (p_state==PORT_STATE_IN_SETUP)
2534 /* sending proceeding */
2535 l3m = create_l3msg();
2536 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2537 /* channel information */
2538 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2539 /* progress information */
2540 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2541 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2542 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2543 if (p_m_mISDNport->tones)
2544 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2546 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2547 new_state(PORT_STATE_IN_PROCEEDING);
2550 /* sending disconnect */
2551 l3m = create_l3msg();
2552 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2553 /* progress information */
2554 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2555 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2556 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2557 if (p_m_mISDNport->tones)
2558 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2560 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2562 if (param->disconnectinfo.display[0])
2563 p = param->disconnectinfo.display;
2564 if (p) if (*p && (p_m_d_ntmode || p_m_d_tespecial))
2565 enc_ie_display(l3m, (unsigned char *)p);
2567 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2568 new_state(PORT_STATE_OUT_DISCONNECT);
2571 /* MESSAGE_RELEASE */
2572 void Pdss1::message_release(unsigned int epoint_id, int message_id, union parameter *param)
2575 class Endpoint *epoint;
2579 * we may only release during incoming disconnect state.
2580 * this means that the endpoint doesnt require audio anymore
2582 if (p_state == PORT_STATE_IN_DISCONNECT
2583 || p_state == PORT_STATE_OUT_DISCONNECT)
2585 /* sending release */
2586 l3m = create_l3msg();
2587 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2589 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2591 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
2592 new_state(PORT_STATE_RELEASE);
2594 free_epointid(epoint_id);
2595 // wait for callref to be released
2600 * if we are on incoming call setup, we may reject by sending a release_complete
2601 * also on outgoing call setup, we send a release complete, BUT this is not conform. (i don't know any other way)
2603 if (p_state==PORT_STATE_IN_SETUP
2604 || p_state==PORT_STATE_OUT_SETUP)
2606 //#warning remove me
2607 //PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
2608 /* sending release complete */
2609 l3m = create_l3msg();
2610 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2612 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2614 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2615 new_state(PORT_STATE_RELEASE);
2617 free_epointid(epoint_id);
2618 // wait for callref to be released
2623 wirklich erst proceeding?:
2624 /* NT-MODE in setup state we must send PROCEEDING first */
2625 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
2627 CALL_PROCEEDING_t *proceeding;
2629 /* sending proceeding */
2630 l3m = create_l3msg();
2631 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2632 /* channel information */
2633 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2634 /* progress information */
2635 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2636 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2637 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2638 if (p_m_mISDNport->tones)
2639 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2641 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2645 /* sending disconnect */
2646 l3m = create_l3msg();
2647 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2648 /* progress information */
2649 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2650 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2651 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2652 if (p_m_mISDNport->tones)
2653 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2655 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2657 epoint = find_epoint_id(epoint_id);
2658 if (param->disconnectinfo.display[0])
2659 p = param->disconnectinfo.display;
2660 if (p) if (*p && (p_m_d_ntmode || p_m_d_tespecial))
2661 enc_ie_display(l3m, (unsigned char *)p);
2663 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2664 new_state(PORT_STATE_OUT_DISCONNECT);
2666 free_epointid(epoint_id);
2667 // wait for release and callref to be released
2668 //#warning remove me
2669 //PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
2674 * endpoint sends messages to the port
2676 int Pdss1::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
2678 struct lcr_msg *message;
2680 if (PmISDN::message_epoint(epoint_id, message_id, param))
2685 case MESSAGE_INFORMATION: /* overlap dialing */
2686 if (p_type==PORT_TYPE_DSS1_NT_OUT
2687 && p_state!=PORT_STATE_OUT_OVERLAP
2688 && p_state!=PORT_STATE_CONNECT
2689 && p_state!=PORT_STATE_OUT_DISCONNECT
2690 && p_state!=PORT_STATE_IN_DISCONNECT)
2694 if (p_type==PORT_TYPE_DSS1_TE_OUT
2695 && p_state!=PORT_STATE_OUT_OVERLAP
2696 && p_state!=PORT_STATE_OUT_PROCEEDING
2697 && p_state!=PORT_STATE_OUT_ALERTING
2698 && p_state!=PORT_STATE_CONNECT
2699 && p_state!=PORT_STATE_OUT_DISCONNECT
2700 && p_state!=PORT_STATE_IN_DISCONNECT)
2704 if ((p_type==PORT_TYPE_DSS1_NT_IN || p_type==PORT_TYPE_DSS1_TE_IN)
2705 && p_state!=PORT_STATE_IN_OVERLAP
2706 && p_state!=PORT_STATE_IN_PROCEEDING
2707 && p_state!=PORT_STATE_IN_ALERTING
2708 && p_state!=PORT_STATE_CONNECT
2709 && p_state!=PORT_STATE_CONNECT_WAITING
2710 && p_state!=PORT_STATE_OUT_DISCONNECT
2711 && p_state!=PORT_STATE_IN_DISCONNECT)
2715 message_information(epoint_id, message_id, param);
2718 case MESSAGE_SETUP: /* dial-out command received from epoint */
2719 if (p_state!=PORT_STATE_IDLE
2720 && p_state!=PORT_STATE_CONNECT)
2722 PERROR("Pdss1(%s) ignoring setup because isdn port is not in idle state (or connected for sending display info).\n", p_name);
2725 if (p_epointlist && p_state==PORT_STATE_IDLE)
2726 FATAL("Pdss1(%s): epoint pointer is set in idle state, how bad!!\n", p_name);
2727 message_setup(epoint_id, message_id, param);
2730 case MESSAGE_NOTIFY: /* display and notifications */
2731 message_notify(epoint_id, message_id, param);
2734 case MESSAGE_FACILITY: /* facility message */
2735 message_facility(epoint_id, message_id, param);
2738 case MESSAGE_OVERLAP: /* more information is needed */
2739 if (p_state!=PORT_STATE_IN_SETUP)
2743 message_overlap(epoint_id, message_id, param);
2746 case MESSAGE_PROCEEDING: /* call of endpoint is proceeding */
2747 if (p_state!=PORT_STATE_IN_SETUP
2748 && p_state!=PORT_STATE_IN_OVERLAP)
2752 message_proceeding(epoint_id, message_id, param);
2755 case MESSAGE_ALERTING: /* call of endpoint is ringing */
2756 if (p_state!=PORT_STATE_IN_SETUP
2757 && p_state!=PORT_STATE_IN_OVERLAP
2758 && p_state!=PORT_STATE_IN_PROCEEDING)
2762 message_alerting(epoint_id, message_id, param);
2765 case MESSAGE_CONNECT: /* call of endpoint is connected */
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_CONNECT && p_m_d_ntmode))
2774 message_connect(epoint_id, message_id, param);
2777 case MESSAGE_DISCONNECT: /* call has been disconnected */
2778 if (p_state!=PORT_STATE_IN_SETUP
2779 && p_state!=PORT_STATE_IN_OVERLAP
2780 && p_state!=PORT_STATE_IN_PROCEEDING
2781 && p_state!=PORT_STATE_IN_ALERTING
2782 && p_state!=PORT_STATE_OUT_SETUP
2783 && p_state!=PORT_STATE_OUT_OVERLAP
2784 && p_state!=PORT_STATE_OUT_PROCEEDING
2785 && p_state!=PORT_STATE_OUT_ALERTING
2786 && p_state!=PORT_STATE_CONNECT
2787 && p_state!=PORT_STATE_CONNECT_WAITING)
2791 message_disconnect(epoint_id, message_id, param);
2794 case MESSAGE_RELEASE: /* release isdn port */
2795 if (p_state==PORT_STATE_RELEASE)
2799 message_release(epoint_id, message_id, param);
2803 PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message);
2812 * data from isdn-stack (layer-3) to pbx (port class)
2814 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
2820 PDEBUG(DEBUG_ISDN, "cmd(0x%x) pid(0x%x)\n", cmd, pid);
2824 PDEBUG(DEBUG_ISDN, "ignoring dummy process from phone.\n");
2828 /* find Port object of type ISDN */
2833 if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
2835 pdss1 = (class Pdss1 *)port;
2836 /* check out correct stack and id */
2837 if (pdss1->p_m_mISDNport == mISDNport)
2839 if (pdss1->p_m_d_l3id & MISDN_PID_CR_FLAG)
2841 /* local callref, so match value only */
2842 if ((pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == (pid & MISDN_PID_CRVAL_MASK))
2846 /* remote callref, ref + channel id */
2847 if (pdss1->p_m_d_l3id == pid)
2855 /* aktueller prozess */
2858 if (cmd == MT_ASSIGN)
2860 /* stack gives us new layer 3 id (during connect) */
2861 l1l2l3_trace_header(mISDNport, pdss1, L3_NEW_L3ID_IND, DIRECTION_IN);
2862 add_trace("callref", "old", "0x%x", pdss1->p_m_d_l3id);
2863 /* nt-library now gives us a new id via CC_SETUP_CONFIRM */
2864 if ((pdss1->p_m_d_l3id&MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER)
2865 PERROR(" strange setup-procid 0x%x\n", pdss1->p_m_d_l3id);
2866 pdss1->p_m_d_l3id = pid;
2867 if (port->p_state == PORT_STATE_CONNECT)
2868 pdss1->p_m_d_ces = pid >> 16;
2869 add_trace("callref", "new", "0x%x", pdss1->p_m_d_l3id);
2873 /* if process id is master process, but a child disconnects */
2874 if (mISDNport->ntmode
2875 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2876 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) == MISDN_PID_MASTER)
2878 if (cmd == MT_DISCONNECT
2879 || cmd == MT_RELEASE)
2881 /* send special indication for child disconnect */
2882 pdss1->disconnect_ind_i(cmd, pid, l3m);
2885 if (cmd == MT_RELEASE_COMPLETE)
2888 /* if we have child pid and got different child pid message, ignore */
2889 if (mISDNport->ntmode
2890 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2891 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2892 && pid != pdss1->p_m_d_l3id)
2895 /* process message */
2896 pdss1->message_isdn(cmd, pid, l3m);
2904 /* creating port object, transparent until setup with hdlc */
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, B_MODE_TRANSPARENT)))
2908 FATAL("Cannot create Port instance.\n");
2909 pdss1->message_isdn(cmd, pid, l3m);
2913 /* creating port object, transparent until setup with hdlc */
2914 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2915 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0, B_MODE_TRANSPARENT)))
2916 FATAL("Cannot create Port instance.\n");
2917 pdss1->message_isdn(cmd, pid, l3m);
2921 PDEBUG(DEBUG_ISDN, "unused call ref released (l3id=0x%x)\n", pid);
2924 case MT_RELEASE_COMPLETE:
2925 PERROR("must be ignored by stack, not sent to app\n");
2929 // facility als broadcast
2933 PERROR("unhandled message: cmd(0x%x) pid(0x%x)\n", cmd, pid);
2937 if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT)
2939 pdss1 = (class Pdss1 *)port;
2940 /* check out correct stack */
2941 if (pdss1->p_m_mISDNport == mISDNport)
2942 /* check out correct id */
2943 PERROR("unhandled message: pid=%x is not associated with port-dinfo=%x\n", pid, pdss1->p_m_d_l3id);
2955 * sending message that were queued during L1 activation
2956 * or releasing port if link is down
2958 void setup_queue(struct mISDNport *mISDNport, int link)
2962 struct lcr_msg *message;
2964 if (!mISDNport->ntmode)
2967 /* check all port objects for pending message */
2971 if ((port->p_type&PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
2973 pdss1 = (class Pdss1 *)port;
2974 if (pdss1->p_m_mISDNport == mISDNport)
2976 if (pdss1->p_m_d_queue)
2980 PDEBUG(DEBUG_ISDN, "the L1 became active, so we send queued message for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
2981 /* LAYER 1 is up, so we send */
2982 pdss1->message_setup(pdss1->p_m_d_queue->id_from, pdss1->p_m_d_queue->type, &pdss1->p_m_d_queue->param);
2983 message_free(pdss1->p_m_d_queue);
2984 pdss1->p_m_d_queue = NULL;
2987 PDEBUG(DEBUG_ISDN, "the L1 became NOT active, so we release port for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
2988 message = message_create(pdss1->p_serial, pdss1->p_m_d_queue->id_from, PORT_TO_EPOINT, MESSAGE_RELEASE);
2989 message->param.disconnectinfo.cause = 27;
2990 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
2991 message_put(message);
2992 pdss1->new_state(PORT_STATE_RELEASE);
2993 pdss1->p_m_delete = 1;