From 059781781605105836d7f91a231f259ae8179f5c Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Sun, 5 Jan 2014 16:46:40 -0500 Subject: [PATCH] update desired address family (based on "direction") when branching --- daemon/call.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 0389b2074..27d730c8d 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1296,12 +1296,28 @@ fail: return -1; } +static void setup_stream_families(struct callstream *cs, struct stream_input *s, int idx) { + int i; + + for (i = 0; i < 2; i++) { + switch (s->direction[i]) { + case DIR_INTERNAL: + cs->peers[i ^ idx].desired_family = AF_INET; + break; + case DIR_EXTERNAL: + cs->peers[i ^ idx].desired_family = AF_INET6; + break; + default: + break; + } + } +} + /* caller is responsible for appropriate locking */ static int setup_peer(struct peer *p, struct stream_input *s, const str *tag) { struct streamrelay *a, *b; struct callstream *cs; struct call *ca; - int i; cs = p->up; ca = cs->call; @@ -1324,18 +1340,7 @@ static int setup_peer(struct peer *p, struct stream_input *s, const str *tag) { a->other->crypto.in = s->crypto; b->other->crypto.in = s->crypto; - for (i = 0; i < 2; i++) { - switch (s->direction[i]) { - case DIR_INTERNAL: - cs->peers[i ^ p->idx].desired_family = AF_INET; - break; - case DIR_EXTERNAL: - cs->peers[i ^ p->idx].desired_family = AF_INET6; - break; - default: - break; - } - } + setup_stream_families(cs, s, p->idx); call_str_cpy(ca, &p->tag, tag); p->filled = 1; @@ -1625,6 +1630,7 @@ found: steal_peer(&cs->peers[0], &cs_o->peers[1]); steal_peer(&cs->peers[1], &cs_o->peers[0]); } + setup_stream_families(cs, t, 0); mutex_unlock(&cs_o->lock); }