X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=gsm_ms.cpp;h=7c43232edea3bf6e5a236a03d9417ee369dccf48;hp=dbd3351c26d3a64a46e909fc47d7e472175b9ae0;hb=afe2e32ae11b1ccdb5d5b36512f3b3b59cfa7c59;hpb=5463e1b62a39ce417b610584e3d34a8bc30ac15e diff --git a/gsm_ms.cpp b/gsm_ms.cpp index dbd3351..7c43232 100644 --- a/gsm_ms.cpp +++ b/gsm_ms.cpp @@ -23,6 +23,8 @@ static int dtmf_timeout(struct lcr_timer *timer, void *instance, int index); #define DTMF_ST_STOP 3 /* DTMF stopped, waiting for resp. */ #define DTMF_ST_SPACE 4 /* wait space between tones */ +#define RTP_PT_GSM_FULL 3 + /* * constructor */ @@ -67,7 +69,14 @@ void Pgsm_ms::setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_ { class Endpoint *epoint; struct lcr_msg *message; - struct gsm_mncc *mode, *proceeding, *frame; + struct gsm_mncc *proceeding, *frame; + struct interface *interface; + + interface = getinterfacebyname(p_g_interface_name); + if (!interface) { + PERROR("Cannot find interface %s.\n", p_g_interface_name); + return; + } /* process given callref */ gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_IN); @@ -264,23 +273,26 @@ void Pgsm_ms::setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_ FATAL("Incoming call but already got an endpoint.\n"); if (!(epoint = new Endpoint(p_serial, 0))) FATAL("No memory for Endpoint instance\n"); - if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 0))) //incoming - FATAL("No memory for Endpoint Application instance\n"); + epoint->ep_app = new_endpointapp(epoint, 0, interface->app); //incoming epointlist_new(epoint->ep_serial); /* modify lchan to GSM codec V1 */ - gsm_trace_header(p_g_interface_name, this, MNCC_LCHAN_MODIFY, DIRECTION_OUT); - mode = create_mncc(MNCC_LCHAN_MODIFY, p_g_callref); - mode->lchan_mode = 0x01; /* GSM V1 */ - mode->lchan_type = 0x02; - add_trace("mode", NULL, "0x%02x", mode->lchan_mode); - end_trace(); - send_and_free_mncc(p_g_lcr_gsm, mode->msg_type, mode); + modify_lchan(RTP_PT_GSM_FULL); /* send call proceeding */ gsm_trace_header(p_g_interface_name, this, MNCC_CALL_CONF_REQ, DIRECTION_OUT); proceeding = create_mncc(MNCC_CALL_CONF_REQ, p_g_callref); - // FIXME: bearer + /* bearer capability (mandatory, if not present in setup message) */ + if (!(mncc->fields & MNCC_F_BEARER_CAP)) { + proceeding->fields |= MNCC_F_BEARER_CAP; + proceeding->bearer_cap.coding = 0; + proceeding->bearer_cap.radio = 1; + proceeding->bearer_cap.speech_ctm = 0; + proceeding->bearer_cap.speech_ver[0] = 0; + proceeding->bearer_cap.speech_ver[1] = -1; /* end of list */ + proceeding->bearer_cap.transfer = 0; + proceeding->bearer_cap.mode = 0; + } /* DTMF supported */ proceeding->fields |= MNCC_F_CCCAP; proceeding->cccap.dtmf = 1; @@ -315,7 +327,6 @@ void Pgsm_ms::setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_ */ int message_ms(struct lcr_gsm *gsm_ms, int msg_type, void *arg) { - struct interface *interface = gsm_ms->interface; struct gsm_mncc *mncc = (struct gsm_mncc *)arg; unsigned int callref = mncc->callref; class Port *port; @@ -340,24 +351,21 @@ int message_ms(struct lcr_gsm *gsm_ms, int msg_type, void *arg) port = port->next; } - if (msg_type == GSM_TCHF_FRAME) { + if (msg_type == GSM_TCHF_FRAME + || msg_type == GSM_BAD_FRAME) { if (port) pgsm_ms->frame_receive(arg); return 0; } if (!port) { + struct interface *interface; + if (msg_type != MNCC_SETUP_IND) return(0); -#if 0 - /* find gsm ms port */ - mISDNport = mISDNport_first; - while(mISDNport) { - if (mISDNport->gsm_ms && !strcmp(mISDNport->ifport->gsm_ms_name, gsm_ms->name)) - break; - mISDNport = mISDNport->next; - } - if (!mISDNport) { + + interface = getinterfacebyname(gsm_ms->interface_name); + if (!interface) { struct gsm_mncc *rej; rej = create_mncc(MNCC_REJ_REQ, callref); @@ -369,11 +377,11 @@ int message_ms(struct lcr_gsm *gsm_ms, int msg_type, void *arg) add_trace("cause", "coding", "%d", rej->cause.coding); add_trace("cause", "location", "%d", rej->cause.location); add_trace("cause", "value", "%d", rej->cause.value); + add_trace("reason", NULL, "interface %s not found", gsm_ms->interface_name); end_trace(); send_and_free_mncc(gsm_ms, rej->msg_type, rej); return 0; } -#endif /* creating port object, transparent until setup with hdlc */ SPRINT(name, "%s-%d-in", interface->name, 0); if (!(pgsm_ms = new Pgsm_ms(PORT_TYPE_GSM_MS_IN, name, NULL, interface))) @@ -720,7 +728,7 @@ int gsm_ms_new(struct interface *interface) /* create gsm instance */ gsm_ms = (struct lcr_gsm *)MALLOC(sizeof(struct lcr_gsm)); - gsm_ms->interface = interface; + SCPY(gsm_ms->interface_name, interface->name); gsm_ms->type = LCR_GSM_TYPE_MS; SCPY(gsm_ms->name, interface->gsm_ms_name); gsm_ms->sun.sun_family = AF_UNIX;