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;
33 p_m_d_queue[0] = '\0';
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 */
48 if (p_m_d_notify_pending)
49 message_free(p_m_d_notify_pending);
54 * create layer 3 message
56 static struct l3_msg *create_l3msg(void)
64 FATAL("Cannot allocate memory, system overloaded.\n");
65 exit(0); // make gcc happy
69 * if we received a first reply to the setup message,
70 * we will check if we have now channel information
71 * return: <0: error, call is released, -cause is given
72 * 0: ok, nothing to do
74 int Pdss1::received_first_reply_to_setup(unsigned int cmd, int channel, int exclusive)
79 /* correct exclusive to 0, if no explicit channel was given */
80 if (exclusive<0 || channel<=0)
84 if (p_m_b_channel && p_m_b_exclusive) {
85 /*** we gave an exclusive channel (or if we are done) ***/
87 /* if not first reply, we are done */
88 if (p_state != PORT_STATE_OUT_SETUP)
91 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
92 add_trace("channel", "request", "%d (forced)", p_m_b_channel);
93 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
95 /* if give channel not accepted or not equal */
96 if (channel!=-1 && p_m_b_channel!=channel) {
97 add_trace("conclusion", NULL, "forced channel not accepted");
103 add_trace("conclusion", NULL, "channel was accepted");
104 add_trace("connect", "channel", "%d", p_m_b_channel);
107 /* activate our exclusive channel */
108 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
111 /*** we gave a non-exclusive channel ***/
113 /* if not first reply, we are done */
114 if (p_state != PORT_STATE_OUT_SETUP)
117 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
118 add_trace("channel", "request", "%d (suggest)", p_m_b_channel);
119 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
121 /* if channel was accepted as given */
122 if (channel==-1 || p_m_b_channel==channel) {
123 add_trace("conclusion", NULL, "channel was accepted as given");
124 add_trace("connect", "channel", "%d", p_m_b_channel);
126 p_m_b_exclusive = 1; // we are done
127 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
131 /* if channel value is faulty */
133 add_trace("conclusion", NULL, "illegal reply");
135 ret = -111; // protocol error
139 /* if channel was not accepted, try to get it */
140 ret = seize_bchannel(channel, 1); // exclusively
141 add_trace("channel", "available", ret<0?"no":"yes");
143 add_trace("conclusion", NULL, "replied channel not available");
147 add_trace("conclusion", NULL, "replied channel accepted");
148 add_trace("connect", "channel", "%d", p_m_b_channel);
151 /* activate channel given by remote */
152 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
155 /*** we sent 'any channel acceptable' ***/
157 /* if not first reply, we are done */
158 if (p_state != PORT_STATE_OUT_SETUP)
161 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
162 add_trace("channel", "request", "any");
163 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
164 /* if no channel was replied */
166 add_trace("conclusion", NULL, "no channel, protocol error");
168 ret = -111; // protocol error
172 /* we will see, if our received channel is available */
173 ret = seize_bchannel(channel, 1); // exclusively
174 add_trace("channel", "available", ret<0?"no":"yes");
176 add_trace("conclusion", NULL, "replied channel not available");
180 add_trace("conclusion", NULL, "replied channel accepted");
181 add_trace("connect", "channel", "%d", p_m_b_channel);
184 /* activate channel given by remote */
185 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
187 /*** we sent 'no channel available' ***/
189 /* if not the first reply, but a connect, we are forced */
190 if (cmd==MT_CONNECT && p_state!=PORT_STATE_OUT_SETUP) {
191 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (connect)", DIRECTION_NONE);
192 add_trace("channel", "request", "no-channel");
193 add_trace("channel", "reply", (channel>=0)?"%d%s":"(none)", channel, exclusive?" (forced)":"");
195 goto use_from_connect;
197 ret = seize_bchannel(CHANNEL_ANY, 0); // any channel
198 add_trace("channel", "available", ret<0?"no":"yes");
200 add_trace("conclusion", NULL, "no channel available during call-waiting");
204 add_trace("conclusion", NULL, "using channel %d", p_m_b_channel);
205 add_trace("connect", "channel", "%d", p_m_b_channel);
207 p_m_b_exclusive = 1; // we are done
209 /* activate channel given by remote */
210 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
214 /* if not first reply, we are done */
215 if (p_state != PORT_STATE_OUT_SETUP)
218 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
219 add_trace("channel", "request", "no-channel");
220 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
221 /* if first reply has no channel, we are done */
223 add_trace("conclusion", NULL, "no channel until connect");
228 /* we will see, if our received channel is available */
230 ret = seize_bchannel(channel, exclusive);
231 add_trace("channel", "available", ret<0?"no":"yes");
233 add_trace("conclusion", NULL, "replied channel not available");
237 add_trace("conclusion", NULL, "replied channel accepted");
238 add_trace("connect", "channel", "%d", p_m_b_channel);
240 p_m_b_exclusive = 1; // we are done
242 /* activate channel given by remote */
243 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
249 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
250 * in response to the setup reply
252 l3m = create_l3msg();
253 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
254 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
256 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
257 new_state(PORT_STATE_RELEASE);
259 return(-34); /* to epoint: no channel available */
264 * hunt bchannel for incoming setup or retrieve or resume
266 int Pdss1::hunt_bchannel(int channel, int exclusive)
268 struct select_channel *selchannel;
269 struct interface_port *ifport = p_m_mISDNport->ifport;
272 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (setup)", DIRECTION_NONE);
275 if (channel == CHANNEL_NO)
276 add_trace("channel", "request", "no-channel");
278 add_trace("channel", "request", (channel>0)?"%d%s":"any", channel, exclusive?" (forced)":"");
279 if (channel==CHANNEL_NO && p_type==PORT_TYPE_DSS1_TE_IN) {
280 add_trace("conclusion", NULL, "incoming call-waiting not supported for TE-mode");
282 return(-6); // channel unacceptable
284 if (channel <= 0) /* not given, no channel, whatever.. */
285 channel = CHANNEL_ANY; /* any channel */
286 add_trace("channel", "reserved", "%d", p_m_mISDNport->b_reserved);
287 if (p_m_mISDNport->b_reserved >= p_m_mISDNport->b_num) { // of out chan..
288 add_trace("conclusion", NULL, "all channels are reserved");
290 return(-34); // no channel
292 if (channel == CHANNEL_ANY)
295 /* check for given channel in selection list */
296 selchannel = ifport->in_channel;
298 if (selchannel->channel == channel || selchannel->channel == CHANNEL_FREE)
300 selchannel = selchannel->next;
305 /* exclusive channel requests must be in the list */
307 /* no exclusive channel */
309 add_trace("conclusion", NULL, "exclusively requested channel not in list");
311 return(-6); // channel unacceptable
313 /* get index for channel */
314 i = channel-1-(channel>=17);
315 if (i < 0 || i >= p_m_mISDNport->b_num || channel == 16) {
316 add_trace("conclusion", NULL, "exclusively requested channel outside interface range");
318 return(-6); // channel unacceptable
321 if (p_m_mISDNport->b_port[i] == NULL)
323 add_trace("conclusion", NULL, "exclusively requested channel is busy");
325 return(-6); // channel unacceptable
328 /* requested channels in list will be used */
330 /* get index for channel */
331 i = channel-1-(channel>=17);
332 if (i < 0 || i >= p_m_mISDNport->b_num || channel == 16) {
333 add_trace("info", NULL, "requested channel %d outside interface range", channel);
334 } else /* if inside range (else) check if available */
335 if (p_m_mISDNport->b_port[i] == NULL)
339 /* if channel is not available or not in list, it must be searched */
341 /* check for first free channel in list */
343 selchannel = ifport->in_channel;
345 switch(selchannel->channel) {
346 case CHANNEL_FREE: /* free channel */
347 add_trace("hunting", "channel", "free");
348 if (p_m_mISDNport->b_reserved >= p_m_mISDNport->b_num)
349 break; /* all channel in use or reserverd */
352 while(i < p_m_mISDNport->b_num) {
353 if (p_m_mISDNport->b_port[i] == NULL) {
354 channel = i+1+(i>=15);
362 add_trace("hunting", "channel", "%d", selchannel->channel);
363 if (selchannel->channel<1 || selchannel->channel==16)
364 break; /* invalid channels */
365 i = selchannel->channel-1-(selchannel->channel>=17);
366 if (i >= p_m_mISDNport->b_num)
367 break; /* channel not in port */
368 if (p_m_mISDNport->b_port[i] == NULL) {
369 channel = selchannel->channel;
375 break; /* found channel */
376 selchannel = selchannel->next;
379 add_trace("conclusion", NULL, "no channel available");
381 return(-6); // channel unacceptable
385 add_trace("conclusion", NULL, "channel available");
386 add_trace("connect", "channel", "%d", channel);
392 * handles all indications
394 /* CC_SETUP INDICATION */
395 void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
397 int calling_type, calling_plan, calling_present, calling_screen;
398 int calling_type2, calling_plan2, calling_present2, calling_screen2;
399 int called_type, called_plan;
400 int redir_type, redir_plan, redir_present, redir_screen, redir_reason;
401 int hlc_coding, hlc_presentation, hlc_interpretation, hlc_hlc, hlc_exthlc;
402 int bearer_coding, bearer_capability, bearer_mode, bearer_rate, bearer_multi, bearer_user;
403 int exclusive, channel;
405 unsigned char keypad[33] = "";
406 unsigned char useruser[128];
407 int useruser_len = 0, useruser_protocol;
408 class Endpoint *epoint;
409 struct lcr_msg *message;
411 /* process given callref */
412 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
413 add_trace("callref", "new", "0x%x", pid);
415 /* release in case the ID is already in use */
416 add_trace("error", NULL, "callref already in use");
418 l3m = create_l3msg();
419 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
420 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
421 add_trace("reason", NULL, "callref already in use");
423 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, pid, l3m);
424 new_state(PORT_STATE_RELEASE);
429 p_m_d_ces = pid >> 16;
432 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_IND, DIRECTION_IN);
433 dec_ie_calling_pn(l3m, &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id), &calling_type2, &calling_plan2, &calling_present2, &calling_screen2, (unsigned char *)p_callerinfo.id2, sizeof(p_callerinfo.id2));
434 dec_ie_called_pn(l3m, &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
435 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
436 /* te-mode: CNIP (calling name identification presentation) */
437 dec_facility_centrex(l3m, (unsigned char *)p_callerinfo.name, sizeof(p_callerinfo.name));
438 dec_ie_useruser(l3m, &useruser_protocol, useruser, &useruser_len);
439 dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
440 dec_ie_redir_nr(l3m, &redir_type, &redir_plan, &redir_present, &redir_screen, &redir_reason, (unsigned char *)p_redirinfo.id, sizeof(p_redirinfo.id));
441 dec_ie_channel_id(l3m, &exclusive, &channel);
442 dec_ie_hlc(l3m, &hlc_coding, &hlc_interpretation, &hlc_presentation, &hlc_hlc, &hlc_exthlc);
443 dec_ie_bearer(l3m, &bearer_coding, &bearer_capability, &bearer_mode, &bearer_rate, &bearer_multi, &bearer_user);
444 dec_ie_display(l3m, (unsigned char *)p_dialinginfo.display, sizeof(p_dialinginfo.display));
447 /* if blocked, release call with MT_RELEASE_COMPLETE */
448 if (p_m_mISDNport->ifport->block) {
449 l3m = create_l3msg();
450 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
451 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 27); /* temporary unavailable */
452 add_trace("reason", NULL, "port blocked");
454 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
455 new_state(PORT_STATE_RELEASE);
461 switch (calling_present) {
463 p_callerinfo.present = INFO_PRESENT_RESTRICTED;
466 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
469 p_callerinfo.present = INFO_PRESENT_ALLOWED;
472 switch (calling_screen) {
474 p_callerinfo.screen = INFO_SCREEN_USER;
477 p_callerinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
480 p_callerinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
483 p_callerinfo.screen = INFO_SCREEN_NETWORK;
486 switch (calling_type) {
488 p_callerinfo.ntype = INFO_NTYPE_NOTPRESENT;
491 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
494 p_callerinfo.ntype = INFO_NTYPE_INTERNATIONAL;
497 p_callerinfo.ntype = INFO_NTYPE_NATIONAL;
500 p_callerinfo.ntype = INFO_NTYPE_SUBSCRIBER;
503 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
506 p_callerinfo.isdn_port = p_m_portnum;
507 SCPY(p_callerinfo.interface, p_m_mISDNport->ifport->interface->name);
510 switch (calling_present2) {
512 p_callerinfo.present2 = INFO_PRESENT_RESTRICTED;
515 p_callerinfo.present2 = INFO_PRESENT_NOTAVAIL;
518 p_callerinfo.present2 = INFO_PRESENT_ALLOWED;
521 switch (calling_screen2) {
523 p_callerinfo.screen2 = INFO_SCREEN_USER;
526 p_callerinfo.screen2 = INFO_SCREEN_USER_VERIFIED_PASSED;
529 p_callerinfo.screen2 = INFO_SCREEN_USER_VERIFIED_FAILED;
532 p_callerinfo.screen2 = INFO_SCREEN_NETWORK;
535 switch (calling_type2) {
537 p_callerinfo.ntype2 = INFO_NTYPE_NOTPRESENT;
540 p_callerinfo.ntype2 = INFO_NTYPE_UNKNOWN;
543 p_callerinfo.ntype2 = INFO_NTYPE_INTERNATIONAL;
546 p_callerinfo.ntype2 = INFO_NTYPE_NATIONAL;
549 p_callerinfo.ntype2 = INFO_NTYPE_SUBSCRIBER;
552 p_callerinfo.ntype2 = INFO_NTYPE_UNKNOWN;
556 /* dialing information */
557 SCAT(p_dialinginfo.id, (char *)keypad);
558 switch (called_type) {
560 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
563 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
566 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
569 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
574 switch (redir_present) {
576 p_redirinfo.present = INFO_PRESENT_RESTRICTED;
579 p_redirinfo.present = INFO_PRESENT_NOTAVAIL;
582 p_redirinfo.present = INFO_PRESENT_ALLOWED;
585 switch (redir_screen) {
587 p_redirinfo.screen = INFO_SCREEN_USER;
590 p_redirinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
593 p_redirinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
596 p_redirinfo.screen = INFO_SCREEN_NETWORK;
599 switch (redir_reason) {
601 p_redirinfo.reason = INFO_REDIR_BUSY;
604 p_redirinfo.reason = INFO_REDIR_NORESPONSE;
607 p_redirinfo.reason = INFO_REDIR_UNCONDITIONAL;
610 p_redirinfo.reason = INFO_REDIR_CALLDEFLECT;
613 p_redirinfo.reason = INFO_REDIR_OUTOFORDER;
616 p_redirinfo.reason = INFO_REDIR_UNKNOWN;
619 switch (redir_type) {
621 p_redirinfo.ntype = INFO_NTYPE_NOTPRESENT;
624 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
627 p_redirinfo.ntype = INFO_NTYPE_INTERNATIONAL;
630 p_redirinfo.ntype = INFO_NTYPE_NATIONAL;
633 p_redirinfo.ntype = INFO_NTYPE_SUBSCRIBER;
636 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
639 p_redirinfo.isdn_port = p_m_portnum;
641 /* bearer capability */
642 switch (bearer_capability) {
644 p_capainfo.bearer_capa = INFO_BC_AUDIO;
645 bearer_user = (options.law=='a')?3:2;
648 p_capainfo.bearer_capa = bearer_capability;
651 switch (bearer_mode) {
653 p_capainfo.bearer_mode = INFO_BMODE_PACKET;
656 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
659 switch (bearer_user) {
661 p_capainfo.bearer_info1 = INFO_INFO1_NONE;
664 p_capainfo.bearer_info1 = bearer_user + 0x80;
671 p_capainfo.hlc = INFO_HLC_NONE;
674 p_capainfo.hlc = hlc_hlc + 0x80;
677 switch (hlc_exthlc) {
679 p_capainfo.exthlc = INFO_HLC_NONE;
682 p_capainfo.exthlc = hlc_exthlc + 0x80;
686 /* set bchannel mode */
687 if (p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED
688 || p_capainfo.bearer_capa==INFO_BC_DATARESTRICTED
689 || p_capainfo.bearer_capa==INFO_BC_VIDEO)
690 p_capainfo.source_mode = B_MODE_HDLC;
692 p_capainfo.source_mode = B_MODE_TRANSPARENT;
693 p_m_b_mode = p_capainfo.source_mode;
696 ret = channel = hunt_bchannel(channel, exclusive);
701 ret = seize_bchannel(channel, 1);
705 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
706 * in response to the setup
708 l3m = create_l3msg();
709 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
710 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
712 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
713 new_state(PORT_STATE_RELEASE);
717 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
719 /* create endpoint */
721 FATAL("Incoming call but already got an endpoint.\n");
722 if (!(epoint = new Endpoint(p_serial, 0)))
723 FATAL("No memory for Endpoint instance\n");
724 if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 0))) //incoming
725 FATAL("No memory for Endpoint Application instance\n");
726 epointlist_new(epoint->ep_serial);
728 /* send setup message to endpoit */
729 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
730 message->param.setup.isdn_port = p_m_portnum;
731 message->param.setup.port_type = p_type;
732 // message->param.setup.dtmf = !p_m_mISDNport->ifport->nodtmf;
733 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
734 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
735 memcpy(&message->param.setup.redirinfo, &p_redirinfo, sizeof(struct redir_info));
736 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
737 memcpy(message->param.setup.useruser.data, &useruser, useruser_len);
738 message->param.setup.useruser.len = useruser_len;
739 message->param.setup.useruser.protocol = useruser_protocol;
740 message_put(message);
742 new_state(PORT_STATE_IN_SETUP);
745 /* CC_INFORMATION INDICATION */
746 void Pdss1::information_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
749 unsigned char keypad[33] = "", display[128] = "";
750 struct lcr_msg *message;
752 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_IND, DIRECTION_IN);
753 dec_ie_called_pn(l3m, &type, &plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
754 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
755 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
756 dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
759 SCAT(p_dialinginfo.id, (char *)keypad);
762 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
765 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
768 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
771 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
774 SCPY(p_dialinginfo.display, (char *)display);
775 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_INFORMATION);
776 memcpy(&message->param.information, &p_dialinginfo, sizeof(struct dialing_info));
777 message_put(message);
778 /* reset overlap timeout */
782 /* CC_SETUP_ACCNOWLEDGE INDICATION */
783 void Pdss1::setup_acknowledge_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
785 int exclusive, channel;
786 int coding, location, progress;
788 struct lcr_msg *message;
789 int max = p_m_mISDNport->ifport->dialmax;
793 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_IND, DIRECTION_IN);
794 dec_ie_channel_id(l3m, &exclusive, &channel);
795 dec_ie_progress(l3m, &coding, &location, &progress);
798 /* process channel */
799 ret = received_first_reply_to_setup(cmd, channel, exclusive);
801 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
802 message->param.disconnectinfo.cause = -ret;
803 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
804 message_put(message);
805 new_state(PORT_STATE_RELEASE);
810 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_OVERLAP);
811 message_put(message);
813 new_state(PORT_STATE_OUT_OVERLAP);
815 number = p_m_d_queue;
816 while (number[0]) { /* as long we have something to dial */
817 if (max > (int)strlen(number) || max == 0)
818 max = (int)strlen(number);
820 nl3m = create_l3msg();
821 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
822 enc_ie_called_pn(nl3m, 0, 1, (unsigned char *)number, max);
824 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, nl3m);
827 p_m_d_queue[0] = '\0';
830 /* CC_PROCEEDING INDICATION */
831 void Pdss1::proceeding_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
833 int exclusive, channel;
834 int coding, location, progress;
836 struct lcr_msg *message;
837 int notify = -1, type, plan, present;
840 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_IND, DIRECTION_IN);
841 dec_ie_channel_id(l3m, &exclusive, &channel);
842 dec_ie_progress(l3m, &coding, &location, &progress);
843 dec_ie_notify(l3m, ¬ify);
844 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
847 ret = received_first_reply_to_setup(cmd, channel, exclusive);
849 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
850 message->param.disconnectinfo.cause = -ret;
851 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
852 message_put(message);
853 new_state(PORT_STATE_RELEASE);
857 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
858 message_put(message);
860 new_state(PORT_STATE_OUT_PROCEEDING);
866 if (type >= 0 || notify) {
867 if (!notify && type >= 0)
869 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
870 message->param.notifyinfo.notify = notify;
871 SCPY(message->param.notifyinfo.id, redir);
872 /* redirection number */
875 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
878 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
881 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
886 message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT;
889 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
892 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
895 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
898 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
901 message->param.notifyinfo.isdn_port = p_m_portnum;
902 message_put(message);
906 /* CC_ALERTING INDICATION */
907 void Pdss1::alerting_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
909 int exclusive, channel;
910 int coding, location, progress;
912 struct lcr_msg *message;
913 int notify = -1, type, plan, present;
916 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_IND, DIRECTION_IN);
917 dec_ie_channel_id(l3m, &exclusive, &channel);
918 dec_ie_progress(l3m, &coding, &location, &progress);
919 dec_ie_notify(l3m, ¬ify);
920 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
923 /* process channel */
924 ret = received_first_reply_to_setup(cmd, channel, exclusive);
926 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
927 message->param.disconnectinfo.cause = -ret;
928 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
929 message_put(message);
930 new_state(PORT_STATE_RELEASE);
934 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ALERTING);
935 message_put(message);
937 new_state(PORT_STATE_OUT_ALERTING);
943 if (type >= 0 || notify) {
944 if (!notify && type >= 0)
946 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
947 message->param.notifyinfo.notify = notify;
948 SCPY(message->param.notifyinfo.id, redir);
951 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
954 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
957 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
962 message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT;
965 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
968 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
971 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
974 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
977 message->param.notifyinfo.isdn_port = p_m_portnum;
978 message_put(message);
982 /* CC_CONNECT INDICATION */
983 void Pdss1::connect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
985 int exclusive, channel;
986 int type, plan, present, screen;
988 struct lcr_msg *message;
991 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_IND, DIRECTION_IN);
992 dec_ie_channel_id(l3m, &exclusive, &channel);
993 dec_ie_connected_pn(l3m, &type, &plan, &present, &screen, (unsigned char *)p_connectinfo.id, sizeof(p_connectinfo.id));
994 dec_ie_display(l3m, (unsigned char *)p_connectinfo.display, sizeof(p_connectinfo.display));
995 /* te-mode: CONP (connected name identification presentation) */
996 dec_facility_centrex(l3m, (unsigned char *)p_connectinfo.name, sizeof(p_connectinfo.name));
1000 bchannel_before = p_m_b_channel;
1001 ret = received_first_reply_to_setup(cmd, channel, exclusive);
1003 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1004 message->param.disconnectinfo.cause = -ret;
1005 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1006 message_put(message);
1007 new_state(PORT_STATE_RELEASE);
1012 /* connect information */
1015 p_connectinfo.present = INFO_PRESENT_RESTRICTED;
1018 p_connectinfo.present = INFO_PRESENT_NOTAVAIL;
1021 p_connectinfo.present = INFO_PRESENT_ALLOWED;
1026 p_connectinfo.screen = INFO_SCREEN_USER;
1029 p_connectinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
1032 p_connectinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
1035 p_connectinfo.screen = INFO_SCREEN_NETWORK;
1040 p_connectinfo.ntype = INFO_NTYPE_NOTPRESENT;
1043 p_connectinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1046 p_connectinfo.ntype = INFO_NTYPE_NATIONAL;
1049 p_connectinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1052 p_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
1055 p_connectinfo.isdn_port = p_m_portnum;
1056 SCPY(p_connectinfo.interface, p_m_mISDNport->ifport->interface->name);
1058 /* only in nt-mode we send connect ack. in te-mode it is done by stack itself or optional */
1060 /* send connect acknowledge */
1061 l3m = create_l3msg();
1062 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_RES, DIRECTION_OUT);
1063 /* if we had no bchannel before, we send it now */
1064 if (!bchannel_before && p_m_b_channel)
1065 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1067 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT_ACKNOWLEDGE, p_m_d_l3id, l3m);
1070 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_CONNECT);
1071 memcpy(&message->param.connectinfo, &p_connectinfo, sizeof(struct connect_info));
1072 message_put(message);
1074 new_state(PORT_STATE_CONNECT);
1077 /* CC_DISCONNECT INDICATION */
1078 void Pdss1::disconnect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1080 int location, cause;
1081 int coding, proglocation, progress;
1082 struct lcr_msg *message;
1083 unsigned char display[128] = "";
1085 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1086 dec_ie_progress(l3m, &coding, &proglocation, &progress);
1087 dec_ie_cause(l3m, &location, &cause);
1088 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1093 location = LOCATION_PRIVATE_LOCAL;
1096 /* release if remote sends us no tones */
1097 if (!p_m_mISDNport->earlyb) {
1100 l3m = create_l3msg();
1101 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
1102 enc_ie_cause(l3m, location, cause); /* normal */
1103 add_trace("reason", NULL, "no remote patterns");
1105 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
1107 /* sending release to endpoint */
1108 if (location == LOCATION_PRIVATE_LOCAL)
1109 location = LOCATION_PRIVATE_REMOTE;
1110 while(p_epointlist) {
1111 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1112 message->param.disconnectinfo.cause = cause;
1113 message->param.disconnectinfo.location = location;
1114 SCAT(message->param.disconnectinfo.display, (char *)display);
1115 message_put(message);
1117 free_epointlist(p_epointlist);
1119 new_state(PORT_STATE_RELEASE);
1124 /* sending disconnect to active endpoint and release to inactive endpoints */
1125 if (location == LOCATION_PRIVATE_LOCAL)
1126 location = LOCATION_PRIVATE_REMOTE;
1127 if (ACTIVE_EPOINT(p_epointlist)) {
1128 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_DISCONNECT);
1129 message->param.disconnectinfo.location = location;
1130 message->param.disconnectinfo.cause = cause;
1131 SCAT(message->param.disconnectinfo.display, (char *)display);
1132 message_put(message);
1134 while(INACTIVE_EPOINT(p_epointlist)) {
1135 message = message_create(p_serial, INACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1136 message->param.disconnectinfo.location = location;
1137 message->param.disconnectinfo.cause = cause;
1138 SCAT(message->param.disconnectinfo.display, (char *)display);
1139 message_put(message);
1141 free_epointid(INACTIVE_EPOINT(p_epointlist));
1143 new_state(PORT_STATE_IN_DISCONNECT);
1146 /* CC_DISCONNECT INDICATION */
1147 void Pdss1::disconnect_ind_i(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1149 int location, cause;
1152 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1153 if (p_m_d_collect_cause > 0) {
1154 add_trace("old-cause", "location", "%d", p_m_d_collect_location);
1155 add_trace("old-cause", "value", "%d", p_m_d_collect_cause);
1157 dec_ie_cause(l3m, &location, &cause);
1158 if (location == LOCATION_PRIVATE_LOCAL)
1159 location = LOCATION_PRIVATE_REMOTE;
1162 collect_cause(&p_m_d_collect_cause, &p_m_d_collect_location, cause, location);
1163 add_trace("new-cause", "location", "%d", p_m_d_collect_location);
1164 add_trace("new-cause", "value", "%d", p_m_d_collect_cause);
1169 /* CC_RELEASE INDICATION */
1170 void Pdss1::release_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1172 int location, cause;
1173 struct lcr_msg *message;
1174 unsigned char display[128] = "";
1176 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_IND, DIRECTION_IN);
1177 dec_ie_cause(l3m, &location, &cause);
1178 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1183 location = LOCATION_PRIVATE_LOCAL;
1186 /* sending release to endpoint */
1187 if (location == LOCATION_PRIVATE_LOCAL)
1188 location = LOCATION_PRIVATE_REMOTE;
1189 while(p_epointlist) {
1190 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1191 message->param.disconnectinfo.cause = cause;
1192 message->param.disconnectinfo.location = location;
1193 SCAT(message->param.disconnectinfo.display, (char *)display);
1194 message_put(message);
1196 free_epointlist(p_epointlist);
1199 new_state(PORT_STATE_RELEASE);
1203 /* CC_RESTART INDICATION */
1204 void Pdss1::restart_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1206 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESTART_IND, DIRECTION_IN);
1209 // L3 process is not toucht. (not even by network stack)
1212 /* CC_RELEASE_COMPLETE INDICATION (a reject) */
1213 void Pdss1::release_complete_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1215 int location, cause;
1216 struct lcr_msg *message;
1218 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_IND, DIRECTION_IN);
1219 /* in case layer 2 is down during setup, we send cause 27 loc 5 */
1220 if (p_state == PORT_STATE_OUT_SETUP && p_m_mISDNport->l1link == 0) {
1224 dec_ie_cause(l3m, &location, &cause);
1225 if (p_m_mISDNport->l1link < 0)
1226 add_trace("layer 1", NULL, "unknown");
1228 add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
1231 if (location == LOCATION_PRIVATE_LOCAL)
1232 location = LOCATION_PRIVATE_REMOTE;
1236 location = LOCATION_PRIVATE_LOCAL;
1239 /* sending release to endpoint */
1240 while(p_epointlist) {
1241 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1242 message->param.disconnectinfo.cause = cause;
1243 message->param.disconnectinfo.location = location;
1244 message_put(message);
1246 free_epointlist(p_epointlist);
1249 new_state(PORT_STATE_RELEASE);
1254 void Pdss1::t312_timeout_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1256 // not required, release is performed with MT_FREE
1259 /* CC_NOTIFY INDICATION */
1260 void Pdss1::notify_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1262 struct lcr_msg *message;
1263 int notify, type, plan, present;
1264 unsigned char notifyid[sizeof(message->param.notifyinfo.id)];
1265 unsigned char display[128] = "";
1267 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_IND, DIRECTION_IN);
1268 dec_ie_notify(l3m, ¬ify);
1269 dec_ie_redir_dn(l3m, &type, &plan, &present, notifyid, sizeof(notifyid));
1270 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1273 if (!ACTIVE_EPOINT(p_epointlist))
1275 /* notification indicator */
1279 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1280 message->param.notifyinfo.notify = notify;
1281 SCPY(message->param.notifyinfo.id, (char *)notifyid);
1282 /* redirection number */
1285 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
1288 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
1291 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
1296 message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT;
1299 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1302 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
1305 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1308 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1311 SCAT(message->param.notifyinfo.display, (char *)display);
1312 message->param.notifyinfo.isdn_port = p_m_portnum;
1313 message_put(message);
1317 /* CC_HOLD INDICATION */
1318 struct lcr_msg *message;
1319 void Pdss1::hold_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1321 // class Endpoint *epoint;
1323 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_IND, DIRECTION_IN);
1326 if (!ACTIVE_EPOINT(p_epointlist) || p_m_hold) {
1327 l3m = create_l3msg();
1328 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_REJECT_REQ, DIRECTION_OUT);
1329 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */
1330 add_trace("reason", NULL, "no endpoint");
1332 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_REJECT, p_m_d_l3id, l3m);
1337 /* notify the hold of call */
1338 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1339 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_HOLD;
1340 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1341 message_put(message);
1343 /* deactivate bchannel */
1344 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (hold)", DIRECTION_NONE);
1345 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1349 /* set hold state */
1352 epoint = find_epoint_id(ACTIVE_EPOINT(p_epointlist));
1353 if (epoint && p_m_d_ntmode) {
1354 p_m_timeout = p_settings.tout_hold;
1359 /* acknowledge hold */
1360 l3m = create_l3msg();
1361 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1363 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_ACKNOWLEDGE, p_m_d_l3id, l3m);
1367 /* CC_RETRIEVE INDICATION */
1368 void Pdss1::retrieve_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1370 struct lcr_msg *message;
1371 int channel, exclusive, cause;
1374 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_IND, DIRECTION_IN);
1375 dec_ie_channel_id(l3m, &exclusive, &channel);
1379 cause = 101; /* incompatible state */
1382 l3m = create_l3msg();
1383 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_REJECT_REQ, DIRECTION_OUT);
1384 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, cause);
1386 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_REJECT, p_m_d_l3id, l3m);
1391 /* notify the retrieve of call */
1392 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1393 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL;
1394 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1395 message_put(message);
1398 ret = channel = hunt_bchannel(channel, exclusive);
1403 ret = seize_bchannel(channel, 1);
1409 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1411 /* set hold state */
1415 /* acknowledge retrieve */
1416 l3m = create_l3msg();
1417 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1418 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1420 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_ACKNOWLEDGE, p_m_d_l3id, l3m);
1423 /* CC_SUSPEND INDICATION */
1424 void Pdss1::suspend_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1426 struct lcr_msg *message;
1427 class Endpoint *epoint;
1428 unsigned char callid[8];
1430 int ret = -31; /* normal, unspecified */
1432 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_IND, DIRECTION_IN);
1433 dec_ie_call_id(l3m, callid, &len);
1436 if (!ACTIVE_EPOINT(p_epointlist)) {
1438 l3m = create_l3msg();
1439 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_REJECT_REQ, DIRECTION_OUT);
1440 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1442 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_REJECT, p_m_d_l3id, l3m);
1449 /* check if call id is in use */
1450 epoint = epoint_first;
1452 if (epoint->ep_park) {
1453 if (epoint->ep_park_len == len)
1454 if (!memcmp(epoint->ep_park_callid, callid, len)) {
1455 ret = -84; /* call id in use */
1459 epoint = epoint->next;
1462 /* notify the hold of call */
1463 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1464 message->param.notifyinfo.notify = INFO_NOTIFY_USER_SUSPENDED;
1465 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1466 message_put(message);
1468 /* deactivate bchannel */
1469 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (suspend)", DIRECTION_NONE);
1470 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1474 /* sending suspend to endpoint */
1475 while (p_epointlist) {
1476 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_SUSPEND);
1477 memcpy(message->param.parkinfo.callid, callid, sizeof(message->param.parkinfo.callid));
1478 message->param.parkinfo.len = len;
1479 message_put(message);
1481 free_epointlist(p_epointlist);
1484 /* sending SUSPEND_ACKNOWLEDGE */
1485 l3m = create_l3msg();
1486 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1488 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_ACKNOWLEDGE, p_m_d_l3id, l3m);
1490 new_state(PORT_STATE_RELEASE);
1494 /* CC_RESUME INDICATION */
1495 void Pdss1::resume_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1497 unsigned char callid[8];
1499 int channel, exclusive;
1500 class Endpoint *epoint;
1501 struct lcr_msg *message;
1504 /* process given callref */
1505 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
1506 add_trace("callref", "new", "0x%x", pid);
1508 /* release is case the ID is already in use */
1509 add_trace("error", NULL, "callref already in use");
1511 l3m = create_l3msg();
1512 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1513 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
1514 add_trace("reason", NULL, "callref already in use");
1516 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, pid, l3m);
1517 new_state(PORT_STATE_RELEASE);
1522 p_m_d_ces = pid >> 16;
1525 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_IND, DIRECTION_IN);
1526 dec_ie_call_id(l3m, callid, &len);
1529 /* if blocked, release call */
1530 if (p_m_mISDNport->ifport->block) {
1538 /* channel_id (no channel is possible in message) */
1540 channel = -1; /* any channel */
1543 ret = channel = hunt_bchannel(channel, exclusive);
1547 // mode (if hdlc parked) to be done. never mind, this is almost never requested
1549 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;
1572 if (epoint->ep_park) {
1573 ret = -83; /* suspended call exists, but this not */
1574 if (epoint->ep_park_len == len)
1575 if (!memcmp(epoint->ep_park_callid, callid, len))
1578 epoint = epoint->next;
1583 epointlist_new(epoint->ep_serial);
1584 if (!(epoint->portlist_new(p_serial, p_type, p_m_mISDNport->earlyb)))
1585 FATAL("No memory for portlist\n");
1586 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RESUME);
1587 message_put(message);
1589 /* notify the resume of call */
1590 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1591 message->param.notifyinfo.notify = INFO_NOTIFY_USER_RESUMED;
1592 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1593 message_put(message);
1595 /* sending RESUME_ACKNOWLEDGE */
1596 l3m = create_l3msg();
1597 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1598 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1600 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_ACKNOWLEDGE, p_m_d_l3id, l3m);
1602 new_state(PORT_STATE_CONNECT);
1606 /* CC_FACILITY INDICATION */
1607 void Pdss1::facility_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1609 unsigned char facil[256];
1611 struct lcr_msg *message;
1613 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_IND, DIRECTION_IN);
1614 dec_ie_facility(l3m, facil, &facil_len);
1621 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_FACILITY);
1622 message->param.facilityinfo.len = facil_len;
1623 memcpy(message->param.facilityinfo.data, facil, facil_len);
1624 message_put(message);
1628 /* CC_PROGRESS INDICATION */
1629 void Pdss1::progress_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1631 int coding, location, progress;
1633 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROGRESS_IND, DIRECTION_IN);
1634 dec_ie_progress(l3m, &coding, &location, &progress);
1640 * handler for isdn connections
1641 * incoming information are parsed and sent via message to the endpoint
1643 void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1650 PERROR("Pdss1(%s) timeout without cause.\n", p_name);
1653 if (l3m->cause[0] != 5) {
1654 PERROR("Pdss1(%s) expecting timeout with timer diagnostic. (got len=%d)\n", p_name, l3m->cause[0]);
1657 timer = (l3m->cause[3]-'0')*100;
1658 timer += (l3m->cause[4]-'0')*10;
1659 timer += (l3m->cause[5]-'0');
1660 l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN);
1661 add_trace("timer", NULL, "%d", timer);
1664 t312_timeout_ind(cmd, pid, l3m);
1668 if (p_state != PORT_STATE_IDLE)
1670 setup_ind(cmd, pid, l3m);
1673 case MT_INFORMATION:
1674 information_ind(cmd, pid, l3m);
1677 case MT_SETUP_ACKNOWLEDGE:
1678 if (p_state != PORT_STATE_OUT_SETUP) {
1679 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received setup_acknowledge, but we are not in outgoing setup state, IGNORING.\n", p_name);
1682 setup_acknowledge_ind(cmd, pid, l3m);
1685 case MT_CALL_PROCEEDING:
1686 if (p_state != PORT_STATE_OUT_SETUP
1687 && p_state != PORT_STATE_OUT_OVERLAP) {
1688 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received proceeding, but we are not in outgoing setup OR overlap state, IGNORING.\n", p_name);
1691 proceeding_ind(cmd, pid, l3m);
1695 if (p_state != PORT_STATE_OUT_SETUP
1696 && p_state != PORT_STATE_OUT_OVERLAP
1697 && p_state != PORT_STATE_OUT_PROCEEDING) {
1698 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding state, IGNORING.\n", p_name);
1701 alerting_ind(cmd, pid, l3m);
1705 if (p_state != PORT_STATE_OUT_SETUP
1706 && p_state != PORT_STATE_OUT_OVERLAP
1707 && p_state != PORT_STATE_OUT_PROCEEDING
1708 && p_state != PORT_STATE_OUT_ALERTING) {
1709 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);
1712 connect_ind(cmd, pid, l3m);
1713 if (p_m_d_notify_pending) {
1714 /* send pending notify message during connect */
1715 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1716 message_free(p_m_d_notify_pending);
1717 p_m_d_notify_pending = NULL;
1721 case MT_CONNECT_ACKNOWLEDGE:
1722 if (p_state == PORT_STATE_CONNECT_WAITING)
1723 new_state(PORT_STATE_CONNECT);
1724 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 progress_ind(cmd, pid, l3m);
1777 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_L3ID_IND, DIRECTION_IN);
1778 add_trace("callref", NULL, "0x%x", p_m_d_l3id);
1783 /* sending release to endpoint in case we still have an endpoint
1784 * this is because we don't get any response if a release_complete is received (or a release in release state)
1786 while(p_epointlist) { // only if not already released
1787 struct lcr_msg *message;
1788 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1789 if (p_m_d_collect_cause) {
1790 message->param.disconnectinfo.cause = p_m_d_collect_cause;
1791 message->param.disconnectinfo.location = p_m_d_collect_location;
1793 message->param.disconnectinfo.cause = CAUSE_NOUSER;
1794 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1796 message_put(message);
1798 free_epointlist(p_epointlist);
1800 new_state(PORT_STATE_RELEASE);
1805 l1l2l3_trace_header(p_m_mISDNport, this, L3_UNKNOWN_IND, DIRECTION_IN);
1806 add_trace("unhandled", "cmd", "0x%x", cmd);
1811 void Pdss1::new_state(int state)
1813 // class Endpoint *epoint;
1816 if (state == PORT_STATE_IN_OVERLAP) {
1817 p_m_timeout = p_m_mISDNport->ifport->tout_dialing;
1820 if (state != p_state) {
1821 if (state == PORT_STATE_IN_SETUP
1822 || state == PORT_STATE_OUT_SETUP
1823 || state == PORT_STATE_IN_OVERLAP
1824 || state == PORT_STATE_OUT_OVERLAP) {
1825 p_m_timeout = p_m_mISDNport->ifport->tout_setup;
1828 if (state == PORT_STATE_IN_PROCEEDING
1829 || state == PORT_STATE_OUT_PROCEEDING) {
1830 p_m_timeout = p_m_mISDNport->ifport->tout_proceeding;
1833 if (state == PORT_STATE_IN_ALERTING
1834 || state == PORT_STATE_OUT_ALERTING) {
1835 p_m_timeout = p_m_mISDNport->ifport->tout_alerting;
1838 if (state == PORT_STATE_CONNECT
1839 || state == PORT_STATE_CONNECT_WAITING) {
1842 if (state == PORT_STATE_IN_DISCONNECT
1843 || state == PORT_STATE_OUT_DISCONNECT) {
1844 p_m_timeout = p_m_mISDNport->ifport->tout_disconnect;
1849 Port::new_state(state);
1856 int Pdss1::handler(void)
1860 if ((ret = PmISDN::handler()))
1863 /* handle destruction */
1864 if (p_m_delete && p_m_d_l3id==0) {
1874 * handles all messages from endpoint
1876 /* MESSAGE_INFORMATION */
1877 void Pdss1::message_information(unsigned int epoint_id, int message_id, union parameter *param)
1880 char *display = param->information.display;
1881 char *number = param->information.id;
1882 int max = p_m_mISDNport->ifport->dialmax;
1884 while (number[0]) { /* as long we have something to dial */
1885 if (max > (int)strlen(number) || max == 0)
1886 max = (int)strlen(number);
1888 l3m = create_l3msg();
1889 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1890 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)number, max);
1891 if ((p_m_d_ntmode || p_m_d_tespecial) && display[0]) {
1892 enc_ie_display(l3m, (unsigned char *)display);
1893 display = (char *)"";
1896 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1904 void Pdss1::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
1908 int plan, type, screen, present, reason;
1909 int plan2, type2, screen2, present2;
1910 int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
1911 int channel, exclusive;
1912 struct epoint_list *epointlist;
1913 int max = p_m_mISDNport->ifport->dialmax;
1915 /* release if port is blocked */
1916 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 /* screen outgoing caller id */
1934 do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_m_mISDNport->ifport->interface);
1935 do_screen(1, p_callerinfo.id2, sizeof(p_callerinfo.id2), &p_callerinfo.ntype2, &p_callerinfo.present2, 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) {
1939 if (p_type!=PORT_TYPE_DSS1_NT_OUT
1940 && p_type!=PORT_TYPE_DSS1_NT_IN)
1942 if (p_callerinfo.display[0]) {
1943 /* sending information */
1944 l3m = create_l3msg();
1945 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1946 if (p_m_d_ntmode || p_m_d_tespecial)
1947 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
1949 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
1954 /* attach only if not already */
1955 epointlist = p_epointlist;
1957 if (epointlist->epoint_id == epoint_id)
1959 epointlist = epointlist->next;
1962 epointlist_new(epoint_id);
1966 if (p_m_b_channel) {
1967 channel = p_m_b_channel;
1968 exclusive = p_m_b_exclusive;
1970 channel = CHANNEL_ANY;
1971 /* nt-port with no channel, not reserverd */
1972 if (!p_m_b_channel && !p_m_b_reserve && p_type==PORT_TYPE_DSS1_NT_OUT)
1973 channel = CHANNEL_NO;
1976 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT);
1977 /* see MT_ASSIGN notes at do_layer3() */
1979 ret = p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ASSIGN, 0, NULL);
1980 if (mt_assign_pid == 0 || ret < 0) {
1981 struct lcr_msg *message;
1983 add_trace("callref", NULL, "no free id");
1985 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1986 message->param.disconnectinfo.cause = 47;
1987 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1988 message_put(message);
1989 new_state(PORT_STATE_RELEASE);
1993 p_m_d_l3id = mt_assign_pid;
1995 add_trace("callref", "new", "0x%x", p_m_d_l3id);
1998 /* preparing setup message */
1999 l3m = create_l3msg();
2000 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_REQ, DIRECTION_OUT);
2001 /* channel information */
2002 if (channel >= 0) /* it should */
2003 enc_ie_channel_id(l3m, exclusive, channel);
2004 /* caller information */
2006 switch (p_callerinfo.ntype) {
2007 case INFO_NTYPE_UNKNOWN:
2010 case INFO_NTYPE_INTERNATIONAL:
2013 case INFO_NTYPE_NATIONAL:
2016 case INFO_NTYPE_SUBSCRIBER:
2019 default: /* INFO_NTYPE_NOTPRESENT */
2023 switch (p_callerinfo.screen) {
2024 case INFO_SCREEN_USER:
2027 case INFO_SCREEN_USER_VERIFIED_PASSED:
2030 case INFO_SCREEN_USER_VERIFIED_FAILED:
2033 default: /* INFO_SCREEN_NETWORK */
2037 switch (p_callerinfo.present) {
2038 case INFO_PRESENT_ALLOWED:
2041 case INFO_PRESENT_RESTRICTED:
2044 default: /* INFO_PRESENT_NOTAVAIL */
2048 /* caller information 2 */
2050 switch (p_callerinfo.ntype2) {
2051 case INFO_NTYPE_UNKNOWN:
2054 case INFO_NTYPE_INTERNATIONAL:
2057 case INFO_NTYPE_NATIONAL:
2060 case INFO_NTYPE_SUBSCRIBER:
2063 default: /* INFO_NTYPE_NOTPRESENT */
2067 switch (p_callerinfo.screen2) {
2068 case INFO_SCREEN_USER:
2071 case INFO_SCREEN_USER_VERIFIED_PASSED:
2074 case INFO_SCREEN_USER_VERIFIED_FAILED:
2077 default: /* INFO_SCREEN_NETWORK */
2081 switch (p_callerinfo.present2) {
2082 case INFO_PRESENT_ALLOWED:
2085 case INFO_PRESENT_RESTRICTED:
2088 default: /* INFO_PRESENT_NOTAVAIL */
2093 enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id, type2, plan2, present2, screen2, (unsigned char *)p_callerinfo.id2);
2094 /* dialing information */
2095 if (p_dialinginfo.id[0]) { /* only if we have something to dial */
2096 if (max > (int)strlen(p_dialinginfo.id) || max == 0)
2097 max = (int)strlen(p_dialinginfo.id);
2098 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id, max);
2099 SCPY(p_m_d_queue, p_dialinginfo.id + max);
2102 if (p_dialinginfo.keypad[0])
2103 enc_ie_keypad(l3m, (unsigned char *)p_dialinginfo.keypad);
2104 /* sending complete */
2105 if (p_dialinginfo.sending_complete)
2106 enc_ie_complete(l3m, 1);
2107 /* sending user-user */
2108 if (param->setup.useruser.len) {
2109 enc_ie_useruser(l3m, param->setup.useruser.protocol, param->setup.useruser.data, param->setup.useruser.len);
2111 /* redirecting number */
2113 switch (p_redirinfo.ntype) {
2114 case INFO_NTYPE_UNKNOWN:
2117 case INFO_NTYPE_INTERNATIONAL:
2120 case INFO_NTYPE_NATIONAL:
2123 case INFO_NTYPE_SUBSCRIBER:
2126 default: /* INFO_NTYPE_NOTPRESENT */
2130 switch (p_redirinfo.screen) {
2131 case INFO_SCREEN_USER:
2134 case INFO_SCREEN_USER_VERIFIED_PASSED:
2137 case INFO_SCREEN_USER_VERIFIED_FAILED:
2140 default: /* INFO_SCREE_NETWORK */
2144 switch (p_redirinfo.reason) {
2145 case INFO_REDIR_BUSY:
2148 case INFO_REDIR_NORESPONSE:
2151 case INFO_REDIR_UNCONDITIONAL:
2154 case INFO_REDIR_CALLDEFLECT:
2157 case INFO_REDIR_OUTOFORDER:
2160 default: /* INFO_REDIR_UNKNOWN */
2164 switch (p_redirinfo.present) {
2165 case INFO_PRESENT_ALLOWED:
2168 case INFO_PRESENT_RESTRICTED:
2171 default: /* INFO_PRESENT_NOTAVAIL */
2175 /* sending redirecting number only in ntmode */
2176 if (type >= 0 && (p_m_d_ntmode || p_m_d_tespecial))
2177 enc_ie_redir_nr(l3m, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
2178 /* bearer capability */
2179 //printf("hlc=%d\n",p_capainfo.hlc);
2181 capability = p_capainfo.bearer_capa;
2182 mode = p_capainfo.bearer_mode;
2183 rate = (mode==INFO_BMODE_CIRCUIT)?0x10:0x00;
2184 switch (p_capainfo.bearer_info1) {
2185 case INFO_INFO1_NONE:
2189 user = p_capainfo.bearer_info1 & 0x7f;
2192 enc_ie_bearer(l3m, coding, capability, mode, rate, -1, user);
2194 if (p_capainfo.hlc) {
2198 hlc = p_capainfo.hlc & 0x7f;
2200 if (p_capainfo.exthlc)
2201 exthlc = p_capainfo.exthlc & 0x7f;
2202 enc_ie_hlc(l3m, coding, interpretation, presentation, hlc, exthlc);
2206 if (p_callerinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2207 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
2208 /* nt-mode: CNIP (calling name identification presentation) */
2209 // if (p_callerinfo.name[0] && (p_m_d_ntmode || p_m_d_tespecial))
2210 // enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
2213 /* send setup message now */
2214 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP, p_m_d_l3id, l3m);
2216 new_state(PORT_STATE_OUT_SETUP);
2219 /* MESSAGE_FACILITY */
2220 void Pdss1::message_facility(unsigned int epoint_id, int message_id, union parameter *param)
2224 /* facility will not be sent to external lines */
2225 if (!p_m_d_ntmode && !p_m_d_tespecial)
2228 /* sending facility */
2229 l3m = create_l3msg();
2230 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
2231 enc_ie_facility(l3m, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len);
2233 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
2236 /* MESSAGE_NOTIFY */
2237 void Pdss1::message_notify(unsigned int epoint_id, int message_id, union parameter *param)
2241 int plan = 0, type = -1, present = 0;
2243 if (p_m_mISDNport->ifport->nonotify) {
2244 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
2245 add_trace("info", NULL, "blocked by config");
2250 // printf("if = %d\n", param->notifyinfo.notify);
2251 if (param->notifyinfo.notify>INFO_NOTIFY_NONE)
2252 notify = param->notifyinfo.notify & 0x7f;
2257 switch (param->notifyinfo.ntype) {
2258 case INFO_NTYPE_UNKNOWN:
2261 case INFO_NTYPE_INTERNATIONAL:
2264 case INFO_NTYPE_NATIONAL:
2267 case INFO_NTYPE_SUBSCRIBER:
2270 default: /* INFO_NTYPE_UNKNOWN */
2274 switch (param->notifyinfo.present) {
2275 case INFO_PRESENT_ALLOWED:
2278 case INFO_PRESENT_RESTRICTED:
2281 default: /* INFO_PRESENT_NOTAVAIL */
2287 if (notify<0 && !param->notifyinfo.display[0]) {
2288 /* nothing to notify, nothing to display */
2293 if (p_state!=PORT_STATE_CONNECT && p_state!=PORT_STATE_IN_PROCEEDING && p_state!=PORT_STATE_IN_ALERTING) {
2294 /* queue notification */
2295 if (p_m_d_notify_pending)
2296 message_free(p_m_d_notify_pending);
2297 p_m_d_notify_pending = message_create(ACTIVE_EPOINT(p_epointlist), p_serial, EPOINT_TO_PORT, message_id);
2298 memcpy(&p_m_d_notify_pending->param, param, sizeof(union parameter));
2300 /* sending notification */
2301 l3m = create_l3msg();
2302 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
2303 enc_ie_notify(l3m, notify);
2304 /* sending redirection number only in ntmode */
2305 if (type >= 0 && (p_m_d_ntmode || p_m_d_tespecial))
2306 enc_ie_redir_dn(l3m, type, plan, present, (unsigned char *)param->notifyinfo.id);
2307 if (param->notifyinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2308 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2310 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_NOTIFY, p_m_d_l3id, l3m);
2312 } else if (p_m_d_ntmode || p_m_d_tespecial) {
2313 /* sending information */
2314 l3m = create_l3msg();
2315 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2316 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2318 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2322 /* MESSAGE_OVERLAP */
2323 void Pdss1::message_overlap(unsigned int epoint_id, int message_id, union parameter *param)
2327 /* in case of sending complete, we proceed */
2328 if (p_dialinginfo.sending_complete) {
2329 PDEBUG(DEBUG_ISDN, "sending proceeding instead of setup_acknowledge, because address is complete.\n");
2330 message_proceeding(epoint_id, message_id, param);
2334 /* sending setup_acknowledge */
2335 l3m = create_l3msg();
2336 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_REQ, DIRECTION_OUT);
2337 /* channel information */
2338 if (p_state == PORT_STATE_IN_SETUP)
2339 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2340 /* progress information */
2341 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2342 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2343 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2344 if (p_m_mISDNport->tones)
2345 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2347 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, l3m);
2349 new_state(PORT_STATE_IN_OVERLAP);
2352 /* MESSAGE_PROCEEDING */
2353 void Pdss1::message_proceeding(unsigned int epoint_id, int message_id, union parameter *param)
2357 /* sending proceeding */
2358 l3m = create_l3msg();
2359 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2360 /* channel information */
2361 if (p_state == PORT_STATE_IN_SETUP)
2362 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2363 /* progress information */
2364 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2365 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2366 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2367 if (p_m_mISDNport->tones)
2368 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2370 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2372 new_state(PORT_STATE_IN_PROCEEDING);
2375 /* MESSAGE_ALERTING */
2376 void Pdss1::message_alerting(unsigned int epoint_id, int message_id, union parameter *param)
2380 /* NT-MODE in setup state we must send PROCEEDING first */
2381 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP) {
2382 /* sending proceeding */
2383 l3m = create_l3msg();
2384 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2385 /* channel information */
2386 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2387 /* progress information */
2388 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2389 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2390 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2391 if (p_m_mISDNport->tones)
2392 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2394 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2395 new_state(PORT_STATE_IN_PROCEEDING);
2398 /* sending alerting */
2399 l3m = create_l3msg();
2400 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_REQ, DIRECTION_OUT);
2401 /* channel information */
2402 if (p_state == PORT_STATE_IN_SETUP)
2403 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2404 /* progress information */
2405 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2406 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2407 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2408 if (p_m_mISDNport->tones)
2409 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2411 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ALERTING, p_m_d_l3id, l3m);
2413 new_state(PORT_STATE_IN_ALERTING);
2416 /* MESSAGE_CONNECT */
2417 void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parameter *param)
2420 int type, plan, present, screen;
2421 class Endpoint *epoint;
2423 /* NT-MODE in setup state we must send PROCEEDING first */
2424 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP) {
2425 /* sending proceeding */
2426 l3m = create_l3msg();
2427 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2428 /* channel information */
2429 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2431 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2432 new_state(PORT_STATE_IN_PROCEEDING);
2435 /* copy connected information */
2436 memcpy(&p_connectinfo, ¶m->connectinfo, sizeof(p_connectinfo));
2437 /* screen outgoing caller id */
2438 do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface);
2440 /* only display at connect state */
2441 if (p_state == PORT_STATE_CONNECT)
2442 if (p_connectinfo.display[0]) {
2443 /* sending information */
2444 l3m = create_l3msg();
2445 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2446 if (p_m_d_ntmode || p_m_d_tespecial)
2447 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2449 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2453 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) {
2454 /* connect command only possible in setup, proceeding or alerting state */
2458 /* preparing connect message */
2459 l3m = create_l3msg();
2460 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_REQ, DIRECTION_OUT);
2461 /* connect information */
2463 switch (p_connectinfo.ntype) {
2464 case INFO_NTYPE_UNKNOWN:
2467 case INFO_NTYPE_INTERNATIONAL:
2470 case INFO_NTYPE_NATIONAL:
2473 case INFO_NTYPE_SUBSCRIBER:
2476 default: /* INFO_NTYPE_NOTPRESENT */
2480 switch (param->connectinfo.screen) {
2481 case INFO_SCREEN_USER:
2484 case INFO_SCREEN_USER_VERIFIED_PASSED:
2487 case INFO_SCREEN_USER_VERIFIED_FAILED:
2490 default: /* INFO_SCREE_NETWORK */
2494 switch (p_connectinfo.present) {
2495 case INFO_PRESENT_ALLOWED:
2498 case INFO_PRESENT_RESTRICTED:
2501 default: /* INFO_PRESENT_NOTAVAIL */
2506 enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
2508 if (p_connectinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2509 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2510 /* nt-mode: CONP (connected name identification presentation) */
2511 // if (p_connectinfo.name[0] && (p_m_d_ntmode || p_m_d_tespecial))
2512 // enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
2514 if (p_m_d_ntmode || p_m_d_tespecial) {
2515 epoint = find_epoint_id(epoint_id);
2516 enc_ie_date(l3m, now, p_settings.no_seconds);
2519 /* finally send message */
2520 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT, p_m_d_l3id, l3m);
2523 new_state(PORT_STATE_CONNECT);
2525 new_state(PORT_STATE_CONNECT_WAITING);
2529 /* MESSAGE_DISCONNECT */
2530 void Pdss1::message_disconnect(unsigned int epoint_id, int message_id, union parameter *param)
2533 struct lcr_msg *message;
2536 /* we reject during incoming setup when we have no tones. also if we are in outgoing setup state */
2537 // if ((p_state==PORT_STATE_IN_SETUP && !p_m_mISDNport->tones)
2538 if (/* ||*/ p_state==PORT_STATE_OUT_SETUP) {
2539 /* sending release to endpoint */
2540 while(p_epointlist) {
2541 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
2542 memcpy(&message->param, param, sizeof(union parameter));
2543 message_put(message);
2545 free_epointlist(p_epointlist);
2547 /* sending release */
2548 l3m = create_l3msg();
2549 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
2551 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2553 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2554 new_state(PORT_STATE_RELEASE);
2559 /* workarround: NT-MODE in setup state we must send PROCEEDING first to make it work */
2560 if (p_state==PORT_STATE_IN_SETUP) {
2561 /* sending proceeding */
2562 l3m = create_l3msg();
2563 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2564 /* channel information */
2565 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2566 /* progress information */
2567 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2568 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2569 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2570 if (p_m_mISDNport->tones)
2571 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2573 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2574 new_state(PORT_STATE_IN_PROCEEDING);
2577 /* sending disconnect */
2578 l3m = create_l3msg();
2579 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2580 /* progress information */
2581 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2582 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2583 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2584 if (p_m_mISDNport->tones)
2585 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2587 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2589 if (param->disconnectinfo.display[0])
2590 p = param->disconnectinfo.display;
2591 if (p) if (*p && (p_m_d_ntmode || p_m_d_tespecial))
2592 enc_ie_display(l3m, (unsigned char *)p);
2594 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2595 new_state(PORT_STATE_OUT_DISCONNECT);
2598 /* MESSAGE_RELEASE */
2599 void Pdss1::message_release(unsigned int epoint_id, int message_id, union parameter *param)
2602 class Endpoint *epoint;
2606 * we may only release during incoming disconnect state.
2607 * this means that the endpoint doesnt require audio anymore
2609 if (p_state == PORT_STATE_IN_DISCONNECT
2610 || p_state == PORT_STATE_OUT_DISCONNECT) {
2611 /* sending release */
2612 l3m = create_l3msg();
2613 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2615 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2617 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
2618 new_state(PORT_STATE_RELEASE);
2620 free_epointid(epoint_id);
2621 // wait for callref to be released
2626 * if we are on incoming call setup, we may reject by sending a release_complete
2627 * also on outgoing call setup, we send a release complete, BUT this is not conform. (i don't know any other way)
2629 if (p_state==PORT_STATE_IN_SETUP
2630 || p_state==PORT_STATE_OUT_SETUP) {
2631 //#warning remove me
2632 //PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
2633 /* sending release complete */
2634 l3m = create_l3msg();
2635 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2637 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2639 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2640 new_state(PORT_STATE_RELEASE);
2642 free_epointid(epoint_id);
2643 // wait for callref to be released
2648 wirklich erst proceeding?:
2649 /* NT-MODE in setup state we must send PROCEEDING first */
2650 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP) {
2651 CALL_PROCEEDING_t *proceeding;
2653 /* sending proceeding */
2654 l3m = create_l3msg();
2655 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2656 /* channel information */
2657 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2658 /* progress information */
2659 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2660 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2661 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2662 if (p_m_mISDNport->tones)
2663 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2665 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2669 /* sending disconnect */
2670 l3m = create_l3msg();
2671 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2672 /* progress information */
2673 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2674 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2675 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2676 if (p_m_mISDNport->tones)
2677 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2679 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2681 epoint = find_epoint_id(epoint_id);
2682 if (param->disconnectinfo.display[0])
2683 p = param->disconnectinfo.display;
2684 if (p) if (*p && (p_m_d_ntmode || p_m_d_tespecial))
2685 enc_ie_display(l3m, (unsigned char *)p);
2687 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2688 new_state(PORT_STATE_OUT_DISCONNECT);
2690 free_epointid(epoint_id);
2691 // wait for release and callref to be released
2692 //#warning remove me
2693 //PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
2698 * endpoint sends messages to the port
2700 int Pdss1::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
2702 if (PmISDN::message_epoint(epoint_id, message_id, param))
2705 switch(message_id) {
2706 case MESSAGE_INFORMATION: /* overlap dialing */
2707 if (p_type==PORT_TYPE_DSS1_NT_OUT
2708 && p_state!=PORT_STATE_OUT_OVERLAP
2709 && p_state!=PORT_STATE_CONNECT
2710 && p_state!=PORT_STATE_OUT_DISCONNECT
2711 && p_state!=PORT_STATE_IN_DISCONNECT) {
2714 if (p_type==PORT_TYPE_DSS1_TE_OUT
2715 && p_state!=PORT_STATE_OUT_OVERLAP
2716 && p_state!=PORT_STATE_OUT_PROCEEDING
2717 && p_state!=PORT_STATE_OUT_ALERTING
2718 && p_state!=PORT_STATE_CONNECT
2719 && p_state!=PORT_STATE_OUT_DISCONNECT
2720 && p_state!=PORT_STATE_IN_DISCONNECT) {
2723 if ((p_type==PORT_TYPE_DSS1_NT_IN || p_type==PORT_TYPE_DSS1_TE_IN)
2724 && p_state!=PORT_STATE_IN_OVERLAP
2725 && p_state!=PORT_STATE_IN_PROCEEDING
2726 && p_state!=PORT_STATE_IN_ALERTING
2727 && p_state!=PORT_STATE_CONNECT
2728 && p_state!=PORT_STATE_CONNECT_WAITING
2729 && p_state!=PORT_STATE_OUT_DISCONNECT
2730 && p_state!=PORT_STATE_IN_DISCONNECT) {
2733 message_information(epoint_id, message_id, param);
2736 case MESSAGE_SETUP: /* dial-out command received from epoint */
2737 if (p_state!=PORT_STATE_IDLE
2738 && p_state!=PORT_STATE_CONNECT) {
2739 PERROR("Pdss1(%s) ignoring setup because isdn port is not in idle state (or connected for sending display info).\n", p_name);
2742 if (p_epointlist && p_state==PORT_STATE_IDLE)
2743 FATAL("Pdss1(%s): epoint pointer is set in idle state, how bad!!\n", p_name);
2744 message_setup(epoint_id, message_id, param);
2747 case MESSAGE_NOTIFY: /* display and notifications */
2748 message_notify(epoint_id, message_id, param);
2751 case MESSAGE_FACILITY: /* facility message */
2752 message_facility(epoint_id, message_id, param);
2755 case MESSAGE_OVERLAP: /* more information is needed */
2756 if (p_state!=PORT_STATE_IN_SETUP) {
2759 message_overlap(epoint_id, message_id, param);
2762 case MESSAGE_PROCEEDING: /* call of endpoint is proceeding */
2763 if (p_state!=PORT_STATE_IN_SETUP
2764 && p_state!=PORT_STATE_IN_OVERLAP) {
2767 message_proceeding(epoint_id, message_id, param);
2768 if (p_m_d_notify_pending) {
2769 /* send pending notify message during connect */
2770 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
2771 message_free(p_m_d_notify_pending);
2772 p_m_d_notify_pending = NULL;
2776 case MESSAGE_ALERTING: /* call of endpoint is ringing */
2777 if (p_state!=PORT_STATE_IN_SETUP
2778 && p_state!=PORT_STATE_IN_OVERLAP
2779 && p_state!=PORT_STATE_IN_PROCEEDING) {
2782 message_alerting(epoint_id, message_id, param);
2783 if (p_m_d_notify_pending) {
2784 /* send pending notify message during connect */
2785 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
2786 message_free(p_m_d_notify_pending);
2787 p_m_d_notify_pending = NULL;
2791 case MESSAGE_CONNECT: /* call of endpoint is connected */
2792 if (p_state!=PORT_STATE_IN_SETUP
2793 && p_state!=PORT_STATE_IN_OVERLAP
2794 && p_state!=PORT_STATE_IN_PROCEEDING
2795 && p_state!=PORT_STATE_IN_ALERTING
2796 && !(p_state==PORT_STATE_CONNECT && p_m_d_ntmode)) {
2799 message_connect(epoint_id, message_id, param);
2800 if (p_m_d_notify_pending) {
2801 /* send pending notify message during connect */
2802 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
2803 message_free(p_m_d_notify_pending);
2804 p_m_d_notify_pending = NULL;
2808 case MESSAGE_DISCONNECT: /* call has been disconnected */
2809 if (p_state!=PORT_STATE_IN_SETUP
2810 && p_state!=PORT_STATE_IN_OVERLAP
2811 && p_state!=PORT_STATE_IN_PROCEEDING
2812 && p_state!=PORT_STATE_IN_ALERTING
2813 && p_state!=PORT_STATE_OUT_SETUP
2814 && p_state!=PORT_STATE_OUT_OVERLAP
2815 && p_state!=PORT_STATE_OUT_PROCEEDING
2816 && p_state!=PORT_STATE_OUT_ALERTING
2817 && p_state!=PORT_STATE_CONNECT
2818 && p_state!=PORT_STATE_CONNECT_WAITING) {
2821 message_disconnect(epoint_id, message_id, param);
2824 case MESSAGE_RELEASE: /* release isdn port */
2825 if (p_state==PORT_STATE_RELEASE) {
2828 message_release(epoint_id, message_id, param);
2832 PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message_id);
2841 * data from isdn-stack (layer-3) to pbx (port class)
2843 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
2849 PDEBUG(DEBUG_ISDN, "cmd(0x%x) pid(0x%x)\n", cmd, pid);
2852 PDEBUG(DEBUG_ISDN, "ignoring dummy process from phone.\n");
2856 /* find Port object of type ISDN */
2860 if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1) {
2861 pdss1 = (class Pdss1 *)port;
2862 /* check out correct stack and id */
2863 if (pdss1->p_m_mISDNport == mISDNport) {
2864 if (pdss1->p_m_d_l3id & MISDN_PID_CR_FLAG) {
2865 /* local callref, so match value only */
2866 if ((pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == (pid & MISDN_PID_CRVAL_MASK))
2869 /* remote callref, ref + channel id */
2870 if (pdss1->p_m_d_l3id == pid)
2878 /* aktueller prozess */
2880 if (cmd == MT_ASSIGN) {
2881 /* stack gives us new layer 3 id (during connect) */
2882 l1l2l3_trace_header(mISDNport, pdss1, L3_NEW_L3ID_IND, DIRECTION_IN);
2883 add_trace("callref", "old", "0x%x", pdss1->p_m_d_l3id);
2884 /* nt-library now gives us a new id via CC_SETUP_CONFIRM */
2885 if ((pdss1->p_m_d_l3id&MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER)
2886 PERROR(" strange setup-procid 0x%x\n", pdss1->p_m_d_l3id);
2887 pdss1->p_m_d_l3id = pid;
2888 if (port->p_state == PORT_STATE_CONNECT)
2889 pdss1->p_m_d_ces = pid >> 16;
2890 add_trace("callref", "new", "0x%x", pdss1->p_m_d_l3id);
2894 /* if process id is master process, but a child disconnects */
2895 if (mISDNport->ntmode
2896 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2897 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) == MISDN_PID_MASTER) {
2898 if (cmd == MT_DISCONNECT
2899 || cmd == MT_RELEASE) {
2900 /* send special indication for child disconnect */
2901 pdss1->disconnect_ind_i(cmd, pid, l3m);
2904 if (cmd == MT_RELEASE_COMPLETE)
2907 /* if we have child pid and got different child pid message, ignore */
2908 if (mISDNport->ntmode
2909 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2910 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2911 && pid != pdss1->p_m_d_l3id)
2914 /* process message */
2915 pdss1->message_isdn(cmd, pid, l3m);
2922 /* creating port object, transparent until setup with hdlc */
2923 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2924 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0, B_MODE_TRANSPARENT)))
2926 FATAL("Cannot create Port instance.\n");
2927 pdss1->message_isdn(cmd, pid, l3m);
2931 /* creating port object, transparent until setup with hdlc */
2932 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2933 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0, B_MODE_TRANSPARENT)))
2934 FATAL("Cannot create Port instance.\n");
2935 pdss1->message_isdn(cmd, pid, l3m);
2939 PDEBUG(DEBUG_ISDN, "unused call ref released (l3id=0x%x)\n", pid);
2942 case MT_RELEASE_COMPLETE:
2943 PERROR("must be ignored by stack, not sent to app\n");
2947 // facility als broadcast
2951 PERROR("unhandled message: cmd(0x%x) pid(0x%x)\n", cmd, pid);
2954 if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT) {
2955 pdss1 = (class Pdss1 *)port;
2956 /* check out correct stack */
2957 if (pdss1->p_m_mISDNport == mISDNport)
2958 /* check out correct id */
2959 PERROR("unhandled message: pid=%x is not associated with port-dinfo=%x\n", pid, pdss1->p_m_d_l3id);