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 */
29 Pgsm_ms::Pgsm_ms(int type, char *portname, struct port_settings *settings, struct interface *interface) : Pgsm(type, portname, settings, interface)
31 struct lcr_gsm *gsm_ms = gsm_ms_first;
34 SCPY(p_g_ms_name, interface->gsm_ms_name);
37 if (gsm_ms->type == LCR_GSM_TYPE_MS && !strcmp(gsm_ms->name, p_g_ms_name)) {
41 gsm_ms = gsm_ms->gsm_ms_next;
44 p_g_dtmf_state = DTMF_ST_IDLE;
47 memset(&p_g_dtmf_timer, 0, sizeof(p_g_dtmf_timer));
48 add_timer(&p_g_dtmf_timer, dtmf_timeout, this, 0);
50 PDEBUG(DEBUG_GSM, "Created new GSMMSPort(%s %s).\n", portname, p_g_ms_name);
58 PDEBUG(DEBUG_GSM, "Destroyed GSM MS process(%s).\n", p_name);
59 del_timer(&p_g_dtmf_timer);
63 * handles all indications
65 /* SETUP INDICATION */
66 void Pgsm_ms::setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc)
68 class Endpoint *epoint;
69 struct lcr_msg *message;
70 struct gsm_mncc *mode, *proceeding, *frame;
71 struct interface *interface;
73 interface = getinterfacebyname(p_g_interface_name);
75 PERROR("Cannot find interface %s.\n", p_g_interface_name);
79 /* process given callref */
80 gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_IN);
81 add_trace("callref", "new", "0x%x", callref);
83 /* release in case the ID is already in use */
84 add_trace("error", NULL, "callref already in use");
86 mncc = create_mncc(MNCC_REJ_REQ, callref);
87 gsm_trace_header(p_g_interface_name, this, MNCC_REJ_REQ, DIRECTION_OUT);
88 mncc->fields |= MNCC_F_CAUSE;
89 mncc->cause.coding = 3;
90 mncc->cause.location = 1;
91 mncc->cause.value = 47;
92 add_trace("cause", "coding", "%d", mncc->cause.coding);
93 add_trace("cause", "location", "%d", mncc->cause.location);
94 add_trace("cause", "value", "%d", mncc->cause.value);
95 add_trace("reason", NULL, "callref already in use");
97 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
98 new_state(PORT_STATE_RELEASE);
99 trigger_work(&p_g_delete);
102 p_g_callref = callref;
105 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_IND, DIRECTION_IN);
106 /* caller information */
107 p_callerinfo.ntype = INFO_NTYPE_NOTPRESENT;
108 if (mncc->fields & MNCC_F_CALLING) {
109 switch (mncc->calling.present) {
111 p_callerinfo.present = INFO_PRESENT_RESTRICTED;
114 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
117 p_callerinfo.present = INFO_PRESENT_ALLOWED;
120 switch (mncc->calling.screen) {
122 p_callerinfo.screen = INFO_SCREEN_USER;
125 p_callerinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
128 p_callerinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
131 p_callerinfo.screen = INFO_SCREEN_NETWORK;
134 switch (mncc->calling.type) {
136 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
139 p_callerinfo.ntype = INFO_NTYPE_INTERNATIONAL;
142 p_callerinfo.ntype = INFO_NTYPE_NATIONAL;
145 p_callerinfo.ntype = INFO_NTYPE_SUBSCRIBER;
148 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
151 SCPY(p_callerinfo.id, mncc->calling.number);
152 add_trace("calling", "type", "%d", mncc->calling.type);
153 add_trace("calling", "plan", "%d", mncc->calling.plan);
154 add_trace("calling", "present", "%d", mncc->calling.present);
155 add_trace("calling", "screen", "%d", mncc->calling.screen);
156 add_trace("calling", "number", "%s", mncc->calling.number);
158 SCPY(p_callerinfo.interface, p_g_interface_name);
159 /* dialing information */
160 if (mncc->fields & MNCC_F_CALLED) {
161 SCAT(p_dialinginfo.id, mncc->called.number);
162 switch (mncc->called.type) {
164 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
167 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
170 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
173 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
176 add_trace("dialing", "type", "%d", mncc->called.type);
177 add_trace("dialing", "plan", "%d", mncc->called.plan);
178 add_trace("dialing", "number", "%s", mncc->called.number);
180 p_dialinginfo.sending_complete = 1;
182 p_redirinfo.ntype = INFO_NTYPE_NOTPRESENT;
183 if (mncc->fields & MNCC_F_REDIRECTING) {
184 switch (mncc->redirecting.present) {
186 p_redirinfo.present = INFO_PRESENT_RESTRICTED;
189 p_redirinfo.present = INFO_PRESENT_NOTAVAIL;
192 p_redirinfo.present = INFO_PRESENT_ALLOWED;
195 switch (mncc->redirecting.screen) {
197 p_redirinfo.screen = INFO_SCREEN_USER;
200 p_redirinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
203 p_redirinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
206 p_redirinfo.screen = INFO_SCREEN_NETWORK;
209 switch (mncc->redirecting.type) {
211 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
214 p_redirinfo.ntype = INFO_NTYPE_INTERNATIONAL;
217 p_redirinfo.ntype = INFO_NTYPE_NATIONAL;
220 p_redirinfo.ntype = INFO_NTYPE_SUBSCRIBER;
223 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
226 SCPY(p_redirinfo.id, mncc->redirecting.number);
227 add_trace("redir", "type", "%d", mncc->redirecting.type);
228 add_trace("redir", "plan", "%d", mncc->redirecting.plan);
229 add_trace("redir", "present", "%d", mncc->redirecting.present);
230 add_trace("redir", "screen", "%d", mncc->redirecting.screen);
231 add_trace("redir", "number", "%s", mncc->redirecting.number);
233 /* bearer capability */
234 if (mncc->fields & MNCC_F_BEARER_CAP) {
235 switch (mncc->bearer_cap.transfer) {
237 p_capainfo.bearer_capa = INFO_BC_DATAUNRESTRICTED;
241 p_capainfo.bearer_capa = INFO_BC_AUDIO;
242 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
245 p_capainfo.bearer_capa = INFO_BC_SPEECH;
246 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
249 switch (mncc->bearer_cap.mode) {
251 p_capainfo.bearer_mode = INFO_BMODE_PACKET;
254 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
257 add_trace("bearer", "transfer", "%d", mncc->bearer_cap.transfer);
258 add_trace("bearer", "mode", "%d", mncc->bearer_cap.mode);
260 p_capainfo.bearer_capa = INFO_BC_SPEECH;
261 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
262 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
264 /* if packet mode works some day, see dss1.cpp for conditions */
265 p_capainfo.source_mode = B_MODE_TRANSPARENT;
269 /* create endpoint */
271 FATAL("Incoming call but already got an endpoint.\n");
272 if (!(epoint = new Endpoint(p_serial, 0)))
273 FATAL("No memory for Endpoint instance\n");
274 epoint->ep_app = new_endpointapp(epoint, 0, interface->app); //incoming
275 epointlist_new(epoint->ep_serial);
277 /* modify lchan to GSM codec V1 */
278 gsm_trace_header(p_g_interface_name, this, MNCC_LCHAN_MODIFY, DIRECTION_OUT);
279 mode = create_mncc(MNCC_LCHAN_MODIFY, p_g_callref);
280 mode->lchan_mode = 0x01; /* GSM V1 */
281 mode->lchan_type = 0x02;
282 add_trace("mode", NULL, "0x%02x", mode->lchan_mode);
284 send_and_free_mncc(p_g_lcr_gsm, mode->msg_type, mode);
286 /* send call proceeding */
287 gsm_trace_header(p_g_interface_name, this, MNCC_CALL_CONF_REQ, DIRECTION_OUT);
288 proceeding = create_mncc(MNCC_CALL_CONF_REQ, p_g_callref);
291 proceeding->fields |= MNCC_F_CCCAP;
292 proceeding->cccap.dtmf = 1;
294 send_and_free_mncc(p_g_lcr_gsm, proceeding->msg_type, proceeding);
296 new_state(PORT_STATE_IN_PROCEEDING);
298 if (p_g_tones && !p_g_tch_connected) { /* only if ... */
299 gsm_trace_header(p_g_interface_name, this, MNCC_FRAME_RECV, DIRECTION_OUT);
301 frame = create_mncc(MNCC_FRAME_RECV, p_g_callref);
302 send_and_free_mncc(p_g_lcr_gsm, frame->msg_type, frame);
303 p_g_tch_connected = 1;
306 /* send setup message to endpoit */
307 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
308 message->param.setup.port_type = p_type;
309 // message->param.setup.dtmf = 0;
310 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
311 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
312 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
313 SCPY((char *)message->param.setup.useruser.data, (char *)mncc->useruser.info);
314 message->param.setup.useruser.len = strlen(mncc->useruser.info);
315 message->param.setup.useruser.protocol = mncc->useruser.proto;
316 message_put(message);
320 * MS sends message to port
322 int message_ms(struct lcr_gsm *gsm_ms, int msg_type, void *arg)
324 struct gsm_mncc *mncc = (struct gsm_mncc *)arg;
325 unsigned int callref = mncc->callref;
327 class Pgsm_ms *pgsm_ms = NULL;
329 // struct mISDNport *mISDNport;
331 /* Special messages */
336 callref = mncc->callref;
339 if ((port->p_type & PORT_CLASS_GSM_MASK) == PORT_CLASS_GSM_MS) {
340 pgsm_ms = (class Pgsm_ms *)port;
341 if (pgsm_ms->p_g_callref == callref) {
348 if (msg_type == GSM_TCHF_FRAME) {
350 pgsm_ms->frame_receive(arg);
355 struct interface *interface;
357 if (msg_type != MNCC_SETUP_IND)
360 interface = getinterfacebyname(gsm_ms->interface_name);
362 struct gsm_mncc *rej;
364 rej = create_mncc(MNCC_REJ_REQ, callref);
365 rej->fields |= MNCC_F_CAUSE;
366 rej->cause.coding = 3;
367 rej->cause.location = 1;
368 rej->cause.value = 27;
369 gsm_trace_header(NULL, NULL, MNCC_REJ_REQ, DIRECTION_OUT);
370 add_trace("cause", "coding", "%d", rej->cause.coding);
371 add_trace("cause", "location", "%d", rej->cause.location);
372 add_trace("cause", "value", "%d", rej->cause.value);
373 add_trace("reason", NULL, "interface %s not found", gsm_ms->interface_name);
375 send_and_free_mncc(gsm_ms, rej->msg_type, rej);
378 /* creating port object, transparent until setup with hdlc */
379 SPRINT(name, "%s-%d-in", interface->name, 0);
380 if (!(pgsm_ms = new Pgsm_ms(PORT_TYPE_GSM_MS_IN, name, NULL, interface)))
381 FATAL("Cannot create Port instance.\n");
386 pgsm_ms->setup_ind(msg_type, callref, mncc);
389 case MNCC_CALL_PROC_IND:
390 pgsm_ms->call_proc_ind(msg_type, callref, mncc);
394 pgsm_ms->alert_ind(msg_type, callref, mncc);
398 pgsm_ms->setup_cnf(msg_type, callref, mncc);
401 case MNCC_SETUP_COMPL_IND:
402 pgsm_ms->setup_compl_ind(msg_type, callref, mncc);
406 pgsm_ms->disc_ind(msg_type, callref, mncc);
412 pgsm_ms->rel_ind(msg_type, callref, mncc);
415 case MNCC_NOTIFY_IND:
416 pgsm_ms->notify_ind(msg_type, callref, mncc);
419 case MNCC_START_DTMF_RSP:
420 case MNCC_START_DTMF_REJ:
421 case MNCC_STOP_DTMF_RSP:
422 pgsm_ms->dtmf_statemachine(mncc);
432 void Pgsm_ms::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
434 struct lcr_msg *message;
435 struct epoint_list *epointlist;
436 struct gsm_mncc *mncc;
438 /* copy setup infos to port */
439 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
440 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
441 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
442 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
445 if (!p_g_lcr_gsm || p_g_lcr_gsm->mncc_lfd.fd < 0) {
446 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
447 add_trace("failure", NULL, "MS %s instance is unavailable", p_g_ms_name);
449 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
450 message->param.disconnectinfo.cause = 41;
451 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
452 message_put(message);
453 new_state(PORT_STATE_RELEASE);
454 trigger_work(&p_g_delete);
459 if (!p_dialinginfo.id[0]) {
460 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
461 add_trace("failure", NULL, "No dialed subscriber given.");
463 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
464 message->param.disconnectinfo.cause = 28;
465 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
466 message_put(message);
467 new_state(PORT_STATE_RELEASE);
468 trigger_work(&p_g_delete);
472 /* attach only if not already */
473 epointlist = p_epointlist;
475 if (epointlist->epoint_id == epoint_id)
477 epointlist = epointlist->next;
480 epointlist_new(epoint_id);
483 gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_OUT);
484 p_g_callref = new_callref++;
485 add_trace("callref", "new", "0x%x", p_g_callref);
488 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
489 mncc = create_mncc(MNCC_SETUP_REQ, p_g_callref);
490 if (!strncasecmp(p_dialinginfo.id, "emerg", 5)) {
493 /* caller info (only clir) */
494 switch (p_callerinfo.present) {
495 case INFO_PRESENT_ALLOWED:
501 /* dialing information (mandatory) */
502 mncc->fields |= MNCC_F_CALLED;
503 mncc->called.type = 0; /* unknown */
504 mncc->called.plan = 1; /* isdn */
505 SCPY(mncc->called.number, p_dialinginfo.id);
506 add_trace("dialing", "number", "%s", mncc->called.number);
508 /* bearer capability (mandatory) */
509 mncc->fields |= MNCC_F_BEARER_CAP;
510 mncc->bearer_cap.coding = 0;
511 mncc->bearer_cap.radio = 1;
512 mncc->bearer_cap.speech_ctm = 0;
513 mncc->bearer_cap.speech_ver[0] = 0;
514 mncc->bearer_cap.speech_ver[1] = -1; /* end of list */
515 switch (p_capainfo.bearer_capa) {
516 case INFO_BC_DATAUNRESTRICTED:
517 case INFO_BC_DATARESTRICTED:
518 mncc->bearer_cap.transfer = 1;
521 mncc->bearer_cap.transfer = 0;
524 mncc->bearer_cap.transfer = 2;
527 switch (p_capainfo.bearer_mode) {
528 case INFO_BMODE_PACKET:
529 mncc->bearer_cap.mode = 1;
532 mncc->bearer_cap.mode = 0;
536 mncc->fields |= MNCC_F_CCCAP;
537 mncc->cccap.dtmf = 1;
539 /* request keypad from remote */
540 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ENABLEKEYPAD);
541 message_put(message);
545 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
547 new_state(PORT_STATE_OUT_SETUP);
549 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
550 message_put(message);
552 new_state(PORT_STATE_OUT_PROCEEDING);
557 void Pgsm_ms::dtmf_statemachine(struct gsm_mncc *mncc)
559 struct gsm_mncc *dtmf;
561 switch (p_g_dtmf_state) {
565 if (!p_g_dtmf[p_g_dtmf_index]) {
566 PDEBUG(DEBUG_GSM, "done with DTMF\n");
567 p_g_dtmf_state = DTMF_ST_IDLE;
570 gsm_trace_header(p_g_interface_name, this, MNCC_START_DTMF_REQ, DIRECTION_OUT);
571 dtmf = create_mncc(MNCC_START_DTMF_REQ, p_g_callref);
572 dtmf->keypad = p_g_dtmf[p_g_dtmf_index++];
573 p_g_dtmf_state = DTMF_ST_START;
574 PDEBUG(DEBUG_GSM, "start DTMF (keypad %c)\n",
577 send_and_free_mncc(p_g_lcr_gsm, dtmf->msg_type, dtmf);
580 if (mncc->msg_type != MNCC_START_DTMF_RSP) {
581 PDEBUG(DEBUG_GSM, "DTMF was rejected\n");
584 schedule_timer(&p_g_dtmf_timer, 0, 70 * 1000);
585 p_g_dtmf_state = DTMF_ST_MARK;
586 PDEBUG(DEBUG_GSM, "DTMF is on\n");
589 gsm_trace_header(p_g_interface_name, this, MNCC_STOP_DTMF_REQ, DIRECTION_OUT);
590 dtmf = create_mncc(MNCC_STOP_DTMF_REQ, p_g_callref);
591 p_g_dtmf_state = DTMF_ST_STOP;
593 send_and_free_mncc(p_g_lcr_gsm, dtmf->msg_type, dtmf);
596 schedule_timer(&p_g_dtmf_timer, 0, 120 * 1000);
597 p_g_dtmf_state = DTMF_ST_SPACE;
598 PDEBUG(DEBUG_GSM, "DTMF is off\n");
603 static int dtmf_timeout(struct lcr_timer *timer, void *instance, int index)
605 class Pgsm_ms *pgsm_ms = (class Pgsm_ms *)instance;
607 PDEBUG(DEBUG_GSM, "DTMF timer has fired\n");
608 pgsm_ms->dtmf_statemachine(NULL);
614 void Pgsm_ms::message_dtmf(unsigned int epoint_id, int message_id, union parameter *param)
616 char digit = param->dtmf;
618 if (digit >= 'a' && digit <= 'c')
619 digit = digit - 'a' + 'A';
620 if (!strchr("01234567890*#ABC", digit))
624 if (p_g_dtmf_state == DTMF_ST_IDLE) {
628 SCCAT(p_g_dtmf, digit);
629 if (p_g_dtmf_state == DTMF_ST_IDLE)
630 dtmf_statemachine(NULL);
633 /* MESSAGE_INFORMATION */
634 void Pgsm_ms::message_information(unsigned int epoint_id, int message_id, union parameter *param)
639 for (i = 0; i < (int)strlen(param->information.id); i++) {
640 digit = param->information.id[i];
641 if (digit >= 'a' && digit <= 'c')
642 digit = digit - 'a' + 'A';
643 if (!strchr("01234567890*#ABC", digit))
647 if (p_g_dtmf_state == DTMF_ST_IDLE) {
651 SCCAT(p_g_dtmf, digit);
652 if (p_g_dtmf_state == DTMF_ST_IDLE)
653 dtmf_statemachine(NULL);
658 * endpoint sends messages to the port
660 int Pgsm_ms::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
662 struct lcr_msg *message;
664 if (message_id == MESSAGE_CONNECT) {
665 /* request keypad from remote */
666 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ENABLEKEYPAD);
667 message_put(message);
670 if (Pgsm::message_epoint(epoint_id, message_id, param))
674 case MESSAGE_SETUP: /* dial-out command received from epoint */
675 if (p_state!=PORT_STATE_IDLE)
677 message_setup(epoint_id, message_id, param);
681 message_dtmf(epoint_id, message_id, param);
684 case MESSAGE_INFORMATION:
685 message_information(epoint_id, message_id, param);
689 PDEBUG(DEBUG_GSM, "Pgsm_ms(%s) gsm port with (caller id %s) received unhandled nessage: %d\n", p_name, p_callerinfo.id, message_id);
695 int gsm_ms_exit(int rc)
697 /* destroy all instances */
699 gsm_ms_delete(gsm_ms_first->name);
704 int gsm_ms_init(void)
709 /* add a new GSM mobile instance */
710 int gsm_ms_new(struct interface *interface)
712 struct lcr_gsm *gsm_ms = gsm_ms_first, **gsm_ms_p = &gsm_ms_first;
715 gsm_ms_p = &gsm_ms->gsm_ms_next;
716 gsm_ms = gsm_ms->gsm_ms_next;
719 PDEBUG(DEBUG_GSM, "GSM: interface for MS '%s' is created\n", interface->gsm_ms_name);
721 /* create gsm instance */
722 gsm_ms = (struct lcr_gsm *)MALLOC(sizeof(struct lcr_gsm));
724 SCPY(gsm_ms->interface_name, interface->name);
725 gsm_ms->type = LCR_GSM_TYPE_MS;
726 SCPY(gsm_ms->name, interface->gsm_ms_name);
727 gsm_ms->sun.sun_family = AF_UNIX;
728 SPRINT(gsm_ms->sun.sun_path, "/tmp/ms_mncc_%s", gsm_ms->name);
730 memset(&gsm_ms->socket_retry, 0, sizeof(gsm_ms->socket_retry));
731 add_timer(&gsm_ms->socket_retry, mncc_socket_retry_cb, gsm_ms, 0);
733 /* do the initial connect */
734 mncc_socket_retry_cb(&gsm_ms->socket_retry, gsm_ms, 0);
741 int gsm_ms_delete(const char *name)
743 struct lcr_gsm *gsm_ms = gsm_ms_first, **gsm_ms_p = &gsm_ms_first;
745 // class Pgsm_ms *pgsm_ms = NULL;
747 PDEBUG(DEBUG_GSM, "GSM: interface for MS '%s' is deleted\n", name);
750 if (gsm_ms->type == LCR_GSM_TYPE_MS && !strcmp(gsm_ms->name, name))
752 gsm_ms_p = &gsm_ms->gsm_ms_next;
753 gsm_ms = gsm_ms->gsm_ms_next;
759 /* not needed, because:
760 * - shutdown of interface will destry port instances locally
761 * - closing of socket will make remote socket destroy calls locally
766 if ((port->p_type & PORT_CLASS_GSM_MASK) == PORT_CLASS_GSM_MS) {
767 pgsm_ms = (class Pgsm_ms *)port;
768 if (pgsm_ms->p_g_lcr_gsm == gsm_ms && pgsm_ms->p_g_callref) {
769 struct gsm_mncc *rej;
771 rej = create_mncc(MNCC_REL_REQ, pgsm_ms->p_g_callref);
772 rej->fields |= MNCC_F_CAUSE;
773 rej->cause.coding = 3;
774 rej->cause.location = 1;
775 rej->cause.value = 27;
776 gsm_trace_header(NULL, NULL, MNCC_REJ_REQ, DIRECTION_OUT);
777 add_trace("cause", "coding", "%d", rej->cause.coding);
778 add_trace("cause", "location", "%d", rej->cause.location);
779 add_trace("cause", "value", "%d", rej->cause.value);
781 send_and_free_mncc(gsm_ms, rej->msg_type, rej);
782 pgsm_ms->new_state(PORT_STATE_RELEASE);
783 trigger_work(&pgsm_ms->p_g_delete);
789 if (gsm_ms->mncc_lfd.fd > -1) {
790 close(gsm_ms->mncc_lfd.fd);
791 unregister_fd(&gsm_ms->mncc_lfd);
793 del_timer(&gsm_ms->socket_retry);
795 /* remove instance from list */
796 *gsm_ms_p = gsm_ms->gsm_ms_next;
797 FREE(gsm_ms, sizeof(struct lcr_gsm));