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_interface_name);
77 PERROR("Cannot find interface %s.\n", p_interface_name);
81 /* process given callref */
82 gsm_trace_header(p_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");
89 mncc = create_mncc(MNCC_REJ_REQ, callref);
90 gsm_trace_header(p_interface_name, this, MNCC_REJ_REQ, DIRECTION_OUT);
91 mncc->fields |= MNCC_F_CAUSE;
92 mncc->cause.coding = 3;
93 mncc->cause.location = 1;
94 mncc->cause.value = 47;
95 add_trace("cause", "coding", "%d", mncc->cause.coding);
96 add_trace("cause", "location", "%d", mncc->cause.location);
97 add_trace("cause", "value", "%d", mncc->cause.value);
98 add_trace("reason", NULL, "callref already in use");
100 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
101 new_state(PORT_STATE_RELEASE);
102 trigger_work(&p_g_delete);
105 if (callref < 0x40000000) {
106 /* release in case the ID is invalid */
107 add_trace("error", NULL, "callref invalid, not of MS type");
111 p_g_callref = callref;
114 gsm_trace_header(p_interface_name, this, MNCC_SETUP_IND, DIRECTION_IN);
115 /* caller information */
116 p_callerinfo.ntype = INFO_NTYPE_NOTPRESENT;
117 if (mncc->fields & MNCC_F_CALLING) {
118 switch (mncc->calling.present) {
120 p_callerinfo.present = INFO_PRESENT_RESTRICTED;
123 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
126 p_callerinfo.present = INFO_PRESENT_ALLOWED;
129 switch (mncc->calling.screen) {
131 p_callerinfo.screen = INFO_SCREEN_USER;
134 p_callerinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
137 p_callerinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
140 p_callerinfo.screen = INFO_SCREEN_NETWORK;
143 switch (mncc->calling.type) {
145 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
148 p_callerinfo.ntype = INFO_NTYPE_INTERNATIONAL;
151 p_callerinfo.ntype = INFO_NTYPE_NATIONAL;
154 p_callerinfo.ntype = INFO_NTYPE_SUBSCRIBER;
157 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
160 SCPY(p_callerinfo.id, mncc->calling.number);
161 add_trace("calling", "type", "%d", mncc->calling.type);
162 add_trace("calling", "plan", "%d", mncc->calling.plan);
163 add_trace("calling", "present", "%d", mncc->calling.present);
164 add_trace("calling", "screen", "%d", mncc->calling.screen);
165 add_trace("calling", "number", "%s", mncc->calling.number);
167 SCPY(p_callerinfo.interface, p_interface_name);
168 /* dialing information */
169 if (mncc->fields & MNCC_F_CALLED) {
170 SCAT(p_dialinginfo.id, mncc->called.number);
171 switch (mncc->called.type) {
173 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
176 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
179 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
182 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
185 add_trace("dialing", "type", "%d", mncc->called.type);
186 add_trace("dialing", "plan", "%d", mncc->called.plan);
187 add_trace("dialing", "number", "%s", mncc->called.number);
189 p_dialinginfo.sending_complete = 1;
191 p_redirinfo.ntype = INFO_NTYPE_NOTPRESENT;
192 if (mncc->fields & MNCC_F_REDIRECTING) {
193 switch (mncc->redirecting.present) {
195 p_redirinfo.present = INFO_PRESENT_RESTRICTED;
198 p_redirinfo.present = INFO_PRESENT_NOTAVAIL;
201 p_redirinfo.present = INFO_PRESENT_ALLOWED;
204 switch (mncc->redirecting.screen) {
206 p_redirinfo.screen = INFO_SCREEN_USER;
209 p_redirinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
212 p_redirinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
215 p_redirinfo.screen = INFO_SCREEN_NETWORK;
218 switch (mncc->redirecting.type) {
220 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
223 p_redirinfo.ntype = INFO_NTYPE_INTERNATIONAL;
226 p_redirinfo.ntype = INFO_NTYPE_NATIONAL;
229 p_redirinfo.ntype = INFO_NTYPE_SUBSCRIBER;
232 p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
235 SCPY(p_redirinfo.id, mncc->redirecting.number);
236 add_trace("redir", "type", "%d", mncc->redirecting.type);
237 add_trace("redir", "plan", "%d", mncc->redirecting.plan);
238 add_trace("redir", "present", "%d", mncc->redirecting.present);
239 add_trace("redir", "screen", "%d", mncc->redirecting.screen);
240 add_trace("redir", "number", "%s", mncc->redirecting.number);
242 /* bearer capability */
243 if (mncc->fields & MNCC_F_BEARER_CAP) {
244 switch (mncc->bearer_cap.transfer) {
246 p_capainfo.bearer_capa = INFO_BC_DATAUNRESTRICTED;
250 p_capainfo.bearer_capa = INFO_BC_AUDIO;
251 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
254 p_capainfo.bearer_capa = INFO_BC_SPEECH;
255 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
258 switch (mncc->bearer_cap.mode) {
260 p_capainfo.bearer_mode = INFO_BMODE_PACKET;
263 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
266 add_trace("bearer", "transfer", "%d", mncc->bearer_cap.transfer);
267 add_trace("bearer", "mode", "%d", mncc->bearer_cap.mode);
269 p_capainfo.bearer_capa = INFO_BC_SPEECH;
270 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
271 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
273 /* if packet mode works some day, see dss1.cpp for conditions */
274 p_capainfo.source_mode = B_MODE_TRANSPARENT;
278 /* create endpoint */
280 FATAL("Incoming call but already got an endpoint.\n");
281 if (!(epoint = new Endpoint(p_serial, 0)))
282 FATAL("No memory for Endpoint instance\n");
283 epoint->ep_app = new_endpointapp(epoint, 0, interface->app); //incoming
284 epointlist_new(epoint->ep_serial);
286 /* modify lchan to GSM codec V1 */
287 modify_lchan(MEDIA_TYPE_GSM);
289 /* send call proceeding */
290 gsm_trace_header(p_interface_name, this, MNCC_CALL_CONF_REQ, DIRECTION_OUT);
291 proceeding = create_mncc(MNCC_CALL_CONF_REQ, p_g_callref);
292 /* bearer capability (mandatory, if not present in setup message) */
293 if (!(mncc->fields & MNCC_F_BEARER_CAP)) {
294 proceeding->fields |= MNCC_F_BEARER_CAP;
295 proceeding->bearer_cap.coding = 0;
296 proceeding->bearer_cap.radio = 1;
297 proceeding->bearer_cap.speech_ctm = 0;
298 proceeding->bearer_cap.speech_ver[0] = 0;
299 proceeding->bearer_cap.speech_ver[1] = -1; /* end of list */
300 proceeding->bearer_cap.transfer = 0;
301 proceeding->bearer_cap.mode = 0;
304 proceeding->fields |= MNCC_F_CCCAP;
305 proceeding->cccap.dtmf = 1;
307 send_and_free_mncc(p_g_lcr_gsm, proceeding->msg_type, proceeding);
309 new_state(PORT_STATE_IN_PROCEEDING);
311 if (p_g_tones && !p_g_tch_connected) { /* only if ... */
312 gsm_trace_header(p_interface_name, this, MNCC_FRAME_RECV, DIRECTION_OUT);
314 frame = create_mncc(MNCC_FRAME_RECV, p_g_callref);
315 send_and_free_mncc(p_g_lcr_gsm, frame->msg_type, frame);
316 p_g_tch_connected = 1;
319 /* send setup message to endpoit */
320 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
321 message->param.setup.port_type = p_type;
322 // message->param.setup.dtmf = 0;
323 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
324 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
325 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
326 SCPY((char *)message->param.setup.useruser.data, (char *)mncc->useruser.info);
327 message->param.setup.useruser.len = strlen(mncc->useruser.info);
328 message->param.setup.useruser.protocol = mncc->useruser.proto;
329 message_put(message);
333 * MS sends message to port
335 int message_ms(struct lcr_gsm *gsm_ms, int msg_type, void *arg)
337 struct gsm_mncc *mncc = (struct gsm_mncc *)arg;
338 unsigned int callref = mncc->callref;
340 class Pgsm_ms *pgsm_ms = NULL;
342 // struct mISDNport *mISDNport;
344 /* Special messages */
349 callref = mncc->callref;
352 if ((port->p_type & PORT_CLASS_GSM_MASK) == PORT_CLASS_GSM_MS) {
353 pgsm_ms = (class Pgsm_ms *)port;
354 if (pgsm_ms->p_g_callref == callref) {
361 if (msg_type == GSM_TCHF_FRAME
362 || msg_type == GSM_BAD_FRAME) {
364 pgsm_ms->frame_receive(arg);
369 struct interface *interface;
371 if (msg_type != MNCC_SETUP_IND)
374 interface = getinterfacebyname(gsm_ms->interface_name);
376 struct gsm_mncc *rej;
378 rej = create_mncc(MNCC_REJ_REQ, callref);
379 rej->fields |= MNCC_F_CAUSE;
380 rej->cause.coding = 3;
381 rej->cause.location = 1;
382 rej->cause.value = 27;
383 gsm_trace_header(NULL, NULL, MNCC_REJ_REQ, DIRECTION_OUT);
384 add_trace("cause", "coding", "%d", rej->cause.coding);
385 add_trace("cause", "location", "%d", rej->cause.location);
386 add_trace("cause", "value", "%d", rej->cause.value);
387 add_trace("reason", NULL, "interface %s not found", gsm_ms->interface_name);
389 send_and_free_mncc(gsm_ms, rej->msg_type, rej);
392 /* creating port object, transparent until setup with hdlc */
393 SPRINT(name, "%s-%d-in", interface->name, 0);
394 if (!(pgsm_ms = new Pgsm_ms(PORT_TYPE_GSM_MS_IN, name, NULL, interface)))
395 FATAL("Cannot create Port instance.\n");
400 pgsm_ms->setup_ind(msg_type, callref, mncc);
403 case MNCC_CALL_PROC_IND:
404 pgsm_ms->call_proc_ind(msg_type, callref, mncc);
408 pgsm_ms->alert_ind(msg_type, callref, mncc);
412 pgsm_ms->setup_cnf(msg_type, callref, mncc);
415 case MNCC_SETUP_COMPL_IND:
416 pgsm_ms->setup_compl_ind(msg_type, callref, mncc);
420 pgsm_ms->disc_ind(msg_type, callref, mncc);
426 pgsm_ms->rel_ind(msg_type, callref, mncc);
429 case MNCC_NOTIFY_IND:
430 pgsm_ms->notify_ind(msg_type, callref, mncc);
433 case MNCC_START_DTMF_RSP:
434 case MNCC_START_DTMF_REJ:
435 case MNCC_STOP_DTMF_RSP:
436 pgsm_ms->dtmf_statemachine(mncc);
446 void Pgsm_ms::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
448 struct lcr_msg *message;
449 struct epoint_list *epointlist;
450 struct gsm_mncc *mncc;
452 /* copy setup infos to port */
453 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
454 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
455 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
456 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
459 if (!p_g_lcr_gsm || p_g_lcr_gsm->mncc_lfd.fd < 0) {
460 gsm_trace_header(p_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
461 add_trace("failure", NULL, "MS %s instance is unavailable", p_g_ms_name);
463 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
464 message->param.disconnectinfo.cause = 41;
465 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
466 message_put(message);
467 new_state(PORT_STATE_RELEASE);
468 trigger_work(&p_g_delete);
473 if (!p_dialinginfo.id[0]) {
474 gsm_trace_header(p_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
475 add_trace("failure", NULL, "No dialed subscriber given.");
477 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
478 message->param.disconnectinfo.cause = 28;
479 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
480 message_put(message);
481 new_state(PORT_STATE_RELEASE);
482 trigger_work(&p_g_delete);
486 /* attach only if not already */
487 epointlist = p_epointlist;
489 if (epointlist->epoint_id == epoint_id)
491 epointlist = epointlist->next;
494 epointlist_new(epoint_id);
497 gsm_trace_header(p_interface_name, this, 0, DIRECTION_OUT);
498 p_g_callref = new_callref++;
499 add_trace("callref", "new", "0x%x", p_g_callref);
502 gsm_trace_header(p_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
503 mncc = create_mncc(MNCC_SETUP_REQ, p_g_callref);
504 if (!strncasecmp(p_dialinginfo.id, "emerg", 5)) {
507 /* caller info (only clir) */
508 switch (p_callerinfo.present) {
509 case INFO_PRESENT_ALLOWED:
515 /* dialing information (mandatory) */
516 mncc->fields |= MNCC_F_CALLED;
517 mncc->called.type = 0; /* unknown */
518 mncc->called.plan = 1; /* isdn */
519 SCPY(mncc->called.number, p_dialinginfo.id);
520 add_trace("dialing", "number", "%s", mncc->called.number);
522 /* bearer capability (mandatory) */
523 mncc->fields |= MNCC_F_BEARER_CAP;
524 mncc->bearer_cap.coding = 0;
525 mncc->bearer_cap.radio = 1;
526 mncc->bearer_cap.speech_ctm = 0;
527 mncc->bearer_cap.speech_ver[0] = 0;
528 mncc->bearer_cap.speech_ver[1] = -1; /* end of list */
529 switch (p_capainfo.bearer_capa) {
530 case INFO_BC_DATAUNRESTRICTED:
531 case INFO_BC_DATARESTRICTED:
532 mncc->bearer_cap.transfer = 1;
535 mncc->bearer_cap.transfer = 0;
538 mncc->bearer_cap.transfer = 2;
541 switch (p_capainfo.bearer_mode) {
542 case INFO_BMODE_PACKET:
543 mncc->bearer_cap.mode = 1;
546 mncc->bearer_cap.mode = 0;
550 mncc->fields |= MNCC_F_CCCAP;
551 mncc->cccap.dtmf = 1;
553 /* request keypad from remote */
554 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ENABLEKEYPAD);
555 message_put(message);
559 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
561 new_state(PORT_STATE_OUT_SETUP);
563 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
564 message_put(message);
566 new_state(PORT_STATE_OUT_PROCEEDING);
571 void Pgsm_ms::dtmf_statemachine(struct gsm_mncc *mncc)
573 struct gsm_mncc *dtmf;
575 switch (p_g_dtmf_state) {
579 if (!p_g_dtmf[p_g_dtmf_index]) {
580 PDEBUG(DEBUG_GSM, "done with DTMF\n");
581 p_g_dtmf_state = DTMF_ST_IDLE;
584 gsm_trace_header(p_interface_name, this, MNCC_START_DTMF_REQ, DIRECTION_OUT);
585 dtmf = create_mncc(MNCC_START_DTMF_REQ, p_g_callref);
586 dtmf->keypad = p_g_dtmf[p_g_dtmf_index++];
587 p_g_dtmf_state = DTMF_ST_START;
588 PDEBUG(DEBUG_GSM, "start DTMF (keypad %c)\n",
591 send_and_free_mncc(p_g_lcr_gsm, dtmf->msg_type, dtmf);
594 if (mncc->msg_type != MNCC_START_DTMF_RSP) {
595 PDEBUG(DEBUG_GSM, "DTMF was rejected\n");
598 schedule_timer(&p_g_dtmf_timer, 0, 70 * 1000);
599 p_g_dtmf_state = DTMF_ST_MARK;
600 PDEBUG(DEBUG_GSM, "DTMF is on\n");
603 gsm_trace_header(p_interface_name, this, MNCC_STOP_DTMF_REQ, DIRECTION_OUT);
604 dtmf = create_mncc(MNCC_STOP_DTMF_REQ, p_g_callref);
605 p_g_dtmf_state = DTMF_ST_STOP;
607 send_and_free_mncc(p_g_lcr_gsm, dtmf->msg_type, dtmf);
610 schedule_timer(&p_g_dtmf_timer, 0, 120 * 1000);
611 p_g_dtmf_state = DTMF_ST_SPACE;
612 PDEBUG(DEBUG_GSM, "DTMF is off\n");
617 static int dtmf_timeout(struct lcr_timer *timer, void *instance, int index)
619 class Pgsm_ms *pgsm_ms = (class Pgsm_ms *)instance;
621 PDEBUG(DEBUG_GSM, "DTMF timer has fired\n");
622 pgsm_ms->dtmf_statemachine(NULL);
628 void Pgsm_ms::message_dtmf(unsigned int epoint_id, int message_id, union parameter *param)
630 char digit = param->dtmf;
632 if (digit >= 'a' && digit <= 'c')
633 digit = digit - 'a' + 'A';
634 if (!strchr("01234567890*#ABC", digit))
638 if (p_g_dtmf_state == DTMF_ST_IDLE) {
642 SCCAT(p_g_dtmf, digit);
643 if (p_g_dtmf_state == DTMF_ST_IDLE)
644 dtmf_statemachine(NULL);
647 /* MESSAGE_INFORMATION */
648 void Pgsm_ms::message_information(unsigned int epoint_id, int message_id, union parameter *param)
653 for (i = 0; i < (int)strlen(param->information.id); i++) {
654 digit = param->information.id[i];
655 if (digit >= 'a' && digit <= 'c')
656 digit = digit - 'a' + 'A';
657 if (!strchr("01234567890*#ABC", digit))
661 if (p_g_dtmf_state == DTMF_ST_IDLE) {
665 SCCAT(p_g_dtmf, digit);
666 if (p_g_dtmf_state == DTMF_ST_IDLE)
667 dtmf_statemachine(NULL);
672 * endpoint sends messages to the port
674 int Pgsm_ms::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
676 struct lcr_msg *message;
678 if (message_id == MESSAGE_CONNECT) {
679 /* request keypad from remote */
680 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ENABLEKEYPAD);
681 message_put(message);
684 if (Pgsm::message_epoint(epoint_id, message_id, param))
688 case MESSAGE_SETUP: /* dial-out command received from epoint */
689 if (p_state!=PORT_STATE_IDLE)
691 message_setup(epoint_id, message_id, param);
695 message_dtmf(epoint_id, message_id, param);
698 case MESSAGE_INFORMATION:
699 message_information(epoint_id, message_id, param);
703 PDEBUG(DEBUG_GSM, "Pgsm_ms(%s) gsm port with (caller id %s) received unhandled nessage: %d\n", p_name, p_callerinfo.id, message_id);
709 int gsm_ms_exit(int rc)
711 /* destroy all instances */
713 gsm_ms_delete(gsm_ms_first->name);
718 int gsm_ms_init(void)
723 /* add a new GSM mobile instance */
724 int gsm_ms_new(struct interface *interface)
726 struct lcr_gsm *gsm_ms = gsm_ms_first, **gsm_ms_p = &gsm_ms_first;
729 gsm_ms_p = &gsm_ms->gsm_ms_next;
730 gsm_ms = gsm_ms->gsm_ms_next;
733 PDEBUG(DEBUG_GSM, "GSM: interface for MS '%s' is created\n", interface->gsm_ms_name);
735 /* create gsm instance */
736 gsm_ms = (struct lcr_gsm *)MALLOC(sizeof(struct lcr_gsm));
738 SCPY(gsm_ms->interface_name, interface->name);
739 gsm_ms->type = LCR_GSM_TYPE_MS;
740 SCPY(gsm_ms->name, interface->gsm_ms_name);
741 gsm_ms->sun.sun_family = AF_UNIX;
742 SPRINT(gsm_ms->sun.sun_path, "/tmp/ms_mncc_%s", gsm_ms->name);
744 memset(&gsm_ms->socket_retry, 0, sizeof(gsm_ms->socket_retry));
745 add_timer(&gsm_ms->socket_retry, mncc_socket_retry_cb, gsm_ms, 0);
747 /* do the initial connect */
748 mncc_socket_retry_cb(&gsm_ms->socket_retry, gsm_ms, 0);
755 int gsm_ms_delete(const char *name)
757 struct lcr_gsm *gsm_ms = gsm_ms_first, **gsm_ms_p = &gsm_ms_first;
759 // class Pgsm_ms *pgsm_ms = NULL;
761 PDEBUG(DEBUG_GSM, "GSM: interface for MS '%s' is deleted\n", name);
764 if (gsm_ms->type == LCR_GSM_TYPE_MS && !strcmp(gsm_ms->name, name))
766 gsm_ms_p = &gsm_ms->gsm_ms_next;
767 gsm_ms = gsm_ms->gsm_ms_next;
773 /* not needed, because:
774 * - shutdown of interface will destry port instances locally
775 * - closing of socket will make remote socket destroy calls locally
780 if ((port->p_type & PORT_CLASS_GSM_MASK) == PORT_CLASS_GSM_MS) {
781 pgsm_ms = (class Pgsm_ms *)port;
782 if (pgsm_ms->p_g_lcr_gsm == gsm_ms && pgsm_ms->p_g_callref) {
783 struct gsm_mncc *rej;
785 rej = create_mncc(MNCC_REL_REQ, pgsm_ms->p_g_callref);
786 rej->fields |= MNCC_F_CAUSE;
787 rej->cause.coding = 3;
788 rej->cause.location = 1;
789 rej->cause.value = 27;
790 gsm_trace_header(NULL, NULL, MNCC_REJ_REQ, DIRECTION_OUT);
791 add_trace("cause", "coding", "%d", rej->cause.coding);
792 add_trace("cause", "location", "%d", rej->cause.location);
793 add_trace("cause", "value", "%d", rej->cause.value);
795 send_and_free_mncc(gsm_ms, rej->msg_type, rej);
796 pgsm_ms->new_state(PORT_STATE_RELEASE);
797 trigger_work(&pgsm_ms->p_g_delete);
803 if (gsm_ms->mncc_lfd.fd > -1) {
804 close(gsm_ms->mncc_lfd.fd);
805 unregister_fd(&gsm_ms->mncc_lfd);
807 del_timer(&gsm_ms->socket_retry);
809 /* remove instance from list */
810 *gsm_ms_p = gsm_ms->gsm_ms_next;
811 FREE(gsm_ms, sizeof(struct lcr_gsm));