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.
diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c
index ce81f3c..96a1865 100644
--- a/openbsc/src/mgcp/mgcp_network.c
+++ b/openbsc/src/mgcp/mgcp_network.c
@@ -215,7 +215,7 @@
}
/* 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 828c33b..2aa66a0 100644
--- a/openbsc/src/mgcp/mgcp_protocol.c
+++ b/openbsc/src/mgcp/mgcp_protocol.c
@@ -430,7 +430,7 @@
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 @@
if (endp->ci == CI_UNUSED)
goto error2;
+ endp->allocated = 1;
endp->bts_end.payload_type = cfg->audio_payload;
/* policy CB */
@@ -667,7 +668,7 @@
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 @@
{
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);