Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/29867 )
Change subject: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
......................................................................
Patch Set 1:
(1 comment)
File src/libosmo-mgcp/mgcp_osmux.c:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-398):
https://gerrit.osmocom.org/c/osmo-mgw/+/29867/comment/faa83a06_4cca9540
PS1, Line 229: memcpy(msg2->data, (char*)msgb_data(msg), msgb_length(msg));
"(foo*)" should be "(foo *)"
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/29867
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ifeec44241079f7a31da12745c92bfdc4fb222f3a
Gerrit-Change-Number: 29867
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Mon, 24 Oct 2022 16:33:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/29867 )
Change subject: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
......................................................................
osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
The Osmux implementation in libosmo-netif expects to work with RTP AMR
in octet-aligned mode. Therefore, if the peer connection received RTP
AMR in bandwidth-efficient mode, we need to convert it to octet-aligned
before feeding the packets to the osmux layer.
Related: SYS#6161
Change-Id: Ifeec44241079f7a31da12745c92bfdc4fb222f3a
---
M include/osmocom/mgcp/mgcp_network.h
M include/osmocom/mgcp/osmux.h
M src/libosmo-mgcp/mgcp_network.c
M src/libosmo-mgcp/mgcp_osmux.c
4 files changed, 20 insertions(+), 11 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/67/29867/1
diff --git a/include/osmocom/mgcp/mgcp_network.h b/include/osmocom/mgcp/mgcp_network.h
index a3d57f0..e95907d 100644
--- a/include/osmocom/mgcp/mgcp_network.h
+++ b/include/osmocom/mgcp/mgcp_network.h
@@ -183,3 +183,5 @@
int id);
void forward_data_tap(int fd, struct mgcp_rtp_tap *tap, struct msgb *msg);
uint32_t mgcp_get_current_ts(unsigned codec_rate);
+
+int amr_oa_bwe_convert(struct mgcp_endpoint *endp, struct msgb *msg, bool target_is_oa);
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 960b496..b4599f2 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -721,7 +721,7 @@
* efficient encoding scheme where all fields are packed together one after
* another and an octet aligned mode where all fields are aligned to octet
* boundaries. This function is used to convert between the two modes */
-static int amr_oa_bwe_convert(struct mgcp_endpoint *endp, struct msgb *msg,
+int amr_oa_bwe_convert(struct mgcp_endpoint *endp, struct msgb *msg,
bool target_is_oa)
{
/* NOTE: the msgb has an allocated length of RTP_BUF_SIZE, so there is
@@ -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..4e58452 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -205,10 +205,10 @@
* \param[in] buf_len length of rtp data
* \param[in] conn associated RTP connection
* \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 +222,21 @@
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_alloc(4096, "RTP");
+ if (!msg2)
return -1;
+ memcpy(msg2->data, (char*)msgb_data(msg), msgb_length(msg));
+ msgb_put(msg2, msgb_length(msg));
- memcpy(msg->data, buf, buf_len);
- msgb_put(msg, buf_len);
+ /* Osmux implementation works with AMR OA only, make sure we convert to it if needed: */
+ if (amr_oa_bwe_convert(conn->conn->endp, msg2, true) < 0) {
+ LOGPCONN(conn->conn, DOSMUX, LOGL_ERROR,
+ "Error converting to AMR octet-aligned mode\n");
+ return -1;
+ }
- 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 +244,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/+/29867
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ifeec44241079f7a31da12745c92bfdc4fb222f3a
Gerrit-Change-Number: 29867
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/29866 )
Change subject: cosmetic: Fix indentation whitespace
......................................................................
cosmetic: Fix indentation whitespace
Change-Id: Ia47d30aceee0db30b403575dd696c1bec2dcf271
---
M src/osmux_input.c
1 file changed, 3 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/66/29866/1
diff --git a/src/osmux_input.c b/src/osmux_input.c
index 2c18b20..3420e8b 100644
--- a/src/osmux_input.c
+++ b/src/osmux_input.c
@@ -563,9 +563,9 @@
return 0;
default:
/* The RTP payload type is dynamically allocated,
- * although we use static ones. Assume that we always
- * receive AMR traffic.
- */
+ * although we use static ones. Assume that we always
+ * receive AMR traffic.
+ */
/* Add this RTP to the OSMUX batch */
ret = osmux_batch_add(batch, h->batch_factor,
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/29866
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Ia47d30aceee0db30b403575dd696c1bec2dcf271
Gerrit-Change-Number: 29866
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/29864 )
Change subject: mgw: rx_rtp(): reorder checks and handlings
......................................................................
mgw: rx_rtp(): reorder checks and handlings
Let's first validate the origin of the message, then the content of the
message and finally execute whatever triggers are necessary.
Change-Id: I011a6d7d705768c32a35cec5cd7169725a21a670
---
M src/libosmo-mgcp/mgcp_network.c
1 file changed, 4 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/64/29864/1
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index f9c7a01..2a4a4eb 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -1510,7 +1510,9 @@
LOG_CONN_RTP(conn_src, LOGL_DEBUG, "rx_rtp(%u bytes)\n", msgb_length(msg));
- mgcp_conn_watchdog_kick(conn_src->conn);
+ /* Check if the origin of the RTP packet seems plausible */
+ if (!trunk->rtp_accept_all && check_rtp_origin(conn_src, from_addr))
+ return -1;
/* If AMR is configured for the ingress connection and conversion of the
* framing mode (octet-aligned vs. bandwith-efficient is explicitly
@@ -1530,9 +1532,7 @@
}
}
- /* Check if the origin of the RTP packet seems plausible */
- if (!trunk->rtp_accept_all && check_rtp_origin(conn_src, from_addr))
- return -1;
+ mgcp_conn_watchdog_kick(conn_src->conn);
/* Execute endpoint specific implementation that handles the
* dispatching of the RTP data */
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/29864
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I011a6d7d705768c32a35cec5cd7169725a21a670
Gerrit-Change-Number: 29864
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/29863 )
Change subject: mgw: reuse mgcp_codec_amr_mode_is_indicated() in mgcp_codec_amr_is_octet_aligned()
......................................................................
mgw: reuse mgcp_codec_amr_mode_is_indicated() in mgcp_codec_amr_is_octet_aligned()
mgcp_codec_amr_mode_is_indicated() has an extra check validating the
subtype is AMR, which is fine for all the callers of
mgcp_codec_amr_is_octet_aligned() (mgcp_iuup.c):
mgcp_conn_iuup_send_rtp: conn_rtp_src is explictly checked to be AMR
just before calling the function.
bridge_iuup_to_rtp_peer: conn_rtp_dst is expected to be an RTP_DEFAULT
conn using AMR.
Change-Id: I4c18510b59fd917ed033393994b21517bf753510
---
M src/libosmo-mgcp/mgcp_codec.c
1 file changed, 1 insertion(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/63/29863/1
diff --git a/src/libosmo-mgcp/mgcp_codec.c b/src/libosmo-mgcp/mgcp_codec.c
index 184ca43..849b0c8 100644
--- a/src/libosmo-mgcp/mgcp_codec.c
+++ b/src/libosmo-mgcp/mgcp_codec.c
@@ -369,9 +369,7 @@
*/
bool mgcp_codec_amr_is_octet_aligned(const struct mgcp_rtp_codec *codec)
{
- if (!codec->param_present)
- return false;
- if (!codec->param.amr_octet_aligned_present)
+ if (!mgcp_codec_amr_mode_is_indicated(codec))
return false;
return codec->param.amr_octet_aligned;
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/29863
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I4c18510b59fd917ed033393994b21517bf753510
Gerrit-Change-Number: 29863
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/29861 )
Change subject: Rename and move func checking if amr mode is explicitly configured
......................................................................
Rename and move func checking if amr mode is explicitly configured
The previous naming was quite confusing, since the function is not
really checking whether a conversion is needed, but rather whether the
codec has the AMR RTP mode defined explicitly and hence forced.
The previous naming didn't harm because the amr_oa_bwe_convert also
supports the conversion path OA<->OA and BE<->BE.
Hence nowadays the amr_oa_bwe_convert() function is called always if the
dst conn has its codec with AMR RTP mode explicitly set, no matter if
the src and dst conn have the same mode.
Related: SYS#6161
Change-Id: I8dce3038ebccf5e1e37e2908070a67d66693a96f
---
M include/osmocom/mgcp/mgcp_codec.h
M src/libosmo-mgcp/mgcp_codec.c
M src/libosmo-mgcp/mgcp_network.c
3 files changed, 15 insertions(+), 16 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/61/29861/1
diff --git a/include/osmocom/mgcp/mgcp_codec.h b/include/osmocom/mgcp/mgcp_codec.h
index 97e6b8d..a460809 100644
--- a/include/osmocom/mgcp/mgcp_codec.h
+++ b/include/osmocom/mgcp/mgcp_codec.h
@@ -17,4 +17,5 @@
int mgcp_codec_pt_translate(struct mgcp_conn_rtp *conn_src, struct mgcp_conn_rtp *conn_dst, int payload_type);
const struct mgcp_rtp_codec *mgcp_codec_pt_find_by_subtype_name(struct mgcp_conn_rtp *conn,
const char *subtype_name, unsigned int match_nr);
+bool mgcp_codec_amr_mode_is_indicated(const struct mgcp_rtp_codec *codec);
bool mgcp_codec_amr_is_octet_aligned(const struct mgcp_rtp_codec *codec);
diff --git a/src/libosmo-mgcp/mgcp_codec.c b/src/libosmo-mgcp/mgcp_codec.c
index 38aa0a7..184ca43 100644
--- a/src/libosmo-mgcp/mgcp_codec.c
+++ b/src/libosmo-mgcp/mgcp_codec.c
@@ -345,6 +345,18 @@
return -EINVAL;
}
+/* Check if the codec has a specific AMR mode (octet-aligned or bandwith-efficient) set. */
+bool mgcp_codec_amr_mode_is_indicated(const struct mgcp_rtp_codec *codec)
+{
+ if (codec->param_present == false)
+ return false;
+ if (!codec->param.amr_octet_aligned_present)
+ return false;
+ if (strcmp(codec->subtype_name, "AMR") != 0)
+ return false;
+ return true;
+}
+
/* Return true if octet-aligned is set in the given codec. Default to octet-aligned=0, i.e. bandwidth-efficient mode.
* See RFC4867 "RTP Payload Format for AMR and AMR-WB" sections "8.1. AMR Media Type Registration" and "8.2. AMR-WB
* Media Type Registration":
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 4ca4914..f9c7a01 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -769,20 +769,6 @@
return msgb_trim(msg, rc + sizeof(struct rtp_hdr));
}
-/* Check if a conversion between octet-aligned and bandwith-efficient mode is
- * indicated. */
-static bool amr_oa_bwe_convert_indicated(struct mgcp_rtp_codec *codec)
-{
- if (codec->param_present == false)
- return false;
- if (!codec->param.amr_octet_aligned_present)
- return false;
- if (strcmp(codec->subtype_name, "AMR") != 0)
- return false;
- return true;
-}
-
-
/* Return whether an RTP packet with AMR payload is in octet-aligned mode.
* Return 0 if in bandwidth-efficient mode, 1 for octet-aligned mode, and negative if the RTP data is invalid. */
static int amr_oa_check(char *data, int len)
@@ -1217,7 +1203,7 @@
if (mgcp_conn_rtp_is_iuup(conn_dst) || mgcp_conn_rtp_is_iuup(conn_src)) {
/* the iuup code will correctly transform to the correct AMR mode */
- } else if (amr_oa_bwe_convert_indicated(conn_dst->end.codec)) {
+ } else if (mgcp_codec_amr_mode_is_indicated(conn_dst->end.codec)) {
rc = amr_oa_bwe_convert(endp, msg,
conn_dst->end.codec->param.amr_octet_aligned);
if (rc < 0) {
@@ -1531,7 +1517,7 @@
* defined, then we check if the incoming payload matches that
* expectation. */
if (mc->proto == MGCP_PROTO_RTP &&
- amr_oa_bwe_convert_indicated(conn_src->end.codec)) {
+ mgcp_codec_amr_mode_is_indicated(conn_src->end.codec)) {
int oa = amr_oa_check((char*)msgb_data(msg), msgb_length(msg));
if (oa < 0)
return -1;
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/29861
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I8dce3038ebccf5e1e37e2908070a67d66693a96f
Gerrit-Change-Number: 29861
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange