summaryrefslogtreecommitdiff
path: root/source4/lib/socket/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/socket/interface.c')
-rw-r--r--source4/lib/socket/interface.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c
index 58d00ba614..9ca4450581 100644
--- a/source4/lib/socket/interface.c
+++ b/source4/lib/socket/interface.c
@@ -23,6 +23,7 @@
#include "system/network.h"
#include "lib/socket/netif.h"
#include "lib/util/dlinklist.h"
+#include "param/param.h"
/** used for network interfaces */
struct interface {
@@ -53,7 +54,7 @@ static struct ipv4_addr tov4(struct in_addr in)
/****************************************************************************
Try and find an interface that matches an ip. If we cannot, return NULL
**************************************************************************/
-static struct interface *iface_find(struct in_addr ip, BOOL CheckMask)
+static struct interface *iface_find(struct in_addr ip, bool CheckMask)
{
struct interface *i;
if (is_zero_ip(tov4(ip))) return local_interfaces;
@@ -74,12 +75,13 @@ static void add_interface(struct in_addr ip, struct in_addr nmask)
{
struct interface *iface;
struct ipv4_addr bcast;
- if (iface_find(ip, False)) {
+
+ if (iface_find(ip, false)) {
DEBUG(3,("not adding duplicate interface %s\n",inet_ntoa(ip)));
return;
}
- iface = talloc(local_interfaces, struct interface);
+ iface = talloc(local_interfaces == NULL ? talloc_autofree_context() : local_interfaces, struct interface);
if (!iface) return;
ZERO_STRUCTPN(iface);
@@ -198,7 +200,7 @@ static void load_interfaces(void)
return;
}
- ptr = lp_interfaces();
+ ptr = lp_interfaces(global_loadparm);
loopback_ip = interpret_addr2("127.0.0.1");
/* probe the kernel for interfaces */
@@ -319,7 +321,7 @@ const char *iface_best_ip(const char *dest)
load_interfaces();
ip.s_addr = interpret_addr(dest);
- iface = iface_find(ip, True);
+ iface = iface_find(ip, true);
if (iface) {
return iface->ip_s;
}
@@ -327,25 +329,25 @@ const char *iface_best_ip(const char *dest)
}
/**
- return True if an IP is one one of our local networks
+ return true if an IP is one one of our local networks
*/
-BOOL iface_is_local(const char *dest)
+bool iface_is_local(const char *dest)
{
struct in_addr ip;
load_interfaces();
ip.s_addr = interpret_addr(dest);
- if (iface_find(ip, True)) {
- return True;
+ if (iface_find(ip, true)) {
+ return true;
}
- return False;
+ return false;
}
/**
- return True if a IP matches a IP/netmask pair
+ return true if a IP matches a IP/netmask pair
*/
-BOOL iface_same_net(const char *ip1, const char *ip2, const char *netmask)
+bool iface_same_net(const char *ip1, const char *ip2, const char *netmask)
{
return same_net(interpret_addr2(ip1),
interpret_addr2(ip2),