diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-03-26 20:34:12 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-03-29 11:46:45 +0200 |
commit | 7cce1d301aff586d8a95765d3b56c0c81266781b (patch) | |
tree | eb776b5e00763402ee30bfc9a2f4f0bf3ab097d2 /openbsc | |
parent | fd603ed9e2f87d05b2261a25e11aceb01814dfbe (diff) |
libmgcp: Fail if transcoding can't be configured
We want to fail theallocation of an endpoint in case the
transcoding can't be configured.
Manually verified with:
./src/osmo-bsc_mgcp/osmo-bsc_mgcp -c doc/examples/osmo-bsc_mgcp/mgcp.cfg
$ ./contrib/mgcp_server.py
0000 32 30 30 20 33 30 36 39 200 3069
0008 31 20 4F 4B 0D 0A 1 OK.. ('127.0.0.1', 2427)
0000 34 30 30 20 35 39 30 36 400 5906
0008 39 20 46 41 49 4C 0D 0A 9 FAIL.. ('127.0.0.1', 2427)
0000 34 30 30 20 33 35 34 36 400 3546
0008 33 20 46 41 49 4C 0D 0A 3 FAIL.. ('127.0.0.1', 2427)
0000 34 30 30 20 36 32 31 37 400 6217
0008 30 20 46 41 49 4C 0D 0A 0 FAIL.. ('127.0.0.1', 2427)
Verified by not sending L: in the CRCX and then failing on the
MDCX.
Diffstat (limited to 'openbsc')
-rw-r--r-- | openbsc/src/libmgcp/mgcp_protocol.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c index ccd15e842..62f6974d0 100644 --- a/openbsc/src/libmgcp/mgcp_protocol.c +++ b/openbsc/src/libmgcp/mgcp_protocol.c @@ -111,7 +111,7 @@ static struct msgb *handle_noti_req(struct mgcp_parse_data *data); static void create_transcoder(struct mgcp_endpoint *endp); static void delete_transcoder(struct mgcp_endpoint *endp); -static void setup_rtp_processing(struct mgcp_endpoint *endp); +static int setup_rtp_processing(struct mgcp_endpoint *endp); static int mgcp_analyze_header(struct mgcp_parse_data *parse, char *data); @@ -1050,7 +1050,8 @@ mgcp_header_done: endp->bts_end.force_output_ptime = 1; } - setup_rtp_processing(endp); + if (setup_rtp_processing(endp) != 0) + goto error2; /* policy CB */ if (p->cfg->policy_cb) { @@ -1161,7 +1162,8 @@ static struct msgb *handle_modify_con(struct mgcp_parse_data *p) set_audio_info(p->cfg, &endp->net_end.codec, PTYPE_UNDEFINED, endp->local_options.codec); - setup_rtp_processing(endp); + if (setup_rtp_processing(endp) != 0) + goto error3; /* policy CB */ if (p->cfg->policy_cb) { @@ -1659,25 +1661,27 @@ int mgcp_send_reset_ep(struct mgcp_endpoint *endp, int endpoint) return send_agent(endp->cfg, buf, len); } -static void setup_rtp_processing(struct mgcp_endpoint *endp) +static int setup_rtp_processing(struct mgcp_endpoint *endp) { + int rc = 0; struct mgcp_config *cfg = endp->cfg; if (endp->type != MGCP_RTP_DEFAULT) - return; + return 0; if (endp->conn_mode == MGCP_CONN_LOOPBACK) - return; + return 0; if (endp->conn_mode & MGCP_CONN_SEND_ONLY) - cfg->setup_rtp_processing_cb(endp, &endp->net_end, &endp->bts_end); + rc |= cfg->setup_rtp_processing_cb(endp, &endp->net_end, &endp->bts_end); else - cfg->setup_rtp_processing_cb(endp, &endp->net_end, NULL); + rc |= cfg->setup_rtp_processing_cb(endp, &endp->net_end, NULL); if (endp->conn_mode & MGCP_CONN_RECV_ONLY) - cfg->setup_rtp_processing_cb(endp, &endp->bts_end, &endp->net_end); + rc |= cfg->setup_rtp_processing_cb(endp, &endp->bts_end, &endp->net_end); else - cfg->setup_rtp_processing_cb(endp, &endp->bts_end, NULL); + rc |= cfg->setup_rtp_processing_cb(endp, &endp->bts_end, NULL); + return rc; } static void create_transcoder(struct mgcp_endpoint *endp) |