[asterisk-commits] file: branch 13 r424288 - in /branches/13: ./ res/res_pjsip_sdp_rtp.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Oct 1 11:19:10 CDT 2014
Author: file
Date: Wed Oct 1 11:19:08 2014
New Revision: 424288
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=424288
Log:
res_pjsip_sdp_rtp: Accept DTLS attributes in top level, not just media session.
#SIPit31
........
Merged revisions 424287 from http://svn.asterisk.org/svn/asterisk/branches/12
Modified:
branches/13/ (props changed)
branches/13/res/res_pjsip_sdp_rtp.c
Propchange: branches/13/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.
Modified: branches/13/res/res_pjsip_sdp_rtp.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/res_pjsip_sdp_rtp.c?view=diff&rev=424288&r1=424287&r2=424288
==============================================================================
--- branches/13/res/res_pjsip_sdp_rtp.c (original)
+++ branches/13/res/res_pjsip_sdp_rtp.c Wed Oct 1 11:19:08 2014
@@ -588,59 +588,69 @@
return 0;
}
+static void apply_dtls_attrib(struct ast_sip_session_media *session_media,
+ pjmedia_sdp_attr *attr)
+{
+ struct ast_rtp_engine_dtls *dtls = ast_rtp_instance_get_dtls(session_media->rtp);
+ pj_str_t *value;
+
+ if (!attr->value.ptr) {
+ return;
+ }
+
+ value = pj_strtrim(&attr->value);
+
+ if (!pj_strcmp2(&attr->name, "setup")) {
+ if (!pj_stricmp2(value, "active")) {
+ dtls->set_setup(session_media->rtp, AST_RTP_DTLS_SETUP_ACTIVE);
+ } else if (!pj_stricmp2(value, "passive")) {
+ dtls->set_setup(session_media->rtp, AST_RTP_DTLS_SETUP_PASSIVE);
+ } else if (!pj_stricmp2(value, "actpass")) {
+ dtls->set_setup(session_media->rtp, AST_RTP_DTLS_SETUP_ACTPASS);
+ } 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", (int)value->slen, value->ptr);
+ }
+ } else if (!pj_strcmp2(&attr->name, "connection")) {
+ if (!pj_stricmp2(value, "new")) {
+ dtls->reset(session_media->rtp);
+ } else if (!pj_stricmp2(value, "existing")) {
+ /* Do nothing */
+ } else {
+ 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[32];
+ char fingerprint_text[value->slen + 1];
+ ast_copy_pj_str(fingerprint_text, value, sizeof(fingerprint_text));
+ if (sscanf(fingerprint_text, "%31s %255s", hash, hash_value) == 2) {
+ if (!strcasecmp(hash, "sha-1")) {
+ dtls->set_fingerprint(session_media->rtp, AST_RTP_DTLS_HASH_SHA1, hash_value);
+ } else if (!strcasecmp(hash, "sha-256")) {
+ dtls->set_fingerprint(session_media->rtp, AST_RTP_DTLS_HASH_SHA256, hash_value);
+ } else {
+ ast_log(LOG_WARNING, "Unsupported fingerprint hash type '%s'\n",
+ hash);
+ }
+ }
+ }
+}
+
static int parse_dtls_attrib(struct ast_sip_session_media *session_media,
+ const struct pjmedia_sdp_session *sdp,
const struct pjmedia_sdp_media *stream)
{
int i;
- struct ast_rtp_engine_dtls *dtls = ast_rtp_instance_get_dtls(session_media->rtp);
+
+ for (i = 0; i < sdp->attr_count; i++) {
+ apply_dtls_attrib(session_media, sdp->attr[i]);
+ }
for (i = 0; i < stream->attr_count; i++) {
- pjmedia_sdp_attr *attr = stream->attr[i];
- pj_str_t *value;
-
- if (!attr->value.ptr) {
- continue;
- }
-
- value = pj_strtrim(&attr->value);
-
- if (!pj_strcmp2(&attr->name, "setup")) {
- if (!pj_stricmp2(value, "active")) {
- dtls->set_setup(session_media->rtp, AST_RTP_DTLS_SETUP_ACTIVE);
- } else if (!pj_stricmp2(value, "passive")) {
- dtls->set_setup(session_media->rtp, AST_RTP_DTLS_SETUP_PASSIVE);
- } else if (!pj_stricmp2(value, "actpass")) {
- dtls->set_setup(session_media->rtp, AST_RTP_DTLS_SETUP_ACTPASS);
- } 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", (int)value->slen, value->ptr);
- }
- } else if (!pj_strcmp2(&attr->name, "connection")) {
- if (!pj_stricmp2(value, "new")) {
- dtls->reset(session_media->rtp);
- } else if (!pj_stricmp2(value, "existing")) {
- /* Do nothing */
- } else {
- 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[32];
- char fingerprint_text[value->slen + 1];
- ast_copy_pj_str(fingerprint_text, value, sizeof(fingerprint_text));
-
- if (sscanf(fingerprint_text, "%31s %255s", hash, hash_value) == 2) {
- if (!strcasecmp(hash, "sha-1")) {
- dtls->set_fingerprint(session_media->rtp, AST_RTP_DTLS_HASH_SHA1, hash_value);
- } else if (!strcasecmp(hash, "sha-256")) {
- dtls->set_fingerprint(session_media->rtp, AST_RTP_DTLS_HASH_SHA256, hash_value);
- } else {
- ast_log(LOG_WARNING, "Unsupported fingerprint hash type '%s'\n",
- hash);
- }
- }
- }
- }
+ apply_dtls_attrib(session_media, stream->attr[i]);
+ }
+
ast_set_flag(session_media->srtp, AST_SRTP_CRYPTO_OFFER_OK);
return 0;
@@ -684,6 +694,7 @@
static int setup_media_encryption(struct ast_sip_session *session,
struct ast_sip_session_media *session_media,
+ const struct pjmedia_sdp_session *sdp,
const struct pjmedia_sdp_media *stream)
{
switch (session->endpoint->media.rtp.encryption) {
@@ -696,7 +707,7 @@
if (setup_dtls_srtp(session, session_media)) {
return -1;
}
- if (parse_dtls_attrib(session_media, stream)) {
+ if (parse_dtls_attrib(session_media, sdp, stream)) {
return -1;
}
break;
@@ -744,7 +755,7 @@
pj_strdup(session->inv_session->pool, &session_media->transport, &stream->desc.transport);
}
- if (setup_media_encryption(session, session_media, stream)) {
+ if (setup_media_encryption(session, session_media, sdp, stream)) {
return -1;
}
@@ -1061,7 +1072,7 @@
return -1;
}
- if (setup_media_encryption(session, session_media, remote_stream)) {
+ if (setup_media_encryption(session, session_media, remote, remote_stream)) {
return -1;
}
More information about the asterisk-commits
mailing list