TT#94201 convert ICE= options internally to enum

Change-Id: I3d7a6049cd7ab8e95da56820ccd3f2981ef03bc5
pull/1099/head
Richard Fuchs 5 years ago
parent a89696c4be
commit 65cf46bc0a

@ -1243,11 +1243,11 @@ static void __ice_offer(const struct sdp_ng_flags *flags, struct call_media *thi
if (!MEDIA_ISSET(this, INITIALIZED))
MEDIA_SET(this, ICE);
// unless instructed not to
if (flags->ice_default) {
if (flags->ice_option == ICE_DEFAULT) {
if (!MEDIA_ISSET(other, ICE))
MEDIA_CLEAR(this, ICE);
}
else if (flags->ice_remove)
else if (flags->ice_option == ICE_REMOVE)
MEDIA_CLEAR(this, ICE);
if (flags->passthrough_on) {
@ -1263,7 +1263,7 @@ static void __ice_offer(const struct sdp_ng_flags *flags, struct call_media *thi
return;
}
if (!flags->ice_force) {
if (flags->ice_option != ICE_FORCE && flags->ice_option != ICE_DEFAULT) {
/* special case: if doing ICE on both sides and ice_force is not set, we cannot
* be sure that media will pass through us, so we have to disable certain features */
if (MEDIA_ISSET(this, ICE) && MEDIA_ISSET(other, ICE)) {

@ -927,20 +927,18 @@ static void call_ng_process_flags(struct sdp_ng_flags *out, bencode_item_t *inpu
if (bencode_dictionary_get_str(input, "ICE", &s)) {
switch (__csh_lookup(&s)) {
case CSH_LOOKUP("remove"):
out->ice_remove = 1;
out->ice_option = ICE_REMOVE;
break;
case CSH_LOOKUP("force"):
out->ice_force = 1;
out->ice_option = ICE_FORCE;
break;
case CSH_LOOKUP("default"):
out->ice_default = 1;
out->ice_force = 1;
out->ice_remove = 1;
out->ice_option = ICE_DEFAULT;
break;
case CSH_LOOKUP("force_relay"):
case CSH_LOOKUP("force-relay"):
case CSH_LOOKUP("force relay"):
out->ice_force_relay = 1;
out->ice_option = ICE_FORCE_RELAY;
break;
default:
ilog(LOG_WARN, "Unknown 'ICE' flag encountered: '"STR_FORMAT"'",

@ -1901,19 +1901,21 @@ static int process_session_attributes(struct sdp_chopper *chop, struct sdp_attri
case ATTR_ICE_PWD:
case ATTR_ICE_OPTIONS:
case ATTR_ICE_LITE:
if (!flags->ice_remove && !flags->ice_force)
if (flags->ice_option != ICE_REMOVE && flags->ice_option != ICE_FORCE
&& flags->ice_option != ICE_DEFAULT)
break;
goto strip;
case ATTR_CANDIDATE:
if (flags->ice_force_relay) {
if (flags->ice_option == ICE_FORCE_RELAY) {
if ((attr->u.candidate.type_str.len == 5) &&
(strncasecmp(attr->u.candidate.type_str.s, "relay", 5) == 0))
goto strip;
else
break;
}
if (!flags->ice_remove && !flags->ice_force)
if (flags->ice_option != ICE_REMOVE && flags->ice_option != ICE_FORCE
&& flags->ice_option != ICE_DEFAULT)
break;
goto strip;
@ -1974,12 +1976,13 @@ static int process_media_attributes(struct sdp_chopper *chop, struct sdp_media *
case ATTR_ICE_LITE:
if (MEDIA_ISSET(media, PASSTHRU))
break;
if (!flags->ice_remove && !flags->ice_force)
if (flags->ice_option != ICE_REMOVE && flags->ice_option != ICE_FORCE
&& flags->ice_option != ICE_DEFAULT)
break;
goto strip;
case ATTR_CANDIDATE:
if (flags->ice_force_relay) {
if (flags->ice_option == ICE_FORCE_RELAY) {
if ((attr->u.candidate.type_str.len == 5) &&
(strncasecmp(attr->u.candidate.type_str.s, "relay", 5) == 0))
goto strip;
@ -1988,13 +1991,14 @@ static int process_media_attributes(struct sdp_chopper *chop, struct sdp_media *
}
if (MEDIA_ISSET(media, PASSTHRU))
break;
if (!flags->ice_remove && !flags->ice_force)
if (flags->ice_option != ICE_REMOVE && flags->ice_option != ICE_FORCE
&& flags->ice_option != ICE_DEFAULT)
break;
goto strip;
case ATTR_RTCP:
case ATTR_RTCP_MUX:
if (flags->ice_force_relay)
if (flags->ice_option == ICE_FORCE_RELAY)
break;
goto strip;
@ -2141,7 +2145,7 @@ static void insert_candidates(struct sdp_chopper *chop, struct packet_stream *rt
media = rtp->media;
cand_type = ICT_HOST;
if (flags->ice_force_relay)
if (flags->ice_option == ICE_FORCE_RELAY)
cand_type = ICT_RELAY;
if (MEDIA_ISSET(media, PASSTHRU))
new_priority(sdp_media, cand_type, &type_pref, &local_pref);
@ -2342,12 +2346,12 @@ int sdp_replace(struct sdp_chopper *chop, GQueue *sessions, struct call_monologu
}
if (session->origin.parsed && flags->replace_origin &&
!flags->ice_force_relay) {
flags->ice_option != ICE_FORCE_RELAY) {
if (replace_network_address(chop, &session->origin.address, ps, flags, 0))
goto error;
}
if (session->connection.parsed && sess_conn &&
!flags->ice_force_relay) {
flags->ice_option != ICE_FORCE_RELAY) {
if (replace_network_address(chop, &session->connection.address, ps, flags, 1))
goto error;
}
@ -2379,7 +2383,7 @@ int sdp_replace(struct sdp_chopper *chop, GQueue *sessions, struct call_monologu
goto error;
ps = j->data;
if (!flags->ice_force_relay && call_media->type_id != MT_MESSAGE) {
if (flags->ice_option != ICE_FORCE_RELAY && call_media->type_id != MT_MESSAGE) {
if (replace_media_type(chop, sdp_media, call_media))
goto error;
if (replace_media_port(chop, sdp_media, ps))
@ -2454,7 +2458,7 @@ int sdp_replace(struct sdp_chopper *chop, GQueue *sessions, struct call_monologu
chopper_append_c(chop, "a=rtcp-mux\r\n");
ps_rtcp = NULL;
}
else if (ps_rtcp && !flags->ice_force_relay) {
else if (ps_rtcp && flags->ice_option != ICE_FORCE_RELAY) {
insert_rtcp_attr(chop, ps_rtcp, flags);
if (MEDIA_ISSET(call_media, RTCP_MUX))
chopper_append_c(chop, "a=rtcp-mux\r\n");

@ -47,6 +47,13 @@ struct sdp_ng_flags {
rev_ptime;
GHashTable *sdes_no;
str dtls_fingerprint;
enum {
ICE_NONE = 0,
ICE_REMOVE,
ICE_FORCE,
ICE_FORCE_RELAY,
ICE_DEFAULT,
} ice_option:3;
int asymmetric:1,
protocol_accept:1,
no_redis_update:1,
@ -55,10 +62,6 @@ struct sdp_ng_flags {
port_latching:1,
replace_origin:1,
replace_sess_conn:1,
ice_remove:1,
ice_force:1,
ice_force_relay:1,
ice_default:1,
rtcp_mux_offer:1,
rtcp_mux_require:1,
rtcp_mux_demux:1,

Loading…
Cancel
Save