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 = interface_first;
74 if (!strcmp(interface->name, p_g_interface_name))
76 interface = interface->next;
79 PERROR("Cannot find interface %s.\n", p_g_interface_name);
83 /* process given callref */
84 gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_IN);
85 add_trace("callref", "new", "0x%x", callref);
87 /* release in case the ID is already in use */
88 add_trace("error", NULL, "callref already in use");
90 mncc = create_mncc(MNCC_REJ_REQ, callref);
91 gsm_trace_header(p_g_interface_name, this, MNCC_REJ_REQ, DIRECTION_OUT);
92 mncc->fields |= MNCC_F_CAUSE;
93 mncc->cause.coding = 3;
94 mncc->cause.location = 1;
95 mncc->cause.value = 47;
96 add_trace("cause", "coding", "%d", mncc->cause.coding);
97 add_trace("cause", "location", "%d", mncc->cause.location);
98 add_trace("cause", "value", "%d", mncc->cause.value);
99 add_trace("reason", NULL, "callref already in use");
101 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
102 new_state(PORT_STATE_RELEASE);
103 trigger_work(&p_g_delete);
106 p_g_callref = callref;
109 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_IND, DIRECTION_IN);
110 /* caller information */
111 p_callerinfo.ntype = INFO_NTYPE_NOTPRESENT;
112 if (mncc->fields & MNCC_F_CALLING) {
113 switch (mncc->calling.present) {
115 p_callerinfo.present = INFO_PRESENT_RESTRICTED;
118 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
121 p_callerinfo.present = INFO_PRESENT_ALLOWED;
124 switch (mncc->calling.screen) {
126 p_callerinfo.screen = INFO_SCREEN_USER;
129 p_callerinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
132 p_callerinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
135 p_callerinfo.screen = INFO_SCREEN_NETWORK;
138 switch (mncc->calling.type) {
140 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
143 p_callerinfo.ntype = INFO_NTYPE_INTERNATIONAL;
146 p_callerinfo.ntype = INFO_NTYPE_NATIONAL;
149 p_callerinfo.ntype = INFO_NTYPE_SUBSCRIBER;
152 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
155 SCPY(p_callerinfo.id, mncc->calling.number);
156 add_trace("calling", "type", "%d", mncc->calling.type);
157 add_trace("calling", "plan", "%d", mncc->calling.plan);
158 add_trace("calling", "present", "%d", mncc->calling.present);
159 add_trace("calling", "screen", "%d", mncc->calling.screen);
160 add_trace("calling", "number", "%s", mncc->calling.number);
162 SCPY(p_callerinfo.interface, p_g_interface_name);
163 /* dialing information */
164 if (mncc->fields & MNCC_F_CALLED) {
165 SCAT(p_dialinginfo.id, mncc->called.number);
166 switch (mncc->called.type) {
168 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
171 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
174 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
177 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
180 add_trace("dialing", "type", "%d", mncc->called.type);
181 add_trace("dialing", "plan", "%d", mncc->called.plan);
182 add_trace("dialing", "number", "%s", mncc->called.number);
184 p_dialinginfo.sending_complete = 1;
186 p_redirinfo.ntype = INFO_NTYPE_NOTPRESENT;
187 if (mncc->fields & MNCC_F_REDIRECTING) {
188 switch (mncc->redirecting.present) {
190 p_redirinfo.present = INFO_PRESENT_RESTRICTED;
193 p_redirinfo.present = INFO_PRESENT_NOTAVAIL;
196 p_redirinfo.present = INFO_PRESENT_ALLOWED;
199 switch (mncc->redirecting.screen) {
201 p_redirinfo.screen = INFO_SCREEN_USER;
204 p_redirinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
207 p_redirinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
210 p_redirinfo.screen = INFO_SCREEN_NETWORK;
213 switch (mncc->redirecting.type) {
215 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
218 p_redirinfo.ntype = INFO_NTYPE_INTERNATIONAL;
221 p_redirinfo.ntype = INFO_NTYPE_NATIONAL;
224 p_redirinfo.ntype = INFO_NTYPE_SUBSCRIBER;
227 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
230 SCPY(p_redirinfo.id, mncc->redirecting.number);
231 add_trace("redir", "type", "%d", mncc->redirecting.type);
232 add_trace("redir", "plan", "%d", mncc->redirecting.plan);
233 add_trace("redir", "present", "%d", mncc->redirecting.present);
234 add_trace("redir", "screen", "%d", mncc->redirecting.screen);
235 add_trace("redir", "number", "%s", mncc->redirecting.number);
237 /* bearer capability */
238 if (mncc->fields & MNCC_F_BEARER_CAP) {
239 switch (mncc->bearer_cap.transfer) {
241 p_capainfo.bearer_capa = INFO_BC_DATAUNRESTRICTED;
245 p_capainfo.bearer_capa = INFO_BC_AUDIO;
246 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
249 p_capainfo.bearer_capa = INFO_BC_SPEECH;
250 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
253 switch (mncc->bearer_cap.mode) {
255 p_capainfo.bearer_mode = INFO_BMODE_PACKET;
258 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
261 add_trace("bearer", "transfer", "%d", mncc->bearer_cap.transfer);
262 add_trace("bearer", "mode", "%d", mncc->bearer_cap.mode);
264 p_capainfo.bearer_capa = INFO_BC_SPEECH;
265 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
266 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
268 /* if packet mode works some day, see dss1.cpp for conditions */
269 p_capainfo.source_mode = B_MODE_TRANSPARENT;
273 /* create endpoint */
275 FATAL("Incoming call but already got an endpoint.\n");
276 if (!(epoint = new Endpoint(p_serial, 0)))
277 FATAL("No memory for Endpoint instance\n");
278 epoint->ep_app = new_endpointapp(epoint, 0, interface->app); //incoming
279 epointlist_new(epoint->ep_serial);
281 /* modify lchan to GSM codec V1 */
282 gsm_trace_header(p_g_interface_name, this, MNCC_LCHAN_MODIFY, DIRECTION_OUT);
283 mode = create_mncc(MNCC_LCHAN_MODIFY, p_g_callref);
284 mode->lchan_mode = 0x01; /* GSM V1 */
285 mode->lchan_type = 0x02;
286 add_trace("mode", NULL, "0x%02x", mode->lchan_mode);
288 send_and_free_mncc(p_g_lcr_gsm, mode->msg_type, mode);
290 /* send call proceeding */
291 gsm_trace_header(p_g_interface_name, this, MNCC_CALL_CONF_REQ, DIRECTION_OUT);
292 proceeding = create_mncc(MNCC_CALL_CONF_REQ, p_g_callref);
295 proceeding->fields |= MNCC_F_CCCAP;
296 proceeding->cccap.dtmf = 1;
298 send_and_free_mncc(p_g_lcr_gsm, proceeding->msg_type, proceeding);
300 new_state(PORT_STATE_IN_PROCEEDING);
302 if (p_g_tones && !p_g_tch_connected) { /* only if ... */
303 gsm_trace_header(p_g_interface_name, this, MNCC_FRAME_RECV, DIRECTION_OUT);
305 frame = create_mncc(MNCC_FRAME_RECV, p_g_callref);
306 send_and_free_mncc(p_g_lcr_gsm, frame->msg_type, frame);
307 p_g_tch_connected = 1;
310 /* send setup message to endpoit */
311 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
312 message->param.setup.port_type = p_type;
313 // message->param.setup.dtmf = 0;
314 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
315 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
316 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
317 SCPY((char *)message->param.setup.useruser.data, (char *)mncc->useruser.info);
318 message->param.setup.useruser.len = strlen(mncc->useruser.info);
319 message->param.setup.useruser.protocol = mncc->useruser.proto;
320 message_put(message);
324 * MS sends message to port
326 int message_ms(struct lcr_gsm *gsm_ms, int msg_type, void *arg)
328 struct interface *interface = gsm_ms->interface;
329 struct gsm_mncc *mncc = (struct gsm_mncc *)arg;
330 unsigned int callref = mncc->callref;
332 class Pgsm_ms *pgsm_ms = NULL;
334 // struct mISDNport *mISDNport;
336 /* Special messages */
341 callref = mncc->callref;
344 if ((port->p_type & PORT_CLASS_GSM_MASK) == PORT_CLASS_GSM_MS) {
345 pgsm_ms = (class Pgsm_ms *)port;
346 if (pgsm_ms->p_g_callref == callref) {
353 if (msg_type == GSM_TCHF_FRAME) {
355 pgsm_ms->frame_receive(arg);
360 if (msg_type != MNCC_SETUP_IND)
363 /* find gsm ms port */
364 mISDNport = mISDNport_first;
366 if (mISDNport->gsm_ms && !strcmp(mISDNport->ifport->gsm_ms_name, gsm_ms->name))
368 mISDNport = mISDNport->next;
371 struct gsm_mncc *rej;
373 rej = create_mncc(MNCC_REJ_REQ, callref);
374 rej->fields |= MNCC_F_CAUSE;
375 rej->cause.coding = 3;
376 rej->cause.location = 1;
377 rej->cause.value = 27;
378 gsm_trace_header(NULL, NULL, MNCC_REJ_REQ, DIRECTION_OUT);
379 add_trace("cause", "coding", "%d", rej->cause.coding);
380 add_trace("cause", "location", "%d", rej->cause.location);
381 add_trace("cause", "value", "%d", rej->cause.value);
383 send_and_free_mncc(gsm_ms, rej->msg_type, rej);
387 /* creating port object, transparent until setup with hdlc */
388 SPRINT(name, "%s-%d-in", interface->name, 0);
389 if (!(pgsm_ms = new Pgsm_ms(PORT_TYPE_GSM_MS_IN, name, NULL, interface)))
390 FATAL("Cannot create Port instance.\n");
395 pgsm_ms->setup_ind(msg_type, callref, mncc);
398 case MNCC_CALL_PROC_IND:
399 pgsm_ms->call_proc_ind(msg_type, callref, mncc);
403 pgsm_ms->alert_ind(msg_type, callref, mncc);
407 pgsm_ms->setup_cnf(msg_type, callref, mncc);
410 case MNCC_SETUP_COMPL_IND:
411 pgsm_ms->setup_compl_ind(msg_type, callref, mncc);
415 pgsm_ms->disc_ind(msg_type, callref, mncc);
421 pgsm_ms->rel_ind(msg_type, callref, mncc);
424 case MNCC_NOTIFY_IND:
425 pgsm_ms->notify_ind(msg_type, callref, mncc);
428 case MNCC_START_DTMF_RSP:
429 case MNCC_START_DTMF_REJ:
430 case MNCC_STOP_DTMF_RSP:
431 pgsm_ms->dtmf_statemachine(mncc);
441 void Pgsm_ms::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
443 struct lcr_msg *message;
444 struct epoint_list *epointlist;
445 struct gsm_mncc *mncc;
447 /* copy setup infos to port */
448 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
449 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
450 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
451 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
454 if (!p_g_lcr_gsm || p_g_lcr_gsm->mncc_lfd.fd < 0) {
455 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
456 add_trace("failure", NULL, "MS %s instance is unavailable", p_g_ms_name);
458 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
459 message->param.disconnectinfo.cause = 41;
460 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
461 message_put(message);
462 new_state(PORT_STATE_RELEASE);
463 trigger_work(&p_g_delete);
468 if (!p_dialinginfo.id[0]) {
469 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
470 add_trace("failure", NULL, "No dialed subscriber given.");
472 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
473 message->param.disconnectinfo.cause = 28;
474 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
475 message_put(message);
476 new_state(PORT_STATE_RELEASE);
477 trigger_work(&p_g_delete);
481 /* attach only if not already */
482 epointlist = p_epointlist;
484 if (epointlist->epoint_id == epoint_id)
486 epointlist = epointlist->next;
489 epointlist_new(epoint_id);
492 gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_OUT);
493 p_g_callref = new_callref++;
494 add_trace("callref", "new", "0x%x", p_g_callref);
497 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
498 mncc = create_mncc(MNCC_SETUP_REQ, p_g_callref);
499 if (!strncasecmp(p_dialinginfo.id, "emerg", 5)) {
502 /* caller info (only clir) */
503 switch (p_callerinfo.present) {
504 case INFO_PRESENT_ALLOWED:
510 /* dialing information (mandatory) */
511 mncc->fields |= MNCC_F_CALLED;
512 mncc->called.type = 0; /* unknown */
513 mncc->called.plan = 1; /* isdn */
514 SCPY(mncc->called.number, p_dialinginfo.id);
515 add_trace("dialing", "number", "%s", mncc->called.number);
517 /* bearer capability (mandatory) */
518 mncc->fields |= MNCC_F_BEARER_CAP;
519 mncc->bearer_cap.coding = 0;
520 mncc->bearer_cap.radio = 1;
521 mncc->bearer_cap.speech_ctm = 0;
522 mncc->bearer_cap.speech_ver[0] = 0;
523 mncc->bearer_cap.speech_ver[1] = -1; /* end of list */
524 switch (p_capainfo.bearer_capa) {
525 case INFO_BC_DATAUNRESTRICTED:
526 case INFO_BC_DATARESTRICTED:
527 mncc->bearer_cap.transfer = 1;
530 mncc->bearer_cap.transfer = 0;
533 mncc->bearer_cap.transfer = 2;
536 switch (p_capainfo.bearer_mode) {
537 case INFO_BMODE_PACKET:
538 mncc->bearer_cap.mode = 1;
541 mncc->bearer_cap.mode = 0;
545 mncc->fields |= MNCC_F_CCCAP;
546 mncc->cccap.dtmf = 1;
548 /* request keypad from remote */
549 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ENABLEKEYPAD);
550 message_put(message);
554 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
556 new_state(PORT_STATE_OUT_SETUP);
558 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
559 message_put(message);
561 new_state(PORT_STATE_OUT_PROCEEDING);
566 void Pgsm_ms::dtmf_statemachine(struct gsm_mncc *mncc)
568 struct gsm_mncc *dtmf;
570 switch (p_g_dtmf_state) {
574 if (!p_g_dtmf[p_g_dtmf_index]) {
575 PDEBUG(DEBUG_GSM, "done with DTMF\n");
576 p_g_dtmf_state = DTMF_ST_IDLE;
579 gsm_trace_header(p_g_interface_name, this, MNCC_START_DTMF_REQ, DIRECTION_OUT);
580 dtmf = create_mncc(MNCC_START_DTMF_REQ, p_g_callref);
581 dtmf->keypad = p_g_dtmf[p_g_dtmf_index++];
582 p_g_dtmf_state = DTMF_ST_START;
583 PDEBUG(DEBUG_GSM, "start DTMF (keypad %c)\n",
586 send_and_free_mncc(p_g_lcr_gsm, dtmf->msg_type, dtmf);
589 if (mncc->msg_type != MNCC_START_DTMF_RSP) {
590 PDEBUG(DEBUG_GSM, "DTMF was rejected\n");
593 schedule_timer(&p_g_dtmf_timer, 0, 70 * 1000);
594 p_g_dtmf_state = DTMF_ST_MARK;
595 PDEBUG(DEBUG_GSM, "DTMF is on\n");
598 gsm_trace_header(p_g_interface_name, this, MNCC_STOP_DTMF_REQ, DIRECTION_OUT);
599 dtmf = create_mncc(MNCC_STOP_DTMF_REQ, p_g_callref);
600 p_g_dtmf_state = DTMF_ST_STOP;
602 send_and_free_mncc(p_g_lcr_gsm, dtmf->msg_type, dtmf);
605 schedule_timer(&p_g_dtmf_timer, 0, 120 * 1000);
606 p_g_dtmf_state = DTMF_ST_SPACE;
607 PDEBUG(DEBUG_GSM, "DTMF is off\n");
612 static int dtmf_timeout(struct lcr_timer *timer, void *instance, int index)
614 class Pgsm_ms *pgsm_ms = (class Pgsm_ms *)instance;
616 PDEBUG(DEBUG_GSM, "DTMF timer has fired\n");
617 pgsm_ms->dtmf_statemachine(NULL);
623 void Pgsm_ms::message_dtmf(unsigned int epoint_id, int message_id, union parameter *param)
625 char digit = param->dtmf;
627 if (digit >= 'a' && digit <= 'c')
628 digit = digit - 'a' + 'A';
629 if (!strchr("01234567890*#ABC", digit))
633 if (p_g_dtmf_state == DTMF_ST_IDLE) {
637 SCCAT(p_g_dtmf, digit);
638 if (p_g_dtmf_state == DTMF_ST_IDLE)
639 dtmf_statemachine(NULL);
642 /* MESSAGE_INFORMATION */
643 void Pgsm_ms::message_information(unsigned int epoint_id, int message_id, union parameter *param)
648 for (i = 0; i < (int)strlen(param->information.id); i++) {
649 digit = param->information.id[i];
650 if (digit >= 'a' && digit <= 'c')
651 digit = digit - 'a' + 'A';
652 if (!strchr("01234567890*#ABC", digit))
656 if (p_g_dtmf_state == DTMF_ST_IDLE) {
660 SCCAT(p_g_dtmf, digit);
661 if (p_g_dtmf_state == DTMF_ST_IDLE)
662 dtmf_statemachine(NULL);
667 * endpoint sends messages to the port
669 int Pgsm_ms::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
671 struct lcr_msg *message;
673 if (message_id == MESSAGE_CONNECT) {
674 /* request keypad from remote */
675 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ENABLEKEYPAD);
676 message_put(message);
679 if (Pgsm::message_epoint(epoint_id, message_id, param))
683 case MESSAGE_SETUP: /* dial-out command received from epoint */
684 if (p_state!=PORT_STATE_IDLE)
686 message_setup(epoint_id, message_id, param);
690 message_dtmf(epoint_id, message_id, param);
693 case MESSAGE_INFORMATION:
694 message_information(epoint_id, message_id, param);
698 PDEBUG(DEBUG_GSM, "Pgsm_ms(%s) gsm port with (caller id %s) received unhandled nessage: %d\n", p_name, p_callerinfo.id, message_id);
704 int gsm_ms_exit(int rc)
706 /* destroy all instances */
708 gsm_ms_delete(gsm_ms_first->name);
713 int gsm_ms_init(void)
718 /* add a new GSM mobile instance */
719 int gsm_ms_new(struct interface *interface)
721 struct lcr_gsm *gsm_ms = gsm_ms_first, **gsm_ms_p = &gsm_ms_first;
724 gsm_ms_p = &gsm_ms->gsm_ms_next;
725 gsm_ms = gsm_ms->gsm_ms_next;
728 PDEBUG(DEBUG_GSM, "GSM: interface for MS '%s' is created\n", interface->gsm_ms_name);
730 /* create gsm instance */
731 gsm_ms = (struct lcr_gsm *)MALLOC(sizeof(struct lcr_gsm));
733 gsm_ms->interface = interface;
734 gsm_ms->type = LCR_GSM_TYPE_MS;
735 SCPY(gsm_ms->name, interface->gsm_ms_name);
736 gsm_ms->sun.sun_family = AF_UNIX;
737 SPRINT(gsm_ms->sun.sun_path, "/tmp/ms_mncc_%s", gsm_ms->name);
739 memset(&gsm_ms->socket_retry, 0, sizeof(gsm_ms->socket_retry));
740 add_timer(&gsm_ms->socket_retry, mncc_socket_retry_cb, gsm_ms, 0);
742 /* do the initial connect */
743 mncc_socket_retry_cb(&gsm_ms->socket_retry, gsm_ms, 0);
750 int gsm_ms_delete(const char *name)
752 struct lcr_gsm *gsm_ms = gsm_ms_first, **gsm_ms_p = &gsm_ms_first;
754 // class Pgsm_ms *pgsm_ms = NULL;
756 PDEBUG(DEBUG_GSM, "GSM: interface for MS '%s' is deleted\n", name);
759 if (gsm_ms->type == LCR_GSM_TYPE_MS && !strcmp(gsm_ms->name, name))
761 gsm_ms_p = &gsm_ms->gsm_ms_next;
762 gsm_ms = gsm_ms->gsm_ms_next;
768 /* not needed, because:
769 * - shutdown of interface will destry port instances locally
770 * - closing of socket will make remote socket destroy calls locally
775 if ((port->p_type & PORT_CLASS_GSM_MASK) == PORT_CLASS_GSM_MS) {
776 pgsm_ms = (class Pgsm_ms *)port;
777 if (pgsm_ms->p_g_lcr_gsm == gsm_ms && pgsm_ms->p_g_callref) {
778 struct gsm_mncc *rej;
780 rej = create_mncc(MNCC_REL_REQ, pgsm_ms->p_g_callref);
781 rej->fields |= MNCC_F_CAUSE;
782 rej->cause.coding = 3;
783 rej->cause.location = 1;
784 rej->cause.value = 27;
785 gsm_trace_header(NULL, NULL, MNCC_REJ_REQ, DIRECTION_OUT);
786 add_trace("cause", "coding", "%d", rej->cause.coding);
787 add_trace("cause", "location", "%d", rej->cause.location);
788 add_trace("cause", "value", "%d", rej->cause.value);
790 send_and_free_mncc(gsm_ms, rej->msg_type, rej);
791 pgsm_ms->new_state(PORT_STATE_RELEASE);
792 trigger_work(&pgsm_ms->p_g_delete);
798 if (gsm_ms->mncc_lfd.fd > -1) {
799 close(gsm_ms->mncc_lfd.fd);
800 unregister_fd(&gsm_ms->mncc_lfd);
802 del_timer(&gsm_ms->socket_retry);
804 /* remove instance from list */
805 *gsm_ms_p = gsm_ms->gsm_ms_next;
806 FREE(gsm_ms, sizeof(struct lcr_gsm));