diff --git a/daemon/call.c b/daemon/call.c index d856404bd..1387aba24 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1666,8 +1666,6 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this MEDIA_SET(this, SETUP_ACTIVE); } else { - if (flags->dtls_passive && MEDIA_ISSET(this, SETUP_PASSIVE)) - MEDIA_CLEAR(this, SETUP_ACTIVE); /* if we can be active, we will, otherwise we'll be passive */ if (MEDIA_ISSET(this, SETUP_ACTIVE)) MEDIA_CLEAR(this, SETUP_PASSIVE); @@ -2212,7 +2210,7 @@ static void __dtls_logic(const sdp_ng_flags *flags, && MEDIA_ARESET2(other_media, SETUP_ACTIVE, SETUP_PASSIVE)) { // if passive mode is requested, honour it - if (flags->dtls_reverse_passive) + if (flags->dtls_passive) MEDIA_CLEAR(other_media, SETUP_ACTIVE); // if we were previously passive, retain that role else if ((tmp & (MEDIA_FLAG_SETUP_ACTIVE | MEDIA_FLAG_SETUP_PASSIVE)) diff --git a/daemon/call_flags.c b/daemon/call_flags.c index 6b6cdd4dd..0af65cedd 100644 --- a/daemon/call_flags.c +++ b/daemon/call_flags.c @@ -446,6 +446,34 @@ static const char *call_ng_flags_bundle(str *s, unsigned int idx, helper_arg arg return NULL; } +static const char *call_ng_flags_dtls(str *s, unsigned int idx, sdp_ng_flags *out) { + switch (__csh_lookup(s)) { + case CSH_LOOKUP("passive"): + if (out->opmode == OP_ANSWER) + ilog(LOG_NOTICE, "Ignoring DTLS=passive flag in answer as it is too late"); + else + out->dtls_passive = true; + break; + case CSH_LOOKUP("active"): + if (out->opmode == OP_ANSWER) + ilog(LOG_NOTICE, "Ignoring DTLS=active flag in answer as it is too late"); + else + out->dtls_passive = false; + break; + case CSH_LOOKUP("no"): + case CSH_LOOKUP("off"): + case CSH_LOOKUP("disabled"): + case CSH_LOOKUP("disable"): + out->dtls_off = true; + break; + default: + ilog(LOG_WARN, "Unknown 'DTLS' flag encountered: '" STR_FORMAT "'", + STR_FMT(s)); + } + + return NULL; +} + static const char *call_ng_flags_moh(const ng_parser_t *parser, str *key, parser_arg value, helper_arg arg) { sdp_ng_flags *out = arg.flags; switch (__csh_lookup(key)) { @@ -1079,7 +1107,6 @@ void call_ng_flags_init(sdp_ng_flags *out, enum ng_opmode opmode) { out->trust_address = trust_address_def; out->dtls_passive = dtls_passive_def; - out->dtls_reverse_passive = dtls_passive_def; out->el_option = rtpe_config.endpoint_learning; out->tos = 256; out->delay_buffer = -1; @@ -1607,56 +1634,15 @@ const char *call_ng_main_flags(const ng_parser_t *parser, str *key, parser_arg v break; case CSH_LOOKUP("DTLS"): case CSH_LOOKUP("dtls"): - switch (__csh_lookup_n(1, &s)) { - case CSH_LOOKUP_N(1, "passive"): - if (out->opmode == OP_ANSWER) - ilog(LOG_NOTICE, "Ignoring DTLS=passive flag in answer as it is too late"); - else - out->dtls_passive = true; - break; - case CSH_LOOKUP_N(1, "active"): - if (out->opmode == OP_ANSWER) - ilog(LOG_NOTICE, "Ignoring DTLS=active flag in answer as it is too late"); - else - out->dtls_passive = false; - break; - case CSH_LOOKUP_N(1, "no"): - case CSH_LOOKUP_N(1, "off"): - case CSH_LOOKUP_N(1, "disabled"): - case CSH_LOOKUP_N(1, "disable"): - out->dtls_off = true; - break; - default: - ilog(LOG_WARN, "Unknown 'DTLS' flag encountered: '" STR_FORMAT "'", - STR_FMT(&s)); - } - break; + case CSH_LOOKUP("DTLS-reverse"): + case CSH_LOOKUP("dtls-reverse"): + return call_ng_flags_str_list(parser, value, call_ng_flags_dtls, out); case CSH_LOOKUP("DTLS fingerprint"): case CSH_LOOKUP("DTLS-fingerprint"): case CSH_LOOKUP("dtls fingerprint"): case CSH_LOOKUP("dtls-fingerprint"): out->dtls_fingerprint = s; break; - case CSH_LOOKUP("DTLS-reverse"): - case CSH_LOOKUP("dtls-reverse"): - case CSH_LOOKUP("DTLS reverse"): - case CSH_LOOKUP("dtls reverse"): - if (out->opmode == OP_ANSWER) - ilog(LOG_NOTICE, "Ignoring DTLS-reverse option in answer as it is too late"); - else { - switch (__csh_lookup_n(1, &s)) { - case CSH_LOOKUP_N(1, "passive"): - out->dtls_reverse_passive = true; - break; - case CSH_LOOKUP_N(1, "active"): - out->dtls_reverse_passive = false; - break; - default: - ilog(LOG_WARN, "Unknown 'DTLS-reverse' flag encountered: '" STR_FORMAT "'", - STR_FMT(&s)); - } - } - break; case CSH_LOOKUP("DTMF-delay"): case CSH_LOOKUP("DTMF delay"): case CSH_LOOKUP("dtmf-delay"): diff --git a/docs/ng_control_protocol.md b/docs/ng_control_protocol.md index 4eb291b1d..b8889303f 100644 --- a/docs/ng_control_protocol.md +++ b/docs/ng_control_protocol.md @@ -337,24 +337,6 @@ Optionally included keys are: Reverts the `passive` setting. Only useful if the `dtls-passive` config option is set. -* `DTLS-reverse` - - Contains a string and influences the behaviour of DTLS-SRTP. Unlike the regular `DTLS` flag, this one - is used to control behaviour towards DTLS that was offered to *rtpengine*. In particular, if `passive` - mode is used, it prevents *rtpengine* from prematurely sending active DTLS connection attempts. - Possible values are: - - - `passive` - - Instructs *rtpengine* to prefer the passive (i.e. server) role for the DTLS - handshake. The default is to take the active (client) role if possible. This is useful in cases - where the SRTP endpoint isn't able to receive or process the DTLS handshake packets, for example - when it's behind NAT or needs to finish ICE processing first. - - - `active` - - Reverts the `passive` setting. Only useful if the `dtls-passive` config option is set. - * `DTLS-fingerprint` Contains a string and is used to select the hashing function to generate the DTLS fingerprint diff --git a/include/call_flags.h b/include/call_flags.h index bbf5128a6..e738e66c3 100644 --- a/include/call_flags.h +++ b/include/call_flags.h @@ -245,7 +245,6 @@ RTPE_NG_FLAGS_STR_CASE_HT_PARAMS strict_source:1, media_handover:1, dtls_passive:1, - dtls_reverse_passive:1, osrtp_accept_legacy:1, osrtp_accept_rfc:1, osrtp_offer:1,