aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-08-03 02:27:21 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-08-03 17:37:30 +0800
commitc4fe5ac43a004f6996d15a6ed1d7fffb7b5e2d6f (patch)
tree813018e32a3b3d57e8d2956812993daf94334c51
parent00d1f0d7a9230eee91e1046abcb7307b8cc93277 (diff)
mgcp: Implement the "loopback" mode for a connection endpoint.
-rw-r--r--openbsc/include/openbsc/mgcp_internal.h9
-rw-r--r--openbsc/src/mgcp/mgcp_network.c4
-rw-r--r--openbsc/src/mgcp/mgcp_protocol.c9
3 files changed, 15 insertions, 7 deletions
diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h
index 918ba4b2f..a17dc9e45 100644
--- a/openbsc/include/openbsc/mgcp_internal.h
+++ b/openbsc/include/openbsc/mgcp_internal.h
@@ -28,6 +28,15 @@
#define CI_UNUSED 0
+enum mgcp_connection_mode {
+ MGCP_CONN_NONE = 0,
+ MGCP_CONN_RECV_ONLY = 1,
+ MGCP_CONN_SEND_ONLY = 2,
+ MGCP_CONN_RECV_SEND = MGCP_CONN_RECV_ONLY | MGCP_CONN_SEND_ONLY,
+ MGCP_CONN_LOOPBACK = 4,
+};
+
+
struct mgcp_endpoint {
int ci;
char *callid;
diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c
index 50318246a..9e9685aef 100644
--- a/openbsc/src/mgcp/mgcp_network.c
+++ b/openbsc/src/mgcp/mgcp_network.c
@@ -206,6 +206,10 @@ static int rtp_data_cb(struct bsc_fd *fd, unsigned int what)
if (cfg->audio_loop)
dest = !dest;
+ /* Loop based on the conn_mode, maybe undoing the above */
+ if (endp->conn_mode == MGCP_CONN_LOOPBACK)
+ dest = !dest;
+
if (dest == DEST_NETWORK) {
if (proto == PROTO_RTP)
patch_and_count(&endp->bts_seq_no, &endp->bts_lost_no,
diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c
index a1abce1ce..87aa967a1 100644
--- a/openbsc/src/mgcp/mgcp_protocol.c
+++ b/openbsc/src/mgcp/mgcp_protocol.c
@@ -38,13 +38,6 @@
#include <openbsc/mgcp.h>
#include <openbsc/mgcp_internal.h>
-enum mgcp_connection_mode {
- MGCP_CONN_NONE = 0,
- MGCP_CONN_RECV_ONLY = 1,
- MGCP_CONN_SEND_ONLY = 2,
- MGCP_CONN_RECV_SEND = MGCP_CONN_RECV_ONLY | MGCP_CONN_SEND_ONLY,
-};
-
/**
* Macro for tokenizing MGCP messages and SDP in one go.
*
@@ -364,6 +357,8 @@ static int parse_conn_mode(const char* msg, int *conn_mode)
*conn_mode = MGCP_CONN_RECV_ONLY;
else if (strcmp(msg, "sendrecv") == 0)
*conn_mode = MGCP_CONN_RECV_SEND;
+ else if (strcmp(msg, "loopback") == 0)
+ *conn_mode = MGCP_CONN_LOOPBACK;
else {
LOGP(DMGCP, LOGL_ERROR, "Unknown connection mode: '%s'\n", msg);
ret = -1;