diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-08-06 18:03:11 +0800 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-08-08 07:28:45 +0800 |
commit | c737fbd4afbe39486e06c98136f120ea995a3286 (patch) | |
tree | a30157ced9fe737bae85be59c7662898e7b273c9 | |
parent | 24963554a86e85df2319c78f6e4f72c2cb5d32a4 (diff) |
mgcp: Remember if the endpoint was allocated...
Do not use the CI_UNUSED to decide if an endpoint is allocated
but introduce a new flag. This way only the CRCX and free_endp
play with the allocated field.
-rw-r--r-- | openbsc/include/openbsc/mgcp_internal.h | 1 | ||||
-rw-r--r-- | openbsc/src/mgcp/mgcp_network.c | 2 | ||||
-rw-r--r-- | openbsc/src/mgcp/mgcp_protocol.c | 6 |
3 files changed, 6 insertions, 3 deletions
diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h index d7be0a244..12e3ad9b1 100644 --- a/openbsc/include/openbsc/mgcp_internal.h +++ b/openbsc/include/openbsc/mgcp_internal.h @@ -85,6 +85,7 @@ struct mgcp_rtp_tap { }; struct mgcp_endpoint { + int allocated; uint32_t ci; char *callid; char *local_options; diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c index 41dfc0ad3..511608b5e 100644 --- a/openbsc/src/mgcp/mgcp_network.c +++ b/openbsc/src/mgcp/mgcp_network.c @@ -215,7 +215,7 @@ static int recevice_from(struct mgcp_endpoint *endp, int fd, struct sockaddr_in } /* do not forward aynthing... maybe there is a packet from the bts */ - if (endp->ci == CI_UNUSED) + if (!endp->allocated) return -1; #warning "Slight spec violation. With connection mode recvonly we should attempt to forward." diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c index 384551a6d..0083a145e 100644 --- a/openbsc/src/mgcp/mgcp_protocol.c +++ b/openbsc/src/mgcp/mgcp_protocol.c @@ -430,7 +430,7 @@ static struct msgb *handle_create_con(struct mgcp_config *cfg, struct msgb *msg) if (found != 0) return create_response(500, "CRCX", trans_id); - if (endp->ci != CI_UNUSED) { + if (endp->allocated) { if (cfg->force_realloc) { LOGP(DMGCP, LOGL_NOTICE, "Endpoint 0x%x already allocated. Forcing realloc.\n", ENDPOINT_NUMBER(endp)); @@ -487,6 +487,7 @@ static struct msgb *handle_create_con(struct mgcp_config *cfg, struct msgb *msg) if (endp->ci == CI_UNUSED) goto error2; + endp->allocated = 1; endp->bts_end.payload_type = cfg->audio_payload; /* policy CB */ @@ -667,7 +668,7 @@ static struct msgb *handle_delete_con(struct mgcp_config *cfg, struct msgb *msg) if (found != 0) return create_response(error_code, "DLCX", trans_id); - if (endp->ci == CI_UNUSED) { + if (!endp->allocated) { LOGP(DMGCP, LOGL_ERROR, "Endpoint is not used. 0x%x\n", ENDPOINT_NUMBER(endp)); return create_response(error_code, "DLCX", trans_id); } @@ -811,6 +812,7 @@ void mgcp_free_endp(struct mgcp_endpoint *endp) { LOGP(DMGCP, LOGL_DEBUG, "Deleting endpoint on: 0x%x\n", ENDPOINT_NUMBER(endp)); endp->ci = CI_UNUSED; + endp->allocated = 0; if (endp->callid) { talloc_free(endp->callid); |