[svn-commits] kmoore: branch kmoore/pjsip_dtls r394806 - in /team/kmoore/pjsip_dtls: includ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jul 19 13:26:09 CDT 2013


Author: kmoore
Date: Fri Jul 19 13:26:07 2013
New Revision: 394806

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394806
Log:
Address review comments from Mark and Joshua

Modified:
    team/kmoore/pjsip_dtls/include/asterisk/res_sip_session.h
    team/kmoore/pjsip_dtls/res/res_sip.c
    team/kmoore/pjsip_dtls/res/res_sip_sdp_rtp.c
    team/kmoore/pjsip_dtls/res/res_sip_session.c

Modified: team/kmoore/pjsip_dtls/include/asterisk/res_sip_session.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_dtls/include/asterisk/res_sip_session.h?view=diff&rev=394806&r1=394805&r2=394806
==============================================================================
--- team/kmoore/pjsip_dtls/include/asterisk/res_sip_session.h (original)
+++ team/kmoore/pjsip_dtls/include/asterisk/res_sip_session.h Fri Jul 19 13:26:07 2013
@@ -28,8 +28,6 @@
 #include "asterisk/netsock.h"
 /* Needed for ast_sdp_srtp struct */
 #include "asterisk/sdp_srtp.h"
-/* Needed for ast_rtp_dtls_cfg struct */
-#include "asterisk/rtp_engine.h"
 
 /* Forward declarations */
 struct ast_sip_endpoint;
@@ -113,8 +111,6 @@
 	struct ast_codec_pref override_prefs;
 	/* Optional DSP, used only for inband DTMF detection if configured */
 	struct ast_dsp *dsp;
-	/*! \brief DTLS-SRTP configuration information */
-	struct ast_rtp_dtls_cfg dtls_cfg;
 	/* Whether the termination of the session should be deferred */
 	unsigned int defer_terminate:1;
 };

Modified: team/kmoore/pjsip_dtls/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_dtls/res/res_sip.c?view=diff&rev=394806&r1=394805&r2=394806
==============================================================================
--- team/kmoore/pjsip_dtls/res/res_sip.c (original)
+++ team/kmoore/pjsip_dtls/res/res_sip.c Fri Jul 19 13:26:07 2013
@@ -425,7 +425,7 @@
 						This option only applies if <replaceable>media_encryption</replaceable> is
 						set to <literal>dtls</literal>.
 					</para><para>
-						Many options for acceptable ciphers see link for more:
+						Many options for acceptable ciphers. See link for more:
 						http://www.openssl.org/docs/apps/ciphers.html#CIPHER_STRINGS
 					</para></description>
 				</configOption>

Modified: team/kmoore/pjsip_dtls/res/res_sip_sdp_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_dtls/res/res_sip_sdp_rtp.c?view=diff&rev=394806&r1=394805&r2=394806
==============================================================================
--- team/kmoore/pjsip_dtls/res/res_sip_sdp_rtp.c (original)
+++ team/kmoore/pjsip_dtls/res/res_sip_sdp_rtp.c Fri Jul 19 13:26:07 2013
@@ -546,7 +546,7 @@
 {
 	struct ast_rtp_engine_dtls *dtls;
 
-	if (!session->dtls_cfg.enabled || !session_media->rtp) {
+	if (!session->endpoint->dtls_cfg.enabled || !session_media->rtp) {
 		return -1;
 	}
 
@@ -555,8 +555,8 @@
 		return -1;
 	}
 
-	session->dtls_cfg.suite = ((session->endpoint->srtp_tag_32) ? AST_AES_CM_128_HMAC_SHA1_32 : AST_AES_CM_128_HMAC_SHA1_80);
-	if (dtls->set_configuration(session_media->rtp, &session->dtls_cfg)) {
+	session->endpoint->dtls_cfg.suite = ((session->endpoint->srtp_tag_32) ? AST_AES_CM_128_HMAC_SHA1_32 : AST_AES_CM_128_HMAC_SHA1_80);
+	if (dtls->set_configuration(session_media->rtp, &session->endpoint->dtls_cfg)) {
 		ast_log(LOG_ERROR, "Attempted to set an invalid DTLS-SRTP configuration on RTP instance '%p'\n",
 			session_media->rtp);
 		return -1;
@@ -585,42 +585,29 @@
 		value = pj_strtrim(&attr->value);
 
 		if (!pj_strcmp2(&attr->name, "setup")) {
-			RAII_VAR(char *, setup_type, ast_strndup(value->ptr, value->slen), ast_free);
-			if (!setup_type) {
-				return -1;
-			}
-
-			if (!strcasecmp(setup_type, "active")) {
+			if (!pj_stricmp2(value, "active")) {
 				dtls->set_setup(session_media->rtp, AST_RTP_DTLS_SETUP_ACTIVE);
-			} else if (!strcasecmp(setup_type, "passive")) {
+			} else if (!pj_stricmp2(value, "passive")) {
 				dtls->set_setup(session_media->rtp, AST_RTP_DTLS_SETUP_PASSIVE);
-			} else if (!strcasecmp(setup_type, "actpass")) {
+			} else if (!pj_stricmp2(value, "actpass")) {
 				dtls->set_setup(session_media->rtp, AST_RTP_DTLS_SETUP_ACTPASS);
-			} else if (!strcasecmp(setup_type, "holdconn")) {
+			} else if (!pj_stricmp2(value, "holdconn")) {
 				dtls->set_setup(session_media->rtp, AST_RTP_DTLS_SETUP_HOLDCONN);
 			} else {
-				ast_log(LOG_WARNING, "Unsupported setup attribute value '%s'\n", setup_type);
+				ast_log(LOG_WARNING, "Unsupported setup attribute value '%*s'\n", (int)value->slen, value->ptr);
 			}
 		} else if (!pj_strcmp2(&attr->name, "connection")) {
-			RAII_VAR(char *, connection_type, ast_strndup(value->ptr, value->slen), ast_free);
-			if (!connection_type) {
-				return -1;
-			}
-
-			if (!strcasecmp(connection_type, "new")) {
+			if (!pj_stricmp2(value, "new")) {
 				dtls->reset(session_media->rtp);
-			} else if (!strcasecmp(connection_type, "existing")) {
+			} else if (!pj_stricmp2(value, "existing")) {
 				/* Do nothing */
 			} else {
-				ast_log(LOG_WARNING, "Unsupported connection attribute value '%s'\n", connection_type);
+				ast_log(LOG_WARNING, "Unsupported connection attribute value '%*s'\n", (int)value->slen, value->ptr);
 			}
 		} else if (!pj_strcmp2(&attr->name, "fingerprint")) {
 			char hash_value[256], hash[6];
-			RAII_VAR(char *, fingerprint_text, ast_strndup(value->ptr, value->slen), ast_free);
-
-			if (!fingerprint_text) {
-				return -1;
-			}
+			char fingerprint_text[value->slen + 1];
+			ast_copy_pj_str(fingerprint_text, value, sizeof(fingerprint_text));
 
 			if (sscanf(fingerprint_text, "%5s %255s", hash, hash_value) == 2) {
 				if (!strcasecmp(hash, "sha-1")) {
@@ -745,6 +732,12 @@
 	pjmedia_sdp_attr *attr;
 	const char *crypto_attribute;
 	struct ast_rtp_engine_dtls *dtls;
+	static const pj_str_t STR_NEW = { "new", 3 };
+	static const pj_str_t STR_EXISTING = { "existing", 8 };
+	static const pj_str_t STR_ACTIVE = { "active", 6 };
+	static const pj_str_t STR_PASSIVE = { "passive", 7 };
+	static const pj_str_t STR_ACTPASS = { "actpass", 7 };
+	static const pj_str_t STR_HOLDCONN = { "holdconn", 8 };
 
 	switch (session->endpoint->media_encryption) {
 	case AST_SIP_MEDIA_ENCRYPT_NONE:
@@ -781,11 +774,11 @@
 
 		switch (dtls->get_connection(session_media->rtp)) {
 		case AST_RTP_DTLS_CONNECTION_NEW:
-			attr = pjmedia_sdp_attr_create(pool, "connection", pj_cstr(&stmp, "new"));
+			attr = pjmedia_sdp_attr_create(pool, "connection", &STR_NEW);
 			media->attr[media->attr_count++] = attr;
 			break;
 		case AST_RTP_DTLS_CONNECTION_EXISTING:
-			attr = pjmedia_sdp_attr_create(pool, "connection", pj_cstr(&stmp, "existing"));
+			attr = pjmedia_sdp_attr_create(pool, "connection", &STR_EXISTING);
 			media->attr[media->attr_count++] = attr;
 			break;
 		default:
@@ -794,19 +787,19 @@
 
 		switch (dtls->get_setup(session_media->rtp)) {
 		case AST_RTP_DTLS_SETUP_ACTIVE:
-			attr = pjmedia_sdp_attr_create(pool, "setup", pj_cstr(&stmp, "active"));
+			attr = pjmedia_sdp_attr_create(pool, "setup", &STR_ACTIVE);
 			media->attr[media->attr_count++] = attr;
 			break;
 		case AST_RTP_DTLS_SETUP_PASSIVE:
-			attr = pjmedia_sdp_attr_create(pool, "setup", pj_cstr(&stmp, "passive"));
+			attr = pjmedia_sdp_attr_create(pool, "setup", &STR_PASSIVE);
 			media->attr[media->attr_count++] = attr;
 			break;
 		case AST_RTP_DTLS_SETUP_ACTPASS:
-			attr = pjmedia_sdp_attr_create(pool, "setup", pj_cstr(&stmp, "actpass"));
+			attr = pjmedia_sdp_attr_create(pool, "setup", &STR_ACTPASS);
 			media->attr[media->attr_count++] = attr;
 			break;
 		case AST_RTP_DTLS_SETUP_HOLDCONN:
-			attr = pjmedia_sdp_attr_create(pool, "setup", pj_cstr(&stmp, "holdconn"));
+			attr = pjmedia_sdp_attr_create(pool, "setup", &STR_HOLDCONN);
 			media->attr[media->attr_count++] = attr;
 			break;
 		default:

Modified: team/kmoore/pjsip_dtls/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_dtls/res/res_sip_session.c?view=diff&rev=394806&r1=394805&r2=394806
==============================================================================
--- team/kmoore/pjsip_dtls/res/res_sip_session.c (original)
+++ team/kmoore/pjsip_dtls/res/res_sip_session.c Fri Jul 19 13:26:07 2013
@@ -854,7 +854,6 @@
 	ast_taskprocessor_unreference(session->serializer);
 	ao2_cleanup(session->datastores);
 	ao2_cleanup(session->media);
-	ast_rtp_dtls_cfg_free(&session->dtls_cfg);
 
 	AST_LIST_HEAD_DESTROY(&session->supplements);
 	while ((delay = AST_LIST_REMOVE_HEAD(&session->delayed_requests, next))) {
@@ -922,8 +921,6 @@
 	}
 	/* fill session->media with available types */
 	ao2_callback(sdp_handlers, OBJ_NODATA, add_session_media, session);
-
-	ast_rtp_dtls_cfg_copy(&endpoint->dtls_cfg, &session->dtls_cfg);
 
 	session->serializer = ast_sip_create_serializer();
 	if (!session->serializer) {




More information about the svn-commits mailing list