[asterisk-commits] twilson: branch group/srtp_reboot r266291 - in /team/group/srtp_reboot/channe...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 28 12:55:25 CDT 2010


Author: twilson
Date: Fri May 28 12:55:23 2010
New Revision: 266291

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=266291
Log:
Address mmichelson's review

Modified:
    team/group/srtp_reboot/channels/chan_sip.c
    team/group/srtp_reboot/channels/sip/include/sdp_crypto.h
    team/group/srtp_reboot/channels/sip/include/srtp.h
    team/group/srtp_reboot/channels/sip/sdp_crypto.c
    team/group/srtp_reboot/channels/sip/srtp.c

Modified: team/group/srtp_reboot/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/srtp_reboot/channels/chan_sip.c?view=diff&rev=266291&r1=266290&r2=266291
==============================================================================
--- team/group/srtp_reboot/channels/chan_sip.c (original)
+++ team/group/srtp_reboot/channels/chan_sip.c Fri May 28 12:55:23 2010
@@ -7839,7 +7839,7 @@
 		} else if ((sscanf(m, "video %30u/%30u RTP/%4s %n", &x, &numberofports, protocol, &len) == 3 && len > 0) ||
 			   (sscanf(m, "video %30d RTP/%4s %n", &x, protocol, &len) == 2 && len >= 0)) {
 			if (!strcmp(protocol, "SAVP")) {
-				secure_video= 1;
+				secure_video = 1;
 			} else if (strcmp(protocol, "AVP")) {
 				ast_log(LOG_WARNING, "unknown SDP media protocol in offer: %s\n", protocol);
 				continue;
@@ -27121,7 +27121,7 @@
 static int process_crypto(struct sip_pvt *p, struct ast_rtp_instance *rtp, struct sip_srtp **srtp, const char *a)
 {
 	if (strncasecmp(a, "crypto:", 7)) {
-		return FALSE;	
+		return FALSE;
 	}
 	if (!*srtp) {
 		if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) {

Modified: team/group/srtp_reboot/channels/sip/include/sdp_crypto.h
URL: http://svnview.digium.com/svn/asterisk/team/group/srtp_reboot/channels/sip/include/sdp_crypto.h?view=diff&rev=266291&r1=266290&r2=266291
==============================================================================
--- team/group/srtp_reboot/channels/sip/include/sdp_crypto.h (original)
+++ team/group/srtp_reboot/channels/sip/include/sdp_crypto.h Fri May 28 12:55:23 2010
@@ -32,11 +32,51 @@
 
 struct sdp_crypto;
 
+/*! \brief Initialize an return an sdp_crypto struct
+ *
+ * \details
+ * This function allocates a new sdp_crypto struct and initializes its values
+ *
+ * \retval NULL on failure
+ * \retval a pointer to a  new sdp_crypto structure
+ */
 struct sdp_crypto *sdp_crypto_setup(void);
+
+/*! \brief Destroy a previously allocated sdp_crypto struct */
 void sdp_crypto_destroy(struct sdp_crypto *crypto);
 
+/*! \brief Parse the a=crypto line from SDP and set appropriate values on the
+ * sdp_crypto struct.
+ *
+ * \param p A valid sdp_crypto struct
+ * \param attr the a:crypto line from SDP
+ * \param rtp The rtp instance associated with the SDP being parsed
+ *
+ * \retval 0 success
+ * \retval nonzero failure
+ */
 int sdp_crypto_process(struct sdp_crypto *p, const char *attr, struct ast_rtp_instance *rtp);
+
+
+/*! \brief Generate an SRTP a=crypto offer
+ *
+ * \details
+ * The offer is stored on the sdp_crypto struct in a_crypto
+ *
+ * \param A valid sdp_crypto struct
+ *
+ * \retval 0 success
+ * \retval nonzero failure
+ */
 int sdp_crypto_offer(struct sdp_crypto *p);
+
+
+/*! \brief Return the a_crypto value of the sdp_crypto struct
+ *
+ * \param p An sdp_crypto struct that has had sdp_crypto_offer called
+ *
+ * \retval The value of the a_crypto for p
+ */
 const char *sdp_crypto_attrib(struct sdp_crypto *p);
 
 #endif	/* _SDP_CRYPTO_H */

Modified: team/group/srtp_reboot/channels/sip/include/srtp.h
URL: http://svnview.digium.com/svn/asterisk/team/group/srtp_reboot/channels/sip/include/srtp.h?view=diff&rev=266291&r1=266290&r2=266291
==============================================================================
--- team/group/srtp_reboot/channels/sip/include/srtp.h (original)
+++ team/group/srtp_reboot/channels/sip/include/srtp.h Fri May 28 12:55:23 2010
@@ -31,9 +31,9 @@
 #include "sdp_crypto.h"
 
 /* SRTP flags */
-#define SRTP_ENCR_OPTIONAL	(1<<1)	/* SRTP encryption optional */
-#define SRTP_CRYPTO_ENABLE	(1<<2)
-#define SRTP_CRYPTO_OFFER_OK	(1<<3)
+#define SRTP_ENCR_OPTIONAL	(1 << 1)	/* SRTP encryption optional */
+#define SRTP_CRYPTO_ENABLE	(1 << 2)
+#define SRTP_CRYPTO_OFFER_OK	(1 << 3)
 
 /*! \brief structure for secure RTP audio */
 struct sip_srtp {

Modified: team/group/srtp_reboot/channels/sip/sdp_crypto.c
URL: http://svnview.digium.com/svn/asterisk/team/group/srtp_reboot/channels/sip/sdp_crypto.c?view=diff&rev=266291&r1=266290&r2=266291
==============================================================================
--- team/group/srtp_reboot/channels/sip/sdp_crypto.c (original)
+++ team/group/srtp_reboot/channels/sip/sdp_crypto.c Fri May 28 12:55:23 2010
@@ -88,10 +88,14 @@
 
 	if (key_len != SRTP_MASTER_LEN) {
 		ast_log(LOG_ERROR, "base64 encode/decode bad len %d != %d\n", key_len, SRTP_MASTER_LEN);
+		ast_free(p);
+		return NULL;
 	}
 
 	if (memcmp(remote_key, p->local_key, SRTP_MASTER_LEN)) {
 		ast_log(LOG_ERROR, "base64 encode/decode bad key\n");
+		ast_free(p);
+		return NULL;
 	}
 
 	ast_debug(1 , "local_key64 %s len %zu\n", p->local_key64, strlen(p->local_key64));

Modified: team/group/srtp_reboot/channels/sip/srtp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/srtp_reboot/channels/sip/srtp.c?view=diff&rev=266291&r1=266290&r2=266291
==============================================================================
--- team/group/srtp_reboot/channels/sip/srtp.c (original)
+++ team/group/srtp_reboot/channels/sip/srtp.c Fri May 28 12:55:23 2010
@@ -36,9 +36,7 @@
 {
 	struct sip_srtp *srtp;
 
-	if (!(srtp = ast_calloc(1, sizeof(*srtp)))) {
-		ast_log(LOG_ERROR, "Out of memory, can't allocate srtp structure\n");
-	}
+	srtp = ast_calloc(1, sizeof(*srtp));
 
 	return srtp;
 }




More information about the asterisk-commits mailing list