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;
216 /* process given callref */
217 gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_IN);
218 add_trace("callref", "new", "0x%x", callref);
220 /* release in case the ID is already in use */
221 add_trace("error", NULL, "callref already in use");
223 mncc = create_mncc(MNCC_REJ_REQ, callref);
224 gsm_trace_header(p_g_interface_name, this, MNCC_REJ_REQ, DIRECTION_OUT);
225 mncc->fields |= MNCC_F_CAUSE;
226 mncc->cause.coding = 3;
227 mncc->cause.location = 1;
228 mncc->cause.value = 47;
229 add_trace("cause", "coding", "%d", mncc->cause.coding);
230 add_trace("cause", "location", "%d", mncc->cause.location);
231 add_trace("cause", "value", "%d", mncc->cause.value);
232 add_trace("reason", NULL, "callref already in use");
234 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
235 new_state(PORT_STATE_RELEASE);
236 trigger_work(&p_g_delete);
239 p_g_callref = callref;
244 p_callerinfo.present = INFO_PRESENT_RESTRICTED;
246 p_callerinfo.present = INFO_PRESENT_ALLOWED;
247 if (mncc->calling.number[0])
248 SCPY(p_callerinfo.id, mncc->calling.number);
250 p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
251 SCPY(p_callerinfo.imsi, mncc->imsi);
252 p_callerinfo.screen = INFO_SCREEN_NETWORK;
253 p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
254 SCPY(p_callerinfo.interface, p_g_interface_name);
256 /* dialing information */
257 SCAT(p_dialinginfo.id, mncc->called.number);
258 switch (mncc->called.type) {
260 p_dialinginfo.ntype = INFO_NTYPE_INTERNATIONAL;
263 p_dialinginfo.ntype = INFO_NTYPE_NATIONAL;
266 p_dialinginfo.ntype = INFO_NTYPE_SUBSCRIBER;
269 p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
272 if (mncc->emergency) {
273 SCPY(p_dialinginfo.id, "emergency");
275 p_dialinginfo.sending_complete = 1;
277 /* bearer capability */
279 p_capainfo.bearer_capa = INFO_BC_SPEECH;
280 p_capainfo.bearer_info1 = (options.law=='a')?3:2;
281 p_capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
282 p_capainfo.source_mode = B_MODE_TRANSPARENT;
283 p_g_mode = p_capainfo.source_mode;
287 /* what infos did we got ... */
288 gsm_trace_header(p_g_interface_name, this, msg_type, DIRECTION_IN);
289 if (p_callerinfo.id[0])
290 add_trace("calling", "number", "%s", p_callerinfo.id);
292 SPRINT(p_callerinfo.id, "imsi-%s", p_callerinfo.imsi);
293 add_trace("calling", "imsi", "%s", p_callerinfo.imsi);
294 add_trace("dialing", "number", "%s", p_dialinginfo.id);
297 /* create endpoint */
299 FATAL("Incoming call but already got an endpoint.\n");
300 if (!(epoint = new Endpoint(p_serial, 0)))
301 FATAL("No memory for Endpoint instance\n");
302 if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 0))) //incoming
303 FATAL("No memory for Endpoint Application instance\n");
304 epointlist_new(epoint->ep_serial);
306 /* modify lchan to GSM codec V1 */
307 gsm_trace_header(p_g_interface_name, this, MNCC_LCHAN_MODIFY, DIRECTION_OUT);
308 mode = create_mncc(MNCC_LCHAN_MODIFY, p_g_callref);
309 mode->lchan_mode = 0x01; /* GSM V1 */
310 mode->lchan_type = 0x02;
311 add_trace("mode", NULL, "0x%02x", mode->lchan_mode);
313 send_and_free_mncc(p_g_lcr_gsm, mode->msg_type, mode);
315 /* send call proceeding */
316 gsm_trace_header(p_g_interface_name, this, MNCC_CALL_PROC_REQ, DIRECTION_OUT);
317 proceeding = create_mncc(MNCC_CALL_PROC_REQ, p_g_callref);
319 proceeding->fields |= MNCC_F_PROGRESS;
320 proceeding->progress.coding = 3; /* GSM */
321 proceeding->progress.location = 1;
322 proceeding->progress.descr = 8;
323 add_trace("progress", "coding", "%d", proceeding->progress.coding);
324 add_trace("progress", "location", "%d", proceeding->progress.location);
325 add_trace("progress", "descr", "%d", proceeding->progress.descr);
328 send_and_free_mncc(p_g_lcr_gsm, proceeding->msg_type, proceeding);
330 new_state(PORT_STATE_IN_PROCEEDING);
332 if (p_g_tones && !p_g_tch_connected) { /* only if ... */
333 gsm_trace_header(p_g_interface_name, this, MNCC_FRAME_RECV, DIRECTION_OUT);
335 frame = create_mncc(MNCC_FRAME_RECV, p_g_callref);
336 send_and_free_mncc(p_g_lcr_gsm, frame->msg_type, frame);
337 p_g_tch_connected = 1;
340 /* send setup message to endpoit */
341 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_SETUP);
342 message->param.setup.port_type = p_type;
343 // message->param.setup.dtmf = 0;
344 memcpy(&message->param.setup.dialinginfo, &p_dialinginfo, sizeof(struct dialing_info));
345 memcpy(&message->param.setup.callerinfo, &p_callerinfo, sizeof(struct caller_info));
346 memcpy(&message->param.setup.capainfo, &p_capainfo, sizeof(struct capa_info));
347 SCPY((char *)message->param.setup.useruser.data, (char *)mncc->useruser.info);
348 message->param.setup.useruser.len = strlen(mncc->useruser.info);
349 message->param.setup.useruser.protocol = mncc->useruser.proto;
350 message->param.setup.rtpinfo.payload_type = 3; /* FIXME: receive payload type from peer */
352 if (p_g_rtp_bridge) {
353 struct gsm_mncc_rtp *rtp;
355 PDEBUG(DEBUG_GSM, "Request RTP peer info, before forwarding setup\n");
356 p_g_setup_pending = message;
357 rtp = (struct gsm_mncc_rtp *) create_mncc(MNCC_RTP_CREATE, p_g_callref);
358 send_and_free_mncc(p_g_lcr_gsm, rtp->msg_type, rtp);
360 message_put(message);
365 * BSC sends message to port
367 int message_bsc(struct lcr_gsm *lcr_gsm, int msg_type, void *arg)
369 struct interface *interface = lcr_gsm->interface;
370 struct gsm_mncc *mncc = (struct gsm_mncc *)arg;
371 unsigned int callref = mncc->callref;
373 class Pgsm_bs *pgsm_bs = NULL;
375 // struct mISDNport *mISDNport;
377 /* Special messages */
382 callref = mncc->callref;
385 if ((port->p_type & PORT_CLASS_GSM_MASK) == PORT_CLASS_GSM_BS) {
386 pgsm_bs = (class Pgsm_bs *)port;
387 if (pgsm_bs->p_g_callref == callref) {
394 if (msg_type == GSM_TCHF_FRAME) {
396 /* inject DTMF, if enabled */
397 if (pgsm_bs->p_g_dtmf) {
398 unsigned char data[160];
401 for (i = 0; i < 160; i++) {
402 data[i] = pgsm_bs->p_g_dtmf[pgsm_bs->p_g_dtmf_index++];
403 if (pgsm_bs->p_g_dtmf_index == 8000)
404 pgsm_bs->p_g_dtmf_index = 0;
407 pgsm_bs->bridge_tx(data, 160);
409 pgsm_bs->frame_receive(arg);
410 /* if we do not bridge we need to inject audio, if available */
411 if (!pgsm_bs->p_bridge) {
412 unsigned char data[160];
415 i = pgsm_bs->read_audio(data, 160);
417 pgsm_bs->bridge_rx(data, i);
424 if (msg_type != MNCC_SETUP_IND)
428 mISDNport = mISDNport_first;
430 if (mISDNport->gsm_bs)
432 mISDNport = mISDNport->next;
435 struct gsm_mncc *rej;
437 rej = create_mncc(MNCC_REJ_REQ, callref);
438 rej->fields |= MNCC_F_CAUSE;
439 rej->cause.coding = 3;
440 rej->cause.location = 1;
441 rej->cause.value = 27;
442 gsm_trace_header(NULL, NULL, MNCC_REJ_REQ, DIRECTION_OUT);
443 add_trace("cause", "coding", "%d", rej->cause.coding);
444 add_trace("cause", "location", "%d", rej->cause.location);
445 add_trace("cause", "value", "%d", rej->cause.value);
447 send_and_free_mncc(lcr_gsm, rej->msg_type, rej);
451 /* creating port object, transparent until setup with hdlc */
452 SPRINT(name, "%s-%d-in", interface->name, 0);
453 if (!(pgsm_bs = new Pgsm_bs(PORT_TYPE_GSM_BS_IN, name, NULL, interface)))
454 FATAL("Cannot create Port instance.\n");
459 pgsm_bs->setup_ind(msg_type, callref, mncc);
462 case MNCC_RTP_CREATE:
463 pgsm_bs->rtp_create_ind(msg_type, callref, mncc);
466 case MNCC_RTP_CONNECT:
467 pgsm_bs->rtp_connect_ind(msg_type, callref, mncc);
470 case MNCC_START_DTMF_IND:
471 pgsm_bs->start_dtmf_ind(msg_type, callref, mncc);
474 case MNCC_STOP_DTMF_IND:
475 pgsm_bs->stop_dtmf_ind(msg_type, callref, mncc);
478 case MNCC_CALL_CONF_IND:
479 pgsm_bs->call_conf_ind(msg_type, callref, mncc);
483 pgsm_bs->alert_ind(msg_type, callref, mncc);
487 pgsm_bs->setup_cnf(msg_type, callref, mncc);
490 case MNCC_SETUP_COMPL_IND:
491 pgsm_bs->setup_compl_ind(msg_type, callref, mncc);
495 pgsm_bs->disc_ind(msg_type, callref, mncc);
501 pgsm_bs->rel_ind(msg_type, callref, mncc);
504 case MNCC_NOTIFY_IND:
505 pgsm_bs->notify_ind(msg_type, callref, mncc);
509 pgsm_bs->hold_ind(msg_type, callref, mncc);
512 case MNCC_RETRIEVE_IND:
513 pgsm_bs->retr_ind(msg_type, callref, mncc);
517 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);
523 void Pgsm_bs::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
525 struct lcr_msg *message;
526 struct epoint_list *epointlist;
527 struct gsm_mncc *mncc;
529 /* copy setup infos to port */
530 memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
531 memcpy(&p_dialinginfo, ¶m->setup.dialinginfo, sizeof(p_dialinginfo));
532 memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
533 memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
535 /* no GSM MNCC connection */
536 if (p_g_lcr_gsm->mncc_lfd.fd < 0) {
537 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
538 add_trace("failure", NULL, "No MNCC connection.");
540 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
541 message->param.disconnectinfo.cause = 41; // temp. failure.
542 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
543 message_put(message);
544 new_state(PORT_STATE_RELEASE);
545 trigger_work(&p_g_delete);
550 if (!p_dialinginfo.id[0]) {
551 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
552 add_trace("failure", NULL, "No dialed subscriber given.");
554 message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
555 message->param.disconnectinfo.cause = 28;
556 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
557 message_put(message);
558 new_state(PORT_STATE_RELEASE);
559 trigger_work(&p_g_delete);
563 // SCPY(&p_m_tones_dir, param->setup.ext.tones_dir);
564 /* screen outgoing caller id */
565 do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_g_interface_name);
567 /* attach only if not already */
568 epointlist = p_epointlist;
570 if (epointlist->epoint_id == epoint_id)
572 epointlist = epointlist->next;
575 epointlist_new(epoint_id);
578 gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_OUT);
579 p_g_callref = new_callref++;
580 add_trace("callref", "new", "0x%x", p_g_callref);
583 gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT);
584 mncc = create_mncc(MNCC_SETUP_REQ, p_g_callref);
585 /* caller information */
586 mncc->fields |= MNCC_F_CALLING;
587 mncc->calling.plan = 1;
588 switch (p_callerinfo.ntype) {
589 case INFO_NTYPE_UNKNOWN:
590 mncc->calling.type = 0x0;
592 case INFO_NTYPE_INTERNATIONAL:
593 mncc->calling.type = 0x1;
595 case INFO_NTYPE_NATIONAL:
596 mncc->calling.type = 0x2;
598 case INFO_NTYPE_SUBSCRIBER:
599 mncc->calling.type = 0x4;
601 default: /* INFO_NTYPE_NOTPRESENT */
602 mncc->fields &= ~MNCC_F_CALLING;
605 switch (p_callerinfo.screen) {
606 case INFO_SCREEN_USER:
607 mncc->calling.screen = 0;
609 default: /* INFO_SCREEN_NETWORK */
610 mncc->calling.screen = 3;
613 switch (p_callerinfo.present) {
614 case INFO_PRESENT_ALLOWED:
615 mncc->calling.present = 0;
617 case INFO_PRESENT_RESTRICTED:
618 mncc->calling.present = 1;
620 default: /* INFO_PRESENT_NOTAVAIL */
621 mncc->calling.present = 2;
624 if (mncc->fields & MNCC_F_CALLING) {
625 SCPY(mncc->calling.number, p_callerinfo.id);
626 add_trace("calling", "type", "%d", mncc->calling.type);
627 add_trace("calling", "plan", "%d", mncc->calling.plan);
628 add_trace("calling", "present", "%d", mncc->calling.present);
629 add_trace("calling", "screen", "%d", mncc->calling.screen);
630 add_trace("calling", "number", "%s", mncc->calling.number);
632 /* dialing information */
633 mncc->fields |= MNCC_F_CALLED;
634 if (!strncmp(p_dialinginfo.id, "imsi-", 5)) {
635 SCPY(mncc->imsi, p_dialinginfo.id+5);
636 add_trace("dialing", "imsi", "%s", mncc->imsi);
638 SCPY(mncc->called.number, p_dialinginfo.id);
639 add_trace("dialing", "number", "%s", mncc->called.number);
642 /* sending user-user */
644 /* redirecting number */
645 mncc->fields |= MNCC_F_REDIRECTING;
646 mncc->redirecting.plan = 1;
647 switch (p_redirinfo.ntype) {
648 case INFO_NTYPE_UNKNOWN:
649 mncc->redirecting.type = 0x0;
651 case INFO_NTYPE_INTERNATIONAL:
652 mncc->redirecting.type = 0x1;
654 case INFO_NTYPE_NATIONAL:
655 mncc->redirecting.type = 0x2;
657 case INFO_NTYPE_SUBSCRIBER:
658 mncc->redirecting.type = 0x4;
660 default: /* INFO_NTYPE_NOTPRESENT */
661 mncc->fields &= ~MNCC_F_REDIRECTING;
664 switch (p_redirinfo.screen) {
665 case INFO_SCREEN_USER:
666 mncc->redirecting.screen = 0;
668 default: /* INFO_SCREE_NETWORK */
669 mncc->redirecting.screen = 3;
672 switch (p_redirinfo.present) {
673 case INFO_PRESENT_ALLOWED:
674 mncc->redirecting.present = 0;
676 case INFO_PRESENT_RESTRICTED:
677 mncc->redirecting.present = 1;
679 default: /* INFO_PRESENT_NOTAVAIL */
680 mncc->redirecting.present = 2;
683 /* sending redirecting number only in ntmode */
684 if (mncc->fields & MNCC_F_REDIRECTING) {
685 SCPY(mncc->redirecting.number, p_redirinfo.id);
686 add_trace("redir", "type", "%d", mncc->redirecting.type);
687 add_trace("redir", "plan", "%d", mncc->redirecting.plan);
688 add_trace("redir", "present", "%d", mncc->redirecting.present);
689 add_trace("redir", "screen", "%d", mncc->redirecting.screen);
690 add_trace("redir", "number", "%s", mncc->redirecting.number);
692 /* bearer capability */
696 send_and_free_mncc(p_g_lcr_gsm, mncc->msg_type, mncc);
698 new_state(PORT_STATE_OUT_SETUP);
700 message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
701 message_put(message);
703 new_state(PORT_STATE_OUT_PROCEEDING);
706 if (param->setup.rtpinfo.port) {
708 p_g_rtp_ip_remote = param->setup.rtpinfo.ip;
709 p_g_rtp_port_remote = param->setup.rtpinfo.port;
715 * endpoint sends messages to the port
717 int Pgsm_bs::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
719 if (Pgsm::message_epoint(epoint_id, message_id, param))
723 case MESSAGE_SETUP: /* dial-out command received from epoint */
724 if (p_state!=PORT_STATE_IDLE)
726 message_setup(epoint_id, message_id, param);
730 PDEBUG(DEBUG_GSM, "Pgsm_bs(%s) gsm port with (caller id %s) received unhandled nessage: %d\n", p_name, p_callerinfo.id, message_id);
736 int gsm_bs_exit(int rc)
738 /* free gsm instance */
740 if (gsm_bs->mncc_lfd.fd > -1) {
741 close(gsm_bs->mncc_lfd.fd);
742 unregister_fd(&gsm_bs->mncc_lfd);
745 del_timer(&gsm_bs->socket_retry);
754 int gsm_bs_init(struct interface *interface)
756 /* create gsm instance */
757 gsm_bs = (struct lcr_gsm *)MALLOC(sizeof(struct lcr_gsm));
759 gsm_bs->interface = interface;
760 gsm_bs->type = LCR_GSM_TYPE_NETWORK;
761 gsm_bs->sun.sun_family = AF_UNIX;
762 SCPY(gsm_bs->sun.sun_path, "/tmp/bsc_mncc");
764 memset(&gsm_bs->socket_retry, 0, sizeof(gsm_bs->socket_retry));
765 add_timer(&gsm_bs->socket_retry, mncc_socket_retry_cb, gsm_bs, 0);
767 /* do the initial connect */
768 mncc_socket_retry_cb(&gsm_bs->socket_retry, gsm_bs, 0);