diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-12-07 16:07:46 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-12-10 13:36:00 +0100 |
commit | 29de346b329fc05750b52446f3516f897415b43b (patch) | |
tree | 301a84d6a3f0813b74783814dfce3c343d092787 /openbsc/src/libmgcp/mgcp_protocol.c | |
parent | a769dcb889325dac6ee200ce891d21bb78861981 (diff) |
mgcp: Change the flow of the code when handling a MGCP response
Attempt to detect a response and return only then. Remove one level
of tabls in preparation for the re-transmission handling.
Diffstat (limited to 'openbsc/src/libmgcp/mgcp_protocol.c')
-rw-r--r-- | openbsc/src/libmgcp/mgcp_protocol.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c index 2faf75b29..2c3a4380b 100644 --- a/openbsc/src/libmgcp/mgcp_protocol.c +++ b/openbsc/src/libmgcp/mgcp_protocol.c @@ -182,6 +182,7 @@ static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp, struct msgb *mgcp_handle_message(struct mgcp_config *cfg, struct msgb *msg) { int code; + int i, handled = 0; struct msgb *resp = NULL; if (msgb_l2len(msg) < 4) { @@ -192,20 +193,22 @@ struct msgb *mgcp_handle_message(struct mgcp_config *cfg, struct msgb *msg) /* attempt to treat it as a response */ if (sscanf((const char *)&msg->l2h[0], "%3d %*s", &code) == 1) { LOGP(DMGCP, LOGL_DEBUG, "Response: Code: %d\n", code); - } else { - int i, handled = 0; - msg->l3h = &msg->l2h[4]; - for (i = 0; i < ARRAY_SIZE(mgcp_requests); ++i) - if (strncmp(mgcp_requests[i].name, (const char *) &msg->l2h[0], 4) == 0) { - handled = 1; - resp = mgcp_requests[i].handle_request(cfg, msg); - break; - } - if (!handled) { - LOGP(DMGCP, LOGL_NOTICE, "MSG with type: '%.4s' not handled\n", &msg->l2h[0]); + return NULL; + } + + msg->l3h = &msg->l2h[4]; + + for (i = 0; i < ARRAY_SIZE(mgcp_requests); ++i) { + if (strncmp(mgcp_requests[i].name, (const char *) &msg->l2h[0], 4) == 0) { + handled = 1; + resp = mgcp_requests[i].handle_request(cfg, msg); + break; } } + if (!handled) + LOGP(DMGCP, LOGL_NOTICE, "MSG with type: '%.4s' not handled\n", &msg->l2h[0]); + return resp; } |