From 70214a15d1d575802d821c3555f61c3797a0a89b Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 24 May 2013 11:56:07 +0200 Subject: osmux: further sanity checkings for AMR FT According to RFC3267, AMR FT upper 9 should be discarded. This patch adds extra validation to make sure that input RTP traffic encapsulating AMR payload and OSMUX amr_ft field are OK with regards to that restriction. --- src/amr.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/amr.c') diff --git a/src/amr.c b/src/amr.c index a6f6a32..55b9300 100644 --- a/src/amr.c +++ b/src/amr.c @@ -41,3 +41,22 @@ size_t osmo_amr_bytes(uint8_t amr_ft) { return amr_ft_to_bytes[amr_ft]; } + +int osmo_amr_ft_valid(uint8_t amr_ft) +{ + /* + * Extracted from RFC3267: + * + * "... with a FT value in the range 9-14 for AMR ... the whole packet + * SHOULD be discarded." + * + * "... packets containing only NO_DATA frames (FT=15) SHOULD NOT be + * transmitted." + * + * So, let's discard frames with a AMR FT >= 9. + */ + if (amr_ft >= 9) + return 0; + + return 1; +} -- cgit v1.2.3