From 634b645b4edd30bbcf7716da7540a071fd76402c Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Thu, 2 Jan 2014 14:48:26 +0100 Subject: [PATCH] MT#5393 Properly set dir flags for v4/v6 handling. --- daemon/call.c | 21 +++++++++++++-------- daemon/sdp.c | 3 +++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index fa6a07269..33dcc69f9 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -122,9 +122,6 @@ static void unkernelize(struct peer *); static void relays_cache_port_used(struct relays_cache *c); static void ng_call_stats(struct call *call, const str *fromtag, const str *totag, bencode_item_t *output); - - - static void stream_closed(int fd, void *p, uintptr_t u) { struct callstream *cs = p; struct streamrelay *r; @@ -1027,11 +1024,14 @@ static int setup_peer(struct peer *p, struct stream_input *s, const str *tag) { switch (s->direction[i]) { case DIR_INTERNAL: cs->peers[i ^ p->idx].desired_family = AF_INET; + mylog(LOG_DEBUG, "dir %d/%d/%d is internal, use AF_INET", i, p->idx, i ^ p->idx); break; case DIR_EXTERNAL: cs->peers[i ^ p->idx].desired_family = AF_INET6; + mylog(LOG_DEBUG, "dir %d/%d/%d is external, use AF_INET6", i, p->idx, i ^ p->idx); break; default: + mylog(LOG_DEBUG, "dir %d unknown (%d)", i, s->direction[i]); break; } } @@ -2274,13 +2274,18 @@ static void call_ng_process_flags(struct sdp_ng_flags *out, GQueue *streams, ben } /* XXX convert to a "desired-family" kinda thing instead */ - diridx = 0; if ((list = bencode_dictionary_get_expect(input, "direction", BENCODE_LIST))) { + diridx = 0; for (it = list->child; it && diridx < 2; it = it->sibling) { - if (!bencode_strcmp(it, "internal")) - dirs[diridx++] = DIR_INTERNAL; - else if (!bencode_strcmp(it, "external")) - dirs[diridx++] = DIR_EXTERNAL; + if (!bencode_strcmp(it, "internal")) { + dirs[diridx] = DIR_INTERNAL; + out->desired_family[diridx] = DIR_INTERNAL; + } + else if (!bencode_strcmp(it, "external")) { + dirs[diridx] = DIR_EXTERNAL; + out->desired_family[diridx] = DIR_EXTERNAL; + } + ++diridx; } for (gl = streams->head; gl; gl = gl->next) { diff --git a/daemon/sdp.c b/daemon/sdp.c index d38e8b874..90d1f4829 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -547,6 +547,9 @@ static int fill_stream(struct stream_input *si, struct sdp_media *media, int off /* we ignore the media type */ si->stream.port = (media->port_num + (offset * 2)) & 0xffff; + si->direction[0] = flags->desired_family[0]; + si->direction[1] = flags->desired_family[1]; + return 0; }