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[32] = "";
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[32] = "", 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);
1906 void Pdss1::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
1910 int plan, type, screen, present, reason;
1911 int plan2, type2, screen2, present2;
1912 int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
1913 int channel, exclusive;
1914 struct epoint_list *epointlist;
1915 int max = p_m_mISDNport->ifport->dialmax;
1917 /* release if port is blocked */
1918 if (p_m_mISDNport->ifport->block) {
1919 struct lcr_msg *message;
1921 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1922 message->param.disconnectinfo.cause = 27; // temp. unavail.
1923 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1924 message_put(message);
1925 new_state(PORT_STATE_RELEASE);
1930 /* copy setup infos to port */
1931 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
1932 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
1933 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
1934 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
1935 /* screen outgoing caller id */
1936 do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_m_mISDNport->ifport->interface);
1937 do_screen(1, p_callerinfo.id2, sizeof(p_callerinfo.id2), &p_callerinfo.ntype2, &p_callerinfo.present2, p_m_mISDNport->ifport->interface);
1939 /* only display at connect state: this case happens if endpoint is in connected mode */
1940 if (p_state==PORT_STATE_CONNECT) {
1941 if (p_type!=PORT_TYPE_DSS1_NT_OUT
1942 && p_type!=PORT_TYPE_DSS1_NT_IN)
1944 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;
1959 if (epointlist->epoint_id == epoint_id)
1961 epointlist = epointlist->next;
1964 epointlist_new(epoint_id);
1968 if (p_m_b_channel) {
1969 channel = p_m_b_channel;
1970 exclusive = p_m_b_exclusive;
1972 channel = CHANNEL_ANY;
1973 /* nt-port with no channel, not reserverd */
1974 if (!p_m_b_channel && !p_m_b_reserve && p_type==PORT_TYPE_DSS1_NT_OUT)
1975 channel = CHANNEL_NO;
1978 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT);
1979 /* see MT_ASSIGN notes at do_layer3() */
1981 ret = p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ASSIGN, 0, NULL);
1982 if (mt_assign_pid == 0 || ret < 0) {
1983 struct lcr_msg *message;
1985 add_trace("callref", NULL, "no free id");
1987 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1988 message->param.disconnectinfo.cause = 47;
1989 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1990 message_put(message);
1991 new_state(PORT_STATE_RELEASE);
1995 p_m_d_l3id = mt_assign_pid;
1997 add_trace("callref", "new", "0x%x", p_m_d_l3id);
2000 /* preparing setup message */
2001 l3m = create_l3msg();
2002 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_REQ, DIRECTION_OUT);
2003 /* channel information */
2004 if (channel >= 0) /* it should */
2005 enc_ie_channel_id(l3m, exclusive, channel);
2006 /* caller information */
2008 switch (p_callerinfo.ntype) {
2009 case INFO_NTYPE_UNKNOWN:
2012 case INFO_NTYPE_INTERNATIONAL:
2015 case INFO_NTYPE_NATIONAL:
2018 case INFO_NTYPE_SUBSCRIBER:
2021 default: /* INFO_NTYPE_NOTPRESENT */
2025 switch (p_callerinfo.screen) {
2026 case INFO_SCREEN_USER:
2029 case INFO_SCREEN_USER_VERIFIED_PASSED:
2032 case INFO_SCREEN_USER_VERIFIED_FAILED:
2035 default: /* INFO_SCREEN_NETWORK */
2039 switch (p_callerinfo.present) {
2040 case INFO_PRESENT_ALLOWED:
2043 case INFO_PRESENT_RESTRICTED:
2046 default: /* INFO_PRESENT_NOTAVAIL */
2050 /* caller information 2 */
2052 switch (p_callerinfo.ntype2) {
2053 case INFO_NTYPE_UNKNOWN:
2056 case INFO_NTYPE_INTERNATIONAL:
2059 case INFO_NTYPE_NATIONAL:
2062 case INFO_NTYPE_SUBSCRIBER:
2065 default: /* INFO_NTYPE_NOTPRESENT */
2069 switch (p_callerinfo.screen2) {
2070 case INFO_SCREEN_USER:
2073 case INFO_SCREEN_USER_VERIFIED_PASSED:
2076 case INFO_SCREEN_USER_VERIFIED_FAILED:
2079 default: /* INFO_SCREEN_NETWORK */
2083 switch (p_callerinfo.present2) {
2084 case INFO_PRESENT_ALLOWED:
2087 case INFO_PRESENT_RESTRICTED:
2090 default: /* INFO_PRESENT_NOTAVAIL */
2095 enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id, type2, plan2, present2, screen2, (unsigned char *)p_callerinfo.id2);
2096 /* dialing information */
2097 if (p_dialinginfo.id[0]) { /* only if we have something to dial */
2098 if (max > (int)strlen(p_dialinginfo.id) || max == 0)
2099 max = (int)strlen(p_dialinginfo.id);
2100 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id, max);
2101 SCPY(p_m_d_queue, p_dialinginfo.id + max);
2103 /* sending complete */
2104 if (p_dialinginfo.sending_complete)
2105 enc_ie_complete(l3m, 1);
2106 /* sending user-user */
2107 if (param->setup.useruser.len) {
2108 enc_ie_useruser(l3m, param->setup.useruser.protocol, param->setup.useruser.data, param->setup.useruser.len);
2110 /* redirecting number */
2112 switch (p_redirinfo.ntype) {
2113 case INFO_NTYPE_UNKNOWN:
2116 case INFO_NTYPE_INTERNATIONAL:
2119 case INFO_NTYPE_NATIONAL:
2122 case INFO_NTYPE_SUBSCRIBER:
2125 default: /* INFO_NTYPE_NOTPRESENT */
2129 switch (p_redirinfo.screen) {
2130 case INFO_SCREEN_USER:
2133 case INFO_SCREEN_USER_VERIFIED_PASSED:
2136 case INFO_SCREEN_USER_VERIFIED_FAILED:
2139 default: /* INFO_SCREE_NETWORK */
2143 switch (p_redirinfo.reason) {
2144 case INFO_REDIR_BUSY:
2147 case INFO_REDIR_NORESPONSE:
2150 case INFO_REDIR_UNCONDITIONAL:
2153 case INFO_REDIR_CALLDEFLECT:
2156 case INFO_REDIR_OUTOFORDER:
2159 default: /* INFO_REDIR_UNKNOWN */
2163 switch (p_redirinfo.present) {
2164 case INFO_PRESENT_ALLOWED:
2167 case INFO_PRESENT_RESTRICTED:
2170 default: /* INFO_PRESENT_NOTAVAIL */
2174 /* sending redirecting number only in ntmode */
2175 if (type >= 0 && (p_m_d_ntmode || p_m_d_tespecial))
2176 enc_ie_redir_nr(l3m, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
2177 /* bearer capability */
2178 //printf("hlc=%d\n",p_capainfo.hlc);
2180 capability = p_capainfo.bearer_capa;
2181 mode = p_capainfo.bearer_mode;
2182 rate = (mode==INFO_BMODE_CIRCUIT)?0x10:0x00;
2183 switch (p_capainfo.bearer_info1) {
2184 case INFO_INFO1_NONE:
2188 user = p_capainfo.bearer_info1 & 0x7f;
2191 enc_ie_bearer(l3m, coding, capability, mode, rate, -1, user);
2193 if (p_capainfo.hlc) {
2197 hlc = p_capainfo.hlc & 0x7f;
2199 if (p_capainfo.exthlc)
2200 exthlc = p_capainfo.exthlc & 0x7f;
2201 enc_ie_hlc(l3m, coding, interpretation, presentation, hlc, exthlc);
2205 if (p_callerinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2206 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
2207 /* nt-mode: CNIP (calling name identification presentation) */
2208 // if (p_callerinfo.name[0] && (p_m_d_ntmode || p_m_d_tespecial))
2209 // enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
2212 /* send setup message now */
2213 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP, p_m_d_l3id, l3m);
2215 new_state(PORT_STATE_OUT_SETUP);
2218 /* MESSAGE_FACILITY */
2219 void Pdss1::message_facility(unsigned int epoint_id, int message_id, union parameter *param)
2223 /* facility will not be sent to external lines */
2224 if (!p_m_d_ntmode && !p_m_d_tespecial)
2227 /* sending facility */
2228 l3m = create_l3msg();
2229 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
2230 enc_ie_facility(l3m, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len);
2232 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
2235 /* MESSAGE_NOTIFY */
2236 void Pdss1::message_notify(unsigned int epoint_id, int message_id, union parameter *param)
2240 int plan = 0, type = -1, present = 0;
2242 // printf("if = %d\n", param->notifyinfo.notify);
2243 if (param->notifyinfo.notify>INFO_NOTIFY_NONE)
2244 notify = param->notifyinfo.notify & 0x7f;
2249 switch (param->notifyinfo.ntype) {
2250 case INFO_NTYPE_UNKNOWN:
2253 case INFO_NTYPE_INTERNATIONAL:
2256 case INFO_NTYPE_NATIONAL:
2259 case INFO_NTYPE_SUBSCRIBER:
2262 default: /* INFO_NTYPE_UNKNOWN */
2266 switch (param->notifyinfo.present) {
2267 case INFO_PRESENT_ALLOWED:
2270 case INFO_PRESENT_RESTRICTED:
2273 default: /* INFO_PRESENT_NOTAVAIL */
2279 if (notify<0 && !param->notifyinfo.display[0]) {
2280 /* nothing to notify, nothing to display */
2285 if (p_state!=PORT_STATE_CONNECT && p_state!=PORT_STATE_IN_PROCEEDING && p_state!=PORT_STATE_IN_ALERTING) {
2286 /* queue notification */
2287 if (p_m_d_notify_pending)
2288 message_free(p_m_d_notify_pending);
2289 p_m_d_notify_pending = message_create(ACTIVE_EPOINT(p_epointlist), p_serial, EPOINT_TO_PORT, message_id);
2290 memcpy(&p_m_d_notify_pending->param, param, sizeof(union parameter));
2292 /* sending notification */
2293 l3m = create_l3msg();
2294 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
2295 enc_ie_notify(l3m, notify);
2296 /* sending redirection number only in ntmode */
2297 if (type >= 0 && (p_m_d_ntmode || p_m_d_tespecial))
2298 enc_ie_redir_dn(l3m, type, plan, present, (unsigned char *)param->notifyinfo.id);
2299 if (param->notifyinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2300 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2302 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_NOTIFY, p_m_d_l3id, l3m);
2304 } else if (p_m_d_ntmode || p_m_d_tespecial) {
2305 /* sending information */
2306 l3m = create_l3msg();
2307 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2308 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2310 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2314 /* MESSAGE_OVERLAP */
2315 void Pdss1::message_overlap(unsigned int epoint_id, int message_id, union parameter *param)
2319 /* in case of sending complete, we proceed */
2320 if (p_dialinginfo.sending_complete) {
2321 PDEBUG(DEBUG_ISDN, "sending proceeding instead of setup_acknowledge, because address is complete.\n");
2322 message_proceeding(epoint_id, message_id, param);
2326 /* sending setup_acknowledge */
2327 l3m = create_l3msg();
2328 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_REQ, DIRECTION_OUT);
2329 /* channel information */
2330 if (p_state == PORT_STATE_IN_SETUP)
2331 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2332 /* progress information */
2333 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2334 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2335 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2336 if (p_m_mISDNport->tones)
2337 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2339 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, l3m);
2341 new_state(PORT_STATE_IN_OVERLAP);
2344 /* MESSAGE_PROCEEDING */
2345 void Pdss1::message_proceeding(unsigned int epoint_id, int message_id, union parameter *param)
2349 /* sending proceeding */
2350 l3m = create_l3msg();
2351 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2352 /* channel information */
2353 if (p_state == PORT_STATE_IN_SETUP)
2354 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2355 /* progress information */
2356 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2357 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2358 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2359 if (p_m_mISDNport->tones)
2360 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2362 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2364 new_state(PORT_STATE_IN_PROCEEDING);
2367 /* MESSAGE_ALERTING */
2368 void Pdss1::message_alerting(unsigned int epoint_id, int message_id, union parameter *param)
2372 /* NT-MODE in setup state we must send PROCEEDING first */
2373 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP) {
2374 /* sending proceeding */
2375 l3m = create_l3msg();
2376 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2377 /* channel information */
2378 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2379 /* progress information */
2380 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2381 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2382 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2383 if (p_m_mISDNport->tones)
2384 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2386 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2387 new_state(PORT_STATE_IN_PROCEEDING);
2390 /* sending alerting */
2391 l3m = create_l3msg();
2392 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_REQ, DIRECTION_OUT);
2393 /* channel information */
2394 if (p_state == PORT_STATE_IN_SETUP)
2395 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2396 /* progress information */
2397 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2398 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2399 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2400 if (p_m_mISDNport->tones)
2401 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2403 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ALERTING, p_m_d_l3id, l3m);
2405 new_state(PORT_STATE_IN_ALERTING);
2408 /* MESSAGE_CONNECT */
2409 void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parameter *param)
2412 int type, plan, present, screen;
2413 class Endpoint *epoint;
2415 /* NT-MODE in setup state we must send PROCEEDING first */
2416 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP) {
2417 /* sending proceeding */
2418 l3m = create_l3msg();
2419 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2420 /* channel information */
2421 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2423 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2424 new_state(PORT_STATE_IN_PROCEEDING);
2427 /* copy connected information */
2428 memcpy(&p_connectinfo, ¶m->connectinfo, sizeof(p_connectinfo));
2429 /* screen outgoing caller id */
2430 do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface);
2432 /* only display at connect state */
2433 if (p_state == PORT_STATE_CONNECT)
2434 if (p_connectinfo.display[0]) {
2435 /* sending information */
2436 l3m = create_l3msg();
2437 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2438 if (p_m_d_ntmode || p_m_d_tespecial)
2439 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2441 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2445 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) {
2446 /* connect command only possible in setup, proceeding or alerting state */
2450 /* preparing connect message */
2451 l3m = create_l3msg();
2452 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_REQ, DIRECTION_OUT);
2453 /* connect information */
2455 switch (p_connectinfo.ntype) {
2456 case INFO_NTYPE_UNKNOWN:
2459 case INFO_NTYPE_INTERNATIONAL:
2462 case INFO_NTYPE_NATIONAL:
2465 case INFO_NTYPE_SUBSCRIBER:
2468 default: /* INFO_NTYPE_NOTPRESENT */
2472 switch (param->connectinfo.screen) {
2473 case INFO_SCREEN_USER:
2476 case INFO_SCREEN_USER_VERIFIED_PASSED:
2479 case INFO_SCREEN_USER_VERIFIED_FAILED:
2482 default: /* INFO_SCREE_NETWORK */
2486 switch (p_connectinfo.present) {
2487 case INFO_PRESENT_ALLOWED:
2490 case INFO_PRESENT_RESTRICTED:
2493 default: /* INFO_PRESENT_NOTAVAIL */
2498 enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
2500 if (p_connectinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2501 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2502 /* nt-mode: CONP (connected name identification presentation) */
2503 // if (p_connectinfo.name[0] && (p_m_d_ntmode || p_m_d_tespecial))
2504 // enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
2506 if (p_m_d_ntmode || p_m_d_tespecial) {
2507 epoint = find_epoint_id(epoint_id);
2508 enc_ie_date(l3m, now, p_settings.no_seconds);
2511 /* finally send message */
2512 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT, p_m_d_l3id, l3m);
2515 new_state(PORT_STATE_CONNECT);
2517 new_state(PORT_STATE_CONNECT_WAITING);
2521 /* MESSAGE_DISCONNECT */
2522 void Pdss1::message_disconnect(unsigned int epoint_id, int message_id, union parameter *param)
2525 struct lcr_msg *message;
2528 /* we reject during incoming setup when we have no tones. also if we are in outgoing setup state */
2529 // if ((p_state==PORT_STATE_IN_SETUP && !p_m_mISDNport->tones)
2530 if (/* ||*/ p_state==PORT_STATE_OUT_SETUP) {
2531 /* sending release to endpoint */
2532 while(p_epointlist) {
2533 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
2534 memcpy(&message->param, param, sizeof(union parameter));
2535 message_put(message);
2537 free_epointlist(p_epointlist);
2539 /* sending release */
2540 l3m = create_l3msg();
2541 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
2543 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2545 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2546 new_state(PORT_STATE_RELEASE);
2551 /* workarround: NT-MODE in setup state we must send PROCEEDING first to make it work */
2552 if (p_state==PORT_STATE_IN_SETUP) {
2553 /* sending proceeding */
2554 l3m = create_l3msg();
2555 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2556 /* channel information */
2557 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2558 /* progress information */
2559 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2560 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2561 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2562 if (p_m_mISDNport->tones)
2563 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2565 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2566 new_state(PORT_STATE_IN_PROCEEDING);
2569 /* sending disconnect */
2570 l3m = create_l3msg();
2571 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2572 /* progress information */
2573 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2574 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2575 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2576 if (p_m_mISDNport->tones)
2577 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2579 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2581 if (param->disconnectinfo.display[0])
2582 p = param->disconnectinfo.display;
2583 if (p) if (*p && (p_m_d_ntmode || p_m_d_tespecial))
2584 enc_ie_display(l3m, (unsigned char *)p);
2586 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2587 new_state(PORT_STATE_OUT_DISCONNECT);
2590 /* MESSAGE_RELEASE */
2591 void Pdss1::message_release(unsigned int epoint_id, int message_id, union parameter *param)
2594 class Endpoint *epoint;
2598 * we may only release during incoming disconnect state.
2599 * this means that the endpoint doesnt require audio anymore
2601 if (p_state == PORT_STATE_IN_DISCONNECT
2602 || p_state == PORT_STATE_OUT_DISCONNECT) {
2603 /* sending release */
2604 l3m = create_l3msg();
2605 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2607 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2609 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
2610 new_state(PORT_STATE_RELEASE);
2612 free_epointid(epoint_id);
2613 // wait for callref to be released
2618 * if we are on incoming call setup, we may reject by sending a release_complete
2619 * also on outgoing call setup, we send a release complete, BUT this is not conform. (i don't know any other way)
2621 if (p_state==PORT_STATE_IN_SETUP
2622 || p_state==PORT_STATE_OUT_SETUP) {
2623 //#warning remove me
2624 //PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
2625 /* sending release complete */
2626 l3m = create_l3msg();
2627 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2629 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2631 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2632 new_state(PORT_STATE_RELEASE);
2634 free_epointid(epoint_id);
2635 // wait for callref to be released
2640 wirklich erst proceeding?:
2641 /* NT-MODE in setup state we must send PROCEEDING first */
2642 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP) {
2643 CALL_PROCEEDING_t *proceeding;
2645 /* sending proceeding */
2646 l3m = create_l3msg();
2647 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2648 /* channel information */
2649 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2650 /* progress information */
2651 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2652 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2653 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2654 if (p_m_mISDNport->tones)
2655 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2657 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2661 /* sending disconnect */
2662 l3m = create_l3msg();
2663 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2664 /* progress information */
2665 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2666 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2667 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2668 if (p_m_mISDNport->tones)
2669 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2671 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2673 epoint = find_epoint_id(epoint_id);
2674 if (param->disconnectinfo.display[0])
2675 p = param->disconnectinfo.display;
2676 if (p) if (*p && (p_m_d_ntmode || p_m_d_tespecial))
2677 enc_ie_display(l3m, (unsigned char *)p);
2679 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2680 new_state(PORT_STATE_OUT_DISCONNECT);
2682 free_epointid(epoint_id);
2683 // wait for release and callref to be released
2684 //#warning remove me
2685 //PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
2690 * endpoint sends messages to the port
2692 int Pdss1::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
2694 if (PmISDN::message_epoint(epoint_id, message_id, param))
2697 switch(message_id) {
2698 case MESSAGE_INFORMATION: /* overlap dialing */
2699 if (p_type==PORT_TYPE_DSS1_NT_OUT
2700 && p_state!=PORT_STATE_OUT_OVERLAP
2701 && p_state!=PORT_STATE_CONNECT
2702 && p_state!=PORT_STATE_OUT_DISCONNECT
2703 && p_state!=PORT_STATE_IN_DISCONNECT) {
2706 if (p_type==PORT_TYPE_DSS1_TE_OUT
2707 && p_state!=PORT_STATE_OUT_OVERLAP
2708 && p_state!=PORT_STATE_OUT_PROCEEDING
2709 && p_state!=PORT_STATE_OUT_ALERTING
2710 && p_state!=PORT_STATE_CONNECT
2711 && p_state!=PORT_STATE_OUT_DISCONNECT
2712 && p_state!=PORT_STATE_IN_DISCONNECT) {
2715 if ((p_type==PORT_TYPE_DSS1_NT_IN || p_type==PORT_TYPE_DSS1_TE_IN)
2716 && p_state!=PORT_STATE_IN_OVERLAP
2717 && p_state!=PORT_STATE_IN_PROCEEDING
2718 && p_state!=PORT_STATE_IN_ALERTING
2719 && p_state!=PORT_STATE_CONNECT
2720 && p_state!=PORT_STATE_CONNECT_WAITING
2721 && p_state!=PORT_STATE_OUT_DISCONNECT
2722 && p_state!=PORT_STATE_IN_DISCONNECT) {
2725 message_information(epoint_id, message_id, param);
2728 case MESSAGE_SETUP: /* dial-out command received from epoint */
2729 if (p_state!=PORT_STATE_IDLE
2730 && p_state!=PORT_STATE_CONNECT) {
2731 PERROR("Pdss1(%s) ignoring setup because isdn port is not in idle state (or connected for sending display info).\n", p_name);
2734 if (p_epointlist && p_state==PORT_STATE_IDLE)
2735 FATAL("Pdss1(%s): epoint pointer is set in idle state, how bad!!\n", p_name);
2736 message_setup(epoint_id, message_id, param);
2739 case MESSAGE_NOTIFY: /* display and notifications */
2740 message_notify(epoint_id, message_id, param);
2743 case MESSAGE_FACILITY: /* facility message */
2744 message_facility(epoint_id, message_id, param);
2747 case MESSAGE_OVERLAP: /* more information is needed */
2748 if (p_state!=PORT_STATE_IN_SETUP) {
2751 message_overlap(epoint_id, message_id, param);
2754 case MESSAGE_PROCEEDING: /* call of endpoint is proceeding */
2755 if (p_state!=PORT_STATE_IN_SETUP
2756 && p_state!=PORT_STATE_IN_OVERLAP) {
2759 message_proceeding(epoint_id, message_id, param);
2760 if (p_m_d_notify_pending) {
2761 /* send pending notify message during connect */
2762 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
2763 message_free(p_m_d_notify_pending);
2764 p_m_d_notify_pending = NULL;
2768 case MESSAGE_ALERTING: /* call of endpoint is ringing */
2769 if (p_state!=PORT_STATE_IN_SETUP
2770 && p_state!=PORT_STATE_IN_OVERLAP
2771 && p_state!=PORT_STATE_IN_PROCEEDING) {
2774 message_alerting(epoint_id, message_id, param);
2775 if (p_m_d_notify_pending) {
2776 /* send pending notify message during connect */
2777 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
2778 message_free(p_m_d_notify_pending);
2779 p_m_d_notify_pending = NULL;
2783 case MESSAGE_CONNECT: /* call of endpoint is connected */
2784 if (p_state!=PORT_STATE_IN_SETUP
2785 && p_state!=PORT_STATE_IN_OVERLAP
2786 && p_state!=PORT_STATE_IN_PROCEEDING
2787 && p_state!=PORT_STATE_IN_ALERTING
2788 && !(p_state==PORT_STATE_CONNECT && p_m_d_ntmode)) {
2791 message_connect(epoint_id, message_id, param);
2792 if (p_m_d_notify_pending) {
2793 /* send pending notify message during connect */
2794 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
2795 message_free(p_m_d_notify_pending);
2796 p_m_d_notify_pending = NULL;
2800 case MESSAGE_DISCONNECT: /* call has been disconnected */
2801 if (p_state!=PORT_STATE_IN_SETUP
2802 && p_state!=PORT_STATE_IN_OVERLAP
2803 && p_state!=PORT_STATE_IN_PROCEEDING
2804 && p_state!=PORT_STATE_IN_ALERTING
2805 && p_state!=PORT_STATE_OUT_SETUP
2806 && p_state!=PORT_STATE_OUT_OVERLAP
2807 && p_state!=PORT_STATE_OUT_PROCEEDING
2808 && p_state!=PORT_STATE_OUT_ALERTING
2809 && p_state!=PORT_STATE_CONNECT
2810 && p_state!=PORT_STATE_CONNECT_WAITING) {
2813 message_disconnect(epoint_id, message_id, param);
2816 case MESSAGE_RELEASE: /* release isdn port */
2817 if (p_state==PORT_STATE_RELEASE) {
2820 message_release(epoint_id, message_id, param);
2824 PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message_id);
2833 * data from isdn-stack (layer-3) to pbx (port class)
2835 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
2841 PDEBUG(DEBUG_ISDN, "cmd(0x%x) pid(0x%x)\n", cmd, pid);
2844 PDEBUG(DEBUG_ISDN, "ignoring dummy process from phone.\n");
2848 /* find Port object of type ISDN */
2852 if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1) {
2853 pdss1 = (class Pdss1 *)port;
2854 /* check out correct stack and id */
2855 if (pdss1->p_m_mISDNport == mISDNport) {
2856 if (pdss1->p_m_d_l3id & MISDN_PID_CR_FLAG) {
2857 /* local callref, so match value only */
2858 if ((pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == (pid & MISDN_PID_CRVAL_MASK))
2861 /* remote callref, ref + channel id */
2862 if (pdss1->p_m_d_l3id == pid)
2870 /* aktueller prozess */
2872 if (cmd == MT_ASSIGN) {
2873 /* stack gives us new layer 3 id (during connect) */
2874 l1l2l3_trace_header(mISDNport, pdss1, L3_NEW_L3ID_IND, DIRECTION_IN);
2875 add_trace("callref", "old", "0x%x", pdss1->p_m_d_l3id);
2876 /* nt-library now gives us a new id via CC_SETUP_CONFIRM */
2877 if ((pdss1->p_m_d_l3id&MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER)
2878 PERROR(" strange setup-procid 0x%x\n", pdss1->p_m_d_l3id);
2879 pdss1->p_m_d_l3id = pid;
2880 if (port->p_state == PORT_STATE_CONNECT)
2881 pdss1->p_m_d_ces = pid >> 16;
2882 add_trace("callref", "new", "0x%x", pdss1->p_m_d_l3id);
2886 /* if process id is master process, but a child disconnects */
2887 if (mISDNport->ntmode
2888 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2889 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) == MISDN_PID_MASTER) {
2890 if (cmd == MT_DISCONNECT
2891 || cmd == MT_RELEASE) {
2892 /* send special indication for child disconnect */
2893 pdss1->disconnect_ind_i(cmd, pid, l3m);
2896 if (cmd == MT_RELEASE_COMPLETE)
2899 /* if we have child pid and got different child pid message, ignore */
2900 if (mISDNport->ntmode
2901 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2902 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2903 && pid != pdss1->p_m_d_l3id)
2906 /* process message */
2907 pdss1->message_isdn(cmd, pid, l3m);
2914 /* creating port object, transparent until setup with hdlc */
2915 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2916 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0, B_MODE_TRANSPARENT)))
2918 FATAL("Cannot create Port instance.\n");
2919 pdss1->message_isdn(cmd, pid, l3m);
2923 /* creating port object, transparent until setup with hdlc */
2924 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2925 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 PDEBUG(DEBUG_ISDN, "unused call ref released (l3id=0x%x)\n", pid);
2934 case MT_RELEASE_COMPLETE:
2935 PERROR("must be ignored by stack, not sent to app\n");
2939 // facility als broadcast
2943 PERROR("unhandled message: cmd(0x%x) pid(0x%x)\n", cmd, pid);
2946 if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT) {
2947 pdss1 = (class Pdss1 *)port;
2948 /* check out correct stack */
2949 if (pdss1->p_m_mISDNport == mISDNport)
2950 /* check out correct id */
2951 PERROR("unhandled message: pid=%x is not associated with port-dinfo=%x\n", pid, pdss1->p_m_d_l3id);