X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=gsm_ms.cpp;h=4d42ee7a45c2e5e23ee8fe2b287ef9878c5c17b0;hp=0cbcca1fdac68842db7cf6ffb80f6dca65fb54dc;hb=5566f74eb29be75da44e29ba72ee6f015249ce61;hpb=f854931ffbee9464b278c433c4fdc7c3ea5af2fb diff --git a/gsm_ms.cpp b/gsm_ms.cpp index 0cbcca1..4d42ee7 100644 --- a/gsm_ms.cpp +++ b/gsm_ms.cpp @@ -40,7 +40,7 @@ Pgsm_ms::Pgsm_ms(int type, char *portname, struct port_settings *settings, struc p_g_lcr_gsm = gsm_ms; break; } - gsm_ms = gsm_ms->gsm_ms_next; + gsm_ms = gsm_ms->gsm_next; } p_g_dtmf_state = DTMF_ST_IDLE; @@ -72,21 +72,22 @@ void Pgsm_ms::setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_ struct gsm_mncc *proceeding, *frame; struct interface *interface; - interface = getinterfacebyname(p_g_interface_name); + interface = getinterfacebyname(p_interface_name); if (!interface) { - PERROR("Cannot find interface %s.\n", p_g_interface_name); + PERROR("Cannot find interface %s.\n", p_interface_name); return; } /* process given callref */ - gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_IN); + gsm_trace_header(p_interface_name, this, 0, DIRECTION_IN); add_trace("callref", "new", "0x%x", callref); if (p_g_callref) { /* release in case the ID is already in use */ add_trace("error", NULL, "callref already in use"); +reject: end_trace(); mncc = create_mncc(MNCC_REJ_REQ, callref); - gsm_trace_header(p_g_interface_name, this, MNCC_REJ_REQ, DIRECTION_OUT); + gsm_trace_header(p_interface_name, this, MNCC_REJ_REQ, DIRECTION_OUT); mncc->fields |= MNCC_F_CAUSE; mncc->cause.coding = 3; mncc->cause.location = 1; @@ -101,10 +102,16 @@ void Pgsm_ms::setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_ trigger_work(&p_g_delete); return; } + if (callref < 0x40000000) { + /* release in case the ID is invalid */ + add_trace("error", NULL, "callref invalid, not of MS type"); + goto reject; + } + p_g_callref = callref; end_trace(); - gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_IND, DIRECTION_IN); + gsm_trace_header(p_interface_name, this, MNCC_SETUP_IND, DIRECTION_IN); /* caller information */ p_callerinfo.ntype = INFO_NTYPE_NOTPRESENT; if (mncc->fields & MNCC_F_CALLING) { @@ -157,7 +164,7 @@ void Pgsm_ms::setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_ add_trace("calling", "screen", "%d", mncc->calling.screen); add_trace("calling", "number", "%s", mncc->calling.number); } - SCPY(p_callerinfo.interface, p_g_interface_name); + SCPY(p_callerinfo.interface, p_interface_name); /* dialing information */ if (mncc->fields & MNCC_F_CALLED) { SCAT(p_dialinginfo.id, mncc->called.number); @@ -277,12 +284,22 @@ void Pgsm_ms::setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_ epointlist_new(epoint->ep_serial); /* modify lchan to GSM codec V1 */ - modify_lchan(RTP_PT_GSM_FULL); + modify_lchan(MEDIA_TYPE_GSM); /* send call proceeding */ - gsm_trace_header(p_g_interface_name, this, MNCC_CALL_CONF_REQ, DIRECTION_OUT); + gsm_trace_header(p_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; @@ -292,7 +309,7 @@ void Pgsm_ms::setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_ new_state(PORT_STATE_IN_PROCEEDING); if (p_g_tones && !p_g_tch_connected) { /* only if ... */ - gsm_trace_header(p_g_interface_name, this, MNCC_FRAME_RECV, DIRECTION_OUT); + gsm_trace_header(p_interface_name, this, MNCC_FRAME_RECV, DIRECTION_OUT); end_trace(); frame = create_mncc(MNCC_FRAME_RECV, p_g_callref); send_and_free_mncc(p_g_lcr_gsm, frame->msg_type, frame); @@ -315,40 +332,24 @@ void Pgsm_ms::setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_ /* * MS sends message to port */ -int message_ms(struct lcr_gsm *gsm_ms, int msg_type, void *arg) +int message_ms(class Pgsm_ms *pgsm_ms, struct lcr_gsm *gsm_ms, int msg_type, void *arg) { struct gsm_mncc *mncc = (struct gsm_mncc *)arg; unsigned int callref = mncc->callref; - class Port *port; - class Pgsm_ms *pgsm_ms = NULL; char name[64]; -// struct mISDNport *mISDNport; /* Special messages */ switch (msg_type) { } - /* find callref */ - callref = mncc->callref; - port = port_first; - while(port) { - if ((port->p_type & PORT_CLASS_GSM_MASK) == PORT_CLASS_GSM_MS) { - pgsm_ms = (class Pgsm_ms *)port; - if (pgsm_ms->p_g_callref == callref) { - break; - } - } - port = port->next; - } - if (msg_type == GSM_TCHF_FRAME - || msg_type == GSM_TCHF_BAD_FRAME) { - if (port) + || msg_type == GSM_BAD_FRAME) { + if (pgsm_ms) pgsm_ms->frame_receive(arg); return 0; } - if (!port) { + if (!pgsm_ms) { struct interface *interface; if (msg_type != MNCC_SETUP_IND) @@ -440,7 +441,7 @@ void Pgsm_ms::message_setup(unsigned int epoint_id, int message_id, union parame /* no instance */ if (!p_g_lcr_gsm || p_g_lcr_gsm->mncc_lfd.fd < 0) { - gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT); + gsm_trace_header(p_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT); add_trace("failure", NULL, "MS %s instance is unavailable", p_g_ms_name); end_trace(); message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE); @@ -454,7 +455,7 @@ void Pgsm_ms::message_setup(unsigned int epoint_id, int message_id, union parame /* no number */ if (!p_dialinginfo.id[0]) { - gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT); + gsm_trace_header(p_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT); add_trace("failure", NULL, "No dialed subscriber given."); end_trace(); message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE); @@ -477,12 +478,12 @@ void Pgsm_ms::message_setup(unsigned int epoint_id, int message_id, union parame epointlist_new(epoint_id); /* creating l3id */ - gsm_trace_header(p_g_interface_name, this, 0, DIRECTION_OUT); + gsm_trace_header(p_interface_name, this, 0, DIRECTION_OUT); p_g_callref = new_callref++; add_trace("callref", "new", "0x%x", p_g_callref); end_trace(); - gsm_trace_header(p_g_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT); + gsm_trace_header(p_interface_name, this, MNCC_SETUP_REQ, DIRECTION_OUT); mncc = create_mncc(MNCC_SETUP_REQ, p_g_callref); if (!strncasecmp(p_dialinginfo.id, "emerg", 5)) { mncc->emergency = 1; @@ -564,7 +565,7 @@ void Pgsm_ms::dtmf_statemachine(struct gsm_mncc *mncc) p_g_dtmf_state = DTMF_ST_IDLE; return; } - gsm_trace_header(p_g_interface_name, this, MNCC_START_DTMF_REQ, DIRECTION_OUT); + gsm_trace_header(p_interface_name, this, MNCC_START_DTMF_REQ, DIRECTION_OUT); dtmf = create_mncc(MNCC_START_DTMF_REQ, p_g_callref); dtmf->keypad = p_g_dtmf[p_g_dtmf_index++]; p_g_dtmf_state = DTMF_ST_START; @@ -583,7 +584,7 @@ void Pgsm_ms::dtmf_statemachine(struct gsm_mncc *mncc) PDEBUG(DEBUG_GSM, "DTMF is on\n"); break; case DTMF_ST_MARK: - gsm_trace_header(p_g_interface_name, this, MNCC_STOP_DTMF_REQ, DIRECTION_OUT); + gsm_trace_header(p_interface_name, this, MNCC_STOP_DTMF_REQ, DIRECTION_OUT); dtmf = create_mncc(MNCC_STOP_DTMF_REQ, p_g_callref); p_g_dtmf_state = DTMF_ST_STOP; end_trace(); @@ -709,8 +710,8 @@ int gsm_ms_new(struct interface *interface) struct lcr_gsm *gsm_ms = gsm_ms_first, **gsm_ms_p = &gsm_ms_first; while (gsm_ms) { - gsm_ms_p = &gsm_ms->gsm_ms_next; - gsm_ms = gsm_ms->gsm_ms_next; + gsm_ms_p = &gsm_ms->gsm_next; + gsm_ms = gsm_ms->gsm_next; } PDEBUG(DEBUG_GSM, "GSM: interface for MS '%s' is created\n", interface->gsm_ms_name); @@ -738,51 +739,19 @@ int gsm_ms_new(struct interface *interface) int gsm_ms_delete(const char *name) { struct lcr_gsm *gsm_ms = gsm_ms_first, **gsm_ms_p = &gsm_ms_first; -// class Port *port; -// class Pgsm_ms *pgsm_ms = NULL; PDEBUG(DEBUG_GSM, "GSM: interface for MS '%s' is deleted\n", name); while (gsm_ms) { if (gsm_ms->type == LCR_GSM_TYPE_MS && !strcmp(gsm_ms->name, name)) break; - gsm_ms_p = &gsm_ms->gsm_ms_next; - gsm_ms = gsm_ms->gsm_ms_next; + gsm_ms_p = &gsm_ms->gsm_next; + gsm_ms = gsm_ms->gsm_next; } if (!gsm_ms) return 0; -/* not needed, because: - * - shutdown of interface will destry port instances locally - * - closing of socket will make remote socket destroy calls locally - */ -#if 0 - port = port_first; - while(port) { - if ((port->p_type & PORT_CLASS_GSM_MASK) == PORT_CLASS_GSM_MS) { - pgsm_ms = (class Pgsm_ms *)port; - if (pgsm_ms->p_g_lcr_gsm == gsm_ms && pgsm_ms->p_g_callref) { - struct gsm_mncc *rej; - - rej = create_mncc(MNCC_REL_REQ, pgsm_ms->p_g_callref); - rej->fields |= MNCC_F_CAUSE; - rej->cause.coding = 3; - rej->cause.location = 1; - rej->cause.value = 27; - gsm_trace_header(NULL, NULL, MNCC_REJ_REQ, DIRECTION_OUT); - add_trace("cause", "coding", "%d", rej->cause.coding); - add_trace("cause", "location", "%d", rej->cause.location); - add_trace("cause", "value", "%d", rej->cause.value); - end_trace(); - send_and_free_mncc(gsm_ms, rej->msg_type, rej); - pgsm_ms->new_state(PORT_STATE_RELEASE); - trigger_work(&pgsm_ms->p_g_delete); - } - } - } -#endif - if (gsm_ms->mncc_lfd.fd > -1) { close(gsm_ms->mncc_lfd.fd); unregister_fd(&gsm_ms->mncc_lfd); @@ -790,7 +759,7 @@ int gsm_ms_delete(const char *name) del_timer(&gsm_ms->socket_retry); /* remove instance from list */ - *gsm_ms_p = gsm_ms->gsm_ms_next; + *gsm_ms_p = gsm_ms->gsm_next; FREE(gsm_ms, sizeof(struct lcr_gsm)); return 0;