diff --git a/daemon/call.c b/daemon/call.c index 7f785bf73..27d730c8d 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -191,6 +191,8 @@ static const struct mediaproxy_srtp __mps_null = { static void call_destroy(struct call *); static void unkernelize(struct peer *); +static void unconfirm(struct peer *); +static void unconfirm_cs(struct callstream *); 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); @@ -1294,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; @@ -1307,12 +1325,8 @@ static int setup_peer(struct peer *p, struct stream_input *s, const str *tag) { b = &p->rtps[1]; if (a->peer_advertised.port != s->stream.port - || !IN6_ARE_ADDR_EQUAL(&a->peer_advertised.ip46, &s->stream.ip46)) { - cs->peers[0].confirmed = 0; - unkernelize(&cs->peers[0]); - cs->peers[1].confirmed = 0; - unkernelize(&cs->peers[1]); - } + || !IN6_ARE_ADDR_EQUAL(&a->peer_advertised.ip46, &s->stream.ip46)) + unconfirm_cs(cs); a->peer = s->stream; b->peer = s->stream; @@ -1326,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; @@ -1364,10 +1367,8 @@ static void steal_peer(struct peer *dest, struct peer *src) { mylog(LOG_DEBUG, LOG_PREFIX_CI "Re-using existing open RTP port %u", LOG_PARAMS_CI(c), r->fd.localport); - dest->confirmed = 0; - unkernelize(dest); - src->confirmed = 0; - unkernelize(src); + unconfirm(dest); + unconfirm(src); dest->filled = src->filled; dest->tag = src->tag; @@ -1590,6 +1591,7 @@ static int call_streams(struct call *c, GQueue *s, const str *tag, enum call_opm if (str_cmp_str0(&cs_o->peers[x].tag, tag)) continue; DBG("found existing call stream to steal"); + unconfirm_cs(cs_o); goto found; } mutex_unlock(&cs_o->lock); @@ -1628,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); } @@ -1658,6 +1661,7 @@ found: got_cs: /* cs and cs_o remain locked, and maybe cs == cs_o */ /* matched_relay == peer[x].rtp[0] of cs_o */ + unconfirm_cs(cs); g_queue_delete_link(c->callstreams, l); /* steal cs ref */ p = &cs->peers[1]; p2 = &cs->peers[0]; @@ -1719,9 +1723,8 @@ got_cs: g_queue_push_tail(c->callstreams, cs_o); /* hand over ref to original cs */ } - time(&c->lookup_done); - skip: + time(&c->lookup_done); g_queue_push_tail(q, p->up); /* hand over ref to cs */ mutex_unlock(&cs->lock); if (cs_o && cs_o != cs) @@ -1752,6 +1755,15 @@ skip: +static void unconfirm(struct peer *p) { + p->confirmed = 0; + unkernelize(p); +} +static void unconfirm_cs(struct callstream *cs) { + unconfirm(&cs->peers[0]); + unconfirm(&cs->peers[1]); +} + static void unkernelize(struct peer *p) { struct streamrelay *r; int i; @@ -1760,8 +1772,6 @@ static void unkernelize(struct peer *p) { return; for (i = 0; i < 2; i++) { - if (!p->kernelized) - continue; r = &p->rtps[i]; if (r->no_kernel_support) continue; diff --git a/debian/copyright b/debian/copyright index a8f3e5108..bad3fe81c 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,12 +1,24 @@ Upstream Author: The Sipwise Team - http://sipwise.com Copyright: 2007-2013, Sipwise GmbH, Austria -License: GPL-3+ +License: GPL-3+ with OpenSSL exception This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. . + In addition, as a special exception, the author of this + program gives permission to link the code of its + release with the OpenSSL project's "OpenSSL" library (or + with modified versions of it that use the same license as + the "OpenSSL" library), and distribute the linked + executables. You must obey the GNU General Public + License in all respects for all of the code used other + than "OpenSSL". If you modify this file, you may extend + this exception to your version of the file, but you are + not obligated to do so. If you do not wish to do so, + delete this exception statement from your version. + . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR diff --git a/iptables-extension/libxt_MEDIAPROXY.c b/iptables-extension/libxt_MEDIAPROXY.c index c307c991b..89973782a 100644 --- a/iptables-extension/libxt_MEDIAPROXY.c +++ b/iptables-extension/libxt_MEDIAPROXY.c @@ -90,7 +90,7 @@ static void print(const void *ip, const struct xt_entry_target *target, int nume #endif struct xt_mediaproxy_info *info = (void *) target->data; - printf("id %u", info->id); + printf(" MEDIAPROXY id:%u", info->id); } #if defined(__ipt) @@ -102,7 +102,7 @@ static void save(const void *ip, const struct xt_entry_target *target) { #endif struct xt_mediaproxy_info *info = (void *) target->data; - printf("--id %u", info->id); + printf(" --id %u", info->id); } static struct option opts[] = { diff --git a/kernel-module/xt_MEDIAPROXY.c b/kernel-module/xt_MEDIAPROXY.c index 01104e8d7..e3671fb82 100644 --- a/kernel-module/xt_MEDIAPROXY.c +++ b/kernel-module/xt_MEDIAPROXY.c @@ -352,7 +352,11 @@ static int table_create_proc(struct mediaproxy_table *t, u_int32_t id) { sprintf(num, "%u", id); +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) + t->proc = create_proc_entry(num, S_IFDIR | S_IRUGO | S_IXUGO, my_proc_root); +#else t->proc = proc_mkdir_mode(num, S_IRUGO | S_IXUGO, my_proc_root); +#endif if (!t->proc) return -1;