X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=gsm_ms.cpp;h=4d42ee7a45c2e5e23ee8fe2b287ef9878c5c17b0;hp=8a314bf23b1376d22d3c108b56fdda9ba16d6792;hb=refs%2Fheads%2Fbackup2;hpb=9b2cabced47630e31cfc57c1384af805170b6d2f diff --git a/gsm_ms.cpp b/gsm_ms.cpp index 8a314bf..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; @@ -84,6 +84,7 @@ void Pgsm_ms::setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_ 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_interface_name, this, MNCC_REJ_REQ, DIRECTION_OUT); @@ -101,6 +102,12 @@ 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(); @@ -325,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_BAD_FRAME) { - if (port) + if (pgsm_ms) pgsm_ms->frame_receive(arg); return 0; } - if (!port) { + if (!pgsm_ms) { struct interface *interface; if (msg_type != MNCC_SETUP_IND) @@ -719,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); @@ -748,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); @@ -800,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;