1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
8 ** mISDN gsm (MS mode) **
10 \*****************************************************************************/
16 struct lcr_gsm *gsm_ms_first = NULL;
18 static int dtmf_timeout(struct lcr_timer *timer, void *instance, int index);
20 #define DTMF_ST_IDLE 0 /* no DTMF active */
21 #define DTMF_ST_START 1 /* DTMF started, waiting for resp. */
22 #define DTMF_ST_MARK 2 /* wait tone duration */
23 #define DTMF_ST_STOP 3 /* DTMF stopped, waiting for resp. */
24 #define DTMF_ST_SPACE 4 /* wait space between tones */
26 #define RTP_PT_GSM_FULL 3
31 Pgsm_ms::Pgsm_ms(int type, char *portname, struct port_settings *settings, struct interface *interface) : Pgsm(type, portname, settings, interface)
33 struct lcr_gsm *gsm_ms = gsm_ms_first;
36 SCPY(p_g_ms_name, interface->gsm_ms_name);
39 if (gsm_ms->type == LCR_GSM_TYPE_MS && !strcmp(gsm_ms->name, p_g_ms_name)) {
43 gsm_ms = gsm_ms->gsm_ms_next;
46 p_g_dtmf_state = DTMF_ST_IDLE;
49 memset(&p_g_dtmf_timer, 0, sizeof(p_g_dtmf_timer));
50 add_timer(&p_g_dtmf_timer, dtmf_timeout, this, 0);
52 PDEBUG(DEBUG_GSM, "Created new GSMMSPort(%s %s).\n", portname, p_g_ms_name);
60 PDEBUG(DEBUG_GSM, "Destroyed GSM MS process(%s).\n", p_name);
61 del_timer(&p_g_dtmf_timer);
65 * handles all indications
67 /* SETUP INDICATION */
68 void Pgsm_ms::setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc)
70 class Endpoint *epoint;
71 struct lcr_msg *message;
72 struct gsm_mncc *proceeding, *frame;
73 struct interface *interface;
75 interface = getinterfacebyname(p_g_interface_name);
77 PERROR("Cannot find interface %s.\n", p_g_interface_name);
81 /* process given callref */
82 gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_IN);
83 add_trace("callref", "new", "0x%x", callref);
85 /* release in case the ID is already in use */
86 add_trace("error", NULL, "callref already in use");
88 mncc = create_mncc(MNCC_REJ_REQ, callref);
89 gsm_trace_header(p_g_interface_name, this, MNCC_REJ_REQ, DIRECTION_OUT);
90 mncc->fields |= MNCC_F_CAUSE;
91 mncc->cause.coding = 3;
92 mncc->cause.location = 1;
93 mncc->cause.value = 47;
94 add_trace("cause", "coding", "%d", mncc->cause.coding);
95 add_trace("cause", "location", "%d", mncc->cause.location);
96 add_trace("cause", "value", "%d", mncc->cause.value);
97 add_trace("reason", NULL, "callref already in use");
99 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
100 new_state(PORT_STATE_RELEASE);
101 trigger_work(&p_g_delete);
104 p_g_callref = callref;
107 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_IND, DIRECTION_IN);
108 /* caller information */
109 p_callerinfo.ntype = INFO_NTYPE_NOTPRESENT;
110 if (mncc->fields & MNCC_F_CALLING) {
111 switch (mncc->calling.present) {
113 p_callerinfo.present = INFO_PRESENT_RESTRICTED;
116 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
119 p_callerinfo.present = INFO_PRESENT_ALLOWED;
122 switch (mncc->calling.screen) {
124 p_callerinfo.screen = INFO_SCREEN_USER;
127 p_callerinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
130 p_callerinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
133 p_callerinfo.screen = INFO_SCREEN_NETWORK;
136 switch (mncc->calling.type) {
138 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
141 p_callerinfo.ntype = INFO_NTYPE_INTERNATIONAL;
144 p_callerinfo.ntype = INFO_NTYPE_NATIONAL;
147 p_callerinfo.ntype = INFO_NTYPE_SUBSCRIBER;
150 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
153 SCPY(p_callerinfo.id, mncc->calling.number);
154 add_trace("calling", "type", "%d", mncc->calling.type);
155 add_trace("calling", "plan", "%d", mncc->calling.plan);
156 add_trace("calling", "present", "%d", mncc->calling.present);
157 add_trace("calling", "screen", "%d", mncc->calling.screen);
158 add_trace("calling", "number", "%s", mncc->calling.number);
160 SCPY(p_callerinfo.interface, p_g_interface_name);
161 /* dialing information */
162 if (mncc->fields & MNCC_F_CALLED) {
163 SCAT(p_dialinginfo.id, mncc->called.number);
164 switch (mncc->called.type) {
166 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
169 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
172 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
175 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
178 add_trace("dialing", "type", "%d", mncc->called.type);
179 add_trace("dialing", "plan", "%d", mncc->called.plan);
180 add_trace("dialing", "number", "%s", mncc->called.number);
182 p_dialinginfo.sending_complete = 1;
184 p_redirinfo.ntype = INFO_NTYPE_NOTPRESENT;
185 if (mncc->fields & MNCC_F_REDIRECTING) {
186 switch (mncc->redirecting.present) {
188 p_redirinfo.present = INFO_PRESENT_RESTRICTED;
191 p_redirinfo.present = INFO_PRESENT_NOTAVAIL;
194 p_redirinfo.present = INFO_PRESENT_ALLOWED;
197 switch (mncc->redirecting.screen) {
199 p_redirinfo.screen = INFO_SCREEN_USER;
202 p_redirinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
205 p_redirinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
208 p_redirinfo.screen = INFO_SCREEN_NETWORK;
211 switch (mncc->redirecting.type) {
213 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
216 p_redirinfo.ntype = INFO_NTYPE_INTERNATIONAL;
219 p_redirinfo.ntype = INFO_NTYPE_NATIONAL;
222 p_redirinfo.ntype = INFO_NTYPE_SUBSCRIBER;
225 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
228 SCPY(p_redirinfo.id, mncc->redirecting.number);
229 add_trace("redir", "type", "%d", mncc->redirecting.type);
230 add_trace("redir", "plan", "%d", mncc->redirecting.plan);
231 add_trace("redir", "present", "%d", mncc->redirecting.present);
232 add_trace("redir", "screen", "%d", mncc->redirecting.screen);
233 add_trace("redir", "number", "%s", mncc->redirecting.number);
235 /* bearer capability */
236 if (mncc->fields & MNCC_F_BEARER_CAP) {
237 switch (mncc->bearer_cap.transfer) {
239 p_capainfo.bearer_capa = INFO_BC_DATAUNRESTRICTED;
243 p_capainfo.bearer_capa = INFO_BC_AUDIO;
244 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
247 p_capainfo.bearer_capa = INFO_BC_SPEECH;
248 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
251 switch (mncc->bearer_cap.mode) {
253 p_capainfo.bearer_mode = INFO_BMODE_PACKET;
256 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
259 add_trace("bearer", "transfer", "%d", mncc->bearer_cap.transfer);
260 add_trace("bearer", "mode", "%d", mncc->bearer_cap.mode);
262 p_capainfo.bearer_capa = INFO_BC_SPEECH;
263 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
264 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
266 /* if packet mode works some day, see dss1.cpp for conditions */
267 p_capainfo.source_mode = B_MODE_TRANSPARENT;
271 /* create endpoint */
273 FATAL("Incoming call but already got an endpoint.\n");
274 if (!(epoint = new Endpoint(p_serial, 0)))
275 FATAL("No memory for Endpoint instance\n");
276 epoint->ep_app = new_endpointapp(epoint, 0, interface->app); //incoming
277 epointlist_new(epoint->ep_serial);
279 /* modify lchan to GSM codec V1 */
280 modify_lchan(RTP_PT_GSM_FULL);
282 /* send call proceeding */
283 gsm_trace_header(p_g_interface_name, this, MNCC_CALL_CONF_REQ, DIRECTION_OUT);
284 proceeding = create_mncc(MNCC_CALL_CONF_REQ, p_g_callref);
287 proceeding->fields |= MNCC_F_CCCAP;
288 proceeding->cccap.dtmf = 1;
290 send_and_free_mncc(p_g_lcr_gsm, proceeding->msg_type, proceeding);
292 new_state(PORT_STATE_IN_PROCEEDING);
294 if (p_g_tones && !p_g_tch_connected) { /* only if ... */
295 gsm_trace_header(p_g_interface_name, this, MNCC_FRAME_RECV, DIRECTION_OUT);
297 frame = create_mncc(MNCC_FRAME_RECV, p_g_callref);
298 send_and_free_mncc(p_g_lcr_gsm, frame->msg_type, frame);
299 p_g_tch_connected = 1;
302 /* send setup message to endpoit */
303 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
304 message->param.setup.port_type = p_type;
305 // message->param.setup.dtmf = 0;
306 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
307 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
308 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
309 SCPY((char *)message->param.setup.useruser.data, (char *)mncc->useruser.info);
310 message->param.setup.useruser.len = strlen(mncc->useruser.info);
311 message->param.setup.useruser.protocol = mncc->useruser.proto;
312 message_put(message);
316 * MS sends message to port
318 int message_ms(struct lcr_gsm *gsm_ms, int msg_type, void *arg)
320 struct gsm_mncc *mncc = (struct gsm_mncc *)arg;
321 unsigned int callref = mncc->callref;
323 class Pgsm_ms *pgsm_ms = NULL;
325 // struct mISDNport *mISDNport;
327 /* Special messages */
332 callref = mncc->callref;
335 if ((port->p_type & PORT_CLASS_GSM_MASK) == PORT_CLASS_GSM_MS) {
336 pgsm_ms = (class Pgsm_ms *)port;
337 if (pgsm_ms->p_g_callref == callref) {
344 if (msg_type == GSM_TCHF_FRAME
345 || msg_type == GSM_BAD_FRAME) {
347 pgsm_ms->frame_receive(arg);
352 struct interface *interface;
354 if (msg_type != MNCC_SETUP_IND)
357 interface = getinterfacebyname(gsm_ms->interface_name);
359 struct gsm_mncc *rej;
361 rej = create_mncc(MNCC_REJ_REQ, callref);
362 rej->fields |= MNCC_F_CAUSE;
363 rej->cause.coding = 3;
364 rej->cause.location = 1;
365 rej->cause.value = 27;
366 gsm_trace_header(NULL, NULL, MNCC_REJ_REQ, DIRECTION_OUT);
367 add_trace("cause", "coding", "%d", rej->cause.coding);
368 add_trace("cause", "location", "%d", rej->cause.location);
369 add_trace("cause", "value", "%d", rej->cause.value);
370 add_trace("reason", NULL, "interface %s not found", gsm_ms->interface_name);
372 send_and_free_mncc(gsm_ms, rej->msg_type, rej);
375 /* creating port object, transparent until setup with hdlc */
376 SPRINT(name, "%s-%d-in", interface->name, 0);
377 if (!(pgsm_ms = new Pgsm_ms(PORT_TYPE_GSM_MS_IN, name, NULL, interface)))
378 FATAL("Cannot create Port instance.\n");
383 pgsm_ms->setup_ind(msg_type, callref, mncc);
386 case MNCC_CALL_PROC_IND:
387 pgsm_ms->call_proc_ind(msg_type, callref, mncc);
391 pgsm_ms->alert_ind(msg_type, callref, mncc);
395 pgsm_ms->setup_cnf(msg_type, callref, mncc);
398 case MNCC_SETUP_COMPL_IND:
399 pgsm_ms->setup_compl_ind(msg_type, callref, mncc);
403 pgsm_ms->disc_ind(msg_type, callref, mncc);
409 pgsm_ms->rel_ind(msg_type, callref, mncc);
412 case MNCC_NOTIFY_IND:
413 pgsm_ms->notify_ind(msg_type, callref, mncc);
416 case MNCC_START_DTMF_RSP:
417 case MNCC_START_DTMF_REJ:
418 case MNCC_STOP_DTMF_RSP:
419 pgsm_ms->dtmf_statemachine(mncc);
429 void Pgsm_ms::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
431 struct lcr_msg *message;
432 struct epoint_list *epointlist;
433 struct gsm_mncc *mncc;
435 /* copy setup infos to port */
436 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
437 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
438 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
439 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
442 if (!p_g_lcr_gsm || p_g_lcr_gsm->mncc_lfd.fd < 0) {
443 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
444 add_trace("failure", NULL, "MS %s instance is unavailable", p_g_ms_name);
446 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
447 message->param.disconnectinfo.cause = 41;
448 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
449 message_put(message);
450 new_state(PORT_STATE_RELEASE);
451 trigger_work(&p_g_delete);
456 if (!p_dialinginfo.id[0]) {
457 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
458 add_trace("failure", NULL, "No dialed subscriber given.");
460 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
461 message->param.disconnectinfo.cause = 28;
462 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
463 message_put(message);
464 new_state(PORT_STATE_RELEASE);
465 trigger_work(&p_g_delete);
469 /* attach only if not already */
470 epointlist = p_epointlist;
472 if (epointlist->epoint_id == epoint_id)
474 epointlist = epointlist->next;
477 epointlist_new(epoint_id);
480 gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_OUT);
481 p_g_callref = new_callref++;
482 add_trace("callref", "new", "0x%x", p_g_callref);
485 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
486 mncc = create_mncc(MNCC_SETUP_REQ, p_g_callref);
487 if (!strncasecmp(p_dialinginfo.id, "emerg", 5)) {
490 /* caller info (only clir) */
491 switch (p_callerinfo.present) {
492 case INFO_PRESENT_ALLOWED:
498 /* dialing information (mandatory) */
499 mncc->fields |= MNCC_F_CALLED;
500 mncc->called.type = 0; /* unknown */
501 mncc->called.plan = 1; /* isdn */
502 SCPY(mncc->called.number, p_dialinginfo.id);
503 add_trace("dialing", "number", "%s", mncc->called.number);
505 /* bearer capability (mandatory) */
506 mncc->fields |= MNCC_F_BEARER_CAP;
507 mncc->bearer_cap.coding = 0;
508 mncc->bearer_cap.radio = 1;
509 mncc->bearer_cap.speech_ctm = 0;
510 mncc->bearer_cap.speech_ver[0] = 0;
511 mncc->bearer_cap.speech_ver[1] = -1; /* end of list */
512 switch (p_capainfo.bearer_capa) {
513 case INFO_BC_DATAUNRESTRICTED:
514 case INFO_BC_DATARESTRICTED:
515 mncc->bearer_cap.transfer = 1;
518 mncc->bearer_cap.transfer = 0;
521 mncc->bearer_cap.transfer = 2;
524 switch (p_capainfo.bearer_mode) {
525 case INFO_BMODE_PACKET:
526 mncc->bearer_cap.mode = 1;
529 mncc->bearer_cap.mode = 0;
533 mncc->fields |= MNCC_F_CCCAP;
534 mncc->cccap.dtmf = 1;
536 /* request keypad from remote */
537 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ENABLEKEYPAD);
538 message_put(message);
542 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
544 new_state(PORT_STATE_OUT_SETUP);
546 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
547 message_put(message);
549 new_state(PORT_STATE_OUT_PROCEEDING);
554 void Pgsm_ms::dtmf_statemachine(struct gsm_mncc *mncc)
556 struct gsm_mncc *dtmf;
558 switch (p_g_dtmf_state) {
562 if (!p_g_dtmf[p_g_dtmf_index]) {
563 PDEBUG(DEBUG_GSM, "done with DTMF\n");
564 p_g_dtmf_state = DTMF_ST_IDLE;
567 gsm_trace_header(p_g_interface_name, this, MNCC_START_DTMF_REQ, DIRECTION_OUT);
568 dtmf = create_mncc(MNCC_START_DTMF_REQ, p_g_callref);
569 dtmf->keypad = p_g_dtmf[p_g_dtmf_index++];
570 p_g_dtmf_state = DTMF_ST_START;
571 PDEBUG(DEBUG_GSM, "start DTMF (keypad %c)\n",
574 send_and_free_mncc(p_g_lcr_gsm, dtmf->msg_type, dtmf);
577 if (mncc->msg_type != MNCC_START_DTMF_RSP) {
578 PDEBUG(DEBUG_GSM, "DTMF was rejected\n");
581 schedule_timer(&p_g_dtmf_timer, 0, 70 * 1000);
582 p_g_dtmf_state = DTMF_ST_MARK;
583 PDEBUG(DEBUG_GSM, "DTMF is on\n");
586 gsm_trace_header(p_g_interface_name, this, MNCC_STOP_DTMF_REQ, DIRECTION_OUT);
587 dtmf = create_mncc(MNCC_STOP_DTMF_REQ, p_g_callref);
588 p_g_dtmf_state = DTMF_ST_STOP;
590 send_and_free_mncc(p_g_lcr_gsm, dtmf->msg_type, dtmf);
593 schedule_timer(&p_g_dtmf_timer, 0, 120 * 1000);
594 p_g_dtmf_state = DTMF_ST_SPACE;
595 PDEBUG(DEBUG_GSM, "DTMF is off\n");
600 static int dtmf_timeout(struct lcr_timer *timer, void *instance, int index)
602 class Pgsm_ms *pgsm_ms = (class Pgsm_ms *)instance;
604 PDEBUG(DEBUG_GSM, "DTMF timer has fired\n");
605 pgsm_ms->dtmf_statemachine(NULL);
611 void Pgsm_ms::message_dtmf(unsigned int epoint_id, int message_id, union parameter *param)
613 char digit = param->dtmf;
615 if (digit >= 'a' && digit <= 'c')
616 digit = digit - 'a' + 'A';
617 if (!strchr("01234567890*#ABC", digit))
621 if (p_g_dtmf_state == DTMF_ST_IDLE) {
625 SCCAT(p_g_dtmf, digit);
626 if (p_g_dtmf_state == DTMF_ST_IDLE)
627 dtmf_statemachine(NULL);
630 /* MESSAGE_INFORMATION */
631 void Pgsm_ms::message_information(unsigned int epoint_id, int message_id, union parameter *param)
636 for (i = 0; i < (int)strlen(param->information.id); i++) {
637 digit = param->information.id[i];
638 if (digit >= 'a' && digit <= 'c')
639 digit = digit - 'a' + 'A';
640 if (!strchr("01234567890*#ABC", digit))
644 if (p_g_dtmf_state == DTMF_ST_IDLE) {
648 SCCAT(p_g_dtmf, digit);
649 if (p_g_dtmf_state == DTMF_ST_IDLE)
650 dtmf_statemachine(NULL);
655 * endpoint sends messages to the port
657 int Pgsm_ms::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
659 struct lcr_msg *message;
661 if (message_id == MESSAGE_CONNECT) {
662 /* request keypad from remote */
663 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ENABLEKEYPAD);
664 message_put(message);
667 if (Pgsm::message_epoint(epoint_id, message_id, param))
671 case MESSAGE_SETUP: /* dial-out command received from epoint */
672 if (p_state!=PORT_STATE_IDLE)
674 message_setup(epoint_id, message_id, param);
678 message_dtmf(epoint_id, message_id, param);
681 case MESSAGE_INFORMATION:
682 message_information(epoint_id, message_id, param);
686 PDEBUG(DEBUG_GSM, "Pgsm_ms(%s) gsm port with (caller id %s) received unhandled nessage: %d\n", p_name, p_callerinfo.id, message_id);
692 int gsm_ms_exit(int rc)
694 /* destroy all instances */
696 gsm_ms_delete(gsm_ms_first->name);
701 int gsm_ms_init(void)
706 /* add a new GSM mobile instance */
707 int gsm_ms_new(struct interface *interface)
709 struct lcr_gsm *gsm_ms = gsm_ms_first, **gsm_ms_p = &gsm_ms_first;
712 gsm_ms_p = &gsm_ms->gsm_ms_next;
713 gsm_ms = gsm_ms->gsm_ms_next;
716 PDEBUG(DEBUG_GSM, "GSM: interface for MS '%s' is created\n", interface->gsm_ms_name);
718 /* create gsm instance */
719 gsm_ms = (struct lcr_gsm *)MALLOC(sizeof(struct lcr_gsm));
721 SCPY(gsm_ms->interface_name, interface->name);
722 gsm_ms->type = LCR_GSM_TYPE_MS;
723 SCPY(gsm_ms->name, interface->gsm_ms_name);
724 gsm_ms->sun.sun_family = AF_UNIX;
725 SPRINT(gsm_ms->sun.sun_path, "/tmp/ms_mncc_%s", gsm_ms->name);
727 memset(&gsm_ms->socket_retry, 0, sizeof(gsm_ms->socket_retry));
728 add_timer(&gsm_ms->socket_retry, mncc_socket_retry_cb, gsm_ms, 0);
730 /* do the initial connect */
731 mncc_socket_retry_cb(&gsm_ms->socket_retry, gsm_ms, 0);
738 int gsm_ms_delete(const char *name)
740 struct lcr_gsm *gsm_ms = gsm_ms_first, **gsm_ms_p = &gsm_ms_first;
742 // class Pgsm_ms *pgsm_ms = NULL;
744 PDEBUG(DEBUG_GSM, "GSM: interface for MS '%s' is deleted\n", name);
747 if (gsm_ms->type == LCR_GSM_TYPE_MS && !strcmp(gsm_ms->name, name))
749 gsm_ms_p = &gsm_ms->gsm_ms_next;
750 gsm_ms = gsm_ms->gsm_ms_next;
756 /* not needed, because:
757 * - shutdown of interface will destry port instances locally
758 * - closing of socket will make remote socket destroy calls locally
763 if ((port->p_type & PORT_CLASS_GSM_MASK) == PORT_CLASS_GSM_MS) {
764 pgsm_ms = (class Pgsm_ms *)port;
765 if (pgsm_ms->p_g_lcr_gsm == gsm_ms && pgsm_ms->p_g_callref) {
766 struct gsm_mncc *rej;
768 rej = create_mncc(MNCC_REL_REQ, pgsm_ms->p_g_callref);
769 rej->fields |= MNCC_F_CAUSE;
770 rej->cause.coding = 3;
771 rej->cause.location = 1;
772 rej->cause.value = 27;
773 gsm_trace_header(NULL, NULL, MNCC_REJ_REQ, DIRECTION_OUT);
774 add_trace("cause", "coding", "%d", rej->cause.coding);
775 add_trace("cause", "location", "%d", rej->cause.location);
776 add_trace("cause", "value", "%d", rej->cause.value);
778 send_and_free_mncc(gsm_ms, rej->msg_type, rej);
779 pgsm_ms->new_state(PORT_STATE_RELEASE);
780 trigger_work(&pgsm_ms->p_g_delete);
786 if (gsm_ms->mncc_lfd.fd > -1) {
787 close(gsm_ms->mncc_lfd.fd);
788 unregister_fd(&gsm_ms->mncc_lfd);
790 del_timer(&gsm_ms->socket_retry);
792 /* remove instance from list */
793 *gsm_ms_p = gsm_ms->gsm_ms_next;
794 FREE(gsm_ms, sizeof(struct lcr_gsm));