<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/libosmo-abis/+/18382">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">TRAU frame RTP conversion<br><br>This adds code that converts codec frames between (decoded) TRAU format<br>and RTP payload format.  The FR + EFR functions have been lifted from<br>OsmoNITB and exended slightly.<br><br>The HR functions have been written from scratch. There is also<br>incomplete code for AMR that needs to be completed + tested.<br><br>Change-Id: I7f6993cce2b95318203043e2e14952e581941b79<br>---<br>M include/Makefile.am<br>A include/osmocom/trau/trau_rtp.h<br>M src/Makefile.am<br>A src/trau/trau_rtp_conv.c<br>4 files changed, 694 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/Makefile.am b/include/Makefile.am</span><br><span>index 2a99211..70f1cd6 100644</span><br><span>--- a/include/Makefile.am</span><br><span>+++ b/include/Makefile.am</span><br><span>@@ -6,4 +6,5 @@</span><br><span>  osmocom/abis/lapd.h osmocom/abis/lapd_pcap.h osmocom/trau/osmo_ortp.h     \</span><br><span>  osmocom/abis/unixsocket_proto.h \</span><br><span>  osmocom/trau/trau_frame.h \</span><br><span style="color: hsl(0, 100%, 40%);">- osmocom/trau/trau_sync.h</span><br><span style="color: hsl(120, 100%, 40%);">+ osmocom/trau/trau_sync.h \</span><br><span style="color: hsl(120, 100%, 40%);">+ osmocom/trau/trau_rtp.h</span><br><span>diff --git a/include/osmocom/trau/trau_rtp.h b/include/osmocom/trau/trau_rtp.h</span><br><span>new file mode 100644</span><br><span>index 0000000..f02d43e</span><br><span>--- /dev/null</span><br><span>+++ b/include/osmocom/trau/trau_rtp.h</span><br><span>@@ -0,0 +1,34 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/* TRAU frame to RTP conversion */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* (C) 2009,2020 by Harald Welte <laforge@gnumonks.org></span><br><span style="color: hsl(120, 100%, 40%);">+ * All Rights Reserved</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * SPDX-License-Identifier: GPL-2.0+</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; either version 2 of the License, or</span><br><span style="color: hsl(120, 100%, 40%);">+ * (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU General Public License</span><br><span style="color: hsl(120, 100%, 40%);">+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/trau/trau_frame.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct osmo_trau2rtp_state {</span><br><span style="color: hsl(120, 100%, 40%);">+ enum osmo_trau_frame_type type;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int osmo_trau2rtp(uint8_t *out, size_t out_len, const struct osmo_trau_frame *tf,</span><br><span style="color: hsl(120, 100%, 40%);">+              struct osmo_trau2rtp_state *st);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int osmo_rtp2trau(struct osmo_trau_frame *tf, const uint8_t *rtp, size_t rtp_len,</span><br><span style="color: hsl(120, 100%, 40%);">+                 struct osmo_trau2rtp_state *st);</span><br><span>diff --git a/src/Makefile.am b/src/Makefile.am</span><br><span>index 0134b00..4254428 100644</span><br><span>--- a/src/Makefile.am</span><br><span>+++ b/src/Makefile.am</span><br><span>@@ -37,6 +37,7 @@</span><br><span> libosmotrau_la_LIBADD = $(COMMONLIBS) $(ORTP_LIBS)</span><br><span> libosmotrau_la_SOURCES = trau/osmo_ortp.c \</span><br><span>                          trau/trau_frame.c \</span><br><span style="color: hsl(0, 100%, 40%);">-                     trau/trau_sync.c</span><br><span style="color: hsl(120, 100%, 40%);">+                      trau/trau_sync.c \</span><br><span style="color: hsl(120, 100%, 40%);">+                    trau/trau_rtp_conv.c</span><br><span> </span><br><span> noinst_HEADERS = trau/ubit_buf.h</span><br><span>diff --git a/src/trau/trau_rtp_conv.c b/src/trau/trau_rtp_conv.c</span><br><span>new file mode 100644</span><br><span>index 0000000..ebbdbef</span><br><span>--- /dev/null</span><br><span>+++ b/src/trau/trau_rtp_conv.c</span><br><span>@@ -0,0 +1,656 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/* TRAU frame to RTP conversion */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* (C) 2009,2020 by Harald Welte <laforge@gnumonks.org></span><br><span style="color: hsl(120, 100%, 40%);">+ * All Rights Reserved</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * SPDX-License-Identifier: GPL-2.0+</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; either version 2 of the License, or</span><br><span style="color: hsl(120, 100%, 40%);">+ * (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU General Public License</span><br><span style="color: hsl(120, 100%, 40%);">+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <errno.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdlib.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <string.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/crc8gen.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/codec/codec.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/trau/trau_frame.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/trau/trau_rtp.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* this corresponds to the bit-lengths of the individual codec</span><br><span style="color: hsl(120, 100%, 40%);">+ * parameters as indicated in Table 1.1 of TS 46.010 */</span><br><span style="color: hsl(120, 100%, 40%);">+static const uint8_t gsm_fr_map[] = {</span><br><span style="color: hsl(120, 100%, 40%);">+      6, 6, 5, 5, 4, 4, 3, 3,</span><br><span style="color: hsl(120, 100%, 40%);">+       7, 2, 2, 6, 3, 3, 3, 3,</span><br><span style="color: hsl(120, 100%, 40%);">+       3, 3, 3, 3, 3, 3, 3, 3,</span><br><span style="color: hsl(120, 100%, 40%);">+       3, 7, 2, 2, 6, 3, 3, 3,</span><br><span style="color: hsl(120, 100%, 40%);">+       3, 3, 3, 3, 3, 3, 3, 3,</span><br><span style="color: hsl(120, 100%, 40%);">+       3, 3, 7, 2, 2, 6, 3, 3,</span><br><span style="color: hsl(120, 100%, 40%);">+       3, 3, 3, 3, 3, 3, 3, 3,</span><br><span style="color: hsl(120, 100%, 40%);">+       3, 3, 3, 7, 2, 2, 6, 3,</span><br><span style="color: hsl(120, 100%, 40%);">+       3, 3, 3, 3, 3, 3, 3, 3,</span><br><span style="color: hsl(120, 100%, 40%);">+       3, 3, 3, 3</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * EFR TRAU parity</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * g(x) = x^3 + x^1 + 1</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+static const struct osmo_crc8gen_code gsm0860_efr_crc3 = {</span><br><span style="color: hsl(120, 100%, 40%);">+      .bits = 3,</span><br><span style="color: hsl(120, 100%, 40%);">+    .poly = 0x3,</span><br><span style="color: hsl(120, 100%, 40%);">+  .init = 0x0,</span><br><span style="color: hsl(120, 100%, 40%);">+  .remainder = 0x7,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* re-combine EFR parity bits */</span><br><span style="color: hsl(120, 100%, 40%);">+static inline void efr_parity_bits_1(ubit_t *check_bits, const ubit_t *d_bits)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  memcpy(check_bits + 0 , d_bits + 0, 22);</span><br><span style="color: hsl(120, 100%, 40%);">+      memcpy(check_bits + 22 , d_bits + 24, 3);</span><br><span style="color: hsl(120, 100%, 40%);">+     check_bits[25] = d_bits[28];</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static inline void efr_parity_bits_2(ubit_t *check_bits, const ubit_t *d_bits)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  memcpy(check_bits + 0 , d_bits + 42, 10);</span><br><span style="color: hsl(120, 100%, 40%);">+     memcpy(check_bits + 10 , d_bits + 90, 2);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static inline void efr_parity_bits_3(ubit_t *check_bits, const ubit_t *d_bits)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     memcpy(check_bits + 0 , d_bits + 98, 5);</span><br><span style="color: hsl(120, 100%, 40%);">+      check_bits[5] = d_bits[104];</span><br><span style="color: hsl(120, 100%, 40%);">+  memcpy(check_bits + 6 , d_bits + 143, 2);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static inline void efr_parity_bits_4(ubit_t *check_bits, const ubit_t *d_bits)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     memcpy(check_bits + 0 , d_bits + 151, 10);</span><br><span style="color: hsl(120, 100%, 40%);">+    memcpy(check_bits + 10 , d_bits + 199, 2);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static inline void efr_parity_bits_5(ubit_t *check_bits, const ubit_t *d_bits)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    memcpy(check_bits + 0 , d_bits + 207, 5);</span><br><span style="color: hsl(120, 100%, 40%);">+     check_bits[5] = d_bits[213];</span><br><span style="color: hsl(120, 100%, 40%);">+  memcpy(check_bits + 6 , d_bits + 252, 2);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+//static const uint8_t c_bits_check_fr[] = { 0, 0, 0, 1, 0 };</span><br><span style="color: hsl(120, 100%, 40%);">+//static const uint8_t c_bits_check_efr[] = { 1, 1, 0, 1, 0 };</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Generate the 33 bytes RTP payload for GSM-FR from a decoded TRAU frame.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[out] out caller-provided output buffer</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] out_len length of out buffer in bytes</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] fr input TRAU frame in decoded form</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns number of bytes generated in 'out'; negative on error. */</span><br><span style="color: hsl(120, 100%, 40%);">+static int trau2rtp_fr(uint8_t *out, size_t out_len, const struct osmo_trau_frame *tf)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  int i, j, k, l, o;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  if (tf->type != OSMO_TRAU16_FT_FR)</span><br><span style="color: hsl(120, 100%, 40%);">+         return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* FR Data Bits according to TS 48.060 Section 5.5.1.1.2 */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (tf->c_bits[11]) /* BFI */</span><br><span style="color: hsl(120, 100%, 40%);">+              return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (out_len < GSM_FR_BYTES)</span><br><span style="color: hsl(120, 100%, 40%);">+                return -ENOSPC;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     out[0] = 0xd << 4;</span><br><span style="color: hsl(120, 100%, 40%);">+      /* reassemble d-bits */</span><br><span style="color: hsl(120, 100%, 40%);">+       i = 0; /* counts bits */</span><br><span style="color: hsl(120, 100%, 40%);">+      j = 4; /* counts output bits */</span><br><span style="color: hsl(120, 100%, 40%);">+       k = gsm_fr_map[0]-1; /* current number bit in element */</span><br><span style="color: hsl(120, 100%, 40%);">+      l = 0; /* counts element bits */</span><br><span style="color: hsl(120, 100%, 40%);">+      o = 0; /* offset input bits */</span><br><span style="color: hsl(120, 100%, 40%);">+        while (i < 260) {</span><br><span style="color: hsl(120, 100%, 40%);">+          out[j/8] |= (tf->d_bits[k+o] << (7-(j%8)));</span><br><span style="color: hsl(120, 100%, 40%);">+          /* to avoid out-of-bounds access in gsm_fr_map[++l] */</span><br><span style="color: hsl(120, 100%, 40%);">+                if (i == 259)</span><br><span style="color: hsl(120, 100%, 40%);">+                 break;</span><br><span style="color: hsl(120, 100%, 40%);">+                if (--k < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     o += gsm_fr_map[l];</span><br><span style="color: hsl(120, 100%, 40%);">+                   k = gsm_fr_map[++l]-1;</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span style="color: hsl(120, 100%, 40%);">+             i++;</span><br><span style="color: hsl(120, 100%, 40%);">+          j++;</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return GSM_FR_BYTES;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* See Section 5.2 of RFC5993 */</span><br><span style="color: hsl(120, 100%, 40%);">+enum rtp_hr_ietf_ft {</span><br><span style="color: hsl(120, 100%, 40%);">+    FT_GOOD_SPEECH  = 0,</span><br><span style="color: hsl(120, 100%, 40%);">+  FT_GOOD_SID     = 2,</span><br><span style="color: hsl(120, 100%, 40%);">+  FT_NO_DATA      = 7,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static const uint8_t rtp_hr_sid[14] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Generate the 14 bytes ETSI TS 101 318 RTP payload for HR from a decoded 16k TRAU frame.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  Note that thsi differs from the IETF RFC5993 format.  However, as OsmoBTS implements</span><br><span style="color: hsl(120, 100%, 40%);">+ *  the TS 101 318 format, we also use the same format here. osmo-mgw can convert them.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[out] out caller-provided output buffer</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] out_len length of out buffer in bytes</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] tf input TRAU frame in decoded form</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns number of bytes generated in 'out'; negative on error. */</span><br><span style="color: hsl(120, 100%, 40%);">+static int trau2rtp_hr16(uint8_t *out, size_t out_len, const struct osmo_trau_frame *tf)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int i;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     if (tf->type != OSMO_TRAU16_FT_HR)</span><br><span style="color: hsl(120, 100%, 40%);">+         return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* HR Data Bits according to TS 48.061 Section 5.1.4.1.1 */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (tf->dir == OSMO_TRAU_DIR_UL && tf->c_bits[11]) /* C12: BFI */</span><br><span style="color: hsl(120, 100%, 40%);">+               goto bad_frame;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     if (out_len < GSM_HR_BYTES)</span><br><span style="color: hsl(120, 100%, 40%);">+                return -ENOSPC;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* TS 101 318 Section 5.2: The order of occurrence of the codec parameters in the buffer is</span><br><span style="color: hsl(120, 100%, 40%);">+    * the same as order of occurrence over the Abis as defined in annex B of ETS 300 969</span><br><span style="color: hsl(120, 100%, 40%);">+  * [which is 3GPP TS 46.020 */</span><br><span style="color: hsl(120, 100%, 40%);">+        osmo_ubit2pbit(out, tf->d_bits, 112);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    if (tf->c_bits[12] || tf->c_bits[13]) {</span><br><span style="color: hsl(120, 100%, 40%);">+         /* Generate SID frame as per TS 101 318 Section 5.2.2 */</span><br><span style="color: hsl(120, 100%, 40%);">+              for (i = 0; i < sizeof(rtp_hr_sid); i++)</span><br><span style="color: hsl(120, 100%, 40%);">+                   out[i] = out[i] | rtp_hr_sid[i];</span><br><span style="color: hsl(120, 100%, 40%);">+      }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return GSM_HR_BYTES;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+bad_frame:</span><br><span style="color: hsl(120, 100%, 40%);">+    return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Generate the 31 bytes RTP payload for GSM-EFR from a decoded TRAU frame.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[out] out caller-provided output buffer</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] out_len length of out buffer in bytes</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] fr input TRAU frame in decoded form</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns number of bytes generated in 'out'; negative on error. */</span><br><span style="color: hsl(120, 100%, 40%);">+static int trau2rtp_efr(uint8_t *out, size_t out_len, const struct osmo_trau_frame *tf)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ int i, j, rc;</span><br><span style="color: hsl(120, 100%, 40%);">+ ubit_t check_bits[26];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      if (tf->type != OSMO_TRAU16_FT_EFR)</span><br><span style="color: hsl(120, 100%, 40%);">+                return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* FR Data Bits according to TS 48.060 Section 5.5.1.1.2 */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (tf->c_bits[11]) /* BFI */</span><br><span style="color: hsl(120, 100%, 40%);">+              return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (out_len < GSM_EFR_BYTES)</span><br><span style="color: hsl(120, 100%, 40%);">+               return -ENOSPC;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     if (tf->c_bits[11]) /* BFI */</span><br><span style="color: hsl(120, 100%, 40%);">+              goto bad_frame;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     out[0] = 0xc << 4;</span><br><span style="color: hsl(120, 100%, 40%);">+      /* reassemble d-bits */</span><br><span style="color: hsl(120, 100%, 40%);">+       for (i = 1, j = 4; i < 39; i++, j++)</span><br><span style="color: hsl(120, 100%, 40%);">+               out[j/8] |= (tf->d_bits[i] << (7-(j%8)));</span><br><span style="color: hsl(120, 100%, 40%);">+    efr_parity_bits_1(check_bits, tf->d_bits);</span><br><span style="color: hsl(120, 100%, 40%);">+ rc = osmo_crc8gen_check_bits(&gsm0860_efr_crc3, check_bits, 26,</span><br><span style="color: hsl(120, 100%, 40%);">+                   tf->d_bits + 39);</span><br><span style="color: hsl(120, 100%, 40%);">+  if (rc)</span><br><span style="color: hsl(120, 100%, 40%);">+               goto bad_frame;</span><br><span style="color: hsl(120, 100%, 40%);">+       for (i = 42, j = 42; i < 95; i++, j++)</span><br><span style="color: hsl(120, 100%, 40%);">+             out[j/8] |= (tf->d_bits[i] << (7-(j%8)));</span><br><span style="color: hsl(120, 100%, 40%);">+    efr_parity_bits_2(check_bits, tf->d_bits);</span><br><span style="color: hsl(120, 100%, 40%);">+ rc = osmo_crc8gen_check_bits(&gsm0860_efr_crc3, check_bits, 12,</span><br><span style="color: hsl(120, 100%, 40%);">+                   tf->d_bits + 95);</span><br><span style="color: hsl(120, 100%, 40%);">+  if (rc)</span><br><span style="color: hsl(120, 100%, 40%);">+               goto bad_frame;</span><br><span style="color: hsl(120, 100%, 40%);">+       for (i = 98, j = 95; i < 148; i++, j++)</span><br><span style="color: hsl(120, 100%, 40%);">+            out[j/8] |= (tf->d_bits[i] << (7-(j%8)));</span><br><span style="color: hsl(120, 100%, 40%);">+    efr_parity_bits_3(check_bits, tf->d_bits);</span><br><span style="color: hsl(120, 100%, 40%);">+ rc = osmo_crc8gen_check_bits(&gsm0860_efr_crc3, check_bits, 8,</span><br><span style="color: hsl(120, 100%, 40%);">+                    tf->d_bits + 148);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (rc)</span><br><span style="color: hsl(120, 100%, 40%);">+               goto bad_frame;</span><br><span style="color: hsl(120, 100%, 40%);">+       for (i = 151, j = 145; i < 204; i++, j++)</span><br><span style="color: hsl(120, 100%, 40%);">+          out[j/8] |= (tf->d_bits[i] << (7-(j%8)));</span><br><span style="color: hsl(120, 100%, 40%);">+    efr_parity_bits_4(check_bits, tf->d_bits);</span><br><span style="color: hsl(120, 100%, 40%);">+ rc = osmo_crc8gen_check_bits(&gsm0860_efr_crc3, check_bits, 12,</span><br><span style="color: hsl(120, 100%, 40%);">+                   tf->d_bits + 204);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (rc)</span><br><span style="color: hsl(120, 100%, 40%);">+               goto bad_frame;</span><br><span style="color: hsl(120, 100%, 40%);">+       for (i = 207, j = 198; i < 257; i++, j++)</span><br><span style="color: hsl(120, 100%, 40%);">+          out[j/8] |= (tf->d_bits[i] << (7-(j%8)));</span><br><span style="color: hsl(120, 100%, 40%);">+    efr_parity_bits_5(check_bits, tf->d_bits);</span><br><span style="color: hsl(120, 100%, 40%);">+ rc = osmo_crc8gen_check_bits(&gsm0860_efr_crc3, check_bits, 8,</span><br><span style="color: hsl(120, 100%, 40%);">+                    tf->d_bits + 257);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (rc)</span><br><span style="color: hsl(120, 100%, 40%);">+               goto bad_frame;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     return GSM_EFR_BYTES;</span><br><span style="color: hsl(120, 100%, 40%);">+bad_frame:</span><br><span style="color: hsl(120, 100%, 40%);">+     return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* TS 48.060 Section 5.5.1.1.2 */</span><br><span style="color: hsl(120, 100%, 40%);">+static int rtp2trau_fr(struct osmo_trau_frame *tf, const uint8_t *data, size_t data_len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        int i, j, k, l, o;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  /* data_len == 0 for BFI frame */</span><br><span style="color: hsl(120, 100%, 40%);">+     if (data_len < GSM_FR_BYTES && data_len != 0)</span><br><span style="color: hsl(120, 100%, 40%);">+              return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     if (data_len && data[0] >> 4 != 0xd)</span><br><span style="color: hsl(120, 100%, 40%);">+            return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     tf->type = OSMO_TRAU16_FT_FR;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    /* FR Data Bits according to TS 48.060 Section 5.5.1.1.2 */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* FIXME: Generate SID frames? */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* set c-bits and t-bits */</span><br><span style="color: hsl(120, 100%, 40%);">+   if (tf->dir == OSMO_TRAU_DIR_UL) {</span><br><span style="color: hsl(120, 100%, 40%);">+         /* C1 .. C5 */</span><br><span style="color: hsl(120, 100%, 40%);">+                tf->c_bits[0] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[1] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[2] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[3] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[4] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              /* C1 .. C5 */</span><br><span style="color: hsl(120, 100%, 40%);">+                tf->c_bits[0] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[1] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[2] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[3] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[4] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+     memset(&tf->c_bits[5], 0, 6);    /* C6 .. C11: Time Alignment */</span><br><span style="color: hsl(120, 100%, 40%);">+       if (tf->dir == OSMO_TRAU_DIR_UL) {</span><br><span style="color: hsl(120, 100%, 40%);">+         if (data_len == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+                    tf->c_bits[11] = 1;  /* C12: BFI */</span><br><span style="color: hsl(120, 100%, 40%);">+                else</span><br><span style="color: hsl(120, 100%, 40%);">+                  tf->c_bits[11] = 0;  /* C12: BFI */</span><br><span style="color: hsl(120, 100%, 40%);">+                tf->c_bits[12] = 0; /* C13: SID=0 */</span><br><span style="color: hsl(120, 100%, 40%);">+               tf->c_bits[13] = 0; /* C14: SID=0 */</span><br><span style="color: hsl(120, 100%, 40%);">+               tf->c_bits[14] = 0; /* C15: TAF (SACCH or not) */</span><br><span style="color: hsl(120, 100%, 40%);">+          tf->c_bits[15] = 1; /* C16: spare */</span><br><span style="color: hsl(120, 100%, 40%);">+               tf->c_bits[16] = 0; /* C17: DTXd not applied */</span><br><span style="color: hsl(120, 100%, 40%);">+    } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              memset(&tf->c_bits[11], 1, 10); /* C12 .. C15: spare */</span><br><span style="color: hsl(120, 100%, 40%);">+                tf->c_bits[15] = 1; /* C16: SP=1 */</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span style="color: hsl(120, 100%, 40%);">+     memset(&tf->c_bits[17], 1, 4); /* C18 .. C12: spare */</span><br><span style="color: hsl(120, 100%, 40%);">+ memset(&tf->t_bits[0], 1, 4);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        if (!data_len)</span><br><span style="color: hsl(120, 100%, 40%);">+                return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* reassemble d-bits */</span><br><span style="color: hsl(120, 100%, 40%);">+       i = 0; /* counts bits */</span><br><span style="color: hsl(120, 100%, 40%);">+      j = 4; /* counts input bits */</span><br><span style="color: hsl(120, 100%, 40%);">+        k = gsm_fr_map[0]-1; /* current number bit in element */</span><br><span style="color: hsl(120, 100%, 40%);">+      l = 0; /* counts element bits */</span><br><span style="color: hsl(120, 100%, 40%);">+      o = 0; /* offset output bits */</span><br><span style="color: hsl(120, 100%, 40%);">+       while (i < 260) {</span><br><span style="color: hsl(120, 100%, 40%);">+          tf->d_bits[k+o] = (data[j/8] >> (7-(j%8))) & 1;</span><br><span style="color: hsl(120, 100%, 40%);">+          /* to avoid out-of-bounds access in gsm_fr_map[++l] */</span><br><span style="color: hsl(120, 100%, 40%);">+                if (i == 259)</span><br><span style="color: hsl(120, 100%, 40%);">+                 break;</span><br><span style="color: hsl(120, 100%, 40%);">+                if (--k < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     o += gsm_fr_map[l];</span><br><span style="color: hsl(120, 100%, 40%);">+                   k = gsm_fr_map[++l]-1;</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span style="color: hsl(120, 100%, 40%);">+             i++;</span><br><span style="color: hsl(120, 100%, 40%);">+          j++;</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* does the RTP HR payload resemble a SID frame or not */</span><br><span style="color: hsl(120, 100%, 40%);">+static bool is_rtp_hr_sid(const uint8_t *data, const uint8_t data_len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  int i;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      if (data_len < GSM_HR_BYTES)</span><br><span style="color: hsl(120, 100%, 40%);">+               return false;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       for (i = 0; i < GSM_HR_BYTES; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+               if ((data[i] & rtp_hr_sid[i]) != rtp_hr_sid[i])</span><br><span style="color: hsl(120, 100%, 40%);">+                   return false;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+     return true;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static int rtp2trau_hr16(struct osmo_trau_frame *tf, const uint8_t *data, size_t data_len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      if (data_len < GSM_HR_BYTES && data_len != 0)</span><br><span style="color: hsl(120, 100%, 40%);">+              return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     tf->type = OSMO_TRAU16_FT_HR;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    if (tf->dir == OSMO_TRAU_DIR_UL) {</span><br><span style="color: hsl(120, 100%, 40%);">+         /* C1 .. C5 */</span><br><span style="color: hsl(120, 100%, 40%);">+                tf->c_bits[0] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[1] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[2] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[3] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[4] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              /* C1 .. C5 */</span><br><span style="color: hsl(120, 100%, 40%);">+                tf->c_bits[0] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[1] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[2] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[3] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[4] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+     /* C6.. C11: Time Alignment */</span><br><span style="color: hsl(120, 100%, 40%);">+        memset(tf->c_bits + 5, 0, 6);</span><br><span style="color: hsl(120, 100%, 40%);">+      if (tf->dir == OSMO_TRAU_DIR_UL) {</span><br><span style="color: hsl(120, 100%, 40%);">+         /* BFI */</span><br><span style="color: hsl(120, 100%, 40%);">+             if (data_len == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+                    tf->c_bits[11] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+                else</span><br><span style="color: hsl(120, 100%, 40%);">+                  tf->c_bits[11] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+                if (is_rtp_hr_sid(data, data_len)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                  /* SID=2 is a valid SID frame */</span><br><span style="color: hsl(120, 100%, 40%);">+                      tf->c_bits[12] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+                        tf->c_bits[13] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+                } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                      tf->c_bits[12] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+                        tf->c_bits[13] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span style="color: hsl(120, 100%, 40%);">+             /* FIXME: C15: TAF */</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[15] = 0; /* C16: SP */</span><br><span style="color: hsl(120, 100%, 40%);">+          tf->c_bits[16] = 0; /* C17: DTXd shall not be applied */</span><br><span style="color: hsl(120, 100%, 40%);">+   } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              tf->c_bits[11] = 0; /* C12: UFE */</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[12] = 1; /* C13: spare */</span><br><span style="color: hsl(120, 100%, 40%);">+               tf->c_bits[13] = 1; /* C14: spare */</span><br><span style="color: hsl(120, 100%, 40%);">+               tf->c_bits[14] = 1; /* C15: spare */</span><br><span style="color: hsl(120, 100%, 40%);">+               if (is_rtp_hr_sid(data, data_len))</span><br><span style="color: hsl(120, 100%, 40%);">+                    tf->c_bits[15] = 0; /* C16: SP */</span><br><span style="color: hsl(120, 100%, 40%);">+          else</span><br><span style="color: hsl(120, 100%, 40%);">+                  tf->c_bits[15] = 1; /* C16: SP */</span><br><span style="color: hsl(120, 100%, 40%);">+          tf->c_bits[16] = 1; /* C17: spare */</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+     memset(tf->c_bits+17, 1, 4); /* C18..C21: spare */</span><br><span style="color: hsl(120, 100%, 40%);">+ memset(&tf->t_bits[0], 1, 4);</span><br><span style="color: hsl(120, 100%, 40%);">+  if (tf->dir == OSMO_TRAU_DIR_UL)</span><br><span style="color: hsl(120, 100%, 40%);">+           tf->ufi = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+       else</span><br><span style="color: hsl(120, 100%, 40%);">+          tf->ufi = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+       /* CRC is computed by TRAU frame encoder */</span><br><span style="color: hsl(120, 100%, 40%);">+   if (data_len)</span><br><span style="color: hsl(120, 100%, 40%);">+         memcpy(tf->d_bits, data, GSM_HR_BYTES);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* TS 48.060 Section 5.5.1.1.2 */</span><br><span style="color: hsl(120, 100%, 40%);">+static int rtp2trau_efr(struct osmo_trau_frame *tf, const uint8_t *data, size_t data_len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       int i, j;</span><br><span style="color: hsl(120, 100%, 40%);">+     ubit_t check_bits[26];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      /* data_len == 0 for BFI frame */</span><br><span style="color: hsl(120, 100%, 40%);">+     if (data_len < GSM_EFR_BYTES && data_len != 0)</span><br><span style="color: hsl(120, 100%, 40%);">+             return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     if (data_len && data[0] >> 4 != 0xc)</span><br><span style="color: hsl(120, 100%, 40%);">+            return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     tf->type = OSMO_TRAU16_FT_EFR;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* FR Data Bits according to TS 48.060 Section 5.5.1.1.2 */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* set c-bits and t-bits */</span><br><span style="color: hsl(120, 100%, 40%);">+   tf->c_bits[0] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ tf->c_bits[1] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ tf->c_bits[2] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ tf->c_bits[3] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ tf->c_bits[4] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       memset(&tf->c_bits[5], 0, 6); /* C6 .. C11: Time Alignment */</span><br><span style="color: hsl(120, 100%, 40%);">+  if (tf->dir == OSMO_TRAU_DIR_UL) {</span><br><span style="color: hsl(120, 100%, 40%);">+         if (data_len == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+                    tf->c_bits[11] = 1; /* C12: BFI=1 */</span><br><span style="color: hsl(120, 100%, 40%);">+               else</span><br><span style="color: hsl(120, 100%, 40%);">+                  tf->c_bits[11] = 0; /* C12: BFI=1 */</span><br><span style="color: hsl(120, 100%, 40%);">+               /* FIXME: Generate SID frames? */</span><br><span style="color: hsl(120, 100%, 40%);">+             tf->c_bits[12] = 0; /* C13: SID=0 */</span><br><span style="color: hsl(120, 100%, 40%);">+               tf->c_bits[13] = 0; /* C14: SID=0 */</span><br><span style="color: hsl(120, 100%, 40%);">+               tf->c_bits[14] = 0; /* C15: TAF (SACCH) */</span><br><span style="color: hsl(120, 100%, 40%);">+         tf->c_bits[15] = 1; /* C16: spare */</span><br><span style="color: hsl(120, 100%, 40%);">+               tf->c_bits[16] = 0; /* C17: DTXd applied */</span><br><span style="color: hsl(120, 100%, 40%);">+        } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              tf->c_bits[11] = 1; /* C12: UFE (good uplink) */</span><br><span style="color: hsl(120, 100%, 40%);">+           memset(&tf->c_bits[12], 1, 3);   /* C13 .. C15: spare */</span><br><span style="color: hsl(120, 100%, 40%);">+               tf->c_bits[15] = 1; /* C16: SP=1 */</span><br><span style="color: hsl(120, 100%, 40%);">+                tf->c_bits[16] = 1; /* C17: spare */</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+     memset(&tf->c_bits[17], 1, 4);   /* C18 .. C21: spare */</span><br><span style="color: hsl(120, 100%, 40%);">+       memset(&tf->t_bits[0], 1, 4);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        if (data_len == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+            return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* reassemble d-bits */</span><br><span style="color: hsl(120, 100%, 40%);">+       tf->d_bits[0] = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ for (i = 1, j = 4; i < 39; i++, j++)</span><br><span style="color: hsl(120, 100%, 40%);">+               tf->d_bits[i] = (data[j/8] >> (7-(j%8))) & 1;</span><br><span style="color: hsl(120, 100%, 40%);">+    efr_parity_bits_1(check_bits, tf->d_bits);</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_crc8gen_set_bits(&gsm0860_efr_crc3, check_bits, 26,</span><br><span style="color: hsl(120, 100%, 40%);">+                  tf->d_bits + 39);</span><br><span style="color: hsl(120, 100%, 40%);">+  for (i = 42, j = 42; i < 95; i++, j++)</span><br><span style="color: hsl(120, 100%, 40%);">+             tf->d_bits[i] = (data[j/8] >> (7-(j%8))) & 1;</span><br><span style="color: hsl(120, 100%, 40%);">+    efr_parity_bits_2(check_bits, tf->d_bits);</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_crc8gen_set_bits(&gsm0860_efr_crc3, check_bits, 12,</span><br><span style="color: hsl(120, 100%, 40%);">+                  tf->d_bits + 95);</span><br><span style="color: hsl(120, 100%, 40%);">+  for (i = 98, j = 95; i < 148; i++, j++)</span><br><span style="color: hsl(120, 100%, 40%);">+            tf->d_bits[i] = (data[j/8] >> (7-(j%8))) & 1;</span><br><span style="color: hsl(120, 100%, 40%);">+    efr_parity_bits_3(check_bits, tf->d_bits);</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_crc8gen_set_bits(&gsm0860_efr_crc3, check_bits, 8,</span><br><span style="color: hsl(120, 100%, 40%);">+                   tf->d_bits + 148);</span><br><span style="color: hsl(120, 100%, 40%);">+ for (i = 151, j = 145; i < 204; i++, j++)</span><br><span style="color: hsl(120, 100%, 40%);">+          tf->d_bits[i] = (data[j/8] >> (7-(j%8))) & 1;</span><br><span style="color: hsl(120, 100%, 40%);">+    efr_parity_bits_4(check_bits, tf->d_bits);</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_crc8gen_set_bits(&gsm0860_efr_crc3, check_bits, 12,</span><br><span style="color: hsl(120, 100%, 40%);">+                  tf->d_bits + 204);</span><br><span style="color: hsl(120, 100%, 40%);">+ for (i = 207, j = 198; i < 257; i++, j++)</span><br><span style="color: hsl(120, 100%, 40%);">+          tf->d_bits[i] = (data[j/8] >> (7-(j%8))) & 1;</span><br><span style="color: hsl(120, 100%, 40%);">+    efr_parity_bits_5(check_bits, tf->d_bits);</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_crc8gen_set_bits(&gsm0860_efr_crc3, check_bits, 8,</span><br><span style="color: hsl(120, 100%, 40%);">+                   tf->d_bits + 257);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#if 0</span><br><span style="color: hsl(120, 100%, 40%);">+static inline memcpy_inc(uint8_t *out, const uint8_t *in, size_t len, unsigned int *idx)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    memcpy_inc(out, in, len);</span><br><span style="color: hsl(120, 100%, 40%);">+     *idx += len;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static int amr_speech_extract_sbits(ubit_t *s_bits, const struct osmo_trau_frame *tf,</span><br><span style="color: hsl(120, 100%, 40%);">+                                  enum osmo_amr_mode mode)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       unsigned int s_idx = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     switch (mode) {</span><br><span style="color: hsl(120, 100%, 40%);">+       case AMR_4_75:</span><br><span style="color: hsl(120, 100%, 40%);">+                memcpy_inc(s_bits + s_idx, tf->d_bits + 44, 67 - 44, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+          memcpy_inc(s_bits + s_idx, tf->d_bits + 67, 92 - 67, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+          memcpy_inc(s_bits + s_idx, tf->d_bits + 95, 108 - 95, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+         memcpy_inc(s_bits + s_idx, tf->d_bits + 111, 132 - 111, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+               memcpy_inc(s_bits + s_idx, tf->d_bits + 135, 148 - 135, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+               break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case AMR_5_15:</span><br><span style="color: hsl(120, 100%, 40%);">+                memcpy_inc(s_bits + s_idx, tf->d_bits + 46, 96 - 46, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+          memcpy_inc(s_bits + s_idx, tf->d_bits + 69, 92 - 69, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+          memcpy_inc(s_bits + s_idx, tf->d_bits + 95, 114 - 95, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+         memcpy_inc(s_bits + s_idx, tf->d_bits + 117, 136 - 117, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+               memcpy_inc(s_bits + s_idx, tf->d_bits + 139, 158 - 139, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+               break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case AMR_5_90:</span><br><span style="color: hsl(120, 100%, 40%);">+                memcpy_inc(s_bits + s_idx, tf->d_bits + 41, 67 - 41, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+          memcpy_inc(s_bits + s_idx, tf->d_bits + 67, 92 - 67, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+          memcpy_inc(s_bits + s_idx, tf->d_bits + 95, 116 - 95, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+         memcpy_inc(s_bits + s_idx, tf->d_bits + 119, 144 - 119, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+               memcpy_inc(s_bits + s_idx, tf->d_bits + 147, 168 - 147, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+               break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case AMR_6_70:</span><br><span style="color: hsl(120, 100%, 40%);">+                memcpy_inc(s_bits + s_idx, tf->d_bits + 37, 63 - 37, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+          memcpy_inc(s_bits + s_idx, tf->d_bits + 63, 92 - 63, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+          memcpy_inc(s_bits + s_idx, tf->d_bits + 95, 120 - 95, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+         memcpy_inc(s_bits + s_idx, tf->d_bits + 123, 152 - 123, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+               memcpy_inc(s_bits + s_idx, tf->d_bits + 155, 180 - 155, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+               break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case AMR_7_40:</span><br><span style="color: hsl(120, 100%, 40%);">+                memcpy_inc(s_bits + s_idx, tf->d_bits + 34, 60 - 34, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+          memcpy_inc(s_bits + s_idx, tf->d_bits + 60, 92 - 60, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+          memcpy_inc(s_bits + s_idx, tf->d_bits + 95, 124 - 95, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+         memcpy_inc(s_bits + s_idx, tf->d_bits + 127, 159 - 127, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+               memcpy_inc(s_bits + s_idx, tf->d_bits + 162, 191 - 162, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+               break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case AMR_7_95:</span><br><span style="color: hsl(120, 100%, 40%);">+                memcpy_inc(s_bits + s_idx, tf->d_bits + 31, 58 - 31, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+          memcpy_inc(s_bits + s_idx, tf->d_bits + 58, 92 - 58, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+          memcpy_inc(s_bits + s_idx, tf->d_bits + 95, 127 - 95, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+         memcpy_inc(s_bits + s_idx, tf->d_bits + 130, 164 - 130, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+               memcpy_inc(s_bits + s_idx, tf->d_bits + 167, 199 - 167, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+               break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case AMR_10_2:</span><br><span style="color: hsl(120, 100%, 40%);">+                memcpy_inc(s_bits + s_idx, tf->d_bits + 20, 46 - 20, &s_idx);    /* D21..D46 */</span><br><span style="color: hsl(120, 100%, 40%);">+                memcpy_inc(s_bits + s_idx, tf->d_bits + 46, 92 - 46, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+          memcpy_inc(s_bits + s_idx, tf->d_bits + 95, 138 - 95, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+         memcpy_inc(s_bits + s_idx, tf->d_bits + 141, 187 - 141, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+               memcpy_inc(s_bits + s_idx, tf->d_bits + 190, 233 - 190, &s_idx);</span><br><span style="color: hsl(120, 100%, 40%);">+               break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case AMR_12_2:</span><br><span style="color: hsl(120, 100%, 40%);">+                memcpy_inc(s_bits + s_idx, tf->d_bits + 0, 38 - 0, &s_idx);      /* D1..D38 */</span><br><span style="color: hsl(120, 100%, 40%);">+         memcpy_inc(s_bits + s_idx, tf->d_bits + 38, 91 - 38, &s_idx);    /* D39..D91 */</span><br><span style="color: hsl(120, 100%, 40%);">+                memcpy_inc(s_bits + s_idx, tf->d_bits + 94, 144 - 94, &s_idx);   /* D95..D144 */</span><br><span style="color: hsl(120, 100%, 40%);">+               memcpy_inc(s_bits + s_idx, tf->d_bits + 147, 200 - 147, &s_idx);/* D148..D200 */</span><br><span style="color: hsl(120, 100%, 40%);">+               memcpy_inc(s_bits + s_idx, tf->d_bits + 203, 253 - 203, &s_idx);/* D204..D253 */</span><br><span style="color: hsl(120, 100%, 40%);">+               break;</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return s_idx;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* TS 48.060 Section 5.5.1.2.2 */</span><br><span style="color: hsl(120, 100%, 40%);">+static int trau2rtp_16(uint8_t *out, const struct osmo_trau_frame *tf, enum osmo_amr_mode last_cmi)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ enum osmo_amr_mode mode = last_cmi;</span><br><span style="color: hsl(120, 100%, 40%);">+   uint8_t frame_class = tf->c_bits[21] << 1 | tf->c_bits[20];</span><br><span style="color: hsl(120, 100%, 40%);">+       uint8_t cmr_cmi = tf->c_bits[23] << 2 | tf->c_bits[24] << 1 | tf->cb_bits[25];</span><br><span style="color: hsl(120, 100%, 40%);">+   uint8_t no_speech_cls;</span><br><span style="color: hsl(120, 100%, 40%);">+        uint8_t s_bits[242];</span><br><span style="color: hsl(120, 100%, 40%);">+  uint8_t d_bits[242];</span><br><span style="color: hsl(120, 100%, 40%);">+  unsigned int s_idx = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+       ubit_t rif = FIXME;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (tf->type != OSMO_TRAU16_FT_AMR)</span><br><span style="color: hsl(120, 100%, 40%);">+                return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     if (rif == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+         mode = cmr_cmi;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     switch (frame_class) {</span><br><span style="color: hsl(120, 100%, 40%);">+        case 0: // no speech</span><br><span style="color: hsl(120, 100%, 40%);">+          no_speech_cls = tf->d_bits[32] << 2 | tf->d_bits[33] << 1 | tf->d_bits[34];</span><br><span style="color: hsl(120, 100%, 40%);">+              cmi_abs = tf->d_bits[35] << 2 | tf->d_bits[36] < 1 || tf->d_bits[37];</span><br><span style="color: hsl(120, 100%, 40%);">+               cmr_abs = tf->d_bits[38] << 2 | tf->d_bits[39] < 1 || tf->d_bits[40];</span><br><span style="color: hsl(120, 100%, 40%);">+               switch (no_speech_cls) {</span><br><span style="color: hsl(120, 100%, 40%);">+              case 7: // sid first</span><br><span style="color: hsl(120, 100%, 40%);">+                  break;</span><br><span style="color: hsl(120, 100%, 40%);">+                case 6: // onset</span><br><span style="color: hsl(120, 100%, 40%);">+                      break;</span><br><span style="color: hsl(120, 100%, 40%);">+                case 5: // sid_update</span><br><span style="color: hsl(120, 100%, 40%);">+                 break;</span><br><span style="color: hsl(120, 100%, 40%);">+                case 4: // sid_bad</span><br><span style="color: hsl(120, 100%, 40%);">+                    break;</span><br><span style="color: hsl(120, 100%, 40%);">+                case 0: // no_data</span><br><span style="color: hsl(120, 100%, 40%);">+                    break;</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span style="color: hsl(120, 100%, 40%);">+             break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case 1: // speech bad</span><br><span style="color: hsl(120, 100%, 40%);">+         break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case 2:</span><br><span style="color: hsl(120, 100%, 40%);">+       case 3:</span><br><span style="color: hsl(120, 100%, 40%);">+               /* Extract the s-bits from the TRAU frame */</span><br><span style="color: hsl(120, 100%, 40%);">+          amr_speech_extract_sbits(s_bits, tf, mode);</span><br><span style="color: hsl(120, 100%, 40%);">+           /* Convert the s-bits to d-bits */</span><br><span style="color: hsl(120, 100%, 40%);">+            osmo_amr_s_to_d(d_bits, s_bits, mode);</span><br><span style="color: hsl(120, 100%, 40%);">+                break;</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int trau2rtp_amr(uint8_t *out, const struct osmo_trau_frame *tf, enum osmo_amr_mode last_cmi))</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     switch (tf->type) {</span><br><span style="color: hsl(120, 100%, 40%);">+        case OSMO_TRAU16_FT_AMR:</span><br><span style="color: hsl(120, 100%, 40%);">+              return trau2rtp_16(out, tf, last_cmi);</span><br><span style="color: hsl(120, 100%, 40%);">+        case OSMO_TRAU8_AMR_LOW:</span><br><span style="color: hsl(120, 100%, 40%);">+      case OSMO_TRAU8_AMR_6k7:</span><br><span style="color: hsl(120, 100%, 40%);">+      case OSMO_TRAU8_AMR_7k4:</span><br><span style="color: hsl(120, 100%, 40%);">+      default:</span><br><span style="color: hsl(120, 100%, 40%);">+              return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int osmo_trau2rtp(uint8_t *out, size_t out_len, const struct osmo_trau_frame *tf,</span><br><span style="color: hsl(120, 100%, 40%);">+               struct osmo_trau2rtp_state *st)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  switch (tf->type) {</span><br><span style="color: hsl(120, 100%, 40%);">+        case OSMO_TRAU16_FT_FR:</span><br><span style="color: hsl(120, 100%, 40%);">+               return trau2rtp_fr(out, out_len, tf);</span><br><span style="color: hsl(120, 100%, 40%);">+ case OSMO_TRAU16_FT_EFR:</span><br><span style="color: hsl(120, 100%, 40%);">+              return trau2rtp_efr(out, out_len, tf);</span><br><span style="color: hsl(120, 100%, 40%);">+        case OSMO_TRAU16_FT_HR:</span><br><span style="color: hsl(120, 100%, 40%);">+               return trau2rtp_hr16(out, out_len, tf);</span><br><span style="color: hsl(120, 100%, 40%);">+       default:</span><br><span style="color: hsl(120, 100%, 40%);">+              return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int osmo_rtp2trau(struct osmo_trau_frame *tf, const uint8_t *rtp, size_t rtp_len,</span><br><span style="color: hsl(120, 100%, 40%);">+               struct osmo_trau2rtp_state *st)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  switch (st->type) {</span><br><span style="color: hsl(120, 100%, 40%);">+        case OSMO_TRAU16_FT_FR:</span><br><span style="color: hsl(120, 100%, 40%);">+               return rtp2trau_fr(tf, rtp, rtp_len);</span><br><span style="color: hsl(120, 100%, 40%);">+ case OSMO_TRAU16_FT_EFR:</span><br><span style="color: hsl(120, 100%, 40%);">+              return rtp2trau_efr(tf, rtp, rtp_len);</span><br><span style="color: hsl(120, 100%, 40%);">+        case OSMO_TRAU16_FT_HR:</span><br><span style="color: hsl(120, 100%, 40%);">+               return rtp2trau_hr16(tf, rtp, rtp_len);</span><br><span style="color: hsl(120, 100%, 40%);">+       default:</span><br><span style="color: hsl(120, 100%, 40%);">+              return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmo-abis/+/18382">change 18382</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmo-abis/+/18382"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmo-abis </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I7f6993cce2b95318203043e2e14952e581941b79 </div>
<div style="display:none"> Gerrit-Change-Number: 18382 </div>
<div style="display:none"> Gerrit-PatchSet: 9 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>