support trust-address flag

git.mgm/mediaproxy-ng/2.2
Richard Fuchs 13 years ago
parent 7a0687bebc
commit e22b6a04fb

@ -2095,7 +2095,7 @@ static void call_ng_process_flags(struct sdp_ng_flags *out, GQueue *streams, ben
if ((list = bencode_dictionary_get_expect(input, "flags", BENCODE_LIST))) {
for (it = list->child; it; it = it->sibling) {
if (!bencode_strcmp(it, "trust-address")) /* XXX not implemented */
if (!bencode_strcmp(it, "trust-address"))
out->trust_address = 1;
else if (!bencode_strcmp(it, "symmetric"))
out->symmetric = 1;
@ -2128,6 +2128,12 @@ static void call_ng_process_flags(struct sdp_ng_flags *out, GQueue *streams, ben
si->direction[1] = dirs[1];
}
}
list = bencode_dictionary_get_expect(input, "received-from", BENCODE_LIST);
if (list && (it = list->child)) {
bencode_get_str(it, &out->received_from_address);
bencode_get_str(it->sibling, &out->received_from_family);
}
}
static const char *call_offer_answer_ng(bencode_item_t *input, struct callmaster *m, bencode_item_t *output, enum call_opmode opmode, const char *tagname) {

@ -415,7 +415,7 @@ static int replace_port(struct string_chopper *chop, str *port, GList *m, int of
return 0;
}
static int replace_network_address(struct string_chopper *chop, struct network_address *address, GList *m, int off) {
static int replace_network_address(struct string_chopper *chop, struct network_address *address, GList *m, int off, struct sdp_ng_flags *flags) {
struct callstream *cs;
struct peer *peer;
@ -430,7 +430,13 @@ static int replace_network_address(struct string_chopper *chop, struct network_a
if (copy_up_to(chop, &address->address_type))
return -1;
call_stream_address(chop->output, peer, 2);
if (!flags->trust_address && flags->received_from_family.len == 3 && flags->received_from_address.len) {
g_string_append_len(chop->output, flags->received_from_family.s, flags->received_from_family.len);
g_string_append_c(chop->output, ' ');
g_string_append_len(chop->output, flags->received_from_address.s, flags->received_from_address.len);
}
else
call_stream_address(chop->output, peer, SAF_NG);
if (skip_over(chop, &address->address))
return -1;
@ -471,11 +477,11 @@ str *sdp_replace(str *body, GQueue *sessions, struct call *call, int num, enum c
session = l->data;
if (session->origin.parsed && flags->replace_origin) {
if (replace_network_address(&chop, &session->origin.address, m, off))
if (replace_network_address(&chop, &session->origin.address, m, off, flags))
goto error;
}
if (session->connection.parsed) {
if (replace_network_address(&chop, &session->connection.address, m, off))
if (replace_network_address(&chop, &session->connection.address, m, off, flags))
goto error;
}
@ -487,7 +493,7 @@ str *sdp_replace(str *body, GQueue *sessions, struct call *call, int num, enum c
goto error;
if (media->connection.parsed && flags->replace_sess_conn) {
if (replace_network_address(&chop, &media->connection.address, m, off))
if (replace_network_address(&chop, &media->connection.address, m, off, flags))
goto error;
}
}

@ -8,6 +8,8 @@
struct sdp_ng_flags {
int desired_family[2];
str received_from_family;
str received_from_address;
int asymmetric:1,
symmetric:1,
trust_address:1,

Loading…
Cancel
Save