From 0da49000ba98858af1128fdcec8580f87bbf06ed Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 25 Feb 2025 13:21:08 -0400 Subject: [PATCH] MT#61404 always update egress RTP index Add a simple function that acts as an encryption callback to just update the ext_seq (index) of the egress SSRC context. The kernel module already does this, but the daemon only did it when SRTP was involved. This now tracks egress packet indexes in all cases. Change-Id: I9460744de55ead4b05aceb322fd8482442ff2b41 --- daemon/media_socket.c | 14 +++++++++++--- daemon/rtp.c | 12 ++++++++++++ include/rtp.h | 2 ++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 09bb18c4b..8c49cd835 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -224,6 +224,10 @@ const int num_transport_protocols = G_N_ELEMENTS(transport_protocols); static const struct streamhandler_io __shio_noop = { .kernel = __k_null, }; +static const struct streamhandler_io __shio_noop_index = { + .kernel = __k_null, + .rtp_crypt = rtp_update_index, +}; static const struct streamhandler_io __shio_decrypt = { .kernel = __k_srtp_decrypt, .rtp_crypt = call_savp2avp_rtp, @@ -259,6 +263,10 @@ static const struct streamhandler __sh_noop = { .in = &__shio_noop, .out = &__shio_noop, }; +static const struct streamhandler __sh_noop_index = { + .in = &__shio_noop, + .out = &__shio_noop_index, +}; static const struct streamhandler __sh_savp2avp = { .in = &__shio_decrypt, .out = &__shio_noop, @@ -295,8 +303,8 @@ static const struct streamhandler __sh_savpf2savp = { /* ********** */ static const struct streamhandler * const __sh_matrix_in_rtp_avp[__PROTO_LAST] = { - [PROTO_RTP_AVP] = &__sh_noop, - [PROTO_RTP_AVPF] = &__sh_noop, + [PROTO_RTP_AVP] = &__sh_noop_index, + [PROTO_RTP_AVPF] = &__sh_noop_index, [PROTO_RTP_SAVP] = &__sh_avp2savp, [PROTO_RTP_SAVPF] = &__sh_avp2savp, [PROTO_UDP_TLS_RTP_SAVP] = &__sh_avp2savp, @@ -307,7 +315,7 @@ static const struct streamhandler * const __sh_matrix_in_rtp_avp[__PROTO_LAST] = }; static const struct streamhandler * const __sh_matrix_in_rtp_avpf[__PROTO_LAST] = { [PROTO_RTP_AVP] = &__sh_avpf2avp, - [PROTO_RTP_AVPF] = &__sh_noop, + [PROTO_RTP_AVPF] = &__sh_noop_index, [PROTO_RTP_SAVP] = &__sh_avpf2savp, [PROTO_RTP_SAVPF] = &__sh_avp2savp, [PROTO_UDP_TLS_RTP_SAVP] = &__sh_avpf2savp, diff --git a/daemon/rtp.c b/daemon/rtp.c index 283f6db7d..29e59b27d 100644 --- a/daemon/rtp.c +++ b/daemon/rtp.c @@ -142,6 +142,18 @@ int rtp_avp2savp(str *s, struct crypto_context *c, struct ssrc_ctx *ssrc_ctx) { return 0; } +// just updates the ext_seq in ssrc +int rtp_update_index(str *s, struct packet_stream *ps, struct ssrc_ctx *ssrc) { + struct rtp_header *rtp; + + if (G_UNLIKELY(!ssrc)) + return -1; + if (rtp_payload(&rtp, NULL, s)) + return -1; + packet_index(ssrc, rtp); + return 0; +} + /* rfc 3711, section 3.3 */ int rtp_savp2avp(str *s, struct crypto_context *c, struct ssrc_ctx *ssrc_ctx) { struct rtp_header *rtp; diff --git a/include/rtp.h b/include/rtp.h index 241196462..04ffecc0f 100644 --- a/include/rtp.h +++ b/include/rtp.h @@ -18,6 +18,8 @@ const rtp_payload_type *get_rtp_payload_type(unsigned int, struct codec_store *) int rtp_avp2savp(str *, struct crypto_context *, struct ssrc_ctx *); int rtp_savp2avp(str *, struct crypto_context *, struct ssrc_ctx *); +int rtp_update_index(str *, struct packet_stream *, struct ssrc_ctx *); + void rtp_append_mki(str *s, struct crypto_context *c); int srtp_payloads(str *to_auth, str *to_decrypt, str *auth_tag, str *mki, int auth_len, int mki_len,