pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-mgw/+/29873 )


Change subject: osmux: Rename function and pass msgb directly to it
......................................................................

osmux: Rename function and pass msgb directly to it

The new prefix now matches other related functions acting on an osmux
connection.
Pass the msgb to it so simplify new msgb copy.

Change-Id: I8c0121485d0c96f70fe8bcbdb150793d428183ff
---
M include/osmocom/mgcp/osmux.h
M src/libosmo-mgcp/mgcp_network.c
M src/libosmo-mgcp/mgcp_osmux.c
3 files changed, 10 insertions(+), 12 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/73/29873/1

diff --git a/include/osmocom/mgcp/osmux.h b/include/osmocom/mgcp/osmux.h
index 044a33f..4ea6da7 100644
--- a/include/osmocom/mgcp/osmux.h
+++ b/include/osmocom/mgcp/osmux.h
@@ -15,7 +15,7 @@
 int conn_osmux_enable(struct mgcp_conn_rtp *conn);
 void conn_osmux_disable(struct mgcp_conn_rtp *conn);
 int conn_osmux_event_rx_crcx_mdcx(struct mgcp_conn_rtp *conn);
-int osmux_xfrm_to_osmux(char *buf, int buf_len, struct mgcp_conn_rtp *conn);
+int conn_osmux_send_rtp(struct mgcp_conn_rtp *conn, struct msgb *msg);
 int osmux_send_dummy(struct mgcp_conn_rtp *conn);

 void osmux_cid_pool_get(uint8_t osmux_cid);
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index f8b68a8..194d9c1 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -1013,7 +1013,7 @@
                LOGPENDP(endp, DRTP, LOGL_DEBUG,
                         "endpoint type is MGCP_RTP_OSMUX, "
                         "using osmux_xfrm_to_osmux() to forward data through 
OSMUX\n");
-               return osmux_xfrm_to_osmux((char*)msgb_data(msg), 
msgb_length(msg), conn_dst);
+               return conn_osmux_send_rtp(conn_dst, msg);
        case MGCP_RTP_IUUP:
                if (proto == MGCP_PROTO_RTP) {
                        LOGPENDP(endp, DRTP, LOGL_DEBUG,
diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c
index 0fd1ba7..e1380ec 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -201,14 +201,13 @@
 }

 /*! send RTP packet through OSMUX connection.
- *  \param[in] buf rtp data
- *  \param[in] buf_len length of rtp data
  *  \param[in] conn associated RTP connection
+ *  \param[in] msg msgb containing an RTP AMR packet
  *  \returns 0 on success, -1 on ERROR */
-int osmux_xfrm_to_osmux(char *buf, int buf_len, struct mgcp_conn_rtp *conn)
+int conn_osmux_send_rtp(struct mgcp_conn_rtp *conn, struct msgb *msg)
 {
        int ret;
-       struct msgb *msg;
+       struct msgb *msg2;

        if (!conn->end.output_enabled) {
                rtpconn_osmux_rate_ctr_inc(conn, 
OSMUX_RTP_PACKETS_TX_DROPPED_CTR);
@@ -222,14 +221,13 @@
                return -1;
        }

-       msg = msgb_alloc(4096, "RTP");
-       if (!msg)
+       /* msg is not owned by us and will be freed by the caller stack upon 
return: */
+       msg2 = msgb_copy_c(conn->conn, msg, "osmux-rtp-send");
+       if (!msg2)
                return -1;

-       memcpy(msg->data, buf, buf_len);
-       msgb_put(msg, buf_len);

-       while ((ret = osmux_xfrm_input(conn->osmux.in, msg, 
conn->osmux.remote_cid)) > 0) {
+       while ((ret = osmux_xfrm_input(conn->osmux.in, msg2, 
conn->osmux.remote_cid)) > 0) {
                /* batch full, build and deliver it */
                osmux_xfrm_input_deliver(conn->osmux.in);
        }
@@ -237,7 +235,7 @@
                rtpconn_osmux_rate_ctr_inc(conn, 
OSMUX_RTP_PACKETS_TX_DROPPED_CTR);
        } else {
                rtpconn_osmux_rate_ctr_inc(conn, OSMUX_RTP_PACKETS_TX_CTR);
-               rtpconn_osmux_rate_ctr_add(conn, OSMUX_AMR_OCTETS_TX_CTR, 
buf_len - sizeof(struct rtp_hdr));
+               rtpconn_osmux_rate_ctr_add(conn, OSMUX_AMR_OCTETS_TX_CTR, 
msgb_length(msg2) - sizeof(struct rtp_hdr));
        }
        return 0;
 }

--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/29873
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I8c0121485d0c96f70fe8bcbdb150793d428183ff
Gerrit-Change-Number: 29873
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to