mirror of
https://github.com/status-im/miniupnp.git
synced 2025-02-20 09:48:26 +00:00
miniupnpd: fix for bridges
you now can setup : listening_ip=igb1 bridge0 xxx0 xxx1 ... miniupnpd will use igd1 address, but will not complain when receiving packets from either igb1, bridge0, xxx0 or xxx1 fixes #379 see also #408
This commit is contained in:
parent
a965520085
commit
7800de9429
@ -2,7 +2,7 @@
|
|||||||
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
||||||
* MiniUPnP project
|
* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
||||||
* (c) 2006-2019 Thomas Bernard
|
* (c) 2006-2020 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
|
|
||||||
@ -991,11 +991,16 @@ ProcessSSDPData(int s, const char *bufr, int n,
|
|||||||
/* get the string representation of the sender address */
|
/* get the string representation of the sender address */
|
||||||
sockaddr_to_string(sender, sender_str, sizeof(sender_str));
|
sockaddr_to_string(sender, sender_str, sizeof(sender_str));
|
||||||
lan_addr = get_lan_for_peer(sender);
|
lan_addr = get_lan_for_peer(sender);
|
||||||
if(source_if >= 0)
|
if(source_if > 0)
|
||||||
{
|
{
|
||||||
if(lan_addr != NULL)
|
if(lan_addr != NULL)
|
||||||
{
|
{
|
||||||
|
#ifndef MULTIPLE_EXTERNAL_IP
|
||||||
|
if(lan_addr->index != (unsigned)source_if && lan_addr->index != 0
|
||||||
|
&& !(lan_addr->add_indexes & (1UL << (source_if - 1))))
|
||||||
|
#else
|
||||||
if(lan_addr->index != (unsigned)source_if && lan_addr->index != 0)
|
if(lan_addr->index != (unsigned)source_if && lan_addr->index != 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
syslog(LOG_WARNING, "interface index not matching %u != %d", lan_addr->index, source_if);
|
syslog(LOG_WARNING, "interface index not matching %u != %d", lan_addr->index, source_if);
|
||||||
}
|
}
|
||||||
|
@ -912,7 +912,7 @@ static int
|
|||||||
parselanaddr(struct lan_addr_s * lan_addr, const char * str)
|
parselanaddr(struct lan_addr_s * lan_addr, const char * str)
|
||||||
{
|
{
|
||||||
const char * p;
|
const char * p;
|
||||||
int n;
|
unsigned int n;
|
||||||
char tmp[16];
|
char tmp[16];
|
||||||
|
|
||||||
memset(lan_addr, 0, sizeof(struct lan_addr_s));
|
memset(lan_addr, 0, sizeof(struct lan_addr_s));
|
||||||
@ -958,7 +958,7 @@ parselanaddr(struct lan_addr_s * lan_addr, const char * str)
|
|||||||
while(*p && (*p=='.' || isdigit(*p)))
|
while(*p && (*p=='.' || isdigit(*p)))
|
||||||
p++;
|
p++;
|
||||||
n = p - q;
|
n = p - q;
|
||||||
if(n>15)
|
if(n >= sizeof(tmp))
|
||||||
goto parselan_error;
|
goto parselan_error;
|
||||||
memcpy(tmp, q, n);
|
memcpy(tmp, q, n);
|
||||||
tmp[n] = '\0';
|
tmp[n] = '\0';
|
||||||
@ -1003,12 +1003,39 @@ parselanaddr(struct lan_addr_s * lan_addr, const char * str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
while(*p) {
|
||||||
|
/* skip spaces */
|
||||||
|
while(*p && isspace(*p))
|
||||||
|
p++;
|
||||||
|
if(*p) {
|
||||||
|
unsigned int index;
|
||||||
|
n = 0;
|
||||||
|
while(p[n] && !isspace(p[n]) && n < sizeof(tmp)) {
|
||||||
|
tmp[n] = p[n];
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
if(n >= sizeof(tmp)) {
|
||||||
|
fprintf(stderr, "Cannot parse '%s'\n", p);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tmp[n] = '\0';
|
||||||
|
index = if_nametoindex(tmp);
|
||||||
|
if(index == 0) {
|
||||||
|
fprintf(stderr, "Cannot get index for network interface %s\n",
|
||||||
|
tmp);
|
||||||
|
} else {
|
||||||
|
lan_addr->add_indexes |= (1UL << (index - 1));
|
||||||
|
}
|
||||||
|
p += n;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if(lan_addr->ifname[0] != '\0')
|
if(lan_addr->ifname[0] != '\0')
|
||||||
{
|
{
|
||||||
lan_addr->index = if_nametoindex(lan_addr->ifname);
|
lan_addr->index = if_nametoindex(lan_addr->ifname);
|
||||||
if(lan_addr->index == 0)
|
if(lan_addr->index == 0)
|
||||||
fprintf(stderr, "Cannot get index for network interface %s",
|
fprintf(stderr, "Cannot get index for network interface %s\n",
|
||||||
lan_addr->ifname);
|
lan_addr->ifname);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
|
@ -38,6 +38,9 @@
|
|||||||
# When MULTIPLE_EXTERNAL_IP is enabled, the external IP
|
# When MULTIPLE_EXTERNAL_IP is enabled, the external IP
|
||||||
# address associated with the subnet follows. For example:
|
# address associated with the subnet follows. For example:
|
||||||
# listening_ip=192.168.0.1/24 88.22.44.13
|
# listening_ip=192.168.0.1/24 88.22.44.13
|
||||||
|
# When MULTIPLE_EXTERNAL_IP is disabled, you can list associated network
|
||||||
|
# interfaces (for bridges)
|
||||||
|
# listening_ip=bridge0 em0 wlan0
|
||||||
#listening_ip=192.168.0.1/24
|
#listening_ip=192.168.0.1/24
|
||||||
#listening_ip=10.5.0.0/16
|
#listening_ip=10.5.0.0/16
|
||||||
#listening_ip=eth0
|
#listening_ip=eth0
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* $Id: miniupnpdtypes.h,v 1.4 2012/04/06 15:27:21 nanard Exp $ */
|
/* $Id: miniupnpdtypes.h,v 1.4 2012/04/06 15:27:21 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
||||||
* (c) 2006-2012 Thomas Bernard
|
* (c) 2006-2020 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
#ifndef MINIUPNPDTYPES_H_INCLUDED
|
#ifndef MINIUPNPDTYPES_H_INCLUDED
|
||||||
@ -22,6 +22,8 @@ struct lan_addr_s {
|
|||||||
#ifdef MULTIPLE_EXTERNAL_IP
|
#ifdef MULTIPLE_EXTERNAL_IP
|
||||||
char ext_ip_str[16];
|
char ext_ip_str[16];
|
||||||
struct in_addr ext_ip_addr;
|
struct in_addr ext_ip_addr;
|
||||||
|
#else
|
||||||
|
unsigned long add_indexes; /* mask of indexes of associated interfaces */
|
||||||
#endif
|
#endif
|
||||||
LIST_ENTRY(lan_addr_s) list;
|
LIST_ENTRY(lan_addr_s) list;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user