1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
8 ** mISDN gsm (BS mode) **
10 \*****************************************************************************/
15 struct lcr_gsm *gsm_bs = NULL;
20 unsigned char dtmf_samples[16][8000];
21 static int dtmf_x[4] = { 1209, 1336, 1477, 1633 };
22 static int dtmf_y[4] = { 697, 770, 852, 941 };
24 void generate_dtmf(void)
26 double fx, fy, sample;
30 for (y = 0; y < 4; y++) {
31 fy = 2 * 3.1415927 * ((double)dtmf_y[y]) / 8000.0;
32 for (x = 0; x < 4; x++) {
33 fx = 2 * 3.1415927 * ((double)dtmf_x[x]) / 8000.0;
34 law = dtmf_samples[y << 2 | x];
35 for (i = 0; i < 8000; i++) {
36 sample = sin(fy * ((double)i)) * 0.251 * 32767.0; /* -6 dB */
37 sample += sin(fx * ((double)i)) * 0.158 * 32767.0; /* -8 dB */
38 *law++ = audio_s16_to_law[(int)sample & 0xffff];
48 Pgsm_bs::Pgsm_bs(int type, char *portname, struct port_settings *settings, struct interface *interface) : Pgsm(type, portname, settings, interface)
54 PDEBUG(DEBUG_GSM, "Created new GSMBSPort(%s).\n", portname);
62 PDEBUG(DEBUG_GSM, "Destroyed GSM BS process(%s).\n", p_name);
66 void Pgsm_bs::start_dtmf_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc)
68 struct lcr_msg *message;
69 struct gsm_mncc *resp;
71 gsm_trace_header(p_g_interface_name, this, msg_type, DIRECTION_IN);
72 add_trace("keypad", NULL, "%c", mncc->keypad);
74 SPRINT(p_dialinginfo.id, "%c", mncc->keypad);
75 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
78 gsm_trace_header(p_g_interface_name, this, MNCC_START_DTMF_RSP, DIRECTION_OUT);
79 add_trace("keypad", NULL, "%c", mncc->keypad);
81 resp = create_mncc(MNCC_START_DTMF_RSP, p_g_callref);
82 resp->fields |= MNCC_F_KEYPAD;
83 resp->keypad = mncc->keypad;
84 send_and_free_mncc(p_g_lcr_gsm, resp->msg_type, resp);
87 /* send dtmf information, because we bridge RTP directly */
88 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_DTMF);
89 message->param.dtmf = mncc->keypad;
92 /* generate DTMF tones, since we do audio forwarding inside LCR */
93 switch (mncc->keypad) {
94 case '1': p_g_dtmf = dtmf_samples[0]; break;
95 case '2': p_g_dtmf = dtmf_samples[1]; break;
96 case '3': p_g_dtmf = dtmf_samples[2]; break;
98 case 'A': p_g_dtmf = dtmf_samples[3]; break;
99 case '4': p_g_dtmf = dtmf_samples[4]; break;
100 case '5': p_g_dtmf = dtmf_samples[5]; break;
101 case '6': p_g_dtmf = dtmf_samples[6]; break;
103 case 'B': p_g_dtmf = dtmf_samples[7]; break;
104 case '7': p_g_dtmf = dtmf_samples[8]; break;
105 case '8': p_g_dtmf = dtmf_samples[9]; break;
106 case '9': p_g_dtmf = dtmf_samples[10]; break;
108 case 'C': p_g_dtmf = dtmf_samples[11]; break;
109 case '*': p_g_dtmf = dtmf_samples[12]; break;
110 case '0': p_g_dtmf = dtmf_samples[13]; break;
111 case '#': p_g_dtmf = dtmf_samples[14]; break;
113 case 'D': p_g_dtmf = dtmf_samples[15]; break;
118 void Pgsm_bs::stop_dtmf_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc)
120 struct gsm_mncc *resp;
122 gsm_trace_header(p_g_interface_name, this, msg_type, DIRECTION_IN);
123 add_trace("keypad", NULL, "%c", mncc->keypad);
127 gsm_trace_header(p_g_interface_name, this, MNCC_STOP_DTMF_RSP, DIRECTION_OUT);
128 add_trace("keypad", NULL, "%c", mncc->keypad);
130 resp = create_mncc(MNCC_STOP_DTMF_RSP, p_g_callref);
131 resp->keypad = mncc->keypad;
132 send_and_free_mncc(p_g_lcr_gsm, resp->msg_type, resp);
138 /* HOLD INDICATION */
139 void Pgsm_bs::hold_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc)
141 struct lcr_msg *message;
142 struct gsm_mncc *resp, *frame;
144 gsm_trace_header(p_g_interface_name, this, msg_type, DIRECTION_IN);
147 /* notify the hold of call */
148 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
149 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_HOLD;
150 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
151 message_put(message);
153 /* acknowledge hold */
154 gsm_trace_header(p_g_interface_name, this, MNCC_HOLD_CNF, DIRECTION_OUT);
156 resp = create_mncc(MNCC_HOLD_CNF, p_g_callref);
157 send_and_free_mncc(p_g_lcr_gsm, resp->msg_type, resp);
160 if (p_g_tch_connected) { /* it should be true */
161 gsm_trace_header(p_g_interface_name, this, MNCC_FRAME_DROP, DIRECTION_OUT);
163 frame = create_mncc(MNCC_FRAME_DROP, p_g_callref);
164 send_and_free_mncc(p_g_lcr_gsm, frame->msg_type, frame);
165 p_g_tch_connected = 0;
170 /* RETRIEVE INDICATION */
171 void Pgsm_bs::retr_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc)
173 struct lcr_msg *message;
174 struct gsm_mncc *resp, *frame;
176 gsm_trace_header(p_g_interface_name, this, msg_type, DIRECTION_IN);
179 /* notify the retrieve of call */
180 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
181 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL;
182 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
183 message_put(message);
185 /* acknowledge retr */
186 gsm_trace_header(p_g_interface_name, this, MNCC_RETRIEVE_CNF, DIRECTION_OUT);
188 resp = create_mncc(MNCC_RETRIEVE_CNF, p_g_callref);
189 send_and_free_mncc(p_g_lcr_gsm, resp->msg_type, resp);
192 if (!p_g_tch_connected) { /* it should be true */
193 gsm_trace_header(p_g_interface_name, this, MNCC_FRAME_RECV, DIRECTION_OUT);
195 frame = create_mncc(MNCC_FRAME_RECV, p_g_callref);
196 send_and_free_mncc(p_g_lcr_gsm, frame->msg_type, frame);
197 p_g_tch_connected = 1;
202 * handles all indications
204 /* SETUP INDICATION */
205 void Pgsm_bs::setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc)
207 class Endpoint *epoint;
208 struct lcr_msg *message;
209 struct gsm_mncc *mode, *proceeding, *frame;
211 /* process given callref */
212 gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_IN);
213 add_trace("callref", "new", "0x%x", callref);
215 /* release in case the ID is already in use */
216 add_trace("error", NULL, "callref already in use");
218 mncc = create_mncc(MNCC_REJ_REQ, callref);
219 gsm_trace_header(p_g_interface_name, this, MNCC_REJ_REQ, DIRECTION_OUT);
220 mncc->fields |= MNCC_F_CAUSE;
221 mncc->cause.coding = 3;
222 mncc->cause.location = 1;
223 mncc->cause.value = 47;
224 add_trace("cause", "coding", "%d", mncc->cause.coding);
225 add_trace("cause", "location", "%d", mncc->cause.location);
226 add_trace("cause", "value", "%d", mncc->cause.value);
227 add_trace("reason", NULL, "callref already in use");
229 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
230 new_state(PORT_STATE_RELEASE);
231 trigger_work(&p_g_delete);
234 p_g_callref = callref;
239 p_callerinfo.present = INFO_PRESENT_RESTRICTED;
241 p_callerinfo.present = INFO_PRESENT_ALLOWED;
242 if (mncc->calling.number[0])
243 SCPY(p_callerinfo.id, mncc->calling.number);
245 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
246 SCPY(p_callerinfo.imsi, mncc->imsi);
247 p_callerinfo.screen = INFO_SCREEN_NETWORK;
248 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
249 SCPY(p_callerinfo.interface, p_g_interface_name);
251 /* dialing information */
252 SCAT(p_dialinginfo.id, mncc->called.number);
253 switch (mncc->called.type) {
255 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
258 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
261 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
264 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
267 if (mncc->emergency) {
268 SCPY(p_dialinginfo.id, "emergency");
270 p_dialinginfo.sending_complete = 1;
272 /* bearer capability */
274 p_capainfo.bearer_capa = INFO_BC_SPEECH;
275 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
276 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
277 p_capainfo.source_mode = B_MODE_TRANSPARENT;
278 p_g_mode = p_capainfo.source_mode;
282 /* what infos did we got ... */
283 gsm_trace_header(p_g_interface_name, this, msg_type, DIRECTION_IN);
284 if (p_callerinfo.id[0])
285 add_trace("calling", "number", "%s", p_callerinfo.id);
287 SPRINT(p_callerinfo.id, "imsi-%s", p_callerinfo.imsi);
288 add_trace("calling", "imsi", "%s", p_callerinfo.imsi);
289 add_trace("dialing", "number", "%s", p_dialinginfo.id);
292 /* create endpoint */
294 FATAL("Incoming call but already got an endpoint.\n");
295 if (!(epoint = new Endpoint(p_serial, 0)))
296 FATAL("No memory for Endpoint instance\n");
297 if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 0))) //incoming
298 FATAL("No memory for Endpoint Application instance\n");
299 epointlist_new(epoint->ep_serial);
301 /* modify lchan to GSM codec V1 */
302 gsm_trace_header(p_g_interface_name, this, MNCC_LCHAN_MODIFY, DIRECTION_OUT);
303 mode = create_mncc(MNCC_LCHAN_MODIFY, p_g_callref);
304 mode->lchan_mode = 0x01; /* GSM V1 */
305 mode->lchan_type = 0x02;
306 add_trace("mode", NULL, "0x%02x", mode->lchan_mode);
308 send_and_free_mncc(p_g_lcr_gsm, mode->msg_type, mode);
310 /* send call proceeding */
311 gsm_trace_header(p_g_interface_name, this, MNCC_CALL_PROC_REQ, DIRECTION_OUT);
312 proceeding = create_mncc(MNCC_CALL_PROC_REQ, p_g_callref);
314 proceeding->fields |= MNCC_F_PROGRESS;
315 proceeding->progress.coding = 3; /* GSM */
316 proceeding->progress.location = 1;
317 proceeding->progress.descr = 8;
318 add_trace("progress", "coding", "%d", proceeding->progress.coding);
319 add_trace("progress", "location", "%d", proceeding->progress.location);
320 add_trace("progress", "descr", "%d", proceeding->progress.descr);
323 send_and_free_mncc(p_g_lcr_gsm, proceeding->msg_type, proceeding);
325 new_state(PORT_STATE_IN_PROCEEDING);
327 if (p_g_tones && !p_g_tch_connected) { /* only if ... */
328 gsm_trace_header(p_g_interface_name, this, MNCC_FRAME_RECV, DIRECTION_OUT);
330 frame = create_mncc(MNCC_FRAME_RECV, p_g_callref);
331 send_and_free_mncc(p_g_lcr_gsm, frame->msg_type, frame);
332 p_g_tch_connected = 1;
335 /* send setup message to endpoit */
336 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
337 message->param.setup.port_type = p_type;
338 // message->param.setup.dtmf = 0;
339 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
340 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
341 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
342 SCPY((char *)message->param.setup.useruser.data, (char *)mncc->useruser.info);
343 message->param.setup.useruser.len = strlen(mncc->useruser.info);
344 message->param.setup.useruser.protocol = mncc->useruser.proto;
345 message->param.setup.rtpinfo.payload_type = 3; /* FIXME: receive payload type from peer */
347 if (p_g_rtp_bridge) {
348 struct gsm_mncc_rtp *rtp;
350 PDEBUG(DEBUG_GSM, "Request RTP peer info, before forwarding setup\n");
351 p_g_setup_pending = message;
352 rtp = (struct gsm_mncc_rtp *) create_mncc(MNCC_RTP_CREATE, p_g_callref);
353 send_and_free_mncc(p_g_lcr_gsm, rtp->msg_type, rtp);
355 message_put(message);
360 * BSC sends message to port
362 int message_bsc(struct lcr_gsm *lcr_gsm, int msg_type, void *arg)
364 struct interface *interface = lcr_gsm->interface;
365 struct gsm_mncc *mncc = (struct gsm_mncc *)arg;
366 unsigned int callref = mncc->callref;
368 class Pgsm_bs *pgsm_bs = NULL;
370 // struct mISDNport *mISDNport;
372 /* Special messages */
377 callref = mncc->callref;
380 if ((port->p_type & PORT_CLASS_GSM_MASK) == PORT_CLASS_GSM_BS) {
381 pgsm_bs = (class Pgsm_bs *)port;
382 if (pgsm_bs->p_g_callref == callref) {
389 if (msg_type == GSM_TCHF_FRAME) {
391 /* inject DTMF, if enabled */
392 if (pgsm_bs->p_g_dtmf) {
393 unsigned char data[160];
396 for (i = 0; i < 160; i++) {
397 data[i] = pgsm_bs->p_g_dtmf[pgsm_bs->p_g_dtmf_index++];
398 if (pgsm_bs->p_g_dtmf_index == 8000)
399 pgsm_bs->p_g_dtmf_index = 0;
402 pgsm_bs->bridge_tx(data, 160);
404 pgsm_bs->frame_receive(arg);
405 /* if we do not bridge we need to inject audio, if available */
406 if (!pgsm_bs->p_bridge) {
407 unsigned char data[160];
410 i = pgsm_bs->read_audio(data, 160);
412 pgsm_bs->bridge_rx(data, i);
419 if (msg_type != MNCC_SETUP_IND)
423 mISDNport = mISDNport_first;
425 if (mISDNport->gsm_bs)
427 mISDNport = mISDNport->next;
430 struct gsm_mncc *rej;
432 rej = create_mncc(MNCC_REJ_REQ, callref);
433 rej->fields |= MNCC_F_CAUSE;
434 rej->cause.coding = 3;
435 rej->cause.location = 1;
436 rej->cause.value = 27;
437 gsm_trace_header(NULL, NULL, MNCC_REJ_REQ, DIRECTION_OUT);
438 add_trace("cause", "coding", "%d", rej->cause.coding);
439 add_trace("cause", "location", "%d", rej->cause.location);
440 add_trace("cause", "value", "%d", rej->cause.value);
442 send_and_free_mncc(lcr_gsm, rej->msg_type, rej);
446 /* creating port object, transparent until setup with hdlc */
447 SPRINT(name, "%s-%d-in", interface->name, 0);
448 if (!(pgsm_bs = new Pgsm_bs(PORT_TYPE_GSM_BS_IN, name, NULL, interface)))
449 FATAL("Cannot create Port instance.\n");
454 pgsm_bs->setup_ind(msg_type, callref, mncc);
457 case MNCC_RTP_CREATE:
458 pgsm_bs->rtp_create_ind(msg_type, callref, mncc);
461 case MNCC_RTP_CONNECT:
462 pgsm_bs->rtp_connect_ind(msg_type, callref, mncc);
465 case MNCC_START_DTMF_IND:
466 pgsm_bs->start_dtmf_ind(msg_type, callref, mncc);
469 case MNCC_STOP_DTMF_IND:
470 pgsm_bs->stop_dtmf_ind(msg_type, callref, mncc);
473 case MNCC_CALL_CONF_IND:
474 pgsm_bs->call_conf_ind(msg_type, callref, mncc);
478 pgsm_bs->alert_ind(msg_type, callref, mncc);
482 pgsm_bs->setup_cnf(msg_type, callref, mncc);
485 case MNCC_SETUP_COMPL_IND:
486 pgsm_bs->setup_compl_ind(msg_type, callref, mncc);
490 pgsm_bs->disc_ind(msg_type, callref, mncc);
496 pgsm_bs->rel_ind(msg_type, callref, mncc);
499 case MNCC_NOTIFY_IND:
500 pgsm_bs->notify_ind(msg_type, callref, mncc);
504 pgsm_bs->hold_ind(msg_type, callref, mncc);
507 case MNCC_RETRIEVE_IND:
508 pgsm_bs->retr_ind(msg_type, callref, mncc);
512 PDEBUG(DEBUG_GSM, "Pgsm_bs(%s) gsm port with (caller id %s) received unhandled nessage: 0x%x\n", pgsm_bs->p_name, pgsm_bs->p_callerinfo.id, msg_type);
518 void Pgsm_bs::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
520 struct lcr_msg *message;
521 struct epoint_list *epointlist;
522 struct gsm_mncc *mncc;
524 /* copy setup infos to port */
525 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
526 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
527 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
528 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
530 /* no GSM MNCC connection */
531 if (p_g_lcr_gsm->mncc_lfd.fd < 0) {
532 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
533 add_trace("failure", NULL, "No MNCC connection.");
535 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
536 message->param.disconnectinfo.cause = 41; // temp. failure.
537 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
538 message_put(message);
539 new_state(PORT_STATE_RELEASE);
540 trigger_work(&p_g_delete);
545 if (!p_dialinginfo.id[0]) {
546 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
547 add_trace("failure", NULL, "No dialed subscriber given.");
549 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
550 message->param.disconnectinfo.cause = 28;
551 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
552 message_put(message);
553 new_state(PORT_STATE_RELEASE);
554 trigger_work(&p_g_delete);
558 // SCPY(&p_m_tones_dir, param->setup.ext.tones_dir);
559 /* screen outgoing caller id */
560 do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_g_interface_name);
562 /* attach only if not already */
563 epointlist = p_epointlist;
565 if (epointlist->epoint_id == epoint_id)
567 epointlist = epointlist->next;
570 epointlist_new(epoint_id);
573 gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_OUT);
574 p_g_callref = new_callref++;
575 add_trace("callref", "new", "0x%x", p_g_callref);
578 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
579 mncc = create_mncc(MNCC_SETUP_REQ, p_g_callref);
580 /* caller information */
581 mncc->fields |= MNCC_F_CALLING;
582 mncc->calling.plan = 1;
583 switch (p_callerinfo.ntype) {
584 case INFO_NTYPE_UNKNOWN:
585 mncc->calling.type = 0x0;
587 case INFO_NTYPE_INTERNATIONAL:
588 mncc->calling.type = 0x1;
590 case INFO_NTYPE_NATIONAL:
591 mncc->calling.type = 0x2;
593 case INFO_NTYPE_SUBSCRIBER:
594 mncc->calling.type = 0x4;
596 default: /* INFO_NTYPE_NOTPRESENT */
597 mncc->fields &= ~MNCC_F_CALLING;
600 switch (p_callerinfo.screen) {
601 case INFO_SCREEN_USER:
602 mncc->calling.screen = 0;
604 default: /* INFO_SCREEN_NETWORK */
605 mncc->calling.screen = 3;
608 switch (p_callerinfo.present) {
609 case INFO_PRESENT_ALLOWED:
610 mncc->calling.present = 0;
612 case INFO_PRESENT_RESTRICTED:
613 mncc->calling.present = 1;
615 default: /* INFO_PRESENT_NOTAVAIL */
616 mncc->calling.present = 2;
619 if (mncc->fields & MNCC_F_CALLING) {
620 SCPY(mncc->calling.number, p_callerinfo.id);
621 add_trace("calling", "type", "%d", mncc->calling.type);
622 add_trace("calling", "plan", "%d", mncc->calling.plan);
623 add_trace("calling", "present", "%d", mncc->calling.present);
624 add_trace("calling", "screen", "%d", mncc->calling.screen);
625 add_trace("calling", "number", "%s", mncc->calling.number);
627 /* dialing information */
628 mncc->fields |= MNCC_F_CALLED;
629 if (!strncmp(p_dialinginfo.id, "imsi-", 5)) {
630 SCPY(mncc->imsi, p_dialinginfo.id+5);
631 add_trace("dialing", "imsi", "%s", mncc->imsi);
633 SCPY(mncc->called.number, p_dialinginfo.id);
634 add_trace("dialing", "number", "%s", mncc->called.number);
637 /* sending user-user */
639 /* redirecting number */
640 mncc->fields |= MNCC_F_REDIRECTING;
641 mncc->redirecting.plan = 1;
642 switch (p_redirinfo.ntype) {
643 case INFO_NTYPE_UNKNOWN:
644 mncc->redirecting.type = 0x0;
646 case INFO_NTYPE_INTERNATIONAL:
647 mncc->redirecting.type = 0x1;
649 case INFO_NTYPE_NATIONAL:
650 mncc->redirecting.type = 0x2;
652 case INFO_NTYPE_SUBSCRIBER:
653 mncc->redirecting.type = 0x4;
655 default: /* INFO_NTYPE_NOTPRESENT */
656 mncc->fields &= ~MNCC_F_REDIRECTING;
659 switch (p_redirinfo.screen) {
660 case INFO_SCREEN_USER:
661 mncc->redirecting.screen = 0;
663 default: /* INFO_SCREE_NETWORK */
664 mncc->redirecting.screen = 3;
667 switch (p_redirinfo.present) {
668 case INFO_PRESENT_ALLOWED:
669 mncc->redirecting.present = 0;
671 case INFO_PRESENT_RESTRICTED:
672 mncc->redirecting.present = 1;
674 default: /* INFO_PRESENT_NOTAVAIL */
675 mncc->redirecting.present = 2;
678 /* sending redirecting number only in ntmode */
679 if (mncc->fields & MNCC_F_REDIRECTING) {
680 SCPY(mncc->redirecting.number, p_redirinfo.id);
681 add_trace("redir", "type", "%d", mncc->redirecting.type);
682 add_trace("redir", "plan", "%d", mncc->redirecting.plan);
683 add_trace("redir", "present", "%d", mncc->redirecting.present);
684 add_trace("redir", "screen", "%d", mncc->redirecting.screen);
685 add_trace("redir", "number", "%s", mncc->redirecting.number);
687 /* bearer capability */
691 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
693 new_state(PORT_STATE_OUT_SETUP);
695 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
696 message_put(message);
698 new_state(PORT_STATE_OUT_PROCEEDING);
701 if (param->setup.rtpinfo.port) {
703 p_g_rtp_ip_remote = param->setup.rtpinfo.ip;
704 p_g_rtp_port_remote = param->setup.rtpinfo.port;
710 * endpoint sends messages to the port
712 int Pgsm_bs::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
714 if (Pgsm::message_epoint(epoint_id, message_id, param))
718 case MESSAGE_SETUP: /* dial-out command received from epoint */
719 if (p_state!=PORT_STATE_IDLE)
721 message_setup(epoint_id, message_id, param);
725 PDEBUG(DEBUG_GSM, "Pgsm_bs(%s) gsm port with (caller id %s) received unhandled nessage: %d\n", p_name, p_callerinfo.id, message_id);
731 int gsm_bs_exit(int rc)
733 /* free gsm instance */
735 if (gsm_bs->mncc_lfd.fd > -1) {
736 close(gsm_bs->mncc_lfd.fd);
737 unregister_fd(&gsm_bs->mncc_lfd);
740 del_timer(&gsm_bs->socket_retry);
749 int gsm_bs_init(struct interface *interface)
751 /* create gsm instance */
752 gsm_bs = (struct lcr_gsm *)MALLOC(sizeof(struct lcr_gsm));
754 gsm_bs->interface = interface;
755 gsm_bs->type = LCR_GSM_TYPE_NETWORK;
756 gsm_bs->sun.sun_family = AF_UNIX;
757 SCPY(gsm_bs->sun.sun_path, "/tmp/bsc_mncc");
759 memset(&gsm_bs->socket_retry, 0, sizeof(gsm_bs->socket_retry));
760 add_timer(&gsm_bs->socket_retry, mncc_socket_retry_cb, gsm_bs, 0);
762 /* do the initial connect */
763 mncc_socket_retry_cb(&gsm_bs->socket_retry, gsm_bs, 0);