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 gsm_mncc *resp;
70 gsm_trace_header(p_g_interface_name, this, msg_type, DIRECTION_IN);
71 add_trace("keypad", NULL, "%c", mncc->keypad);
73 SPRINT(p_dialinginfo.id, "%c", mncc->keypad);
74 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
77 gsm_trace_header(p_g_interface_name, this, MNCC_START_DTMF_RSP, DIRECTION_OUT);
78 add_trace("keypad", NULL, "%c", mncc->keypad);
80 resp = create_mncc(MNCC_START_DTMF_RSP, p_g_callref);
81 resp->fields |= MNCC_F_KEYPAD;
82 resp->keypad = mncc->keypad;
83 send_and_free_mncc(p_g_lcr_gsm, resp->msg_type, resp);
86 class Port *remote = bridge_remote();
89 struct lcr_msg *message;
91 /* send dtmf information, because we bridge RTP directly */
92 message = message_create(0, remote->p_serial, EPOINT_TO_PORT, MESSAGE_DTMF);
93 message->param.dtmf = mncc->keypad;
97 /* generate DTMF tones, since we do audio forwarding inside LCR */
98 switch (mncc->keypad) {
99 case '1': p_g_dtmf = dtmf_samples[0]; break;
100 case '2': p_g_dtmf = dtmf_samples[1]; break;
101 case '3': p_g_dtmf = dtmf_samples[2]; break;
103 case 'A': p_g_dtmf = dtmf_samples[3]; break;
104 case '4': p_g_dtmf = dtmf_samples[4]; break;
105 case '5': p_g_dtmf = dtmf_samples[5]; break;
106 case '6': p_g_dtmf = dtmf_samples[6]; break;
108 case 'B': p_g_dtmf = dtmf_samples[7]; break;
109 case '7': p_g_dtmf = dtmf_samples[8]; break;
110 case '8': p_g_dtmf = dtmf_samples[9]; break;
111 case '9': p_g_dtmf = dtmf_samples[10]; break;
113 case 'C': p_g_dtmf = dtmf_samples[11]; break;
114 case '*': p_g_dtmf = dtmf_samples[12]; break;
115 case '0': p_g_dtmf = dtmf_samples[13]; break;
116 case '#': p_g_dtmf = dtmf_samples[14]; break;
118 case 'D': p_g_dtmf = dtmf_samples[15]; break;
123 void Pgsm_bs::stop_dtmf_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc)
125 struct gsm_mncc *resp;
127 gsm_trace_header(p_g_interface_name, this, msg_type, DIRECTION_IN);
128 add_trace("keypad", NULL, "%c", mncc->keypad);
132 gsm_trace_header(p_g_interface_name, this, MNCC_STOP_DTMF_RSP, DIRECTION_OUT);
133 add_trace("keypad", NULL, "%c", mncc->keypad);
135 resp = create_mncc(MNCC_STOP_DTMF_RSP, p_g_callref);
136 resp->keypad = mncc->keypad;
137 send_and_free_mncc(p_g_lcr_gsm, resp->msg_type, resp);
143 /* HOLD INDICATION */
144 void Pgsm_bs::hold_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc)
146 struct lcr_msg *message;
147 struct gsm_mncc *resp, *frame;
149 gsm_trace_header(p_g_interface_name, this, msg_type, DIRECTION_IN);
152 /* notify the hold of call */
153 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
154 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_HOLD;
155 message->param.notifyinfo.local = 1; /* call is held by supplementary service */
156 message_put(message);
158 /* acknowledge hold */
159 gsm_trace_header(p_g_interface_name, this, MNCC_HOLD_CNF, DIRECTION_OUT);
161 resp = create_mncc(MNCC_HOLD_CNF, p_g_callref);
162 send_and_free_mncc(p_g_lcr_gsm, resp->msg_type, resp);
165 if (p_g_tch_connected) { /* it should be true */
166 gsm_trace_header(p_g_interface_name, this, MNCC_FRAME_DROP, DIRECTION_OUT);
168 frame = create_mncc(MNCC_FRAME_DROP, p_g_callref);
169 send_and_free_mncc(p_g_lcr_gsm, frame->msg_type, frame);
170 p_g_tch_connected = 0;
175 /* RETRIEVE INDICATION */
176 void Pgsm_bs::retr_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc)
178 struct lcr_msg *message;
179 struct gsm_mncc *resp, *frame;
181 gsm_trace_header(p_g_interface_name, this, msg_type, DIRECTION_IN);
184 /* notify the retrieve of call */
185 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY);
186 message->param.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL;
187 message->param.notifyinfo.local = 1; /* call is retrieved by supplementary service */
188 message_put(message);
190 /* acknowledge retr */
191 gsm_trace_header(p_g_interface_name, this, MNCC_RETRIEVE_CNF, DIRECTION_OUT);
193 resp = create_mncc(MNCC_RETRIEVE_CNF, p_g_callref);
194 send_and_free_mncc(p_g_lcr_gsm, resp->msg_type, resp);
197 if (!p_g_tch_connected) { /* it should be true */
198 gsm_trace_header(p_g_interface_name, this, MNCC_FRAME_RECV, DIRECTION_OUT);
200 frame = create_mncc(MNCC_FRAME_RECV, p_g_callref);
201 send_and_free_mncc(p_g_lcr_gsm, frame->msg_type, frame);
202 p_g_tch_connected = 1;
207 * handles all indications
209 /* SETUP INDICATION */
210 void Pgsm_bs::setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc)
212 class Endpoint *epoint;
213 struct lcr_msg *message;
214 struct gsm_mncc *mode, *proceeding, *frame;
215 struct interface *interface;
217 interface = getinterfacebyname(p_g_interface_name);
219 PERROR("Cannot find interface %s.\n", p_g_interface_name);
223 /* process given callref */
224 gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_IN);
225 add_trace("callref", "new", "0x%x", callref);
227 /* release in case the ID is already in use */
228 add_trace("error", NULL, "callref already in use");
230 mncc = create_mncc(MNCC_REJ_REQ, callref);
231 gsm_trace_header(p_g_interface_name, this, MNCC_REJ_REQ, DIRECTION_OUT);
232 mncc->fields |= MNCC_F_CAUSE;
233 mncc->cause.coding = 3;
234 mncc->cause.location = 1;
235 mncc->cause.value = 47;
236 add_trace("cause", "coding", "%d", mncc->cause.coding);
237 add_trace("cause", "location", "%d", mncc->cause.location);
238 add_trace("cause", "value", "%d", mncc->cause.value);
239 add_trace("reason", NULL, "callref already in use");
241 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
242 new_state(PORT_STATE_RELEASE);
243 trigger_work(&p_g_delete);
246 p_g_callref = callref;
251 p_callerinfo.present = INFO_PRESENT_RESTRICTED;
253 p_callerinfo.present = INFO_PRESENT_ALLOWED;
254 if (mncc->calling.number[0])
255 SCPY(p_callerinfo.id, mncc->calling.number);
257 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
258 SCPY(p_callerinfo.imsi, mncc->imsi);
259 p_callerinfo.screen = INFO_SCREEN_NETWORK;
260 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
261 SCPY(p_callerinfo.interface, p_g_interface_name);
263 /* dialing information */
264 SCAT(p_dialinginfo.id, mncc->called.number);
265 switch (mncc->called.type) {
267 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
270 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
273 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
276 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
279 if (mncc->emergency) {
280 SCPY(p_dialinginfo.id, "emergency");
282 p_dialinginfo.sending_complete = 1;
284 /* bearer capability */
286 p_capainfo.bearer_capa = INFO_BC_SPEECH;
287 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
288 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
289 p_capainfo.source_mode = B_MODE_TRANSPARENT;
290 p_g_mode = p_capainfo.source_mode;
294 /* what infos did we got ... */
295 gsm_trace_header(p_g_interface_name, this, msg_type, DIRECTION_IN);
296 if (p_callerinfo.id[0])
297 add_trace("calling", "number", "%s", p_callerinfo.id);
299 SPRINT(p_callerinfo.id, "imsi-%s", p_callerinfo.imsi);
300 add_trace("calling", "imsi", "%s", p_callerinfo.imsi);
301 add_trace("dialing", "number", "%s", p_dialinginfo.id);
304 /* create endpoint */
306 FATAL("Incoming call but already got an endpoint.\n");
307 if (!(epoint = new Endpoint(p_serial, 0)))
308 FATAL("No memory for Endpoint instance\n");
309 epoint->ep_app = new_endpointapp(epoint, 0, interface->app); //incoming
310 epointlist_new(epoint->ep_serial);
312 /* modify lchan to GSM codec V1 */
313 gsm_trace_header(p_g_interface_name, this, MNCC_LCHAN_MODIFY, DIRECTION_OUT);
314 mode = create_mncc(MNCC_LCHAN_MODIFY, p_g_callref);
315 mode->lchan_mode = 0x01; /* GSM V1 */
316 mode->lchan_type = 0x02;
317 add_trace("mode", NULL, "0x%02x", mode->lchan_mode);
319 send_and_free_mncc(p_g_lcr_gsm, mode->msg_type, mode);
321 /* send call proceeding */
322 gsm_trace_header(p_g_interface_name, this, MNCC_CALL_PROC_REQ, DIRECTION_OUT);
323 proceeding = create_mncc(MNCC_CALL_PROC_REQ, p_g_callref);
325 proceeding->fields |= MNCC_F_PROGRESS;
326 proceeding->progress.coding = 3; /* GSM */
327 proceeding->progress.location = 1;
328 proceeding->progress.descr = 8;
329 add_trace("progress", "coding", "%d", proceeding->progress.coding);
330 add_trace("progress", "location", "%d", proceeding->progress.location);
331 add_trace("progress", "descr", "%d", proceeding->progress.descr);
334 send_and_free_mncc(p_g_lcr_gsm, proceeding->msg_type, proceeding);
336 new_state(PORT_STATE_IN_PROCEEDING);
338 if (p_g_tones && !p_g_tch_connected) { /* only if ... */
339 gsm_trace_header(p_g_interface_name, this, MNCC_FRAME_RECV, DIRECTION_OUT);
341 frame = create_mncc(MNCC_FRAME_RECV, p_g_callref);
342 send_and_free_mncc(p_g_lcr_gsm, frame->msg_type, frame);
343 p_g_tch_connected = 1;
346 /* send setup message to endpoit */
347 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
348 message->param.setup.port_type = p_type;
349 // message->param.setup.dtmf = 0;
350 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
351 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
352 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
353 SCPY((char *)message->param.setup.useruser.data, (char *)mncc->useruser.info);
354 message->param.setup.useruser.len = strlen(mncc->useruser.info);
355 message->param.setup.useruser.protocol = mncc->useruser.proto;
356 message->param.setup.rtpinfo.payload_type = 3; /* FIXME: receive payload type from peer */
358 if (p_g_rtp_bridge) {
359 struct gsm_mncc_rtp *rtp;
361 PDEBUG(DEBUG_GSM, "Request RTP peer info, before forwarding setup\n");
362 p_g_setup_pending = message;
363 rtp = (struct gsm_mncc_rtp *) create_mncc(MNCC_RTP_CREATE, p_g_callref);
364 send_and_free_mncc(p_g_lcr_gsm, rtp->msg_type, rtp);
366 message_put(message);
371 * BSC sends message to port
373 int message_bsc(struct lcr_gsm *lcr_gsm, int msg_type, void *arg)
375 struct gsm_mncc *mncc = (struct gsm_mncc *)arg;
376 unsigned int callref = mncc->callref;
378 class Pgsm_bs *pgsm_bs = NULL;
380 // struct mISDNport *mISDNport;
382 /* Special messages */
387 callref = mncc->callref;
390 if ((port->p_type & PORT_CLASS_GSM_MASK) == PORT_CLASS_GSM_BS) {
391 pgsm_bs = (class Pgsm_bs *)port;
392 if (pgsm_bs->p_g_callref == callref) {
399 if (msg_type == GSM_TCHF_FRAME
400 || msg_type == GSM_TCHF_BAD_FRAME) {
402 /* inject DTMF, if enabled */
403 if (pgsm_bs->p_g_dtmf) {
404 unsigned char data[160];
407 for (i = 0; i < 160; i++) {
408 data[i] = pgsm_bs->p_g_dtmf[pgsm_bs->p_g_dtmf_index++];
409 if (pgsm_bs->p_g_dtmf_index == 8000)
410 pgsm_bs->p_g_dtmf_index = 0;
413 pgsm_bs->bridge_tx(data, 160);
415 pgsm_bs->frame_receive(arg);
416 /* if we do not bridge we need to inject audio, if available */
417 if (!pgsm_bs->p_bridge || pgsm_bs->p_tone_name[0]) {
418 unsigned char data[160];
421 i = pgsm_bs->read_audio(data, 160);
423 pgsm_bs->audio_send(data, i);
430 struct interface *interface;
432 if (msg_type != MNCC_SETUP_IND)
435 interface = getinterfacebyname(lcr_gsm->interface_name);
437 struct gsm_mncc *rej;
439 rej = create_mncc(MNCC_REJ_REQ, callref);
440 rej->fields |= MNCC_F_CAUSE;
441 rej->cause.coding = 3;
442 rej->cause.location = 1;
443 rej->cause.value = 27;
444 gsm_trace_header(NULL, NULL, MNCC_REJ_REQ, DIRECTION_OUT);
445 add_trace("cause", "coding", "%d", rej->cause.coding);
446 add_trace("cause", "location", "%d", rej->cause.location);
447 add_trace("cause", "value", "%d", rej->cause.value);
448 add_trace("reason", NULL, "interface %s not found", lcr_gsm->interface_name);
450 send_and_free_mncc(lcr_gsm, rej->msg_type, rej);
453 /* creating port object, transparent until setup with hdlc */
454 SPRINT(name, "%s-%d-in", interface->name, 0);
455 if (!(pgsm_bs = new Pgsm_bs(PORT_TYPE_GSM_BS_IN, name, NULL, interface)))
456 FATAL("Cannot create Port instance.\n");
461 pgsm_bs->setup_ind(msg_type, callref, mncc);
464 case MNCC_RTP_CREATE:
465 pgsm_bs->rtp_create_ind(msg_type, callref, mncc);
468 case MNCC_RTP_CONNECT:
469 pgsm_bs->rtp_connect_ind(msg_type, callref, mncc);
472 case MNCC_START_DTMF_IND:
473 pgsm_bs->start_dtmf_ind(msg_type, callref, mncc);
476 case MNCC_STOP_DTMF_IND:
477 pgsm_bs->stop_dtmf_ind(msg_type, callref, mncc);
480 case MNCC_CALL_CONF_IND:
481 pgsm_bs->call_conf_ind(msg_type, callref, mncc);
485 pgsm_bs->alert_ind(msg_type, callref, mncc);
489 pgsm_bs->setup_cnf(msg_type, callref, mncc);
492 case MNCC_SETUP_COMPL_IND:
493 pgsm_bs->setup_compl_ind(msg_type, callref, mncc);
497 pgsm_bs->disc_ind(msg_type, callref, mncc);
503 pgsm_bs->rel_ind(msg_type, callref, mncc);
506 case MNCC_NOTIFY_IND:
507 pgsm_bs->notify_ind(msg_type, callref, mncc);
511 pgsm_bs->hold_ind(msg_type, callref, mncc);
514 case MNCC_RETRIEVE_IND:
515 pgsm_bs->retr_ind(msg_type, callref, mncc);
519 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);
525 void Pgsm_bs::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
527 struct lcr_msg *message;
528 struct epoint_list *epointlist;
529 struct gsm_mncc *mncc;
531 /* copy setup infos to port */
532 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
533 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
534 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
535 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
537 /* no GSM MNCC connection */
538 if (p_g_lcr_gsm->mncc_lfd.fd < 0) {
539 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
540 add_trace("failure", NULL, "No MNCC connection.");
542 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
543 message->param.disconnectinfo.cause = 41; // temp. failure.
544 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
545 message_put(message);
546 new_state(PORT_STATE_RELEASE);
547 trigger_work(&p_g_delete);
552 if (!p_dialinginfo.id[0]) {
553 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
554 add_trace("failure", NULL, "No dialed subscriber given.");
556 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
557 message->param.disconnectinfo.cause = 28;
558 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
559 message_put(message);
560 new_state(PORT_STATE_RELEASE);
561 trigger_work(&p_g_delete);
565 // SCPY(&p_m_tones_dir, param->setup.ext.tones_dir);
566 /* screen outgoing caller id */
567 do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_g_interface_name);
569 /* attach only if not already */
570 epointlist = p_epointlist;
572 if (epointlist->epoint_id == epoint_id)
574 epointlist = epointlist->next;
577 epointlist_new(epoint_id);
580 gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_OUT);
581 p_g_callref = new_callref++;
582 add_trace("callref", "new", "0x%x", p_g_callref);
585 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
586 mncc = create_mncc(MNCC_SETUP_REQ, p_g_callref);
587 /* caller information */
588 mncc->fields |= MNCC_F_CALLING;
589 mncc->calling.plan = 1;
590 switch (p_callerinfo.ntype) {
591 case INFO_NTYPE_UNKNOWN:
592 mncc->calling.type = 0x0;
594 case INFO_NTYPE_INTERNATIONAL:
595 mncc->calling.type = 0x1;
597 case INFO_NTYPE_NATIONAL:
598 mncc->calling.type = 0x2;
600 case INFO_NTYPE_SUBSCRIBER:
601 mncc->calling.type = 0x4;
603 default: /* INFO_NTYPE_NOTPRESENT */
604 mncc->fields &= ~MNCC_F_CALLING;
607 switch (p_callerinfo.screen) {
608 case INFO_SCREEN_USER:
609 mncc->calling.screen = 0;
611 default: /* INFO_SCREEN_NETWORK */
612 mncc->calling.screen = 3;
615 switch (p_callerinfo.present) {
616 case INFO_PRESENT_ALLOWED:
617 mncc->calling.present = 0;
619 case INFO_PRESENT_RESTRICTED:
620 mncc->calling.present = 1;
622 default: /* INFO_PRESENT_NOTAVAIL */
623 mncc->calling.present = 2;
626 if (mncc->fields & MNCC_F_CALLING) {
627 SCPY(mncc->calling.number, p_callerinfo.id);
628 add_trace("calling", "type", "%d", mncc->calling.type);
629 add_trace("calling", "plan", "%d", mncc->calling.plan);
630 add_trace("calling", "present", "%d", mncc->calling.present);
631 add_trace("calling", "screen", "%d", mncc->calling.screen);
632 add_trace("calling", "number", "%s", mncc->calling.number);
634 /* dialing information */
635 mncc->fields |= MNCC_F_CALLED;
636 if (!strncmp(p_dialinginfo.id, "imsi-", 5)) {
637 SCPY(mncc->imsi, p_dialinginfo.id+5);
638 add_trace("dialing", "imsi", "%s", mncc->imsi);
640 SCPY(mncc->called.number, p_dialinginfo.id);
641 add_trace("dialing", "number", "%s", mncc->called.number);
644 /* sending user-user */
646 /* redirecting number */
647 mncc->fields |= MNCC_F_REDIRECTING;
648 mncc->redirecting.plan = 1;
649 switch (p_redirinfo.ntype) {
650 case INFO_NTYPE_UNKNOWN:
651 mncc->redirecting.type = 0x0;
653 case INFO_NTYPE_INTERNATIONAL:
654 mncc->redirecting.type = 0x1;
656 case INFO_NTYPE_NATIONAL:
657 mncc->redirecting.type = 0x2;
659 case INFO_NTYPE_SUBSCRIBER:
660 mncc->redirecting.type = 0x4;
662 default: /* INFO_NTYPE_NOTPRESENT */
663 mncc->fields &= ~MNCC_F_REDIRECTING;
666 switch (p_redirinfo.screen) {
667 case INFO_SCREEN_USER:
668 mncc->redirecting.screen = 0;
670 default: /* INFO_SCREE_NETWORK */
671 mncc->redirecting.screen = 3;
674 switch (p_redirinfo.present) {
675 case INFO_PRESENT_ALLOWED:
676 mncc->redirecting.present = 0;
678 case INFO_PRESENT_RESTRICTED:
679 mncc->redirecting.present = 1;
681 default: /* INFO_PRESENT_NOTAVAIL */
682 mncc->redirecting.present = 2;
685 /* sending redirecting number only in ntmode */
686 if (mncc->fields & MNCC_F_REDIRECTING) {
687 SCPY(mncc->redirecting.number, p_redirinfo.id);
688 add_trace("redir", "type", "%d", mncc->redirecting.type);
689 add_trace("redir", "plan", "%d", mncc->redirecting.plan);
690 add_trace("redir", "present", "%d", mncc->redirecting.present);
691 add_trace("redir", "screen", "%d", mncc->redirecting.screen);
692 add_trace("redir", "number", "%s", mncc->redirecting.number);
694 /* bearer capability */
698 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
700 new_state(PORT_STATE_OUT_SETUP);
702 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
703 message_put(message);
705 new_state(PORT_STATE_OUT_PROCEEDING);
708 if (param->setup.rtpinfo.port) {
710 p_g_rtp_ip_remote = param->setup.rtpinfo.ip;
711 p_g_rtp_port_remote = param->setup.rtpinfo.port;
717 * endpoint sends messages to the port
719 int Pgsm_bs::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
721 if (Pgsm::message_epoint(epoint_id, message_id, param))
725 case MESSAGE_SETUP: /* dial-out command received from epoint */
726 if (p_state!=PORT_STATE_IDLE)
728 message_setup(epoint_id, message_id, param);
732 PDEBUG(DEBUG_GSM, "Pgsm_bs(%s) gsm port with (caller id %s) received unhandled nessage: %d\n", p_name, p_callerinfo.id, message_id);
738 int gsm_bs_exit(int rc)
740 /* free gsm instance */
742 if (gsm_bs->mncc_lfd.fd > -1) {
743 close(gsm_bs->mncc_lfd.fd);
744 unregister_fd(&gsm_bs->mncc_lfd);
747 del_timer(&gsm_bs->socket_retry);
756 int gsm_bs_init(struct interface *interface)
758 /* create gsm instance */
759 gsm_bs = (struct lcr_gsm *)MALLOC(sizeof(struct lcr_gsm));
761 SCPY(gsm_bs->interface_name, interface->name);
762 gsm_bs->type = LCR_GSM_TYPE_NETWORK;
763 gsm_bs->sun.sun_family = AF_UNIX;
764 SCPY(gsm_bs->sun.sun_path, "/tmp/bsc_mncc");
766 memset(&gsm_bs->socket_retry, 0, sizeof(gsm_bs->socket_retry));
767 add_timer(&gsm_bs->socket_retry, mncc_socket_retry_cb, gsm_bs, 0);
769 /* do the initial connect */
770 mncc_socket_retry_cb(&gsm_bs->socket_retry, gsm_bs, 0);