diff options
author | Mychaela N. Falconia <falcon@freecalypso.org> | 2023-05-29 20:28:57 +0000 |
---|---|---|
committer | Mychaela N. Falconia <falcon@freecalypso.org> | 2023-05-29 20:28:57 +0000 |
commit | 1dd710944f9bf1eb19bcc11f71cb30fdd6a9c309 (patch) | |
tree | 89eb485fb775ce85f6b1fd65c3b88b38d77b1925 | |
parent | a84b9a02610448be60de40f8ea490d4e5fa7ac60 (diff) |
HR1 codec: validate ToC header in RFC5993 RTP input
osmo-bts-trx always accepted (and previously required) HR1 codec RTP
input in RFC 5993 format; currently we accept this RTP format as
input for all BTS models, but no longer require it. However, we
have never applied any checks to this format's ToC header, even
when we previously required it in osmo-bts-trx. Check this header
and reject invalid payloads that just happen to have the same octet
length as valid ones.
Change-Id: If16d38641913bb46bcd7cc11685407ed17136bfe
-rw-r--r-- | src/common/rtp_input_preen.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/common/rtp_input_preen.c b/src/common/rtp_input_preen.c index e5cef6ff..dd526fdb 100644 --- a/src/common/rtp_input_preen.c +++ b/src/common/rtp_input_preen.c @@ -89,6 +89,20 @@ input_preen_hr(const uint8_t *rtp_pl, unsigned rtp_pl_len) /* RTP input matches our internal format - we are good */ return PL_DECISION_ACCEPT; case GSM_HR_BYTES_RTP_RFC5993: + /* Validate ToC octet: for payload of this length to be valid, + * the F bit must be 0 and the FT field must be either 0 (good + * speech) or 2 (good SID). */ + switch (rtp_pl[0] & 0xF0) { + case 0x00: + break; + case 0x20: + /* TODO (next patch): signal this SID to the + * fr_hr_efr_dtxd_input() handler in l1sap. */ + break; + default: + /* invalid payload */ + return PL_DECISION_DROP; + } /* Strip ToC octet, leaving only "pure" TS 101 318 payload. */ return PL_DECISION_STRIP_HDR_OCTET; default: |