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
349 || msg_type == GSM_TCHF_BAD_FRAME) {
351 pgsm_ms->frame_receive(arg);
356 struct interface *interface;
358 if (msg_type != MNCC_SETUP_IND)
361 interface = getinterfacebyname(gsm_ms->interface_name);
363 struct gsm_mncc *rej;
365 rej = create_mncc(MNCC_REJ_REQ, callref);
366 rej->fields |= MNCC_F_CAUSE;
367 rej->cause.coding = 3;
368 rej->cause.location = 1;
369 rej->cause.value = 27;
370 gsm_trace_header(NULL, NULL, MNCC_REJ_REQ, DIRECTION_OUT);
371 add_trace("cause", "coding", "%d", rej->cause.coding);
372 add_trace("cause", "location", "%d", rej->cause.location);
373 add_trace("cause", "value", "%d", rej->cause.value);
374 add_trace("reason", NULL, "interface %s not found", gsm_ms->interface_name);
376 send_and_free_mncc(gsm_ms, rej->msg_type, rej);
379 /* creating port object, transparent until setup with hdlc */
380 SPRINT(name, "%s-%d-in", interface->name, 0);
381 if (!(pgsm_ms = new Pgsm_ms(PORT_TYPE_GSM_MS_IN, name, NULL, interface)))
382 FATAL("Cannot create Port instance.\n");
387 pgsm_ms->setup_ind(msg_type, callref, mncc);
390 case MNCC_CALL_PROC_IND:
391 pgsm_ms->call_proc_ind(msg_type, callref, mncc);
395 pgsm_ms->alert_ind(msg_type, callref, mncc);
399 pgsm_ms->setup_cnf(msg_type, callref, mncc);
402 case MNCC_SETUP_COMPL_IND:
403 pgsm_ms->setup_compl_ind(msg_type, callref, mncc);
407 pgsm_ms->disc_ind(msg_type, callref, mncc);
413 pgsm_ms->rel_ind(msg_type, callref, mncc);
416 case MNCC_NOTIFY_IND:
417 pgsm_ms->notify_ind(msg_type, callref, mncc);
420 case MNCC_START_DTMF_RSP:
421 case MNCC_START_DTMF_REJ:
422 case MNCC_STOP_DTMF_RSP:
423 pgsm_ms->dtmf_statemachine(mncc);
433 void Pgsm_ms::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
435 struct lcr_msg *message;
436 struct epoint_list *epointlist;
437 struct gsm_mncc *mncc;
439 /* copy setup infos to port */
440 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
441 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
442 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
443 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
446 if (!p_g_lcr_gsm || p_g_lcr_gsm->mncc_lfd.fd < 0) {
447 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
448 add_trace("failure", NULL, "MS %s instance is unavailable", p_g_ms_name);
450 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
451 message->param.disconnectinfo.cause = 41;
452 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
453 message_put(message);
454 new_state(PORT_STATE_RELEASE);
455 trigger_work(&p_g_delete);
460 if (!p_dialinginfo.id[0]) {
461 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
462 add_trace("failure", NULL, "No dialed subscriber given.");
464 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
465 message->param.disconnectinfo.cause = 28;
466 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
467 message_put(message);
468 new_state(PORT_STATE_RELEASE);
469 trigger_work(&p_g_delete);
473 /* attach only if not already */
474 epointlist = p_epointlist;
476 if (epointlist->epoint_id == epoint_id)
478 epointlist = epointlist->next;
481 epointlist_new(epoint_id);
484 gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_OUT);
485 p_g_callref = new_callref++;
486 add_trace("callref", "new", "0x%x", p_g_callref);
489 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
490 mncc = create_mncc(MNCC_SETUP_REQ, p_g_callref);
491 if (!strncasecmp(p_dialinginfo.id, "emerg", 5)) {
494 /* caller info (only clir) */
495 switch (p_callerinfo.present) {
496 case INFO_PRESENT_ALLOWED:
502 /* dialing information (mandatory) */
503 mncc->fields |= MNCC_F_CALLED;
504 mncc->called.type = 0; /* unknown */
505 mncc->called.plan = 1; /* isdn */
506 SCPY(mncc->called.number, p_dialinginfo.id);
507 add_trace("dialing", "number", "%s", mncc->called.number);
509 /* bearer capability (mandatory) */
510 mncc->fields |= MNCC_F_BEARER_CAP;
511 mncc->bearer_cap.coding = 0;
512 mncc->bearer_cap.radio = 1;
513 mncc->bearer_cap.speech_ctm = 0;
514 mncc->bearer_cap.speech_ver[0] = 0;
515 mncc->bearer_cap.speech_ver[1] = -1; /* end of list */
516 switch (p_capainfo.bearer_capa) {
517 case INFO_BC_DATAUNRESTRICTED:
518 case INFO_BC_DATARESTRICTED:
519 mncc->bearer_cap.transfer = 1;
522 mncc->bearer_cap.transfer = 0;
525 mncc->bearer_cap.transfer = 2;
528 switch (p_capainfo.bearer_mode) {
529 case INFO_BMODE_PACKET:
530 mncc->bearer_cap.mode = 1;
533 mncc->bearer_cap.mode = 0;
537 mncc->fields |= MNCC_F_CCCAP;
538 mncc->cccap.dtmf = 1;
540 /* request keypad from remote */
541 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ENABLEKEYPAD);
542 message_put(message);
546 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
548 new_state(PORT_STATE_OUT_SETUP);
550 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
551 message_put(message);
553 new_state(PORT_STATE_OUT_PROCEEDING);
558 void Pgsm_ms::dtmf_statemachine(struct gsm_mncc *mncc)
560 struct gsm_mncc *dtmf;
562 switch (p_g_dtmf_state) {
566 if (!p_g_dtmf[p_g_dtmf_index]) {
567 PDEBUG(DEBUG_GSM, "done with DTMF\n");
568 p_g_dtmf_state = DTMF_ST_IDLE;
571 gsm_trace_header(p_g_interface_name, this, MNCC_START_DTMF_REQ, DIRECTION_OUT);
572 dtmf = create_mncc(MNCC_START_DTMF_REQ, p_g_callref);
573 dtmf->keypad = p_g_dtmf[p_g_dtmf_index++];
574 p_g_dtmf_state = DTMF_ST_START;
575 PDEBUG(DEBUG_GSM, "start DTMF (keypad %c)\n",
578 send_and_free_mncc(p_g_lcr_gsm, dtmf->msg_type, dtmf);
581 if (mncc->msg_type != MNCC_START_DTMF_RSP) {
582 PDEBUG(DEBUG_GSM, "DTMF was rejected\n");
585 schedule_timer(&p_g_dtmf_timer, 0, 70 * 1000);
586 p_g_dtmf_state = DTMF_ST_MARK;
587 PDEBUG(DEBUG_GSM, "DTMF is on\n");
590 gsm_trace_header(p_g_interface_name, this, MNCC_STOP_DTMF_REQ, DIRECTION_OUT);
591 dtmf = create_mncc(MNCC_STOP_DTMF_REQ, p_g_callref);
592 p_g_dtmf_state = DTMF_ST_STOP;
594 send_and_free_mncc(p_g_lcr_gsm, dtmf->msg_type, dtmf);
597 schedule_timer(&p_g_dtmf_timer, 0, 120 * 1000);
598 p_g_dtmf_state = DTMF_ST_SPACE;
599 PDEBUG(DEBUG_GSM, "DTMF is off\n");
604 static int dtmf_timeout(struct lcr_timer *timer, void *instance, int index)
606 class Pgsm_ms *pgsm_ms = (class Pgsm_ms *)instance;
608 PDEBUG(DEBUG_GSM, "DTMF timer has fired\n");
609 pgsm_ms->dtmf_statemachine(NULL);
615 void Pgsm_ms::message_dtmf(unsigned int epoint_id, int message_id, union parameter *param)
617 char digit = param->dtmf;
619 if (digit >= 'a' && digit <= 'c')
620 digit = digit - 'a' + 'A';
621 if (!strchr("01234567890*#ABC", digit))
625 if (p_g_dtmf_state == DTMF_ST_IDLE) {
629 SCCAT(p_g_dtmf, digit);
630 if (p_g_dtmf_state == DTMF_ST_IDLE)
631 dtmf_statemachine(NULL);
634 /* MESSAGE_INFORMATION */
635 void Pgsm_ms::message_information(unsigned int epoint_id, int message_id, union parameter *param)
640 for (i = 0; i < (int)strlen(param->information.id); i++) {
641 digit = param->information.id[i];
642 if (digit >= 'a' && digit <= 'c')
643 digit = digit - 'a' + 'A';
644 if (!strchr("01234567890*#ABC", digit))
648 if (p_g_dtmf_state == DTMF_ST_IDLE) {
652 SCCAT(p_g_dtmf, digit);
653 if (p_g_dtmf_state == DTMF_ST_IDLE)
654 dtmf_statemachine(NULL);
659 * endpoint sends messages to the port
661 int Pgsm_ms::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
663 struct lcr_msg *message;
665 if (message_id == MESSAGE_CONNECT) {
666 /* request keypad from remote */
667 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ENABLEKEYPAD);
668 message_put(message);
671 if (Pgsm::message_epoint(epoint_id, message_id, param))
675 case MESSAGE_SETUP: /* dial-out command received from epoint */
676 if (p_state!=PORT_STATE_IDLE)
678 message_setup(epoint_id, message_id, param);
682 message_dtmf(epoint_id, message_id, param);
685 case MESSAGE_INFORMATION:
686 message_information(epoint_id, message_id, param);
690 PDEBUG(DEBUG_GSM, "Pgsm_ms(%s) gsm port with (caller id %s) received unhandled nessage: %d\n", p_name, p_callerinfo.id, message_id);
696 int gsm_ms_exit(int rc)
698 /* destroy all instances */
700 gsm_ms_delete(gsm_ms_first->name);
705 int gsm_ms_init(void)
710 /* add a new GSM mobile instance */
711 int gsm_ms_new(struct interface *interface)
713 struct lcr_gsm *gsm_ms = gsm_ms_first, **gsm_ms_p = &gsm_ms_first;
716 gsm_ms_p = &gsm_ms->gsm_ms_next;
717 gsm_ms = gsm_ms->gsm_ms_next;
720 PDEBUG(DEBUG_GSM, "GSM: interface for MS '%s' is created\n", interface->gsm_ms_name);
722 /* create gsm instance */
723 gsm_ms = (struct lcr_gsm *)MALLOC(sizeof(struct lcr_gsm));
725 SCPY(gsm_ms->interface_name, interface->name);
726 gsm_ms->type = LCR_GSM_TYPE_MS;
727 SCPY(gsm_ms->name, interface->gsm_ms_name);
728 gsm_ms->sun.sun_family = AF_UNIX;
729 SPRINT(gsm_ms->sun.sun_path, "/tmp/ms_mncc_%s", gsm_ms->name);
731 memset(&gsm_ms->socket_retry, 0, sizeof(gsm_ms->socket_retry));
732 add_timer(&gsm_ms->socket_retry, mncc_socket_retry_cb, gsm_ms, 0);
734 /* do the initial connect */
735 mncc_socket_retry_cb(&gsm_ms->socket_retry, gsm_ms, 0);
742 int gsm_ms_delete(const char *name)
744 struct lcr_gsm *gsm_ms = gsm_ms_first, **gsm_ms_p = &gsm_ms_first;
746 // class Pgsm_ms *pgsm_ms = NULL;
748 PDEBUG(DEBUG_GSM, "GSM: interface for MS '%s' is deleted\n", name);
751 if (gsm_ms->type == LCR_GSM_TYPE_MS && !strcmp(gsm_ms->name, name))
753 gsm_ms_p = &gsm_ms->gsm_ms_next;
754 gsm_ms = gsm_ms->gsm_ms_next;
760 /* not needed, because:
761 * - shutdown of interface will destry port instances locally
762 * - closing of socket will make remote socket destroy calls locally
767 if ((port->p_type & PORT_CLASS_GSM_MASK) == PORT_CLASS_GSM_MS) {
768 pgsm_ms = (class Pgsm_ms *)port;
769 if (pgsm_ms->p_g_lcr_gsm == gsm_ms && pgsm_ms->p_g_callref) {
770 struct gsm_mncc *rej;
772 rej = create_mncc(MNCC_REL_REQ, pgsm_ms->p_g_callref);
773 rej->fields |= MNCC_F_CAUSE;
774 rej->cause.coding = 3;
775 rej->cause.location = 1;
776 rej->cause.value = 27;
777 gsm_trace_header(NULL, NULL, MNCC_REJ_REQ, DIRECTION_OUT);
778 add_trace("cause", "coding", "%d", rej->cause.coding);
779 add_trace("cause", "location", "%d", rej->cause.location);
780 add_trace("cause", "value", "%d", rej->cause.value);
782 send_and_free_mncc(gsm_ms, rej->msg_type, rej);
783 pgsm_ms->new_state(PORT_STATE_RELEASE);
784 trigger_work(&pgsm_ms->p_g_delete);
790 if (gsm_ms->mncc_lfd.fd > -1) {
791 close(gsm_ms->mncc_lfd.fd);
792 unregister_fd(&gsm_ms->mncc_lfd);
794 del_timer(&gsm_ms->socket_retry);
796 /* remove instance from list */
797 *gsm_ms_p = gsm_ms->gsm_ms_next;
798 FREE(gsm_ms, sizeof(struct lcr_gsm));