[asterisk-commits] kmoore: branch kmoore/pimp_sip_srtp r386332 - in /team/kmoore/pimp_sip_srtp: ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Apr 23 08:25:03 CDT 2013
Author: kmoore
Date: Tue Apr 23 08:24:58 2013
New Revision: 386332
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386332
Log:
Fix some obvious bugs
Ensure crypto gets created and destroyed properly for res_sip and clean
up attribute handling among res_sip, chan_sip, and the shared code.
Modified:
team/kmoore/pimp_sip_srtp/channels/chan_sip.c
team/kmoore/pimp_sip_srtp/main/sdp_srtp.c
team/kmoore/pimp_sip_srtp/res/res_sip_sdp_rtp.c
team/kmoore/pimp_sip_srtp/res/res_sip_session.c
Modified: team/kmoore/pimp_sip_srtp/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pimp_sip_srtp/channels/chan_sip.c?view=diff&rev=386332&r1=386331&r2=386332
==============================================================================
--- team/kmoore/pimp_sip_srtp/channels/chan_sip.c (original)
+++ team/kmoore/pimp_sip_srtp/channels/chan_sip.c Tue Apr 23 08:24:58 2013
@@ -33269,6 +33269,9 @@
if (strncasecmp(a, "crypto:", 7)) {
return FALSE;
}
+ /* skip "crypto:" */
+ a += strlen("crypto:");
+
if (!*srtp) {
if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
ast_log(LOG_WARNING, "Ignoring unexpected crypto attribute in SDP answer\n");
Modified: team/kmoore/pimp_sip_srtp/main/sdp_srtp.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pimp_sip_srtp/main/sdp_srtp.c?view=diff&rev=386332&r1=386331&r2=386332
==============================================================================
--- team/kmoore/pimp_sip_srtp/main/sdp_srtp.c (original)
+++ team/kmoore/pimp_sip_srtp/main/sdp_srtp.c Tue Apr 23 08:24:58 2013
@@ -75,7 +75,7 @@
static int set_crypto_policy(struct ast_srtp_policy *policy, int suite_val, const unsigned char *master_key, unsigned long ssrc, int inbound);
-static struct ast_sdp_crypto *ast_sdp_crypto_alloc(void)
+static struct ast_sdp_crypto *crypto_alloc(void)
{
return ast_calloc(1, sizeof(struct ast_sdp_crypto));
}
@@ -99,7 +99,7 @@
return NULL;
}
- if (!(p = ast_sdp_crypto_alloc())) {
+ if (!(p = crypto_alloc())) {
return NULL;
}
@@ -231,7 +231,6 @@
str = ast_strdupa(attr);
- strsep(&str, ":");
tag = strsep(&str, " ");
suite = strsep(&str, " ");
key_params = strsep(&str, " ");
Modified: team/kmoore/pimp_sip_srtp/res/res_sip_sdp_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pimp_sip_srtp/res/res_sip_sdp_rtp.c?view=diff&rev=386332&r1=386331&r2=386332
==============================================================================
--- team/kmoore/pimp_sip_srtp/res/res_sip_sdp_rtp.c (original)
+++ team/kmoore/pimp_sip_srtp/res/res_sip_sdp_rtp.c Tue Apr 23 08:24:58 2013
@@ -602,6 +602,8 @@
/* No crypto attribute to add */
return -1;
}
+ /* skip over a=crypto: since it will be added by pjsip */
+ crypto_attribute += strlen("a=crypto:");
attr = pjmedia_sdp_attr_create(pool, "crypto", pj_cstr(&stmp, crypto_attribute));
media->attr[media->attr_count++] = attr;
Modified: team/kmoore/pimp_sip_srtp/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pimp_sip_srtp/res/res_sip_session.c?view=diff&rev=386332&r1=386331&r2=386332
==============================================================================
--- team/kmoore/pimp_sip_srtp/res/res_sip_session.c (original)
+++ team/kmoore/pimp_sip_srtp/res/res_sip_session.c Tue Apr 23 08:24:58 2013
@@ -40,6 +40,7 @@
#include "asterisk/pbx.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/causes.h"
+#include "asterisk/sdp_srtp.h"
#define SDP_HANDLER_BUCKETS 11
@@ -859,6 +860,9 @@
if (session_media->handler) {
session_media->handler->stream_destroy(session_media);
}
+ if (session_media->srtp.crypto) {
+ ast_sdp_crypto_destroy(session_media->srtp.crypto);
+ }
}
static void session_destructor(void *obj)
@@ -913,6 +917,12 @@
if (!session_media) {
return CMP_STOP;
}
+
+ session_media->srtp.crypto = ast_sdp_crypto_setup();
+ if (!session_media->srtp.crypto) {
+ return CMP_STOP;
+ }
+
/* Safe use of strcpy */
strcpy(session_media->stream_type, handler_list->stream_type);
ao2_link(session->media, session_media);
More information about the asterisk-commits
mailing list