From: Sylvain Munaut <tnt(a)246tNt.com>
For GSM V1 FR, the payload type is fixed to 3 in the RFC.
But for the other codecs, the payload type is dynamically assigned
between 96 and 127. Here, we use a static mapping internal to OpenBSC.
This patch is needed to make a rather old 139 unit (with sw version
120a002_v149b42d0) work with something else than FR codec. I also tested
this patch on a newer 139 (with sw version 120a352_v267b22d0) to make
sure it didn't add a regression. More testing with newer EDGE units
should be done by whoever has some of theses.
Signed-off-by: Sylvain Munaut <tnt(a)246tNt.com>
---
openbsc/include/openbsc/gsm_data.h | 1 +
openbsc/include/openbsc/rtp_proxy.h | 6 ++++
openbsc/src/abis_rsl.c | 53 ++++++++++++++++++++++++++++++++--
openbsc/src/rtp_proxy.c | 3 --
4 files changed, 56 insertions(+), 7 deletions(-)
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index bc1dbe6..16d6d94 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -204,6 +204,7 @@ struct gsm_lchan {
u_int16_t bound_port;
u_int16_t connect_port;
u_int16_t conn_id;
+ u_int8_t rtp_payload;
u_int8_t rtp_payload2;
u_int8_t speech_mode;
struct rtp_socket *rtp_socket;
diff --git a/openbsc/include/openbsc/rtp_proxy.h b/openbsc/include/openbsc/rtp_proxy.h
index a3e4596..07cf5a2 100644
--- a/openbsc/include/openbsc/rtp_proxy.h
+++ b/openbsc/include/openbsc/rtp_proxy.h
@@ -28,6 +28,12 @@
#include <openbsc/linuxlist.h>
#include <openbsc/select.h>
+#define RTP_PT_GSM_FULL 3
+#define RTP_PT_GSM_HALF 96
+#define RTP_PT_GSM_EFR 97
+#define RTP_PT_AMR_FULL 98
+#define RTP_PT_AMR_HALF 99
+
enum rtp_rx_action {
RTP_NONE,
RTP_PROXY,
diff --git a/openbsc/src/abis_rsl.c b/openbsc/src/abis_rsl.c
index 2d55806..f4c42b8 100644
--- a/openbsc/src/abis_rsl.c
+++ b/openbsc/src/abis_rsl.c
@@ -39,6 +39,7 @@
#include <openbsc/paging.h>
#include <openbsc/signal.h>
#include <openbsc/meas_rep.h>
+#include <openbsc/rtp_proxy.h>
#define RSL_ALLOC_SIZE 1024
#define RSL_ALLOC_HEADROOM 128
@@ -1496,6 +1497,44 @@ static u_int8_t ipa_smod_s_for_lchan(struct gsm_lchan *lchan)
return 0;
}
+static u_int8_t ipa_rtp_pt_for_lchan(struct gsm_lchan *lchan)
+{
+ switch (lchan->tch_mode) {
+ case GSM48_CMODE_SPEECH_V1:
+ switch (lchan->type) {
+ case GSM_LCHAN_TCH_F:
+ return RTP_PT_GSM_FULL;
+ case GSM_LCHAN_TCH_H:
+ return RTP_PT_GSM_HALF;
+ default:
+ break;
+ }
+ case GSM48_CMODE_SPEECH_EFR:
+ switch (lchan->type) {
+ case GSM_LCHAN_TCH_F:
+ return RTP_PT_GSM_EFR;
+ /* there's no half-rate EFR */
+ default:
+ break;
+ }
+ case GSM48_CMODE_SPEECH_AMR:
+ switch (lchan->type) {
+ case GSM_LCHAN_TCH_F:
+ return RTP_PT_AMR_FULL;
+ case GSM_LCHAN_TCH_H:
+ return RTP_PT_AMR_HALF;
+ default:
+ break;
+ }
+ default:
+ break;
+ }
+ LOGP(DRSL, LOGL_ERROR, "Cannot determine ip.access rtp payload type for "
+ "tch_mode == 0x%02x\n & lchan_type == %d",
+ lchan->tch_mode, lchan->type);
+ return 0;
+}
+
/* ip.access specific RSL extensions */
static void ipac_parse_rtp(struct gsm_lchan *lchan, struct tlv_parsed *tv)
{
@@ -1562,11 +1601,14 @@ int rsl_ipacc_crcx(struct gsm_lchan *lchan)
/* 0x1- == receive-only, 0x-1 == EFR codec */
lchan->abis_ip.speech_mode = 0x10 | ipa_smod_s_for_lchan(lchan);
+ lchan->abis_ip.rtp_payload = ipa_rtp_pt_for_lchan(lchan);
msgb_tv_put(msg, RSL_IE_IPAC_SPEECH_MODE, lchan->abis_ip.speech_mode);
+ msgb_tv_put(msg, RSL_IE_IPAC_RTP_PAYLOAD, lchan->abis_ip.rtp_payload);
DEBUGP(DRSL, "channel=%s chan_nr=0x%02x IPAC_BIND "
- "speech_mode=0x%02x\n", gsm_ts_name(lchan->ts),
- dh->chan_nr, lchan->abis_ip.speech_mode);
+ "RTP_PAYLOAD=%d speech_mode=0x%02x\n",
+ gsm_ts_name(lchan->ts), dh->chan_nr,
+ lchan->abis_ip.rtp_payload, lchan->abis_ip.speech_mode);
msg->trx = lchan->ts->trx;
@@ -1593,12 +1635,14 @@ int rsl_ipacc_mdcx(struct gsm_lchan *lchan, u_int32_t ip,
u_int16_t port,
/* 0x0- == both directions, 0x-1 == EFR codec */
lchan->abis_ip.speech_mode = 0x00 | ipa_smod_s_for_lchan(lchan);
+ lchan->abis_ip.rtp_payload = ipa_rtp_pt_for_lchan(lchan);
ia.s_addr = htonl(ip);
DEBUGP(DRSL, "channel=%s chan_nr=0x%02x IPAC_MDCX "
- "IP=%s PORT=%d RTP_PAYLOAD2=%d CONN_ID=%d speech_mode=0x%02x\n",
+ "IP=%s PORT=%d RTP_PAYLOAD=%d RTP_PAYLOAD2=%d CONN_ID=%d
speech_mode=0x%02x\n",
gsm_ts_name(lchan->ts), dh->chan_nr, inet_ntoa(ia), port,
- rtp_payload2, lchan->abis_ip.conn_id, lchan->abis_ip.speech_mode);
+ lchan->abis_ip.rtp_payload, rtp_payload2,
+ lchan->abis_ip.conn_id, lchan->abis_ip.speech_mode);
msgb_tv16_put(msg, RSL_IE_IPAC_CONN_ID, lchan->abis_ip.conn_id);
msgb_v_put(msg, RSL_IE_IPAC_REMOTE_IP);
@@ -1606,6 +1650,7 @@ int rsl_ipacc_mdcx(struct gsm_lchan *lchan, u_int32_t ip, u_int16_t
port,
*att_ip = ia.s_addr;
msgb_tv16_put(msg, RSL_IE_IPAC_REMOTE_PORT, port);
msgb_tv_put(msg, RSL_IE_IPAC_SPEECH_MODE, lchan->abis_ip.speech_mode);
+ msgb_tv_put(msg, RSL_IE_IPAC_RTP_PAYLOAD, lchan->abis_ip.rtp_payload);
if (rtp_payload2)
msgb_tv_put(msg, RSL_IE_IPAC_RTP_PAYLOAD2, rtp_payload2);
diff --git a/openbsc/src/rtp_proxy.c b/openbsc/src/rtp_proxy.c
index 5513497..6896755 100644
--- a/openbsc/src/rtp_proxy.c
+++ b/openbsc/src/rtp_proxy.c
@@ -81,9 +81,6 @@ struct rtp_x_hdr {
#define RTP_VERSION 2
-#define RTP_PT_GSM_FULL 3
-#define RTP_PT_GSM_EFR 97
-
/* decode an rtp frame and create a new buffer with payload */
static int rtp_decode(struct msgb *msg, u_int32_t callref, struct msgb **data)
{
--
1.6.5.1