Merge branch 'extend-default-intf' of https://github.com/1and1/rtpengine

Change-Id: I187bc7c67146011a76acc17576cd4338e095c754
changes/56/19156/1
Richard Fuchs 7 years ago
commit 165cb0cd4b

@ -696,6 +696,10 @@ no alternatives would be used. When IPv6 is needed as a primary address, either
`pub:3` might be selected. If at any given time not enough ports are available on any interface,
it will not be selected by the round-robin algorithm.
It is possible to use the round-robin algorithm even if the `direction` is not given. If the first
given interface has the `BASE:SUFFIX` format then the round-robin algorithm is used and will select
interfaces with the same `BASE` name.
If you're not using the NG protocol but rather the legacy UDP protocol used by the *rtpproxy* module,
the interfaces must be named `internal` and `external` corresponding to the `i` and `e` flags if you
wish to use network bridging in this mode.

@ -391,6 +391,7 @@ done:
// 'fam' may only be NULL if 'name' is also NULL
struct logical_intf *get_logical_interface(const str *name, sockfamily_t *fam, int num_ports) {
struct logical_intf *log = NULL;
int rr_use_default_intf = 0;
__C_DBG("Get logical interface for %d ports", num_ports);
@ -410,14 +411,26 @@ struct logical_intf *get_logical_interface(const str *name, sockfamily_t *fam, i
got_some:
;
}
return q->head ? q->head->data : NULL;
if (!q->head)
return NULL;
log = q->head->data;
// if interface is in the form foo:bar then use round-robin
if (!fam || log->name.len == log->name_base.len)
return log;
else
rr_use_default_intf = 1;
}
// check if round-robin is desired
struct logical_intf key;
key.name = *name;
if (rr_use_default_intf)
key.name = log->name_base;
else
key.name = *name;
key.preferred_family = fam;
struct intf_rr *rr = g_hash_table_lookup(__logical_intf_name_family_rr_hash, &key);
if (!rr)
return __get_logical_interface(name, fam);
@ -535,7 +548,9 @@ static void __interface_append(struct intf_config *ifa, sockfamily_t *fam) {
if (!lif) {
lif = g_slice_alloc0(sizeof(*lif));
g_queue_init(&lif->list);
lif->name = ifa->name;
lif->name_base = ifa->name_base;
lif->preferred_family = fam;
lif->addr_hash = g_hash_table_new(__addr_type_hash, __addr_type_eq);
lif->rr_specs = g_hash_table_new(str_hash, str_equal);

@ -28,6 +28,7 @@ struct logical_intf {
GQueue list; /* struct local_intf */
GHashTable *addr_hash; // addr + type -> struct local_intf XXX obsolete?
GHashTable *rr_specs;
str name_base; // if name is "foo:bar", this is "foo"
};
struct port_pool {
BIT_ARRAY_DECLARE(ports_used, 0x10000);

Loading…
Cancel
Save