iuup_cn_node.c: use correct header for AMR SID frames
rx_data(): if iuup header (4 bytes) + amr payload (5 bytes) is 9 bytes
then it means that this is AMR SID (Comfort Noise Frame) and other
header should be used. The second byte of AMR header is set to 0x44.
diff --git a/src/libosmo-mgcp/iuup_cn_node.c b/src/libosmo-mgcp/iuup_cn_node.c
index fda7a7a..6a7e3b5 100644
--- a/src/libosmo-mgcp/iuup_cn_node.c
+++ b/src/libosmo-mgcp/iuup_cn_node.c
@@ -87,9 +87,12 @@
/* Remove the IuUP bit from the middle of the buffer by writing the RTP header forward. */
/* And append AMR 12.2k header "0xf03c". - AD HOC fix */
unsigned int pre_hdr_len = ((uint8_t*)hdr) - pdu->data;
+
+ int is_comfort_noise = ((pdu->len - pre_hdr_len) == 9);
+
memmove(pdu->data + sizeof(*hdr) - 2, pdu->data, pre_hdr_len);
((uint8_t*)hdr)[2] = 0xf0;
- ((uint8_t*)hdr)[3] = 0x3c;
+ ((uint8_t*)hdr)[3] = is_comfort_noise ? 0x44 : 0x3c;
msgb_pull(pdu, sizeof(*hdr) - 2);
LOGP(DIUUP, LOGL_DEBUG, "(%s) IuUP stripping IuUP header from RTP data\n", cn->name);
diff --git a/tests/iuup/iuup_test.c b/tests/iuup/iuup_test.c
index e6f2ca5..6144ac8 100644
--- a/tests/iuup/iuup_test.c
+++ b/tests/iuup/iuup_test.c
@@ -116,6 +116,13 @@
msgb_from_hex("IuUP-Data",
RTP_HEADER IUUP_HEADER RTP_PAYLOAD));
+ printf("\nReceive payload encapsulated in IuUP. Expecting rx_payload() of just RTP packet\n");
+ printf("i.e. should strip away " "0401479e" "\n");
+ expect_rx_payload = RTP_HEADER "f044" "26e9b851ee";
+ rx_pdu(cn,
+ msgb_from_hex("IuUP-Data",
+ RTP_HEADER "0401479e" "26e9b851ee"));
+
printf("\nTransmit RTP. Expecting tx_msg() with inserted IuUP header\n");
expect_tx_msg = RTP_HEADER "000002b3" RTP_PAYLOAD;
tx_payload(cn,
diff --git a/tests/iuup/iuup_test.ok b/tests/iuup/iuup_test.ok
index 8c473d6..8cc4f4f 100644
--- a/tests/iuup/iuup_test.ok
+++ b/tests/iuup/iuup_test.ok
@@ -20,6 +20,17 @@
ok: matches expected msg
rc=0
+Receive payload encapsulated in IuUP. Expecting rx_payload() of just RTP packet
+i.e. should strip away 0401479e
+ -PDU-> [IuUP]
+8060944c6256042c000101020401479e26e9b851ee
+rx_payload() invoked by iuup_cn!
+ [IuUP] -RTP->
+8060944c6256042c00010102f04426e9b851ee
+node_priv=0x2342
+ok: matches expected msg
+rc=0
+
Transmit RTP. Expecting tx_msg() with inserted IuUP header
[IuUP] <-RTP-
8060944c6256042c00010102f03c6cfb23bc46d18180c3e5ffe040045600005a7d35b625b80005fff03214ced0