1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
10 \*****************************************************************************/
15 //#include <sys/socket.h>
19 extern unsigned int mt_assign_pid;
23 static int delete_event(struct lcr_work *work, void *instance, int index);
28 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)
30 p_callerinfo.itype = (mISDNport->ifport->interface->extension)?INFO_ITYPE_ISDN_EXTENSION:INFO_ITYPE_ISDN;
31 p_m_d_ntmode = mISDNport->ntmode;
32 p_m_d_tespecial = mISDNport->tespecial;
34 memset(&p_m_d_delete, 0, sizeof(p_m_d_delete));
35 add_work(&p_m_d_delete, delete_event, this, 0);
37 p_m_d_queue[0] = '\0';
38 p_m_d_notify_pending = NULL;
39 p_m_d_collect_cause = 0;
40 p_m_d_collect_location = 0;
42 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);
51 del_work(&p_m_d_delete);
53 /* remove queued message */
54 if (p_m_d_notify_pending)
55 message_free(p_m_d_notify_pending);
60 * create layer 3 message
62 static struct l3_msg *create_l3msg(void)
70 FATAL("Cannot allocate memory, system overloaded.\n");
71 exit(0); // make gcc happy
75 * if we received a first reply to the setup message,
76 * we will check if we have now channel information
77 * return: <0: error, call is released, -cause is given
78 * 0: ok, nothing to do
80 int Pdss1::received_first_reply_to_setup(unsigned int cmd, int channel, int exclusive)
85 /* correct exclusive to 0, if no explicit channel was given */
86 if (exclusive<0 || channel<=0)
90 if (p_m_b_channel && p_m_b_exclusive) {
91 /*** we gave an exclusive channel (or if we are done) ***/
93 /* if not first reply, we are done */
94 if (p_state != PORT_STATE_OUT_SETUP)
97 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
98 add_trace("channel", "request", "%d (forced)", p_m_b_channel);
99 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
101 /* if give channel not accepted or not equal */
102 if (channel!=-1 && p_m_b_channel!=channel) {
103 add_trace("conclusion", NULL, "forced channel not accepted");
109 add_trace("conclusion", NULL, "channel was accepted");
110 add_trace("connect", "channel", "%d", p_m_b_channel);
113 /* activate our exclusive channel */
114 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
117 /*** we gave a non-exclusive channel ***/
119 /* if not first reply, we are done */
120 if (p_state != PORT_STATE_OUT_SETUP)
123 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
124 add_trace("channel", "request", "%d (suggest)", p_m_b_channel);
125 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
127 /* if channel was accepted as given */
128 if (channel==-1 || p_m_b_channel==channel) {
129 add_trace("conclusion", NULL, "channel was accepted as given");
130 add_trace("connect", "channel", "%d", p_m_b_channel);
132 p_m_b_exclusive = 1; // we are done
133 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
137 /* if channel value is faulty */
139 add_trace("conclusion", NULL, "illegal reply");
141 ret = -111; // protocol error
145 /* if channel was not accepted, try to get it */
146 ret = seize_bchannel(channel, 1); // exclusively
147 add_trace("channel", "available", ret<0?"no":"yes");
149 add_trace("conclusion", NULL, "replied channel not available");
153 add_trace("conclusion", NULL, "replied channel accepted");
154 add_trace("connect", "channel", "%d", p_m_b_channel);
157 /* activate channel given by remote */
158 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
161 /*** we sent 'any channel acceptable' ***/
163 /* if not first reply, we are done */
164 if (p_state != PORT_STATE_OUT_SETUP)
167 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
168 add_trace("channel", "request", "any");
169 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
170 /* if no channel was replied */
172 add_trace("conclusion", NULL, "no channel, protocol error");
174 ret = -111; // protocol error
178 /* we will see, if our received channel is available */
179 ret = seize_bchannel(channel, 1); // exclusively
180 add_trace("channel", "available", ret<0?"no":"yes");
182 add_trace("conclusion", NULL, "replied channel not available");
186 add_trace("conclusion", NULL, "replied channel accepted");
187 add_trace("connect", "channel", "%d", p_m_b_channel);
190 /* activate channel given by remote */
191 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
193 /*** we sent 'no channel available' ***/
195 /* if not the first reply, but a connect, we are forced */
196 if (cmd==MT_CONNECT && p_state!=PORT_STATE_OUT_SETUP) {
197 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (connect)", DIRECTION_NONE);
198 add_trace("channel", "request", "no-channel");
199 add_trace("channel", "reply", (channel>=0)?"%d%s":"(none)", channel, exclusive?" (forced)":"");
201 goto use_from_connect;
203 ret = seize_bchannel(CHANNEL_ANY, 0); // any channel
204 add_trace("channel", "available", ret<0?"no":"yes");
206 add_trace("conclusion", NULL, "no channel available during call-waiting");
210 add_trace("conclusion", NULL, "using channel %d", p_m_b_channel);
211 add_trace("connect", "channel", "%d", p_m_b_channel);
213 p_m_b_exclusive = 1; // we are done
215 /* activate channel given by remote */
216 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
220 /* if not first reply, we are done */
221 if (p_state != PORT_STATE_OUT_SETUP)
224 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (first reply to setup)", DIRECTION_NONE);
225 add_trace("channel", "request", "no-channel");
226 add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel);
227 /* if first reply has no channel, we are done */
229 add_trace("conclusion", NULL, "no channel until connect");
234 /* we will see, if our received channel is available */
236 ret = seize_bchannel(channel, exclusive);
237 add_trace("channel", "available", ret<0?"no":"yes");
239 add_trace("conclusion", NULL, "replied channel not available");
243 add_trace("conclusion", NULL, "replied channel accepted");
244 add_trace("connect", "channel", "%d", p_m_b_channel);
246 p_m_b_exclusive = 1; // we are done
248 /* activate channel given by remote */
249 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
255 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
256 * in response to the setup reply
258 l3m = create_l3msg();
259 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
260 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
262 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
263 new_state(PORT_STATE_RELEASE);
264 trigger_work(&p_m_d_delete);
265 return(-34); /* to epoint: no channel available */
270 * hunt bchannel for incoming setup or retrieve or resume
272 int Pdss1::hunt_bchannel(int channel, int exclusive)
274 struct select_channel *selchannel;
275 struct interface_port *ifport = p_m_mISDNport->ifport;
278 chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (setup)", DIRECTION_NONE);
281 if (channel == CHANNEL_NO)
282 add_trace("channel", "request", "no-channel");
284 add_trace("channel", "request", (channel>0)?"%d%s":"any", channel, exclusive?" (forced)":"");
285 if (channel==CHANNEL_NO && p_type==PORT_TYPE_DSS1_TE_IN) {
286 add_trace("conclusion", NULL, "incoming call-waiting not supported for TE-mode");
288 return(-6); // channel unacceptable
290 if (channel <= 0) /* not given, no channel, whatever.. */
291 channel = CHANNEL_ANY; /* any channel */
292 add_trace("channel", "reserved", "%d", p_m_mISDNport->b_reserved);
293 if (p_m_mISDNport->b_reserved >= p_m_mISDNport->b_num) { // of out chan..
294 add_trace("conclusion", NULL, "all channels are reserved");
296 return(-34); // no channel
298 if (channel == CHANNEL_ANY)
301 /* check for given channel in selection list */
302 selchannel = ifport->in_channel;
304 if (selchannel->channel == channel || selchannel->channel == CHANNEL_FREE)
306 selchannel = selchannel->next;
311 /* exclusive channel requests must be in the list */
313 /* no exclusive channel */
315 add_trace("conclusion", NULL, "exclusively requested channel not in list");
317 return(-6); // channel unacceptable
319 /* get index for channel */
320 i = channel-1-(channel>=17);
321 if (i < 0 || i >= p_m_mISDNport->b_num || channel == 16) {
322 add_trace("conclusion", NULL, "exclusively requested channel outside interface range");
324 return(-6); // channel unacceptable
327 if (p_m_mISDNport->b_port[i] == NULL)
329 add_trace("conclusion", NULL, "exclusively requested channel is busy");
331 return(-6); // channel unacceptable
334 /* requested channels in list will be used */
336 /* get index for channel */
337 i = channel-1-(channel>=17);
338 if (i < 0 || i >= p_m_mISDNport->b_num || channel == 16) {
339 add_trace("info", NULL, "requested channel %d outside interface range", channel);
340 } else /* if inside range (else) check if available */
341 if (p_m_mISDNport->b_port[i] == NULL)
345 /* if channel is not available or not in list, it must be searched */
347 /* check for first free channel in list */
349 selchannel = ifport->in_channel;
351 switch(selchannel->channel) {
352 case CHANNEL_FREE: /* free channel */
353 add_trace("hunting", "channel", "free");
354 if (p_m_mISDNport->b_reserved >= p_m_mISDNport->b_num)
355 break; /* all channel in use or reserverd */
358 while(i < p_m_mISDNport->b_num) {
359 if (p_m_mISDNport->b_port[i] == NULL) {
360 channel = i+1+(i>=15);
368 add_trace("hunting", "channel", "%d", selchannel->channel);
369 if (selchannel->channel<1 || selchannel->channel==16)
370 break; /* invalid channels */
371 i = selchannel->channel-1-(selchannel->channel>=17);
372 if (i >= p_m_mISDNport->b_num)
373 break; /* channel not in port */
374 if (p_m_mISDNport->b_port[i] == NULL) {
375 channel = selchannel->channel;
381 break; /* found channel */
382 selchannel = selchannel->next;
385 add_trace("conclusion", NULL, "no channel available");
387 return(-6); // channel unacceptable
391 add_trace("conclusion", NULL, "channel available");
392 add_trace("connect", "channel", "%d", channel);
398 * handles all indications
400 /* CC_SETUP INDICATION */
401 void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
403 int calling_type, calling_plan, calling_present, calling_screen;
404 int calling_type2, calling_plan2, calling_present2, calling_screen2;
405 int called_type, called_plan;
406 int redir_type, redir_plan, redir_present, redir_screen, redir_reason;
407 int hlc_coding, hlc_presentation, hlc_interpretation, hlc_hlc, hlc_exthlc;
408 int bearer_coding, bearer_capability, bearer_mode, bearer_rate, bearer_multi, bearer_user;
409 int exclusive, channel;
411 unsigned char keypad[33] = "";
412 unsigned char useruser[128];
413 int useruser_len = 0, useruser_protocol;
414 class Endpoint *epoint;
415 struct lcr_msg *message;
417 /* process given callref */
418 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
419 add_trace("callref", "new", "0x%x", pid);
421 /* release in case the ID is already in use */
422 add_trace("error", NULL, "callref already in use");
424 l3m = create_l3msg();
425 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
426 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
427 add_trace("reason", NULL, "callref already in use");
429 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, pid, l3m);
430 new_state(PORT_STATE_RELEASE);
431 trigger_work(&p_m_d_delete);
435 p_m_d_ces = pid >> 16;
438 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_IND, DIRECTION_IN);
439 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));
440 dec_ie_called_pn(l3m, &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
441 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
442 /* te-mode: CNIP (calling name identification presentation) */
443 dec_facility_centrex(l3m, (unsigned char *)p_callerinfo.name, sizeof(p_callerinfo.name));
444 dec_ie_useruser(l3m, &useruser_protocol, useruser, &useruser_len);
445 dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
446 dec_ie_redir_nr(l3m, &redir_type, &redir_plan, &redir_present, &redir_screen, &redir_reason, (unsigned char *)p_redirinfo.id, sizeof(p_redirinfo.id));
447 dec_ie_channel_id(l3m, &exclusive, &channel);
448 dec_ie_hlc(l3m, &hlc_coding, &hlc_interpretation, &hlc_presentation, &hlc_hlc, &hlc_exthlc);
449 dec_ie_bearer(l3m, &bearer_coding, &bearer_capability, &bearer_mode, &bearer_rate, &bearer_multi, &bearer_user);
450 dec_ie_display(l3m, (unsigned char *)p_dialinginfo.display, sizeof(p_dialinginfo.display));
453 /* if blocked, release call with MT_RELEASE_COMPLETE */
454 if (p_m_mISDNport->ifport->block) {
455 l3m = create_l3msg();
456 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
457 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 27); /* temporary unavailable */
458 add_trace("reason", NULL, "port blocked");
460 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
461 new_state(PORT_STATE_RELEASE);
462 trigger_work(&p_m_d_delete);
467 switch (calling_present) {
469 p_callerinfo.present = INFO_PRESENT_RESTRICTED;
472 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
475 p_callerinfo.present = INFO_PRESENT_ALLOWED;
478 switch (calling_screen) {
480 p_callerinfo.screen = INFO_SCREEN_USER;
483 p_callerinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
486 p_callerinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
489 p_callerinfo.screen = INFO_SCREEN_NETWORK;
492 switch (calling_type) {
494 p_callerinfo.ntype = INFO_NTYPE_NOTPRESENT;
497 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
500 p_callerinfo.ntype = INFO_NTYPE_INTERNATIONAL;
503 p_callerinfo.ntype = INFO_NTYPE_NATIONAL;
506 p_callerinfo.ntype = INFO_NTYPE_SUBSCRIBER;
509 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
512 p_callerinfo.isdn_port = p_m_portnum;
513 SCPY(p_callerinfo.interface, p_m_mISDNport->ifport->interface->name);
516 switch (calling_present2) {
518 p_callerinfo.present2 = INFO_PRESENT_RESTRICTED;
521 p_callerinfo.present2 = INFO_PRESENT_NOTAVAIL;
524 p_callerinfo.present2 = INFO_PRESENT_ALLOWED;
527 switch (calling_screen2) {
529 p_callerinfo.screen2 = INFO_SCREEN_USER;
532 p_callerinfo.screen2 = INFO_SCREEN_USER_VERIFIED_PASSED;
535 p_callerinfo.screen2 = INFO_SCREEN_USER_VERIFIED_FAILED;
538 p_callerinfo.screen2 = INFO_SCREEN_NETWORK;
541 switch (calling_type2) {
543 p_callerinfo.ntype2 = INFO_NTYPE_NOTPRESENT;
546 p_callerinfo.ntype2 = INFO_NTYPE_UNKNOWN;
549 p_callerinfo.ntype2 = INFO_NTYPE_INTERNATIONAL;
552 p_callerinfo.ntype2 = INFO_NTYPE_NATIONAL;
555 p_callerinfo.ntype2 = INFO_NTYPE_SUBSCRIBER;
558 p_callerinfo.ntype2 = INFO_NTYPE_UNKNOWN;
562 /* dialing information */
563 SCAT(p_dialinginfo.id, (char *)keypad);
564 switch (called_type) {
566 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
569 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
572 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
575 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
580 switch (redir_present) {
582 p_redirinfo.present = INFO_PRESENT_RESTRICTED;
585 p_redirinfo.present = INFO_PRESENT_NOTAVAIL;
588 p_redirinfo.present = INFO_PRESENT_ALLOWED;
591 switch (redir_screen) {
593 p_redirinfo.screen = INFO_SCREEN_USER;
596 p_redirinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
599 p_redirinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
602 p_redirinfo.screen = INFO_SCREEN_NETWORK;
605 switch (redir_reason) {
607 p_redirinfo.reason = INFO_REDIR_BUSY;
610 p_redirinfo.reason = INFO_REDIR_NORESPONSE;
613 p_redirinfo.reason = INFO_REDIR_UNCONDITIONAL;
616 p_redirinfo.reason = INFO_REDIR_CALLDEFLECT;
619 p_redirinfo.reason = INFO_REDIR_OUTOFORDER;
622 p_redirinfo.reason = INFO_REDIR_UNKNOWN;
625 switch (redir_type) {
627 p_redirinfo.ntype = INFO_NTYPE_NOTPRESENT;
630 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
633 p_redirinfo.ntype = INFO_NTYPE_INTERNATIONAL;
636 p_redirinfo.ntype = INFO_NTYPE_NATIONAL;
639 p_redirinfo.ntype = INFO_NTYPE_SUBSCRIBER;
642 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
645 p_redirinfo.isdn_port = p_m_portnum;
647 /* bearer capability */
648 switch (bearer_capability) {
650 p_capainfo.bearer_capa = INFO_BC_AUDIO;
651 bearer_user = (options.law=='a')?3:2;
654 p_capainfo.bearer_capa = bearer_capability;
657 switch (bearer_mode) {
659 p_capainfo.bearer_mode = INFO_BMODE_PACKET;
662 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
665 switch (bearer_user) {
667 p_capainfo.bearer_info1 = INFO_INFO1_NONE;
670 p_capainfo.bearer_info1 = bearer_user + 0x80;
677 p_capainfo.hlc = INFO_HLC_NONE;
680 p_capainfo.hlc = hlc_hlc + 0x80;
683 switch (hlc_exthlc) {
685 p_capainfo.exthlc = INFO_HLC_NONE;
688 p_capainfo.exthlc = hlc_exthlc + 0x80;
692 /* set bchannel mode */
693 if (p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED
694 || p_capainfo.bearer_capa==INFO_BC_DATARESTRICTED
695 || p_capainfo.bearer_capa==INFO_BC_VIDEO)
696 p_capainfo.source_mode = B_MODE_HDLC;
698 p_capainfo.source_mode = B_MODE_TRANSPARENT;
699 p_m_b_mode = p_capainfo.source_mode;
702 ret = channel = hunt_bchannel(channel, exclusive);
707 ret = seize_bchannel(channel, 1);
711 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
712 * in response to the setup
714 l3m = create_l3msg();
715 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
716 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
718 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
719 new_state(PORT_STATE_RELEASE);
720 trigger_work(&p_m_d_delete);
723 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
725 /* create endpoint */
727 FATAL("Incoming call but already got an endpoint.\n");
728 if (!(epoint = new Endpoint(p_serial, 0)))
729 FATAL("No memory for Endpoint instance\n");
730 if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 0))) //incoming
731 FATAL("No memory for Endpoint Application instance\n");
732 epointlist_new(epoint->ep_serial);
734 /* send setup message to endpoit */
735 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
736 message->param.setup.isdn_port = p_m_portnum;
737 message->param.setup.port_type = p_type;
738 // message->param.setup.dtmf = !p_m_mISDNport->ifport->nodtmf;
739 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
740 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
741 memcpy(&message->param.setup.redirinfo, &p_redirinfo, sizeof(struct redir_info));
742 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
743 memcpy(message->param.setup.useruser.data, &useruser, useruser_len);
744 message->param.setup.useruser.len = useruser_len;
745 message->param.setup.useruser.protocol = useruser_protocol;
746 message_put(message);
748 new_state(PORT_STATE_IN_SETUP);
751 /* CC_INFORMATION INDICATION */
752 void Pdss1::information_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
755 unsigned char keypad[33] = "", display[128] = "";
756 struct lcr_msg *message;
758 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_IND, DIRECTION_IN);
759 dec_ie_called_pn(l3m, &type, &plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
760 dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
761 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
762 dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
765 SCAT(p_dialinginfo.id, (char *)keypad);
768 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
771 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
774 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
777 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
780 SCPY(p_dialinginfo.display, (char *)display);
781 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_INFORMATION);
782 memcpy(&message->param.information, &p_dialinginfo, sizeof(struct dialing_info));
783 message_put(message);
784 /* reset overlap timeout */
788 /* CC_SETUP_ACCNOWLEDGE INDICATION */
789 void Pdss1::setup_acknowledge_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
791 int exclusive, channel;
792 int coding, location, progress;
794 struct lcr_msg *message;
795 int max = p_m_mISDNport->ifport->dialmax;
799 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_IND, DIRECTION_IN);
800 dec_ie_channel_id(l3m, &exclusive, &channel);
801 dec_ie_progress(l3m, &coding, &location, &progress);
804 /* process channel */
805 ret = received_first_reply_to_setup(cmd, channel, exclusive);
807 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
808 message->param.disconnectinfo.cause = -ret;
809 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
810 message_put(message);
811 new_state(PORT_STATE_RELEASE);
812 trigger_work(&p_m_d_delete);
816 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_OVERLAP);
817 message_put(message);
819 new_state(PORT_STATE_OUT_OVERLAP);
821 number = p_m_d_queue;
822 while (number[0]) { /* as long we have something to dial */
823 if (max > (int)strlen(number) || max == 0)
824 max = (int)strlen(number);
826 nl3m = create_l3msg();
827 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
828 enc_ie_called_pn(nl3m, 0, 1, (unsigned char *)number, max);
830 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, nl3m);
833 p_m_d_queue[0] = '\0';
836 /* CC_PROCEEDING INDICATION */
837 void Pdss1::proceeding_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
839 int exclusive, channel;
840 int coding, location, progress;
842 struct lcr_msg *message;
843 int notify = -1, type, plan, present;
846 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_IND, DIRECTION_IN);
847 dec_ie_channel_id(l3m, &exclusive, &channel);
848 dec_ie_progress(l3m, &coding, &location, &progress);
849 dec_ie_notify(l3m, ¬ify);
850 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
853 ret = received_first_reply_to_setup(cmd, channel, exclusive);
855 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
856 message->param.disconnectinfo.cause = -ret;
857 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
858 message_put(message);
859 new_state(PORT_STATE_RELEASE);
860 trigger_work(&p_m_d_delete);
863 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
864 message_put(message);
866 new_state(PORT_STATE_OUT_PROCEEDING);
872 if (type >= 0 || notify) {
873 if (!notify && type >= 0)
875 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
876 message->param.notifyinfo.notify = notify;
877 SCPY(message->param.notifyinfo.id, redir);
878 /* redirection number */
881 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
884 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
887 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
892 message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT;
895 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
898 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
901 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
904 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
907 message->param.notifyinfo.isdn_port = p_m_portnum;
908 message_put(message);
912 /* CC_ALERTING INDICATION */
913 void Pdss1::alerting_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
915 int exclusive, channel;
916 int coding, location, progress;
918 struct lcr_msg *message;
919 int notify = -1, type, plan, present;
922 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_IND, DIRECTION_IN);
923 dec_ie_channel_id(l3m, &exclusive, &channel);
924 dec_ie_progress(l3m, &coding, &location, &progress);
925 dec_ie_notify(l3m, ¬ify);
926 dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
929 /* process channel */
930 ret = received_first_reply_to_setup(cmd, channel, exclusive);
932 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
933 message->param.disconnectinfo.cause = -ret;
934 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
935 message_put(message);
936 new_state(PORT_STATE_RELEASE);
937 trigger_work(&p_m_d_delete);
940 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ALERTING);
941 message_put(message);
943 new_state(PORT_STATE_OUT_ALERTING);
949 if (type >= 0 || notify) {
950 if (!notify && type >= 0)
952 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
953 message->param.notifyinfo.notify = notify;
954 SCPY(message->param.notifyinfo.id, redir);
957 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
960 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
963 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
968 message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT;
971 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
974 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
977 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
980 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
983 message->param.notifyinfo.isdn_port = p_m_portnum;
984 message_put(message);
988 /* CC_CONNECT INDICATION */
989 void Pdss1::connect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
991 int exclusive, channel;
992 int type, plan, present, screen;
994 struct lcr_msg *message;
997 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_IND, DIRECTION_IN);
998 dec_ie_channel_id(l3m, &exclusive, &channel);
999 dec_ie_connected_pn(l3m, &type, &plan, &present, &screen, (unsigned char *)p_connectinfo.id, sizeof(p_connectinfo.id));
1000 dec_ie_display(l3m, (unsigned char *)p_connectinfo.display, sizeof(p_connectinfo.display));
1001 /* te-mode: CONP (connected name identification presentation) */
1002 dec_facility_centrex(l3m, (unsigned char *)p_connectinfo.name, sizeof(p_connectinfo.name));
1005 /* select channel */
1006 bchannel_before = p_m_b_channel;
1007 ret = received_first_reply_to_setup(cmd, channel, exclusive);
1009 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1010 message->param.disconnectinfo.cause = -ret;
1011 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1012 message_put(message);
1013 new_state(PORT_STATE_RELEASE);
1014 trigger_work(&p_m_d_delete);
1018 /* connect information */
1021 p_connectinfo.present = INFO_PRESENT_RESTRICTED;
1024 p_connectinfo.present = INFO_PRESENT_NOTAVAIL;
1027 p_connectinfo.present = INFO_PRESENT_ALLOWED;
1032 p_connectinfo.screen = INFO_SCREEN_USER;
1035 p_connectinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
1038 p_connectinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
1041 p_connectinfo.screen = INFO_SCREEN_NETWORK;
1046 p_connectinfo.ntype = INFO_NTYPE_NOTPRESENT;
1049 p_connectinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1052 p_connectinfo.ntype = INFO_NTYPE_NATIONAL;
1055 p_connectinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1058 p_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
1061 p_connectinfo.isdn_port = p_m_portnum;
1062 SCPY(p_connectinfo.interface, p_m_mISDNport->ifport->interface->name);
1064 /* only in nt-mode we send connect ack. in te-mode it is done by stack itself or optional */
1066 /* send connect acknowledge */
1067 l3m = create_l3msg();
1068 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_RES, DIRECTION_OUT);
1069 /* if we had no bchannel before, we send it now */
1070 if (!bchannel_before && p_m_b_channel)
1071 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1073 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT_ACKNOWLEDGE, p_m_d_l3id, l3m);
1076 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_CONNECT);
1077 memcpy(&message->param.connectinfo, &p_connectinfo, sizeof(struct connect_info));
1078 message_put(message);
1080 new_state(PORT_STATE_CONNECT);
1083 /* CC_DISCONNECT INDICATION */
1084 void Pdss1::disconnect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1086 int location, cause;
1087 int coding, proglocation, progress;
1088 struct lcr_msg *message;
1089 unsigned char display[128] = "";
1091 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1092 dec_ie_progress(l3m, &coding, &proglocation, &progress);
1093 dec_ie_cause(l3m, &location, &cause);
1094 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1099 location = LOCATION_PRIVATE_LOCAL;
1102 /* release if remote sends us no tones */
1103 if (!p_m_mISDNport->earlyb) {
1106 l3m = create_l3msg();
1107 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
1108 enc_ie_cause(l3m, location, cause); /* normal */
1109 add_trace("reason", NULL, "no remote patterns");
1111 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
1113 /* sending release to endpoint */
1114 if (location == LOCATION_PRIVATE_LOCAL)
1115 location = LOCATION_PRIVATE_REMOTE;
1116 while(p_epointlist) {
1117 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1118 message->param.disconnectinfo.cause = cause;
1119 message->param.disconnectinfo.location = location;
1120 SCAT(message->param.disconnectinfo.display, (char *)display);
1121 message_put(message);
1123 free_epointlist(p_epointlist);
1125 new_state(PORT_STATE_RELEASE);
1126 trigger_work(&p_m_d_delete);
1130 /* sending disconnect to active endpoint and release to inactive endpoints */
1131 if (location == LOCATION_PRIVATE_LOCAL)
1132 location = LOCATION_PRIVATE_REMOTE;
1133 if (ACTIVE_EPOINT(p_epointlist)) {
1134 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_DISCONNECT);
1135 message->param.disconnectinfo.location = location;
1136 message->param.disconnectinfo.cause = cause;
1137 SCAT(message->param.disconnectinfo.display, (char *)display);
1138 message_put(message);
1140 while(INACTIVE_EPOINT(p_epointlist)) {
1141 message = message_create(p_serial, INACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
1142 message->param.disconnectinfo.location = location;
1143 message->param.disconnectinfo.cause = cause;
1144 SCAT(message->param.disconnectinfo.display, (char *)display);
1145 message_put(message);
1147 free_epointid(INACTIVE_EPOINT(p_epointlist));
1149 new_state(PORT_STATE_IN_DISCONNECT);
1152 /* CC_DISCONNECT INDICATION */
1153 void Pdss1::disconnect_ind_i(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1155 int location, cause;
1158 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
1159 if (p_m_d_collect_cause > 0) {
1160 add_trace("old-cause", "location", "%d", p_m_d_collect_location);
1161 add_trace("old-cause", "value", "%d", p_m_d_collect_cause);
1163 dec_ie_cause(l3m, &location, &cause);
1164 if (location == LOCATION_PRIVATE_LOCAL)
1165 location = LOCATION_PRIVATE_REMOTE;
1168 collect_cause(&p_m_d_collect_cause, &p_m_d_collect_location, cause, location);
1169 add_trace("new-cause", "location", "%d", p_m_d_collect_location);
1170 add_trace("new-cause", "value", "%d", p_m_d_collect_cause);
1175 /* CC_RELEASE INDICATION */
1176 void Pdss1::release_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1178 int location, cause;
1179 struct lcr_msg *message;
1180 unsigned char display[128] = "";
1182 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_IND, DIRECTION_IN);
1183 dec_ie_cause(l3m, &location, &cause);
1184 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1189 location = LOCATION_PRIVATE_LOCAL;
1192 /* sending release to endpoint */
1193 if (location == LOCATION_PRIVATE_LOCAL)
1194 location = LOCATION_PRIVATE_REMOTE;
1195 while(p_epointlist) {
1196 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1197 message->param.disconnectinfo.cause = cause;
1198 message->param.disconnectinfo.location = location;
1199 SCAT(message->param.disconnectinfo.display, (char *)display);
1200 message_put(message);
1202 free_epointlist(p_epointlist);
1205 new_state(PORT_STATE_RELEASE);
1206 trigger_work(&p_m_d_delete);
1209 /* CC_RESTART INDICATION */
1210 void Pdss1::restart_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1212 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESTART_IND, DIRECTION_IN);
1215 // L3 process is not toucht. (not even by network stack)
1218 /* CC_RELEASE_COMPLETE INDICATION (a reject) */
1219 void Pdss1::release_complete_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1221 int location, cause;
1222 struct lcr_msg *message;
1224 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_IND, DIRECTION_IN);
1225 /* in case layer 2 is down during setup, we send cause 27 loc 5 */
1226 if (p_state == PORT_STATE_OUT_SETUP && p_m_mISDNport->l1link == 0) {
1230 dec_ie_cause(l3m, &location, &cause);
1231 if (p_m_mISDNport->l1link < 0)
1232 add_trace("layer 1", NULL, "unknown");
1234 add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
1237 if (location == LOCATION_PRIVATE_LOCAL)
1238 location = LOCATION_PRIVATE_REMOTE;
1242 location = LOCATION_PRIVATE_LOCAL;
1245 /* sending release to endpoint */
1246 while(p_epointlist) {
1247 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1248 message->param.disconnectinfo.cause = cause;
1249 message->param.disconnectinfo.location = location;
1250 message_put(message);
1252 free_epointlist(p_epointlist);
1255 new_state(PORT_STATE_RELEASE);
1256 trigger_work(&p_m_d_delete);
1260 void Pdss1::t312_timeout_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1262 // not required, release is performed with MT_FREE
1265 /* CC_NOTIFY INDICATION */
1266 void Pdss1::notify_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1268 struct lcr_msg *message;
1269 int notify, type, plan, present;
1270 unsigned char notifyid[sizeof(message->param.notifyinfo.id)];
1271 unsigned char display[128] = "";
1273 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_IND, DIRECTION_IN);
1274 dec_ie_notify(l3m, ¬ify);
1275 dec_ie_redir_dn(l3m, &type, &plan, &present, notifyid, sizeof(notifyid));
1276 dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
1279 if (!ACTIVE_EPOINT(p_epointlist))
1281 /* notification indicator */
1285 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1286 message->param.notifyinfo.notify = notify;
1287 SCPY(message->param.notifyinfo.id, (char *)notifyid);
1288 /* redirection number */
1291 message->param.notifyinfo.present = INFO_PRESENT_RESTRICTED;
1294 message->param.notifyinfo.present = INFO_PRESENT_NOTAVAIL;
1297 message->param.notifyinfo.present = INFO_PRESENT_ALLOWED;
1302 message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT;
1305 message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
1308 message->param.notifyinfo.ntype = INFO_NTYPE_NATIONAL;
1311 message->param.notifyinfo.ntype = INFO_NTYPE_SUBSCRIBER;
1314 message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
1317 SCAT(message->param.notifyinfo.display, (char *)display);
1318 message->param.notifyinfo.isdn_port = p_m_portnum;
1319 message_put(message);
1323 /* CC_HOLD INDICATION */
1324 struct lcr_msg *message;
1325 void Pdss1::hold_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1327 // class Endpoint *epoint;
1329 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_IND, DIRECTION_IN);
1332 if (!ACTIVE_EPOINT(p_epointlist) || p_m_hold) {
1333 l3m = create_l3msg();
1334 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_REJECT_REQ, DIRECTION_OUT);
1335 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */
1336 add_trace("reason", NULL, "no endpoint");
1338 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_REJECT, p_m_d_l3id, l3m);
1343 /* notify the hold of call */
1344 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1345 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_HOLD;
1346 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1347 message_put(message);
1349 /* deactivate bchannel */
1350 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (hold)", DIRECTION_NONE);
1351 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1355 /* set hold state */
1358 epoint = find_epoint_id(ACTIVE_EPOINT(p_epointlist));
1359 if (epoint && p_m_d_ntmode) {
1360 if (p_settings.tout_hold)
1361 schedule_timer(&p_m_timeout, p_settings.tout_hold, 0);
1365 /* acknowledge hold */
1366 l3m = create_l3msg();
1367 l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1369 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_ACKNOWLEDGE, p_m_d_l3id, l3m);
1373 /* CC_RETRIEVE INDICATION */
1374 void Pdss1::retrieve_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1376 struct lcr_msg *message;
1377 int channel, exclusive, cause;
1380 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_IND, DIRECTION_IN);
1381 dec_ie_channel_id(l3m, &exclusive, &channel);
1385 cause = 101; /* incompatible state */
1388 l3m = create_l3msg();
1389 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_REJECT_REQ, DIRECTION_OUT);
1390 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, cause);
1392 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_REJECT, p_m_d_l3id, l3m);
1397 /* notify the retrieve of call */
1398 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1399 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL;
1400 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1401 message_put(message);
1404 ret = channel = hunt_bchannel(channel, exclusive);
1409 ret = seize_bchannel(channel, 1);
1415 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1417 /* set hold state */
1419 unsched_timer(&p_m_timeout);
1421 /* acknowledge retrieve */
1422 l3m = create_l3msg();
1423 l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1424 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1426 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_ACKNOWLEDGE, p_m_d_l3id, l3m);
1429 /* CC_SUSPEND INDICATION */
1430 void Pdss1::suspend_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1432 struct lcr_msg *message;
1433 class Endpoint *epoint;
1434 unsigned char callid[8];
1436 int ret = -31; /* normal, unspecified */
1438 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_IND, DIRECTION_IN);
1439 dec_ie_call_id(l3m, callid, &len);
1442 if (!ACTIVE_EPOINT(p_epointlist)) {
1444 l3m = create_l3msg();
1445 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_REJECT_REQ, DIRECTION_OUT);
1446 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1448 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_REJECT, p_m_d_l3id, l3m);
1455 /* check if call id is in use */
1456 epoint = epoint_first;
1458 if (epoint->ep_park) {
1459 if (epoint->ep_park_len == len)
1460 if (!memcmp(epoint->ep_park_callid, callid, len)) {
1461 ret = -84; /* call id in use */
1465 epoint = epoint->next;
1468 /* notify the hold of call */
1469 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1470 message->param.notifyinfo.notify = INFO_NOTIFY_USER_SUSPENDED;
1471 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
1472 message_put(message);
1474 /* deactivate bchannel */
1475 chan_trace_header(p_m_mISDNport, this, "CHANNEL RELEASE (suspend)", DIRECTION_NONE);
1476 add_trace("disconnect", "channel", "%d", p_m_b_channel);
1480 /* sending suspend to endpoint */
1481 while (p_epointlist) {
1482 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_SUSPEND);
1483 memcpy(message->param.parkinfo.callid, callid, sizeof(message->param.parkinfo.callid));
1484 message->param.parkinfo.len = len;
1485 message_put(message);
1487 free_epointlist(p_epointlist);
1490 /* sending SUSPEND_ACKNOWLEDGE */
1491 l3m = create_l3msg();
1492 l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1494 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_ACKNOWLEDGE, p_m_d_l3id, l3m);
1496 new_state(PORT_STATE_RELEASE);
1497 trigger_work(&p_m_d_delete);
1500 /* CC_RESUME INDICATION */
1501 void Pdss1::resume_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1503 unsigned char callid[8];
1505 int channel, exclusive;
1506 class Endpoint *epoint;
1507 struct lcr_msg *message;
1510 /* process given callref */
1511 l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
1512 add_trace("callref", "new", "0x%x", pid);
1514 /* release is case the ID is already in use */
1515 add_trace("error", NULL, "callref already in use");
1517 l3m = create_l3msg();
1518 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1519 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
1520 add_trace("reason", NULL, "callref already in use");
1522 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, pid, l3m);
1523 new_state(PORT_STATE_RELEASE);
1524 trigger_work(&p_m_d_delete);
1528 p_m_d_ces = pid >> 16;
1531 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_IND, DIRECTION_IN);
1532 dec_ie_call_id(l3m, callid, &len);
1535 /* if blocked, release call */
1536 if (p_m_mISDNport->ifport->block) {
1544 /* channel_id (no channel is possible in message) */
1546 channel = -1; /* any channel */
1549 ret = channel = hunt_bchannel(channel, exclusive);
1553 // mode (if hdlc parked) to be done. never mind, this is almost never requested
1555 ret = seize_bchannel(channel, 1);
1559 l3m = create_l3msg();
1560 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
1561 enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
1563 add_trace("reason", NULL, "port blocked");
1565 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, p_m_d_l3id, l3m);
1566 new_state(PORT_STATE_RELEASE);
1567 trigger_work(&p_m_d_delete);
1570 bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
1572 /* create endpoint */
1574 FATAL("Incoming resume but already got an endpoint.\n");
1575 ret = -85; /* no call suspended */
1576 epoint = epoint_first;
1578 if (epoint->ep_park) {
1579 ret = -83; /* suspended call exists, but this not */
1580 if (epoint->ep_park_len == len)
1581 if (!memcmp(epoint->ep_park_callid, callid, len))
1584 epoint = epoint->next;
1589 epointlist_new(epoint->ep_serial);
1590 if (!(epoint->portlist_new(p_serial, p_type, p_m_mISDNport->earlyb)))
1591 FATAL("No memory for portlist\n");
1592 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RESUME);
1593 message_put(message);
1595 /* notify the resume of call */
1596 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
1597 message->param.notifyinfo.notify = INFO_NOTIFY_USER_RESUMED;
1598 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
1599 message_put(message);
1601 /* sending RESUME_ACKNOWLEDGE */
1602 l3m = create_l3msg();
1603 l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_ACKNOWLEDGE_REQ, DIRECTION_OUT);
1604 enc_ie_channel_id(l3m, 1, p_m_b_channel);
1606 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_ACKNOWLEDGE, p_m_d_l3id, l3m);
1608 new_state(PORT_STATE_CONNECT);
1612 /* CC_FACILITY INDICATION */
1613 void Pdss1::facility_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1615 unsigned char facil[256];
1617 struct lcr_msg *message;
1619 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_IND, DIRECTION_IN);
1620 dec_ie_facility(l3m, facil, &facil_len);
1627 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_FACILITY);
1628 message->param.facilityinfo.len = facil_len;
1629 memcpy(message->param.facilityinfo.data, facil, facil_len);
1630 message_put(message);
1634 /* CC_PROGRESS INDICATION */
1635 void Pdss1::progress_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1637 int coding, location, progress;
1639 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROGRESS_IND, DIRECTION_IN);
1640 dec_ie_progress(l3m, &coding, &location, &progress);
1646 * handler for isdn connections
1647 * incoming information are parsed and sent via message to the endpoint
1649 void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
1656 PERROR("Pdss1(%s) timeout without cause.\n", p_name);
1659 if (l3m->cause[0] != 5) {
1660 PERROR("Pdss1(%s) expecting timeout with timer diagnostic. (got len=%d)\n", p_name, l3m->cause[0]);
1663 timer = (l3m->cause[3]-'0')*100;
1664 timer += (l3m->cause[4]-'0')*10;
1665 timer += (l3m->cause[5]-'0');
1666 l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN);
1667 add_trace("timer", NULL, "%d", timer);
1670 t312_timeout_ind(cmd, pid, l3m);
1674 if (p_state != PORT_STATE_IDLE)
1676 setup_ind(cmd, pid, l3m);
1679 case MT_INFORMATION:
1680 information_ind(cmd, pid, l3m);
1683 case MT_SETUP_ACKNOWLEDGE:
1684 if (p_state != PORT_STATE_OUT_SETUP) {
1685 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received setup_acknowledge, but we are not in outgoing setup state, IGNORING.\n", p_name);
1688 setup_acknowledge_ind(cmd, pid, l3m);
1691 case MT_CALL_PROCEEDING:
1692 if (p_state != PORT_STATE_OUT_SETUP
1693 && p_state != PORT_STATE_OUT_OVERLAP) {
1694 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received proceeding, but we are not in outgoing setup OR overlap state, IGNORING.\n", p_name);
1697 proceeding_ind(cmd, pid, l3m);
1701 if (p_state != PORT_STATE_OUT_SETUP
1702 && p_state != PORT_STATE_OUT_OVERLAP
1703 && p_state != PORT_STATE_OUT_PROCEEDING) {
1704 PDEBUG(DEBUG_ISDN, "Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding state, IGNORING.\n", p_name);
1707 alerting_ind(cmd, pid, l3m);
1711 if (p_state != PORT_STATE_OUT_SETUP
1712 && p_state != PORT_STATE_OUT_OVERLAP
1713 && p_state != PORT_STATE_OUT_PROCEEDING
1714 && p_state != PORT_STATE_OUT_ALERTING) {
1715 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);
1718 connect_ind(cmd, pid, l3m);
1719 if (p_m_d_notify_pending) {
1720 /* send pending notify message during connect */
1721 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1722 message_free(p_m_d_notify_pending);
1723 p_m_d_notify_pending = NULL;
1727 case MT_CONNECT_ACKNOWLEDGE:
1728 if (p_state == PORT_STATE_CONNECT_WAITING)
1729 new_state(PORT_STATE_CONNECT);
1730 if (p_m_d_notify_pending) {
1731 /* send pending notify message during connect-ack */
1732 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
1733 message_free(p_m_d_notify_pending);
1734 p_m_d_notify_pending = NULL;
1739 disconnect_ind(cmd, pid, l3m);
1743 release_ind(cmd, pid, l3m);
1746 case MT_RELEASE_COMPLETE:
1747 release_complete_ind(cmd, pid, l3m);
1751 restart_ind(cmd, pid, l3m);
1755 notify_ind(cmd, pid, l3m);
1759 hold_ind(cmd, pid, l3m);
1763 retrieve_ind(cmd, pid, l3m);
1767 suspend_ind(cmd, pid, l3m);
1771 resume_ind(cmd, pid, l3m);
1775 facility_ind(cmd, pid, l3m);
1779 progress_ind(cmd, pid, l3m);
1783 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_L3ID_IND, DIRECTION_IN);
1784 add_trace("callref", NULL, "0x%x", p_m_d_l3id);
1787 trigger_work(&p_m_d_delete);
1789 /* sending release to endpoint in case we still have an endpoint
1790 * this is because we don't get any response if a release_complete is received (or a release in release state)
1792 while(p_epointlist) { // only if not already released
1793 struct lcr_msg *message;
1794 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
1795 if (p_m_d_collect_cause) {
1796 message->param.disconnectinfo.cause = p_m_d_collect_cause;
1797 message->param.disconnectinfo.location = p_m_d_collect_location;
1799 message->param.disconnectinfo.cause = CAUSE_NOUSER;
1800 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
1802 message_put(message);
1804 free_epointlist(p_epointlist);
1806 new_state(PORT_STATE_RELEASE);
1811 l1l2l3_trace_header(p_m_mISDNport, this, L3_UNKNOWN_IND, DIRECTION_IN);
1812 add_trace("unhandled", "cmd", "0x%x", cmd);
1817 void Pdss1::new_state(int state)
1819 // class Endpoint *epoint;
1822 if (state == PORT_STATE_IN_OVERLAP) {
1823 if (p_m_mISDNport->ifport->tout_dialing)
1824 schedule_timer(&p_m_timeout, p_m_mISDNport->ifport->tout_dialing, 0);
1826 if (state != p_state) {
1827 unsched_timer(&p_m_timeout);
1828 if (state == PORT_STATE_IN_SETUP
1829 || state == PORT_STATE_OUT_SETUP
1830 || state == PORT_STATE_IN_OVERLAP
1831 || state == PORT_STATE_OUT_OVERLAP) {
1832 if (p_m_mISDNport->ifport->tout_setup)
1833 schedule_timer(&p_m_timeout, p_m_mISDNport->ifport->tout_setup, 0);
1835 if (state == PORT_STATE_IN_PROCEEDING
1836 || state == PORT_STATE_OUT_PROCEEDING) {
1837 if (p_m_mISDNport->ifport->tout_proceeding)
1838 schedule_timer(&p_m_timeout, p_m_mISDNport->ifport->tout_proceeding, 0);
1840 if (state == PORT_STATE_IN_ALERTING
1841 || state == PORT_STATE_OUT_ALERTING) {
1842 if (p_m_mISDNport->ifport->tout_alerting)
1843 schedule_timer(&p_m_timeout, p_m_mISDNport->ifport->tout_alerting, 0);
1846 if (state == PORT_STATE_CONNECT
1847 || state == PORT_STATE_CONNECT_WAITING) {
1848 if (p_m_mISDNport->ifport->tout_connect)
1849 schedule_timer(&p_m_timeout, p_m_mISDNport->ifport->tout_connect, 0);
1852 if (state == PORT_STATE_IN_DISCONNECT
1853 || state == PORT_STATE_OUT_DISCONNECT) {
1854 if (p_m_mISDNport->ifport->tout_disconnect)
1855 schedule_timer(&p_m_timeout, p_m_mISDNport->ifport->tout_disconnect, 0);
1859 Port::new_state(state);
1863 /* deletes only if l3id is release, otherwhise it will be triggered then */
1864 static int delete_event(struct lcr_work *work, void *instance, int index)
1866 class Pdss1 *isdnport = (class Pdss1 *)instance;
1868 if (!isdnport->p_m_d_l3id)
1876 * handles all messages from endpoint
1878 /* MESSAGE_INFORMATION */
1879 void Pdss1::message_information(unsigned int epoint_id, int message_id, union parameter *param)
1882 char *display = param->information.display;
1883 char *number = param->information.id;
1884 int max = p_m_mISDNport->ifport->dialmax;
1886 while (number[0]) { /* as long we have something to dial */
1887 if (max > (int)strlen(number) || max == 0)
1888 max = (int)strlen(number);
1890 l3m = create_l3msg();
1891 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
1892 enc_ie_called_pn(l3m, 0, 1, (unsigned char *)number, max);
1893 if ((p_m_d_ntmode || p_m_d_tespecial) && display[0]) {
1894 enc_ie_display(l3m, (unsigned char *)display);
1895 display = (char *)"";
1898 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);
1926 trigger_work(&p_m_d_delete);
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);
1992 trigger_work(&p_m_d_delete);
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);
2104 if (p_dialinginfo.keypad[0])
2105 enc_ie_keypad(l3m, (unsigned char *)p_dialinginfo.keypad);
2106 /* sending complete */
2107 if (p_dialinginfo.sending_complete)
2108 enc_ie_complete(l3m, 1);
2109 /* sending user-user */
2110 if (param->setup.useruser.len) {
2111 enc_ie_useruser(l3m, param->setup.useruser.protocol, param->setup.useruser.data, param->setup.useruser.len);
2113 /* redirecting number */
2115 switch (p_redirinfo.ntype) {
2116 case INFO_NTYPE_UNKNOWN:
2119 case INFO_NTYPE_INTERNATIONAL:
2122 case INFO_NTYPE_NATIONAL:
2125 case INFO_NTYPE_SUBSCRIBER:
2128 default: /* INFO_NTYPE_NOTPRESENT */
2132 switch (p_redirinfo.screen) {
2133 case INFO_SCREEN_USER:
2136 case INFO_SCREEN_USER_VERIFIED_PASSED:
2139 case INFO_SCREEN_USER_VERIFIED_FAILED:
2142 default: /* INFO_SCREE_NETWORK */
2146 switch (p_redirinfo.reason) {
2147 case INFO_REDIR_BUSY:
2150 case INFO_REDIR_NORESPONSE:
2153 case INFO_REDIR_UNCONDITIONAL:
2156 case INFO_REDIR_CALLDEFLECT:
2159 case INFO_REDIR_OUTOFORDER:
2162 default: /* INFO_REDIR_UNKNOWN */
2166 switch (p_redirinfo.present) {
2167 case INFO_PRESENT_ALLOWED:
2170 case INFO_PRESENT_RESTRICTED:
2173 default: /* INFO_PRESENT_NOTAVAIL */
2177 /* sending redirecting number only in ntmode */
2178 if (type >= 0 && (p_m_d_ntmode || p_m_d_tespecial))
2179 enc_ie_redir_nr(l3m, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
2180 /* bearer capability */
2181 //printf("hlc=%d\n",p_capainfo.hlc);
2183 capability = p_capainfo.bearer_capa;
2184 mode = p_capainfo.bearer_mode;
2185 rate = (mode==INFO_BMODE_CIRCUIT)?0x10:0x00;
2186 switch (p_capainfo.bearer_info1) {
2187 case INFO_INFO1_NONE:
2191 user = p_capainfo.bearer_info1 & 0x7f;
2194 enc_ie_bearer(l3m, coding, capability, mode, rate, -1, user);
2196 if (p_capainfo.hlc) {
2200 hlc = p_capainfo.hlc & 0x7f;
2202 if (p_capainfo.exthlc)
2203 exthlc = p_capainfo.exthlc & 0x7f;
2204 enc_ie_hlc(l3m, coding, interpretation, presentation, hlc, exthlc);
2208 if (p_callerinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2209 enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
2210 /* nt-mode: CNIP (calling name identification presentation) */
2211 // if (p_callerinfo.name[0] && (p_m_d_ntmode || p_m_d_tespecial))
2212 // enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
2215 /* send setup message now */
2216 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP, p_m_d_l3id, l3m);
2218 new_state(PORT_STATE_OUT_SETUP);
2221 /* MESSAGE_FACILITY */
2222 void Pdss1::message_facility(unsigned int epoint_id, int message_id, union parameter *param)
2226 /* facility will not be sent to external lines */
2227 if (!p_m_d_ntmode && !p_m_d_tespecial)
2230 /* sending facility */
2231 l3m = create_l3msg();
2232 l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
2233 enc_ie_facility(l3m, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len);
2235 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
2238 /* MESSAGE_NOTIFY */
2239 void Pdss1::message_notify(unsigned int epoint_id, int message_id, union parameter *param)
2243 int plan = 0, type = -1, present = 0;
2245 if (p_m_mISDNport->ifport->nonotify) {
2246 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
2247 add_trace("info", NULL, "blocked by config");
2252 // printf("if = %d\n", param->notifyinfo.notify);
2253 if (param->notifyinfo.notify>INFO_NOTIFY_NONE)
2254 notify = param->notifyinfo.notify & 0x7f;
2259 switch (param->notifyinfo.ntype) {
2260 case INFO_NTYPE_UNKNOWN:
2263 case INFO_NTYPE_INTERNATIONAL:
2266 case INFO_NTYPE_NATIONAL:
2269 case INFO_NTYPE_SUBSCRIBER:
2272 default: /* INFO_NTYPE_UNKNOWN */
2276 switch (param->notifyinfo.present) {
2277 case INFO_PRESENT_ALLOWED:
2280 case INFO_PRESENT_RESTRICTED:
2283 default: /* INFO_PRESENT_NOTAVAIL */
2289 if (notify<0 && !param->notifyinfo.display[0]) {
2290 /* nothing to notify, nothing to display */
2295 if (p_state!=PORT_STATE_CONNECT && p_state!=PORT_STATE_IN_PROCEEDING && p_state!=PORT_STATE_IN_ALERTING) {
2296 /* queue notification */
2297 if (p_m_d_notify_pending)
2298 message_free(p_m_d_notify_pending);
2299 p_m_d_notify_pending = message_create(ACTIVE_EPOINT(p_epointlist), p_serial, EPOINT_TO_PORT, message_id);
2300 memcpy(&p_m_d_notify_pending->param, param, sizeof(union parameter));
2302 /* sending notification */
2303 l3m = create_l3msg();
2304 l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
2305 enc_ie_notify(l3m, notify);
2306 /* sending redirection number only in ntmode */
2307 if (type >= 0 && (p_m_d_ntmode || p_m_d_tespecial))
2308 enc_ie_redir_dn(l3m, type, plan, present, (unsigned char *)param->notifyinfo.id);
2309 if (param->notifyinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2310 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2312 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_NOTIFY, p_m_d_l3id, l3m);
2314 } else if (p_m_d_ntmode || p_m_d_tespecial) {
2315 /* sending information */
2316 l3m = create_l3msg();
2317 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2318 enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
2320 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2324 /* MESSAGE_OVERLAP */
2325 void Pdss1::message_overlap(unsigned int epoint_id, int message_id, union parameter *param)
2329 /* in case of sending complete, we proceed */
2330 if (p_dialinginfo.sending_complete) {
2331 PDEBUG(DEBUG_ISDN, "sending proceeding instead of setup_acknowledge, because address is complete.\n");
2332 message_proceeding(epoint_id, message_id, param);
2336 /* sending setup_acknowledge */
2337 l3m = create_l3msg();
2338 l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_REQ, DIRECTION_OUT);
2339 /* channel information */
2340 if (p_state == PORT_STATE_IN_SETUP)
2341 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2342 /* progress information */
2343 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2344 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2345 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2346 if (p_m_mISDNport->tones)
2347 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2349 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, l3m);
2351 new_state(PORT_STATE_IN_OVERLAP);
2354 /* MESSAGE_PROCEEDING */
2355 void Pdss1::message_proceeding(unsigned int epoint_id, int message_id, union parameter *param)
2359 /* sending proceeding */
2360 l3m = create_l3msg();
2361 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2362 /* channel information */
2363 if (p_state == PORT_STATE_IN_SETUP)
2364 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2365 /* progress information */
2366 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2367 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2368 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2369 if (p_m_mISDNport->tones)
2370 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2372 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2374 new_state(PORT_STATE_IN_PROCEEDING);
2377 /* MESSAGE_ALERTING */
2378 void Pdss1::message_alerting(unsigned int epoint_id, int message_id, union parameter *param)
2382 /* NT-MODE in setup state we must send PROCEEDING first */
2383 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP) {
2384 /* sending proceeding */
2385 l3m = create_l3msg();
2386 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2387 /* channel information */
2388 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2389 /* progress information */
2390 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2391 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2392 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2393 if (p_m_mISDNport->tones)
2394 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2396 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2397 new_state(PORT_STATE_IN_PROCEEDING);
2400 /* sending alerting */
2401 l3m = create_l3msg();
2402 l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_REQ, DIRECTION_OUT);
2403 /* channel information */
2404 if (p_state == PORT_STATE_IN_SETUP)
2405 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2406 /* progress information */
2407 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2408 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2409 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2410 if (p_m_mISDNport->tones)
2411 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2413 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ALERTING, p_m_d_l3id, l3m);
2415 new_state(PORT_STATE_IN_ALERTING);
2418 /* MESSAGE_CONNECT */
2419 void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parameter *param)
2422 int type, plan, present, screen;
2423 class Endpoint *epoint;
2424 time_t current_time;
2426 /* NT-MODE in setup state we must send PROCEEDING first */
2427 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP) {
2428 /* sending proceeding */
2429 l3m = create_l3msg();
2430 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2431 /* channel information */
2432 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2434 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2435 new_state(PORT_STATE_IN_PROCEEDING);
2438 /* copy connected information */
2439 memcpy(&p_connectinfo, ¶m->connectinfo, sizeof(p_connectinfo));
2440 /* screen outgoing caller id */
2441 do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface);
2443 /* only display at connect state */
2444 if (p_state == PORT_STATE_CONNECT)
2445 if (p_connectinfo.display[0]) {
2446 /* sending information */
2447 l3m = create_l3msg();
2448 l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
2449 if (p_m_d_ntmode || p_m_d_tespecial)
2450 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2452 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
2456 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) {
2457 /* connect command only possible in setup, proceeding or alerting state */
2461 /* preparing connect message */
2462 l3m = create_l3msg();
2463 l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_REQ, DIRECTION_OUT);
2464 /* connect information */
2466 switch (p_connectinfo.ntype) {
2467 case INFO_NTYPE_UNKNOWN:
2470 case INFO_NTYPE_INTERNATIONAL:
2473 case INFO_NTYPE_NATIONAL:
2476 case INFO_NTYPE_SUBSCRIBER:
2479 default: /* INFO_NTYPE_NOTPRESENT */
2483 switch (param->connectinfo.screen) {
2484 case INFO_SCREEN_USER:
2487 case INFO_SCREEN_USER_VERIFIED_PASSED:
2490 case INFO_SCREEN_USER_VERIFIED_FAILED:
2493 default: /* INFO_SCREE_NETWORK */
2497 switch (p_connectinfo.present) {
2498 case INFO_PRESENT_ALLOWED:
2501 case INFO_PRESENT_RESTRICTED:
2504 default: /* INFO_PRESENT_NOTAVAIL */
2509 enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
2511 if (p_connectinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
2512 enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
2513 /* nt-mode: CONP (connected name identification presentation) */
2514 // if (p_connectinfo.name[0] && (p_m_d_ntmode || p_m_d_tespecial))
2515 // enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
2517 if (p_m_d_ntmode || p_m_d_tespecial) {
2518 epoint = find_epoint_id(epoint_id);
2519 time(¤t_time);
2520 enc_ie_date(l3m, current_time, p_settings.no_seconds);
2523 /* finally send message */
2524 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT, p_m_d_l3id, l3m);
2527 new_state(PORT_STATE_CONNECT);
2529 new_state(PORT_STATE_CONNECT_WAITING);
2533 /* MESSAGE_DISCONNECT */
2534 void Pdss1::message_disconnect(unsigned int epoint_id, int message_id, union parameter *param)
2537 struct lcr_msg *message;
2540 /* we reject during incoming setup when we have no tones. also if we are in outgoing setup state */
2541 // if ((p_state==PORT_STATE_IN_SETUP && !p_m_mISDNport->tones)
2542 if (/* ||*/ p_state==PORT_STATE_OUT_SETUP) {
2543 /* sending release to endpoint */
2544 while(p_epointlist) {
2545 message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
2546 memcpy(&message->param, param, sizeof(union parameter));
2547 message_put(message);
2549 free_epointlist(p_epointlist);
2551 /* sending release */
2552 l3m = create_l3msg();
2553 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
2555 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2557 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2558 new_state(PORT_STATE_RELEASE);
2559 trigger_work(&p_m_d_delete);
2563 /* workarround: NT-MODE in setup state we must send PROCEEDING first to make it work */
2564 if (p_state==PORT_STATE_IN_SETUP) {
2565 /* sending proceeding */
2566 l3m = create_l3msg();
2567 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2568 /* channel information */
2569 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2570 /* progress information */
2571 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2572 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2573 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2574 if (p_m_mISDNport->tones)
2575 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2577 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2578 new_state(PORT_STATE_IN_PROCEEDING);
2581 /* sending disconnect */
2582 l3m = create_l3msg();
2583 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2584 /* progress information */
2585 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2586 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2587 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2588 if (p_m_mISDNport->tones)
2589 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2591 enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
2593 if (param->disconnectinfo.display[0])
2594 p = param->disconnectinfo.display;
2595 if (p) if (*p && (p_m_d_ntmode || p_m_d_tespecial))
2596 enc_ie_display(l3m, (unsigned char *)p);
2598 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2599 new_state(PORT_STATE_OUT_DISCONNECT);
2602 /* MESSAGE_RELEASE */
2603 void Pdss1::message_release(unsigned int epoint_id, int message_id, union parameter *param)
2606 class Endpoint *epoint;
2610 * we may only release during incoming disconnect state.
2611 * this means that the endpoint doesnt require audio anymore
2613 if (p_state == PORT_STATE_IN_DISCONNECT
2614 || p_state == PORT_STATE_OUT_DISCONNECT) {
2615 /* sending release */
2616 l3m = create_l3msg();
2617 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2619 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2621 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
2622 new_state(PORT_STATE_RELEASE);
2624 free_epointid(epoint_id);
2625 // wait for callref to be released
2630 * if we are on incoming call setup, we may reject by sending a release_complete
2631 * also on outgoing call setup, we send a release complete, BUT this is not conform. (i don't know any other way)
2633 if (p_state==PORT_STATE_IN_SETUP
2634 || p_state==PORT_STATE_OUT_SETUP) {
2635 //#warning remove me
2636 //PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
2637 /* sending release complete */
2638 l3m = create_l3msg();
2639 l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
2641 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2643 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
2644 new_state(PORT_STATE_RELEASE);
2646 free_epointid(epoint_id);
2647 // wait for callref to be released
2652 wirklich erst proceeding?:
2653 /* NT-MODE in setup state we must send PROCEEDING first */
2654 if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP) {
2655 CALL_PROCEEDING_t *proceeding;
2657 /* sending proceeding */
2658 l3m = create_l3msg();
2659 l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
2660 /* channel information */
2661 enc_ie_channel_id(l3m, 1, p_m_b_channel);
2662 /* progress information */
2663 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2664 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2665 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2666 if (p_m_mISDNport->tones)
2667 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2669 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
2673 /* sending disconnect */
2674 l3m = create_l3msg();
2675 l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
2676 /* progress information */
2677 if (p_capainfo.bearer_capa==INFO_BC_SPEECH
2678 || p_capainfo.bearer_capa==INFO_BC_AUDIO
2679 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
2680 if (p_m_mISDNport->tones)
2681 enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
2683 enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
2685 epoint = find_epoint_id(epoint_id);
2686 if (param->disconnectinfo.display[0])
2687 p = param->disconnectinfo.display;
2688 if (p) if (*p && (p_m_d_ntmode || p_m_d_tespecial))
2689 enc_ie_display(l3m, (unsigned char *)p);
2691 p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
2692 new_state(PORT_STATE_OUT_DISCONNECT);
2694 free_epointid(epoint_id);
2695 // wait for release and callref to be released
2696 //#warning remove me
2697 //PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
2702 * endpoint sends messages to the port
2704 int Pdss1::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
2706 if (PmISDN::message_epoint(epoint_id, message_id, param))
2709 switch(message_id) {
2710 case MESSAGE_INFORMATION: /* overlap dialing */
2711 if (p_type==PORT_TYPE_DSS1_NT_OUT
2712 && p_state!=PORT_STATE_OUT_OVERLAP
2713 && p_state!=PORT_STATE_CONNECT
2714 && p_state!=PORT_STATE_OUT_DISCONNECT
2715 && p_state!=PORT_STATE_IN_DISCONNECT) {
2718 if (p_type==PORT_TYPE_DSS1_TE_OUT
2719 && p_state!=PORT_STATE_OUT_OVERLAP
2720 && p_state!=PORT_STATE_OUT_PROCEEDING
2721 && p_state!=PORT_STATE_OUT_ALERTING
2722 && p_state!=PORT_STATE_CONNECT
2723 && p_state!=PORT_STATE_OUT_DISCONNECT
2724 && p_state!=PORT_STATE_IN_DISCONNECT) {
2727 if ((p_type==PORT_TYPE_DSS1_NT_IN || p_type==PORT_TYPE_DSS1_TE_IN)
2728 && p_state!=PORT_STATE_IN_OVERLAP
2729 && p_state!=PORT_STATE_IN_PROCEEDING
2730 && p_state!=PORT_STATE_IN_ALERTING
2731 && p_state!=PORT_STATE_CONNECT
2732 && p_state!=PORT_STATE_CONNECT_WAITING
2733 && p_state!=PORT_STATE_OUT_DISCONNECT
2734 && p_state!=PORT_STATE_IN_DISCONNECT) {
2737 message_information(epoint_id, message_id, param);
2740 case MESSAGE_SETUP: /* dial-out command received from epoint */
2741 if (p_state!=PORT_STATE_IDLE
2742 && p_state!=PORT_STATE_CONNECT) {
2743 PERROR("Pdss1(%s) ignoring setup because isdn port is not in idle state (or connected for sending display info).\n", p_name);
2746 if (p_epointlist && p_state==PORT_STATE_IDLE)
2747 FATAL("Pdss1(%s): epoint pointer is set in idle state, how bad!!\n", p_name);
2748 message_setup(epoint_id, message_id, param);
2751 case MESSAGE_NOTIFY: /* display and notifications */
2752 message_notify(epoint_id, message_id, param);
2755 case MESSAGE_FACILITY: /* facility message */
2756 message_facility(epoint_id, message_id, param);
2759 case MESSAGE_OVERLAP: /* more information is needed */
2760 if (p_state!=PORT_STATE_IN_SETUP) {
2763 message_overlap(epoint_id, message_id, param);
2766 case MESSAGE_PROCEEDING: /* call of endpoint is proceeding */
2767 if (p_state!=PORT_STATE_IN_SETUP
2768 && p_state!=PORT_STATE_IN_OVERLAP) {
2771 message_proceeding(epoint_id, message_id, param);
2772 if (p_m_d_notify_pending) {
2773 /* send pending notify message during connect */
2774 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
2775 message_free(p_m_d_notify_pending);
2776 p_m_d_notify_pending = NULL;
2780 case MESSAGE_ALERTING: /* call of endpoint is ringing */
2781 if (p_state!=PORT_STATE_IN_SETUP
2782 && p_state!=PORT_STATE_IN_OVERLAP
2783 && p_state!=PORT_STATE_IN_PROCEEDING) {
2786 message_alerting(epoint_id, message_id, param);
2787 if (p_m_d_notify_pending) {
2788 /* send pending notify message during connect */
2789 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
2790 message_free(p_m_d_notify_pending);
2791 p_m_d_notify_pending = NULL;
2795 case MESSAGE_CONNECT: /* call of endpoint is connected */
2796 if (p_state!=PORT_STATE_IN_SETUP
2797 && p_state!=PORT_STATE_IN_OVERLAP
2798 && p_state!=PORT_STATE_IN_PROCEEDING
2799 && p_state!=PORT_STATE_IN_ALERTING
2800 && !(p_state==PORT_STATE_CONNECT && p_m_d_ntmode)) {
2803 message_connect(epoint_id, message_id, param);
2804 if (p_m_d_notify_pending) {
2805 /* send pending notify message during connect */
2806 message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
2807 message_free(p_m_d_notify_pending);
2808 p_m_d_notify_pending = NULL;
2812 case MESSAGE_DISCONNECT: /* call has been disconnected */
2813 if (p_state!=PORT_STATE_IN_SETUP
2814 && p_state!=PORT_STATE_IN_OVERLAP
2815 && p_state!=PORT_STATE_IN_PROCEEDING
2816 && p_state!=PORT_STATE_IN_ALERTING
2817 && p_state!=PORT_STATE_OUT_SETUP
2818 && p_state!=PORT_STATE_OUT_OVERLAP
2819 && p_state!=PORT_STATE_OUT_PROCEEDING
2820 && p_state!=PORT_STATE_OUT_ALERTING
2821 && p_state!=PORT_STATE_CONNECT
2822 && p_state!=PORT_STATE_CONNECT_WAITING) {
2825 message_disconnect(epoint_id, message_id, param);
2828 case MESSAGE_RELEASE: /* release isdn port */
2829 if (p_state==PORT_STATE_RELEASE) {
2832 message_release(epoint_id, message_id, param);
2836 PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message_id);
2845 * data from isdn-stack (layer-3) to pbx (port class)
2847 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
2853 PDEBUG(DEBUG_ISDN, "cmd(0x%x) pid(0x%x)\n", cmd, pid);
2856 PDEBUG(DEBUG_ISDN, "ignoring dummy process from phone.\n");
2860 /* find Port object of type ISDN */
2864 if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1) {
2865 pdss1 = (class Pdss1 *)port;
2866 /* check out correct stack and id */
2867 if (pdss1->p_m_mISDNport == mISDNport) {
2868 if (pdss1->p_m_d_l3id & MISDN_PID_CR_FLAG) {
2869 /* local callref, so match value only */
2870 if ((pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == (pid & MISDN_PID_CRVAL_MASK))
2873 /* remote callref, ref + channel id */
2874 if (pdss1->p_m_d_l3id == pid)
2882 /* aktueller prozess */
2884 if (cmd == MT_ASSIGN) {
2885 /* stack gives us new layer 3 id (during connect) */
2886 l1l2l3_trace_header(mISDNport, pdss1, L3_NEW_L3ID_IND, DIRECTION_IN);
2887 add_trace("callref", "old", "0x%x", pdss1->p_m_d_l3id);
2888 /* nt-library now gives us a new id via CC_SETUP_CONFIRM */
2889 if ((pdss1->p_m_d_l3id&MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER)
2890 PERROR(" strange setup-procid 0x%x\n", pdss1->p_m_d_l3id);
2891 pdss1->p_m_d_l3id = pid;
2892 if (port->p_state == PORT_STATE_CONNECT)
2893 pdss1->p_m_d_ces = pid >> 16;
2894 add_trace("callref", "new", "0x%x", pdss1->p_m_d_l3id);
2898 /* if process id is master process, but a child disconnects */
2899 if (mISDNport->ntmode
2900 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2901 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) == MISDN_PID_MASTER) {
2902 if (cmd == MT_DISCONNECT
2903 || cmd == MT_RELEASE) {
2904 /* send special indication for child disconnect */
2905 pdss1->disconnect_ind_i(cmd, pid, l3m);
2908 if (cmd == MT_RELEASE_COMPLETE)
2911 /* if we have child pid and got different child pid message, ignore */
2912 if (mISDNport->ntmode
2913 && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2914 && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
2915 && pid != pdss1->p_m_d_l3id)
2918 /* process message */
2919 pdss1->message_isdn(cmd, pid, l3m);
2926 /* creating port object, transparent until setup with hdlc */
2927 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2928 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0, B_MODE_TRANSPARENT)))
2930 FATAL("Cannot create Port instance.\n");
2931 pdss1->message_isdn(cmd, pid, l3m);
2935 /* creating port object, transparent until setup with hdlc */
2936 SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
2937 if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0, B_MODE_TRANSPARENT)))
2938 FATAL("Cannot create Port instance.\n");
2939 pdss1->message_isdn(cmd, pid, l3m);
2943 PDEBUG(DEBUG_ISDN, "unused call ref released (l3id=0x%x)\n", pid);
2946 case MT_RELEASE_COMPLETE:
2947 PERROR("must be ignored by stack, not sent to app\n");
2951 // facility als broadcast
2955 PERROR("unhandled message: cmd(0x%x) pid(0x%x)\n", cmd, pid);
2958 if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT) {
2959 pdss1 = (class Pdss1 *)port;
2960 /* check out correct stack */
2961 if (pdss1->p_m_mISDNport == mISDNport)
2962 /* check out correct id */
2963 PERROR("unhandled message: pid=%x is not associated with port-dinfo=%x\n", pid, pdss1->p_m_d_l3id);