summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-06-08 14:27:18 +0200
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-06-08 14:27:18 +0200
commit191f69acd388c6afac8462c4ca0717455c9fa6b8 (patch)
tree4cf57ef5b2a1d1dbd234a08df66f715f30cf0630 /modules
parentb241a49e977d48a6b8b445447c27da96964f9ce6 (diff)
zrtp: check for RTP packet in send handler
non-RTP packets such as STUN, TURN, ICE might be shared on the same UDP socket, and these packets should not be processed by ZRTP. ref #262
Diffstat (limited to 'modules')
-rw-r--r--modules/zrtp/zrtp.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/modules/zrtp/zrtp.c b/modules/zrtp/zrtp.c
index 4b42e61..da05e5a 100644
--- a/modules/zrtp/zrtp.c
+++ b/modules/zrtp/zrtp.c
@@ -50,6 +50,19 @@ static zrtp_config_t zrtp_config;
static zrtp_zid_t zid;
+static inline bool is_rtp_or_rtcp(const struct mbuf *mb)
+{
+ uint8_t b;
+
+ if (mbuf_get_left(mb) < 1)
+ return false;
+
+ b = mbuf_buf(mb)[0];
+
+ return 127 < b && b < 192;
+}
+
+
static void session_destructor(void *arg)
{
struct menc_sess *st = arg;
@@ -81,9 +94,19 @@ static bool udp_helper_send(int *err, struct sa *dst,
length = (unsigned int)mbuf_get_left(mb);
+ /* only RTP packets should be processed */
+ if (!is_rtp_or_rtcp(mb))
+ return false;
+
s = zrtp_process_rtp(st->zrtp_stream, (char *)mbuf_buf(mb), &length);
if (s != zrtp_status_ok) {
- warning("zrtp: zrtp_process_rtp failed (status = %d)\n", s);
+
+ if (s == zrtp_status_drop)
+ return true;
+
+ warning("zrtp: send: zrtp_process_rtp failed"
+ " (status = %d '%s')\n",
+ s, zrtp_log_status2str(s));
return false;
}
@@ -115,7 +138,8 @@ static bool udp_helper_recv(struct sa *src, struct mbuf *mb, void *arg)
if (s == zrtp_status_drop)
return true;
- warning("zrtp: zrtp_process_srtp: %d\n", s);
+ warning("zrtp: recv: zrtp_process_srtp: %d '%s'\n",
+ s, zrtp_log_status2str(s));
return false;
}