aboutsummaryrefslogtreecommitdiff
path: root/src/common/address.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-01-23 10:13:37 -0500
committerNick Mathewson <nickm@torproject.org>2015-01-23 10:13:37 -0500
commit420037dcefade09f43e4a6e44282ed04f9f3ac52 (patch)
tree18a1f5b09b41cada52537b763740e4b3b39c0b13 /src/common/address.h
parent0b121433464804889240a6884179fa4631f0d7b0 (diff)
parent3966145dff817adb67e5b46020632d55f19e289f (diff)
downloadtor-420037dcefade09f43e4a6e44282ed04f9f3ac52.tar.gz
tor-420037dcefade09f43e4a6e44282ed04f9f3ac52.zip
Merge branch 'if_addr_refactoring_squashed'
Conflicts: src/test/include.am src/test/test.c
Diffstat (limited to 'src/common/address.h')
-rw-r--r--src/common/address.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/common/address.h b/src/common/address.h
index d70bb9c508..8c6ee5abbb 100644
--- a/src/common/address.h
+++ b/src/common/address.h
@@ -11,10 +11,41 @@
#ifndef TOR_ADDRESS_H
#define TOR_ADDRESS_H
+//#include <sys/sockio.h>
#include "orconfig.h"
#include "torint.h"
#include "compat.h"
+#ifdef ADDRESS_PRIVATE
+
+#if defined(HAVE_SYS_IOCTL_H)
+#include <sys/ioctl.h>
+#endif
+
+#ifdef HAVE_GETIFADDRS
+#define HAVE_IFADDRS_TO_SMARTLIST
+#endif
+
+#ifdef _WIN32
+#define HAVE_IP_ADAPTER_TO_SMARTLIST
+#endif
+
+#if defined(SIOCGIFCONF) && defined(HAVE_IOCTL)
+#define HAVE_IFCONF_TO_SMARTLIST
+#endif
+
+#if defined(HAVE_NET_IF_H)
+#include <net/if.h> // for struct ifconf
+#endif
+
+#if defined(HAVE_IFADDRS_TO_SMARTLIST)
+#include <ifaddrs.h>
+#endif
+
+// TODO win32 specific includes
+#include "container.h"
+#endif // ADDRESS_PRIVATE
+
/** The number of bits from an address to consider while doing a masked
* comparison. */
typedef uint8_t maskbits_t;
@@ -241,5 +272,27 @@ MOCK_DECL(int,get_interface_address,(int severity, uint32_t *addr));
tor_addr_port_t *tor_addr_port_new(const tor_addr_t *addr, uint16_t port);
+#ifdef ADDRESS_PRIVATE
+STATIC smartlist_t *get_interface_addresses_raw(int severity);
+
+#ifdef HAVE_IFADDRS_TO_SMARTLIST
+STATIC smartlist_t *ifaddrs_to_smartlist(const struct ifaddrs *ifa);
+STATIC smartlist_t *get_interface_addresses_ifaddrs(int severity);
+#endif
+
+#ifdef HAVE_IP_ADAPTER_TO_SMARTLIST
+STATIC smartlist_t *ip_adapter_addresses_to_smartlist(
+ const IP_ADAPTER_ADDRESSES *addresses);
+STATIC smartlist_t *get_interface_addresses_win32(int severity);
+#endif
+
+#ifdef HAVE_IFCONF_TO_SMARTLIST
+STATIC smartlist_t *ifreq_to_smartlist(const struct ifreq *ifr,
+ size_t buflen);
+STATIC smartlist_t *get_interface_addresses_ioctl(int severity);
+#endif
+
+#endif // ADDRESS_PRIVATE
+
#endif