aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-04-07 09:53:54 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-04-07 09:53:54 +0200
commit3a67035411f295e193adcef45c1503c1eb99aaf5 (patch)
tree558906c93c65be3b560ebe1c551d2d676937a41b /openbsc
parentcb1937a4c53c723c8757117d074c3be29936b872 (diff)
nat: Attempt to make MGCP forwarding more robust
When not being able to allocate the msgb for the forwarded data there is no point in keeping and preparing the transaction. So we can move the msg creation a bit up and only do the allocations after having done the msgb allocation. When receiving a DLCX we will now delete the endpoint right away. This means when a BSS does not respond to the DLCX our endpoint will not be blocked. E.g. this could happen when the MGCP is restarting or in similiar conditions. When the BSS is not responding we move the burden up the chain to the CallAgent. We have to still keep track of the transaction id and the bsc pointer to keep the mgcp forward routine working.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/nat/bsc_mgcp_utils.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/openbsc/src/nat/bsc_mgcp_utils.c b/openbsc/src/nat/bsc_mgcp_utils.c
index 2dbf1fd00..435c8584b 100644
--- a/openbsc/src/nat/bsc_mgcp_utils.c
+++ b/openbsc/src/nat/bsc_mgcp_utils.c
@@ -148,9 +148,18 @@ int bsc_mgcp_policy_cb(struct mgcp_config *cfg, int endpoint, int state, const c
talloc_free(bsc_endp->transaction_id);
}
+ /* we need to generate a new and patched message */
+ bsc_msg = bsc_mgcp_rewrite((char *) nat->mgcp_msg, nat->mgcp_length,
+ nat->mgcp_cfg->source_addr, mgcp_endp->rtp_port);
+ if (!bsc_msg) {
+ LOGP(DMGCP, LOGL_ERROR, "Failed to patch the msg.\n");
+ return MGCP_POLICY_CONT;
+ }
+
+
bsc_endp->transaction_id = talloc_strdup(nat, transaction_id);
bsc_endp->bsc = bsc_con;
- bsc_endp->pending_delete = state == MGCP_ENDP_DLCX;
+ bsc_endp->pending_delete = 0;
/* we need to update some bits */
if (state == MGCP_ENDP_CRCX) {
@@ -162,14 +171,10 @@ int bsc_mgcp_policy_cb(struct mgcp_config *cfg, int endpoint, int state, const c
} else {
mgcp_endp->bts = sock.sin_addr;
}
- }
-
- /* we need to generate a new and patched message */
- bsc_msg = bsc_mgcp_rewrite((char *) nat->mgcp_msg, nat->mgcp_length,
- nat->mgcp_cfg->source_addr, mgcp_endp->rtp_port);
- if (!bsc_msg) {
- LOGP(DMGCP, LOGL_ERROR, "Failed to patch the msg.\n");
- return MGCP_POLICY_CONT;
+ } else if (state == MGCP_ENDP_DLCX) {
+ /* we will free the endpoint now in case the BSS does not respond */
+ bsc_endp->pending_delete = 1;
+ mgcp_free_endp(mgcp_endp);
}
bsc_write_mgcp_msg(bsc_con, bsc_msg);
@@ -223,21 +228,26 @@ void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg)
return;
}
+ /* make it point to our endpoint if it was not deleted */
+ if (bsc_endp->pending_delete) {
+ bsc_endp->bsc = NULL;
+ bsc_endp->pending_delete = 0;
+ } else {
+ endp->ci = bsc_mgcp_extract_ci((const char *) msg->l2h);
+ }
+
/* free some stuff */
talloc_free(bsc_endp->transaction_id);
bsc_endp->transaction_id = NULL;
- /* make it point to our endpoint */
- endp->ci = bsc_mgcp_extract_ci((const char *) msg->l2h);
+ /*
+ * rewrite the information. In case the endpoint was deleted
+ * there should be nothing for us to rewrite so putting endp->rtp_port
+ * with the value of 0 should be no problem.
+ */
output = bsc_mgcp_rewrite((char * ) msg->l2h, msgb_l2len(msg),
bsc->nat->mgcp_cfg->source_addr, endp->rtp_port);
- if (bsc_endp->pending_delete) {
- mgcp_free_endp(endp);
- bsc_endp->bsc = NULL;
- bsc_endp->pending_delete = 0;
- }
-
if (!output) {
LOGP(DMGCP, LOGL_ERROR, "Failed to rewrite MGCP msg.\n");
return;