[asterisk-commits] kmoore: branch group/pimp_my_sip r388171 - /team/group/pimp_my_sip/res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu May 9 08:16:55 CDT 2013
Author: kmoore
Date: Thu May 9 08:16:48 2013
New Revision: 388171
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388171
Log:
Ensure res_sip SRTP support parses multiple crypto attributes properly
During testing, it was discovered that res_sip_sdp_rtp would not handle
crypto properly if the first offer was not acceptable and there were
subsequent acceptable offers. This ensures that addtional offers are
parsed and used if acceptable.
Review: https://reviewboard.asterisk.org/r/2503/
Modified:
team/group/pimp_my_sip/res/res_sip_sdp_rtp.c
Modified: team/group/pimp_my_sip/res/res_sip_sdp_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_sdp_rtp.c?view=diff&rev=388171&r1=388170&r2=388171
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_sdp_rtp.c (original)
+++ team/group/pimp_my_sip/res/res_sip_sdp_rtp.c Thu May 9 08:16:48 2013
@@ -519,39 +519,47 @@
static int setup_sdes_srtp(struct ast_sip_session_media *session_media,
const struct pjmedia_sdp_media *stream)
{
- pjmedia_sdp_attr *attr;
- RAII_VAR(char *, crypto_str, NULL, ast_free);
-
- /* check the stream for the required crypto attribute */
- attr = pjmedia_sdp_media_find_attr2(stream, "crypto", NULL);
- if (!attr) {
- return -1;
- }
-
- crypto_str = ast_strndup(attr->value.ptr, attr->value.slen);
- if (!crypto_str) {
- return -1;
- }
-
- if (!session_media->srtp) {
- session_media->srtp = ast_sdp_srtp_alloc();
+ int i;
+
+ for (i = 0; i < stream->attr_count; i++) {
+ pjmedia_sdp_attr *attr;
+ RAII_VAR(char *, crypto_str, NULL, ast_free);
+
+ /* check the stream for the required crypto attribute */
+ attr = stream->attr[i];
+ if (pj_strcmp2(&attr->name, "crypto")) {
+ continue;
+ }
+
+ crypto_str = ast_strndup(attr->value.ptr, attr->value.slen);
+ if (!crypto_str) {
+ return -1;
+ }
+
if (!session_media->srtp) {
- return -1;
- }
- }
-
- if (!session_media->srtp->crypto) {
- session_media->srtp->crypto = ast_sdp_crypto_alloc();
+ session_media->srtp = ast_sdp_srtp_alloc();
+ if (!session_media->srtp) {
+ return -1;
+ }
+ }
+
if (!session_media->srtp->crypto) {
- return -1;
- }
- }
-
- if (ast_sdp_crypto_process(session_media->rtp, session_media->srtp, crypto_str)) {
- return -1;
- }
-
- return 0;
+ session_media->srtp->crypto = ast_sdp_crypto_alloc();
+ if (!session_media->srtp->crypto) {
+ return -1;
+ }
+ }
+
+ if (!ast_sdp_crypto_process(session_media->rtp, session_media->srtp, crypto_str)) {
+ /* found a valid crypto attribute */
+ return 0;
+ }
+
+ ast_debug(1, "Ignoring crypto offer with unsupported parameters: %s\n", crypto_str);
+ }
+
+ /* no usable crypto attributes found */
+ return -1;
}
/*! \brief Function which negotiates an incoming media stream */
More information about the asterisk-commits
mailing list