Merge pull request #2 in FSA/freeswitch-advantage from ~PIOTRGREGOR/freeswitch:feature/FS-10778-srtp-mki-support to v1.8-fsa

* commit '903ea6e6114d3ee8219644f5c7f1f1479bf0bb17':
  FS-10778: Fix compilation and refactor code
This commit is contained in:
Mike Jerris 2017-12-04 20:03:42 +00:00
commit 366bf3f89c

View File

@ -1388,7 +1388,10 @@ switch_status_t switch_core_media_add_crypto(switch_core_session_t *session, swi
p = strchr(key_param, ' ');
if (p && *p && *(p + 1)) {
if (!(p && *p && *(p + 1))) {
goto no_crypto_found;
}
p++;
type = switch_core_media_crypto_str2type(p);
@ -1409,7 +1412,10 @@ switch_status_t switch_core_media_add_crypto(switch_core_session_t *session, swi
}
p = switch_strip_spaces((char*) p, 0);
if (p) {
if (!p) {
break;
}
key_material_begin = p;
key_material_end = switch_core_media_crypto_find_key_material_candidate_end(p);
@ -1458,9 +1464,11 @@ switch_status_t switch_core_media_add_crypto(switch_core_session_t *session, swi
p += keysalt_len;
if (p < key_material_end) { /* Parse LIFETIME or MKI. */
if (!(p < key_material_end)) {
continue;
}
if (opts) { /* if opts != NULL then opts points to first '|' in current key-material cadidate */
if (opts) { /* if opts != NULL then opts points to first '|' in current key-material cadidate, parse it as LIFETIME or MKI */
lifetime = 0;
mki_id = 0;
@ -1524,8 +1532,6 @@ switch_status_t switch_core_media_add_crypto(switch_core_session_t *session, swi
key_material = switch_core_media_crypto_append_key_material(session, key_material, method, (unsigned char*) key,
SUITES[type].keysalt_len, (char*) key_material_begin, key_material_end - key_material_begin, lifetime, mki_id, mki_size);
*key_material_n = *key_material_n + 1;
}
}
} while ((p = switch_strip_spaces((char*) key_material_end, 0)) && (*p != '\0'));
if (direction == SWITCH_RTP_CRYPTO_SEND || direction == SWITCH_RTP_CRYPTO_SEND_RTCP) {
@ -1535,7 +1541,7 @@ switch_status_t switch_core_media_add_crypto(switch_core_session_t *session, swi
}
return SWITCH_STATUS_SUCCESS;
}
no_crypto_found:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error! No crypto to parse\n");