aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPascal Buhler <pabuhler@cisco.com>2019-05-15 20:48:39 +0200
committerPascal Buhler <pabuhler@cisco.com>2019-05-15 20:48:39 +0200
commit7486bcc7d0871c69d4bf65db95a0ed8c3e78691f (patch)
tree9f4e3a9cde6080ee8e8481f99f2c52d3dd6983e4
parenteaa8a9b025e3d827c6495a3dc424678352b53890 (diff)
downloadlibsrtp2-7486bcc7d0871c69d4bf65db95a0ed8c3e78691f.tar.gz
change ssrc type of rtp_decoder to ssrc_any_inbound
Previously the type ssrc_specific was used, this effectively meant that only the first SSRC in the input would ever be able to be decoded. This would be ok in some cases but the input is never validated so when processing pcap files the first packet would bet treated as an RTP packet regardless of its actual content. By changing to ssrc_any_inbound, rtp_decoder becomes more flexible and supports SSRC multiplexing.
-rw-r--r--test/rtp_decoder.c31
-rw-r--r--test/rtp_decoder.h5
2 files changed, 14 insertions, 22 deletions
diff --git a/test/rtp_decoder.c b/test/rtp_decoder.c
index 544c4f0..2aa6b68 100644
--- a/test/rtp_decoder.c
+++ b/test/rtp_decoder.c
@@ -558,14 +558,17 @@ int main(int argc, char *argv[])
exit(1);
}
fprintf(stderr, "Starting decoder\n");
- rtp_decoder_init(dec, policy);
+ if (rtp_decoder_init(dec, policy)) {
+ fprintf(stderr, "error: init failed\n");
+ exit(1);
+ }
pcap_loop(pcap_handle, 0, rtp_decoder_handle_pkt, (u_char *)dec);
fprintf(stderr, "SRTP packets decoded: %d\n", dec->srtp_cnt);
fprintf(stderr, "Packet decode errors: %d\n", dec->error_cnt);
- rtp_decoder_deinit_srtp(dec);
+ rtp_decoder_deinit(dec);
rtp_decoder_dealloc(dec);
status = srtp_shutdown();
@@ -609,14 +612,7 @@ void rtp_decoder_dealloc(rtp_decoder_t rtp_ctx)
free(rtp_ctx);
}
-srtp_err_status_t rtp_decoder_init_srtp(rtp_decoder_t decoder,
- unsigned int ssrc)
-{
- decoder->policy.ssrc.value = htonl(ssrc);
- return srtp_create(&decoder->srtp_ctx, &decoder->policy);
-}
-
-int rtp_decoder_deinit_srtp(rtp_decoder_t decoder)
+int rtp_decoder_deinit(rtp_decoder_t decoder)
{
if (decoder->srtp_ctx) {
return srtp_dealloc(decoder->srtp_ctx);
@@ -634,7 +630,11 @@ int rtp_decoder_init(rtp_decoder_t dcdr, srtp_policy_t policy)
dcdr->error_cnt = 0;
dcdr->srtp_cnt = 0;
dcdr->policy = policy;
- dcdr->policy.ssrc.type = ssrc_specific;
+ dcdr->policy.ssrc.type = ssrc_any_inbound;
+
+ if (srtp_create(&dcdr->srtp_ctx, &dcdr->policy)) {
+ return 1;
+ }
return 0;
}
@@ -689,13 +689,8 @@ void rtp_decoder_handle_pkt(u_char *arg,
if (message.header.version != 2) {
return;
}
- if (dcdr->srtp_ctx == NULL) {
- status = rtp_decoder_init_srtp(dcdr, dcdr->message.header.ssrc);
- if (status) {
- exit(1);
- }
- }
- status = srtp_unprotect_rtcp(dcdr->srtp_ctx, &message, &octets_recvd);
+
+ status = srtp_unprotect(dcdr->srtp_ctx, &message, &octets_recvd);
if (status) {
dcdr->error_cnt++;
return;
diff --git a/test/rtp_decoder.h b/test/rtp_decoder.h
index 5b02cab..30178a2 100644
--- a/test/rtp_decoder.h
+++ b/test/rtp_decoder.h
@@ -98,10 +98,7 @@ void rtp_decoder_dealloc(rtp_decoder_t rtp_ctx);
int rtp_decoder_init(rtp_decoder_t dcdr, srtp_policy_t policy);
-srtp_err_status_t rtp_decoder_init_srtp(rtp_decoder_t decoder,
- unsigned int ssrc);
-
-int rtp_decoder_deinit_srtp(rtp_decoder_t decoder);
+int rtp_decoder_deinit(rtp_decoder_t decoder);
void rtp_decoder_srtp_log_handler(srtp_log_level_t level,
const char *msg,