summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2013-12-19 12:23:24 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-01-16 13:20:44 +0100
commit2645c9e7fc0698434f0555bbc8653252d56496ad (patch)
treeda4bc83fc1ec513409b8baba5a5086194bc13a02
parent84dfba15799a8426dcba28624a388e5a1962c2bf (diff)
mgcp: Set output_enabled flags based on the MGCP mode
This patch enhances parse_conn_mode() to set the output_enabled flags of each end based on the MGCP mode. Ticket: OW#1044 Sponsored-by: On-Waves ehf
-rw-r--r--openbsc/src/libmgcp/mgcp_protocol.c37
-rw-r--r--openbsc/tests/mgcp/mgcp_test.ok14
2 files changed, 37 insertions, 14 deletions
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c
index 95f3910c0..b55da37e9 100644
--- a/openbsc/src/libmgcp/mgcp_protocol.c
+++ b/openbsc/src/libmgcp/mgcp_protocol.c
@@ -488,22 +488,45 @@ static struct msgb *handle_audit_endpoint(struct mgcp_parse_data *p)
return create_ok_response(p->endp, 200, "AUEP", p->trans);
}
-static int parse_conn_mode(const char *msg, int *conn_mode)
+static int parse_conn_mode(const char *msg, struct mgcp_endpoint *endp)
{
int ret = 0;
if (strcmp(msg, "recvonly") == 0)
- *conn_mode = MGCP_CONN_RECV_ONLY;
+ endp->conn_mode = MGCP_CONN_RECV_ONLY;
else if (strcmp(msg, "sendrecv") == 0)
- *conn_mode = MGCP_CONN_RECV_SEND;
+ endp->conn_mode = MGCP_CONN_RECV_SEND;
else if (strcmp(msg, "sendonly") == 0)
- *conn_mode = MGCP_CONN_SEND_ONLY;
+ endp->conn_mode = MGCP_CONN_SEND_ONLY;
else if (strcmp(msg, "loopback") == 0)
- *conn_mode = MGCP_CONN_LOOPBACK;
+ endp->conn_mode = MGCP_CONN_LOOPBACK;
else {
LOGP(DMGCP, LOGL_ERROR, "Unknown connection mode: '%s'\n", msg);
ret = -1;
}
+ switch (endp->conn_mode) {
+ case MGCP_CONN_NONE:
+ endp->net_end.output_enabled = 0;
+ endp->bts_end.output_enabled = 0;
+ break;
+
+ case MGCP_CONN_RECV_ONLY:
+ endp->net_end.output_enabled = 0;
+ endp->bts_end.output_enabled = 1;
+ break;
+
+ case MGCP_CONN_SEND_ONLY:
+ endp->net_end.output_enabled = 1;
+ endp->bts_end.output_enabled = 0;
+ break;
+
+ default:
+ endp->net_end.output_enabled = 1;
+ endp->bts_end.output_enabled = 1;
+ break;
+ }
+
+
return ret;
}
@@ -794,7 +817,7 @@ mgcp_header_done:
set_local_cx_options(endp->tcfg->endpoints, &endp->local_options,
local_options);
- if (parse_conn_mode(mode, &endp->conn_mode) != 0) {
+ if (parse_conn_mode(mode, endp) != 0) {
error_code = 517;
goto error2;
}
@@ -895,7 +918,7 @@ static struct msgb *handle_modify_con(struct mgcp_parse_data *p)
local_options = (const char *) line + 3;
break;
case 'M':
- if (parse_conn_mode(line + 3, &endp->conn_mode) != 0) {
+ if (parse_conn_mode(line + 3, endp) != 0) {
error_code = 517;
goto error3;
}
diff --git a/openbsc/tests/mgcp/mgcp_test.ok b/openbsc/tests/mgcp/mgcp_test.ok
index 43a740216..6db72262c 100644
--- a/openbsc/tests/mgcp/mgcp_test.ok
+++ b/openbsc/tests/mgcp/mgcp_test.ok
@@ -18,7 +18,7 @@ Testing MDCX2
Testing CRCX
Detected packet duration: 40
Requested packetetization period: 20-20
-Connection mode: 1, BTS output disabled, NET output disabled
+Connection mode: 1, BTS output enabled, NET output disabled
Testing MDCX3
Packet duration not set
Requested packetization period not set
@@ -26,23 +26,23 @@ Connection mode not set
Testing MDCX4
Detected packet duration: 40
Requested packetetization period: 20-20
-Connection mode: 3, BTS output disabled, NET output disabled
+Connection mode: 3, BTS output enabled, NET output enabled
Testing MDCX4_PT1
Detected packet duration: 40
Requested packetetization period: 20-40
-Connection mode: 3, BTS output disabled, NET output disabled
+Connection mode: 3, BTS output enabled, NET output enabled
Testing MDCX4_PT2
Detected packet duration: 40
Requested packetetization period: 20-20
-Connection mode: 3, BTS output disabled, NET output disabled
+Connection mode: 3, BTS output enabled, NET output enabled
Testing MDCX4_PT3
Detected packet duration: 40
Requested packetization period not set
-Connection mode: 3, BTS output disabled, NET output disabled
+Connection mode: 3, BTS output enabled, NET output enabled
Testing MDCX4_SO
Detected packet duration: 40
Requested packetetization period: 20-20
-Connection mode: 2, BTS output disabled, NET output disabled
+Connection mode: 2, BTS output disabled, NET output enabled
Testing DLCX
Detected packet duration: 20
Requested packetization period not set
@@ -50,7 +50,7 @@ Connection mode: 0, BTS output enabled, NET output enabled
Testing CRCX_ZYN
Packet duration not set
Requested packetization period not set
-Connection mode: 1, BTS output disabled, NET output disabled
+Connection mode: 1, BTS output enabled, NET output disabled
Testing EMPTY
Testing SHORT1
Testing SHORT2