minissdpd/upnputils.c: removed get_lan_for_peer()
This commit is contained in:
parent
a4fd83e968
commit
e61a713d02
|
@ -1,4 +1,4 @@
|
|||
/* $Id: upnputils.c,v 1.7 2013/04/20 09:03:18 nanard Exp $ */
|
||||
/* $Id: upnputils.c,v 1.1 2013/09/07 06:45:39 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2013 Thomas Bernard
|
||||
|
@ -21,10 +21,6 @@
|
|||
#endif
|
||||
|
||||
#include "upnputils.h"
|
||||
#include "upnpglobalvars.h"
|
||||
#ifdef ENABLE_IPV6
|
||||
#include "getroute.h"
|
||||
#endif
|
||||
|
||||
int
|
||||
sockaddr_to_string(const struct sockaddr * addr, char * str, size_t size)
|
||||
|
@ -89,75 +85,3 @@ set_non_blocking(int fd)
|
|||
return 1;
|
||||
}
|
||||
|
||||
struct lan_addr_s *
|
||||
get_lan_for_peer(const struct sockaddr * peer)
|
||||
{
|
||||
struct lan_addr_s * lan_addr = NULL;
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
if(peer->sa_family == AF_INET6)
|
||||
{
|
||||
struct sockaddr_in6 * peer6 = (struct sockaddr_in6 *)peer;
|
||||
if(IN6_IS_ADDR_V4MAPPED(&peer6->sin6_addr))
|
||||
{
|
||||
struct in_addr peer_addr;
|
||||
memcpy(&peer_addr, &peer6->sin6_addr.s6_addr[12], 4);
|
||||
for(lan_addr = lan_addrs.lh_first;
|
||||
lan_addr != NULL;
|
||||
lan_addr = lan_addr->list.le_next)
|
||||
{
|
||||
if( (peer_addr.s_addr & lan_addr->mask.s_addr)
|
||||
== (lan_addr->addr.s_addr & lan_addr->mask.s_addr))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = -1;
|
||||
if(peer6->sin6_scope_id > 0)
|
||||
index = (int)peer6->sin6_scope_id;
|
||||
else
|
||||
{
|
||||
if(get_src_for_route_to(peer, NULL, NULL, &index) < 0)
|
||||
return NULL;
|
||||
}
|
||||
syslog(LOG_DEBUG, "%s looking for LAN interface index=%d",
|
||||
"get_lan_for_peer()", index);
|
||||
for(lan_addr = lan_addrs.lh_first;
|
||||
lan_addr != NULL;
|
||||
lan_addr = lan_addr->list.le_next)
|
||||
{
|
||||
syslog(LOG_DEBUG,
|
||||
"ifname=%s index=%u str=%s addr=%08x mask=%08x",
|
||||
lan_addr->ifname, lan_addr->index,
|
||||
lan_addr->str,
|
||||
ntohl(lan_addr->addr.s_addr),
|
||||
ntohl(lan_addr->mask.s_addr));
|
||||
if(index == (int)lan_addr->index)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(peer->sa_family == AF_INET)
|
||||
{
|
||||
#endif
|
||||
for(lan_addr = lan_addrs.lh_first;
|
||||
lan_addr != NULL;
|
||||
lan_addr = lan_addr->list.le_next)
|
||||
{
|
||||
if( (((const struct sockaddr_in *)peer)->sin_addr.s_addr & lan_addr->mask.s_addr)
|
||||
== (lan_addr->addr.s_addr & lan_addr->mask.s_addr))
|
||||
break;
|
||||
}
|
||||
#ifdef ENABLE_IPV6
|
||||
}
|
||||
#endif
|
||||
|
||||
if(lan_addr)
|
||||
syslog(LOG_DEBUG, "%s: found in LAN %s %s",
|
||||
"get_lan_for_peer()", lan_addr->ifname, lan_addr->str);
|
||||
else
|
||||
syslog(LOG_DEBUG, "%s: not found !", "get_lan_for_peer()");
|
||||
return lan_addr;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: upnputils.h,v 1.4 2013/02/06 10:50:04 nanard Exp $ */
|
||||
/* $Id: upnputils.h,v 1.1 2013/09/07 06:45:39 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2011-2013 Thomas Bernard
|
||||
|
@ -23,11 +23,5 @@ sockaddr_to_string(const struct sockaddr * addr, char * str, size_t size);
|
|||
int
|
||||
set_non_blocking(int fd);
|
||||
|
||||
/**
|
||||
* get the LAN which the peer belongs to
|
||||
*/
|
||||
struct lan_addr_s *
|
||||
get_lan_for_peer(const struct sockaddr * peer);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue