summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/basic.m41
-rw-r--r--source4/lib/basic.mk14
-rw-r--r--source4/lib/netif/interface.c (renamed from source4/lib/interface.c)66
-rw-r--r--source4/lib/netif/netif.c (renamed from source4/lib/interfaces.c)19
-rw-r--r--source4/lib/netif/netif.h34
-rw-r--r--source4/lib/replace.c2
-rw-r--r--source4/lib/socket/access.c1
-rw-r--r--source4/lib/socket/socket_ipv4.c13
-rw-r--r--source4/lib/socket/socket_ipv6.c1
-rw-r--r--source4/lib/system.c22
-rw-r--r--source4/lib/util.c15
-rw-r--r--source4/lib/util_sock.c21
-rw-r--r--source4/lib/util_strlist.c16
-rw-r--r--source4/lib/wins_srv.c30
14 files changed, 166 insertions, 89 deletions
diff --git a/source4/lib/basic.m4 b/source4/lib/basic.m4
index 6701ddaee5..1640ef2b9d 100644
--- a/source4/lib/basic.m4
+++ b/source4/lib/basic.m4
@@ -1,4 +1,5 @@
dnl # LIB BASIC subsystem
SMB_SUBSYSTEM_MK(LIBREPLACE,lib/basic.mk)
+SMB_SUBSYSTEM_MK(LIBNETIF,lib/basic.mk)
SMB_SUBSYSTEM_MK(LIBBASIC,lib/basic.mk)
diff --git a/source4/lib/basic.mk b/source4/lib/basic.mk
index 56fc19dca7..55e654ec74 100644
--- a/source4/lib/basic.mk
+++ b/source4/lib/basic.mk
@@ -10,6 +10,16 @@ ADD_OBJ_FILES = \
##############################
##############################
+# Start SUBSYSTEM LIBNETIF
+[SUBSYSTEM::LIBNETIF]
+INIT_OBJ_FILES = \
+ lib/netif/interface.o
+ADD_OBJ_FILES = \
+ lib/netif/netif.o
+# End SUBSYSTEM LIBNETIF
+##############################
+
+##############################
# Start SUBSYSTEM LIBBASIC
[SUBSYSTEM::LIBBASIC]
INIT_OBJ_FILES = lib/version.o
@@ -17,8 +27,6 @@ ADD_OBJ_FILES = \
lib/debug.o \
lib/fault.o \
lib/getsmbpass.o \
- lib/interface.o \
- lib/interfaces.o \
lib/pidfile.o \
lib/signal.o \
lib/system.o \
@@ -57,6 +65,6 @@ ADD_OBJ_FILES = \
lib/server_mutex.o \
lib/idtree.o
REQUIRED_SUBSYSTEMS = \
- LIBTDB CHARSET LIBREPLACE
+ LIBTDB CHARSET LIBREPLACE LIBNETIF
# End SUBSYSTEM LIBBASIC
##############################
diff --git a/source4/lib/interface.c b/source4/lib/netif/interface.c
index 72568912af..75fdf8c976 100644
--- a/source4/lib/interface.c
+++ b/source4/lib/netif/interface.c
@@ -19,19 +19,21 @@
*/
#include "includes.h"
+#include "system/network.h"
+#include "lib/netif/netif.h"
static struct iface_struct *probed_ifaces;
static int total_probed;
-static struct in_addr allones_ip;
-struct in_addr loopback_ip;
+static struct ipv4_addr allones_ip;
+struct ipv4_addr loopback_ip;
/* used for network interfaces */
struct interface {
struct interface *next, *prev;
- struct in_addr ip;
- struct in_addr bcast;
- struct in_addr nmask;
+ struct ipv4_addr ip;
+ struct ipv4_addr bcast;
+ struct ipv4_addr nmask;
};
static struct interface *local_interfaces;
@@ -40,17 +42,24 @@ static struct interface *local_interfaces;
#define MKBCADDR(_IP, _NM) ((_IP & _NM) | (_NM ^ ALLONES))
#define MKNETADDR(_IP, _NM) (_IP & _NM)
+static struct ipv4_addr tov4(struct in_addr in)
+{
+ struct ipv4_addr in2;
+ in2.s_addr = in.s_addr;
+ return in2;
+}
+
/****************************************************************************
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)
{
struct interface *i;
- if (is_zero_ip(ip)) return local_interfaces;
+ if (is_zero_ip(tov4(ip))) return local_interfaces;
for (i=local_interfaces;i;i=i->next)
if (CheckMask) {
- if (same_net(i->ip,ip,i->nmask)) return i;
+ if (same_net(i->ip,tov4(ip),i->nmask)) return i;
} else if ((i->ip).s_addr == ip.s_addr) return i;
return NULL;
@@ -78,15 +87,15 @@ static void add_interface(struct in_addr ip, struct in_addr nmask)
ZERO_STRUCTPN(iface);
- iface->ip = ip;
- iface->nmask = nmask;
+ iface->ip = tov4(ip);
+ iface->nmask = tov4(nmask);
iface->bcast.s_addr = MKBCADDR(iface->ip.s_addr, iface->nmask.s_addr);
DLIST_ADD(local_interfaces, iface);
- DEBUG(2,("added interface ip=%s ",inet_ntoa(iface->ip)));
- DEBUG(2,("bcast=%s ",inet_ntoa(iface->bcast)));
- DEBUG(2,("nmask=%s\n",inet_ntoa(iface->nmask)));
+ DEBUG(2,("added interface ip=%s ",sys_inet_ntoa(iface->ip)));
+ DEBUG(2,("bcast=%s ",sys_inet_ntoa(iface->bcast)));
+ DEBUG(2,("nmask=%s\n",sys_inet_ntoa(iface->nmask)));
}
@@ -108,8 +117,8 @@ static void interpret_interface(TALLOC_CTX *mem_ctx, const char *token)
char *p;
int i, added=0;
- zero_ip(&ip);
- zero_ip(&nmask);
+ ip.s_addr = 0;
+ nmask.s_addr = 0;
/* first check if it is an interface name */
for (i=0;i<total_probed;i++) {
@@ -124,7 +133,7 @@ static void interpret_interface(TALLOC_CTX *mem_ctx, const char *token)
/* maybe it is a DNS name */
p = strchr_m(token,'/');
if (!p) {
- ip = interpret_addr2(token);
+ ip.s_addr = interpret_addr2(token).s_addr;
for (i=0;i<total_probed;i++) {
if (ip.s_addr == probed_ifaces[i].ip.s_addr &&
!ip_equal(allones_ip, probed_ifaces[i].netmask)) {
@@ -140,10 +149,10 @@ static void interpret_interface(TALLOC_CTX *mem_ctx, const char *token)
/* parse it into an IP address/netmasklength pair */
*p++ = 0;
- ip = interpret_addr2(token);
+ ip.s_addr = interpret_addr2(token).s_addr;
if (strlen(p) > 2) {
- nmask = interpret_addr2(p);
+ nmask.s_addr = interpret_addr2(p).s_addr;
} else {
nmask.s_addr = htonl(((ALLONES >> atoi(p)) ^ ALLONES));
}
@@ -152,7 +161,7 @@ static void interpret_interface(TALLOC_CTX *mem_ctx, const char *token)
if (ip.s_addr == MKBCADDR(ip.s_addr, nmask.s_addr) ||
ip.s_addr == MKNETADDR(ip.s_addr, nmask.s_addr)) {
for (i=0;i<total_probed;i++) {
- if (same_net(ip, probed_ifaces[i].ip, nmask)) {
+ if (same_net(tov4(ip), tov4(probed_ifaces[i].ip), tov4(nmask))) {
add_interface(probed_ifaces[i].ip, nmask);
return;
}
@@ -257,7 +266,7 @@ BOOL interfaces_changed(void)
/****************************************************************************
check if an IP is one of mine
**************************************************************************/
-BOOL ismyip(struct in_addr ip)
+BOOL ismyip(struct ipv4_addr ip)
{
struct interface *i;
for (i=local_interfaces;i;i=i->next)
@@ -268,7 +277,7 @@ BOOL ismyip(struct in_addr ip)
/****************************************************************************
check if a packet is from a local (known) net
**************************************************************************/
-BOOL is_local_net(struct in_addr from)
+BOOL is_local_net(struct ipv4_addr from)
{
struct interface *i;
for (i=local_interfaces;i;i=i->next) {
@@ -295,7 +304,7 @@ int iface_count(void)
/****************************************************************************
return IP of the Nth interface
**************************************************************************/
-struct in_addr *iface_n_ip(int n)
+struct ipv4_addr *iface_n_ip(int n)
{
struct interface *i;
@@ -309,7 +318,7 @@ struct in_addr *iface_n_ip(int n)
/****************************************************************************
return bcast of the Nth interface
**************************************************************************/
-struct in_addr *iface_n_bcast(int n)
+struct ipv4_addr *iface_n_bcast(int n)
{
struct interface *i;
@@ -326,16 +335,21 @@ struct in_addr *iface_n_bcast(int n)
an appropriate interface they return the requested field of the
first known interface. */
-struct in_addr *iface_ip(struct in_addr ip)
+struct ipv4_addr *iface_ip(struct ipv4_addr ip)
{
- struct interface *i = iface_find(ip, True);
+ struct in_addr in;
+ struct interface *i;
+ in.s_addr = ip.s_addr;
+ i = iface_find(in, True);
return(i ? &i->ip : &local_interfaces->ip);
}
/*
return True if a IP is directly reachable on one of our interfaces
*/
-BOOL iface_local(struct in_addr ip)
+BOOL iface_local(struct ipv4_addr ip)
{
- return iface_find(ip, True) ? True : False;
+ struct in_addr in;
+ in.s_addr = ip.s_addr;
+ return iface_find(in, True) ? True : False;
}
diff --git a/source4/lib/interfaces.c b/source4/lib/netif/netif.c
index 89ed144eec..729aeedbe3 100644
--- a/source4/lib/interfaces.c
+++ b/source4/lib/netif/netif.c
@@ -33,23 +33,18 @@
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+#include <netdb.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <net/if.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <net/if.h>
-#ifdef AUTOCONF_TEST
-struct iface_struct {
- char name[16];
- struct in_addr ip;
- struct in_addr netmask;
-};
-#else
+#ifndef AUTOCONF_TEST
+#include "lib/netif/netif.h"
#include "config.h"
-#include "interfaces.h"
#endif
#ifdef HAVE_SYS_TIME_H
@@ -386,8 +381,6 @@ int get_interfaces(struct iface_struct *ifaces, int max_interfaces)
#ifdef AUTOCONF_TEST
/* this is the autoconf driver to test get_interfaces() */
-#define MAX_INTERFACES 128
-
int main()
{
struct iface_struct ifaces[MAX_INTERFACES];
diff --git a/source4/lib/netif/netif.h b/source4/lib/netif/netif.h
new file mode 100644
index 0000000000..d25294f8c2
--- /dev/null
+++ b/source4/lib/netif/netif.h
@@ -0,0 +1,34 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ structures for lib/netif/
+
+ Copyright (C) Andrew Tridgell 2004
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+struct iface_struct {
+ char name[16];
+ struct in_addr ip;
+ struct in_addr netmask;
+};
+
+#define MAX_INTERFACES 128
+
diff --git a/source4/lib/replace.c b/source4/lib/replace.c
index c23c65c8c8..28c60130f8 100644
--- a/source4/lib/replace.c
+++ b/source4/lib/replace.c
@@ -326,7 +326,7 @@ duplicate a string
#ifndef WITH_PTHREADS
/* REWRITE: not thread safe */
#ifdef REPLACE_INET_NTOA
-char *rep_inet_ntoa(struct in_addr ip)
+char *rep_inet_ntoa(struct ipv4_addr ip)
{
uint8_t *p = (uint8_t *)&ip.s_addr;
static char buf[18];
diff --git a/source4/lib/socket/access.c b/source4/lib/socket/access.c
index f33f8d56b1..f5093177dd 100644
--- a/source4/lib/socket/access.c
+++ b/source4/lib/socket/access.c
@@ -32,6 +32,7 @@
*/
#include "includes.h"
+#include "system/network.h"
#define FAIL (-1)
#define ALLONES ((uint32_t)0xFFFFFFFF)
diff --git a/source4/lib/socket/socket_ipv4.c b/source4/lib/socket/socket_ipv4.c
index f9318a29bb..9777705419 100644
--- a/source4/lib/socket/socket_ipv4.c
+++ b/source4/lib/socket/socket_ipv4.c
@@ -19,6 +19,7 @@
*/
#include "includes.h"
+#include "system/network.h"
static NTSTATUS ipv4_tcp_init(struct socket_context *sock)
{
@@ -41,8 +42,8 @@ static NTSTATUS ipv4_tcp_connect(struct socket_context *sock,
uint32_t flags)
{
struct sockaddr_in srv_addr;
- struct in_addr my_ip;
- struct in_addr srv_ip;
+ struct ipv4_addr my_ip;
+ struct ipv4_addr srv_ip;
int ret;
my_ip = interpret_addr2(my_address);
@@ -53,7 +54,7 @@ static NTSTATUS ipv4_tcp_connect(struct socket_context *sock,
#ifdef HAVE_SOCK_SIN_LEN
my_addr.sin_len = sizeof(my_addr);
#endif
- my_addr.sin_addr = my_ip;
+ my_addr.sin_addr.s_addr = my_ip.s_addr;
my_addr.sin_port = htons(my_port);
my_addr.sin_family = PF_INET;
@@ -69,7 +70,7 @@ static NTSTATUS ipv4_tcp_connect(struct socket_context *sock,
#ifdef HAVE_SOCK_SIN_LEN
srv_addr.sin_len = sizeof(srv_addr);
#endif
- srv_addr.sin_addr = srv_ip;
+ srv_addr.sin_addr.s_addr= srv_ip.s_addr;
srv_addr.sin_port = htons(srv_port);
srv_addr.sin_family = PF_INET;
@@ -95,7 +96,7 @@ static NTSTATUS ipv4_tcp_listen(struct socket_context *sock,
int queue_size, uint32_t flags)
{
struct sockaddr_in my_addr;
- struct in_addr ip_addr;
+ struct ipv4_addr ip_addr;
int ret;
ip_addr = interpret_addr2(my_address);
@@ -104,7 +105,7 @@ static NTSTATUS ipv4_tcp_listen(struct socket_context *sock,
#ifdef HAVE_SOCK_SIN_LEN
my_addr.sin_len = sizeof(my_addr);
#endif
- my_addr.sin_addr = ip_addr;
+ my_addr.sin_addr.s_addr = ip_addr.s_addr;
my_addr.sin_port = htons(port);
my_addr.sin_family = PF_INET;
diff --git a/source4/lib/socket/socket_ipv6.c b/source4/lib/socket/socket_ipv6.c
index 268212dcca..75e6fcab5c 100644
--- a/source4/lib/socket/socket_ipv6.c
+++ b/source4/lib/socket/socket_ipv6.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "system/network.h"
static struct in6_addr interpret_addr6(const char *name)
{
diff --git a/source4/lib/system.c b/source4/lib/system.c
index 1407e7474e..2baa412622 100644
--- a/source4/lib/system.c
+++ b/source4/lib/system.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "system/network.h"
/*
The idea is that this file will eventually have wrappers around all
@@ -533,3 +534,24 @@ int sys_dup2(int oldfd, int newfd)
#endif
}
+
+const char *sys_inet_ntoa(struct ipv4_addr in)
+{
+ struct in_addr in2;
+ in2.s_addr = in.s_addr;
+ return inet_ntoa(in2);
+}
+
+uint32_t sys_inet_addr(const char *s)
+{
+ return inet_addr(s);
+}
+
+struct ipv4_addr sys_inet_makeaddr(int net, int host)
+{
+ struct in_addr in;
+ struct ipv4_addr in2;
+ in = inet_makeaddr(net, host);
+ in2.s_addr = in.s_addr;
+ return in2;
+}
diff --git a/source4/lib/util.c b/source4/lib/util.c
index 07dc182580..7b6396fa93 100644
--- a/source4/lib/util.c
+++ b/source4/lib/util.c
@@ -23,6 +23,7 @@
*/
#include "includes.h"
+#include "system/network.h"
/**************************************************************************n
Find a suitable temporary directory. The result should be copied immediately
@@ -421,7 +422,7 @@ uint32_t interpret_addr(const char *str)
/* if it's in the form of an IP address then get the lib to interpret it */
if (is_ipaddress(str)) {
- res = inet_addr(str);
+ res = sys_inet_addr(str);
} else {
/* otherwise assume it's a network name of some sort and use
sys_gethostbyname */
@@ -446,9 +447,9 @@ uint32_t interpret_addr(const char *str)
/*******************************************************************
A convenient addition to interpret_addr().
******************************************************************/
-struct in_addr interpret_addr2(const char *str)
+struct ipv4_addr interpret_addr2(const char *str)
{
- struct in_addr ret;
+ struct ipv4_addr ret;
uint32_t a = interpret_addr(str);
ret.s_addr = a;
return ret;
@@ -458,7 +459,7 @@ struct in_addr interpret_addr2(const char *str)
Check if an IP is the 0.0.0.0.
******************************************************************/
-BOOL is_zero_ip(struct in_addr ip)
+BOOL is_zero_ip(struct ipv4_addr ip)
{
uint32_t a;
putip((char *)&a,(char *)&ip);
@@ -469,9 +470,9 @@ BOOL is_zero_ip(struct in_addr ip)
Set an IP to 0.0.0.0.
******************************************************************/
-void zero_ip(struct in_addr *ip)
+void zero_ip(struct ipv4_addr *ip)
{
- *ip = inet_makeaddr(0,0);
+ *ip = sys_inet_makeaddr(0,0);
return;
}
@@ -480,7 +481,7 @@ void zero_ip(struct in_addr *ip)
Are two IPs on the same subnet?
********************************************************************/
-BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask)
+BOOL same_net(struct ipv4_addr ip1,struct ipv4_addr ip2,struct ipv4_addr mask)
{
uint32_t net1,net2,nmask;
diff --git a/source4/lib/util_sock.c b/source4/lib/util_sock.c
index 0cb23920f1..dbd71b58b6 100644
--- a/source4/lib/util_sock.c
+++ b/source4/lib/util_sock.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "system/network.h"
/****************************************************************************
@@ -156,7 +157,7 @@ void set_socket_options(int fd, const char *options)
****************************************************************************/
ssize_t read_udp_socket(int fd, char *buf, size_t len,
- struct in_addr *from_addr, int *from_port)
+ struct ipv4_addr *from_addr, int *from_port)
{
ssize_t ret;
struct sockaddr_in sock;
@@ -169,7 +170,7 @@ ssize_t read_udp_socket(int fd, char *buf, size_t len,
}
if (from_addr) {
- *from_addr = sock.sin_addr;
+ from_addr->s_addr = sock.sin_addr.s_addr;
}
if (from_port) {
*from_port = ntohs(sock.sin_port);
@@ -337,7 +338,7 @@ int open_socket_in( int type, int port, int dlevel, uint32_t socket_addr, BOOL r
/****************************************************************************
create an outgoing socket. timeout is in milliseconds.
**************************************************************************/
-int open_socket_out(int type, struct in_addr *addr, int port, int timeout)
+int open_socket_out(int type, struct ipv4_addr *addr, int port, int timeout)
{
struct sockaddr_in sock_out;
int res,ret;
@@ -360,7 +361,7 @@ int open_socket_out(int type, struct in_addr *addr, int port, int timeout)
/* set it non-blocking */
set_blocking(res,False);
- DEBUG(3,("Connecting to %s at port %d\n",inet_ntoa(*addr),port));
+ DEBUG(3,("Connecting to %s at port %d\n", sys_inet_ntoa(*addr),port));
/* and connect it to the destination */
connect_again:
@@ -375,7 +376,7 @@ connect_again:
if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY ||
errno == EAGAIN)) {
- DEBUG(1,("timeout connecting to %s:%d\n",inet_ntoa(*addr),port));
+ DEBUG(1,("timeout connecting to %s:%d\n", sys_inet_ntoa(*addr),port));
close(res);
return -1;
}
@@ -389,7 +390,7 @@ connect_again:
if (ret < 0) {
DEBUG(2,("error connecting to %s:%d (%s)\n",
- inet_ntoa(*addr),port,strerror(errno)));
+ sys_inet_ntoa(*addr),port,strerror(errno)));
close(res);
return -1;
}
@@ -408,7 +409,7 @@ int open_udp_socket(const char *host, int port)
int type = SOCK_DGRAM;
struct sockaddr_in sock_out;
int res;
- struct in_addr addr;
+ struct ipv4_addr addr;
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_init("open_udp_socket");
@@ -442,7 +443,7 @@ int open_udp_socket(const char *host, int port)
matchname - determine if host name matches IP address. Used to
confirm a hostname lookup to prevent spoof attacks
******************************************************************/
-static BOOL matchname(char *remotehost, struct in_addr addr)
+static BOOL matchname(char *remotehost, struct ipv4_addr addr)
{
struct hostent *hp;
int i;
@@ -480,7 +481,7 @@ static BOOL matchname(char *remotehost, struct in_addr addr)
*/
DEBUG(0,("host name/address mismatch: %s != %s\n",
- inet_ntoa(addr), hp->h_name));
+ sys_inet_ntoa(addr), hp->h_name));
return False;
}
@@ -492,7 +493,7 @@ char *get_socket_name(TALLOC_CTX *mem_ctx, int fd, BOOL force_lookup)
{
char *name_buf;
struct hostent *hp;
- struct in_addr addr;
+ struct ipv4_addr addr;
char *p;
/* reverse lookups can be *very* expensive, and in many
diff --git a/source4/lib/util_strlist.c b/source4/lib/util_strlist.c
index 12fb0946e2..0b32955ac2 100644
--- a/source4/lib/util_strlist.c
+++ b/source4/lib/util_strlist.c
@@ -228,7 +228,7 @@ BOOL str_list_substitute(char **list, const char *pattern, const char *insert)
* reallocated to new length
**/
-char* ipstr_list_add(char** ipstr_list, const struct in_addr *ip)
+char* ipstr_list_add(char** ipstr_list, const struct ipv4_addr *ip)
{
char* new_ipstr = NULL;
@@ -237,10 +237,10 @@ char* ipstr_list_add(char** ipstr_list, const struct in_addr *ip)
/* attempt to convert ip to a string and append colon separator to it */
if (*ipstr_list) {
- asprintf(&new_ipstr, "%s%s%s", *ipstr_list, IPSTR_LIST_SEP,inet_ntoa(*ip));
+ asprintf(&new_ipstr, "%s%s%s", *ipstr_list, IPSTR_LIST_SEP,sys_inet_ntoa(*ip));
SAFE_FREE(*ipstr_list);
} else {
- asprintf(&new_ipstr, "%s", inet_ntoa(*ip));
+ asprintf(&new_ipstr, "%s", sys_inet_ntoa(*ip));
}
*ipstr_list = new_ipstr;
return *ipstr_list;
@@ -256,7 +256,7 @@ char* ipstr_list_add(char** ipstr_list, const struct in_addr *ip)
* @return pointer to allocated ip string
**/
-char* ipstr_list_make(char** ipstr_list, const struct in_addr* ip_list, int ip_count)
+char* ipstr_list_make(char** ipstr_list, const struct ipv4_addr* ip_list, int ip_count)
{
int i;
@@ -283,7 +283,7 @@ char* ipstr_list_make(char** ipstr_list, const struct in_addr* ip_list, int ip_c
* @return number of succesfully parsed addresses
**/
-int ipstr_list_parse(const char* ipstr_list, struct in_addr** ip_list)
+int ipstr_list_parse(const char* ipstr_list, struct ipv4_addr** ip_list)
{
fstring token_str;
int count;
@@ -294,14 +294,14 @@ int ipstr_list_parse(const char* ipstr_list, struct in_addr** ip_list)
next_token(&ipstr_list, token_str, IPSTR_LIST_SEP, FSTRING_LEN);
count++) {
- struct in_addr addr;
+ struct ipv4_addr addr;
/* convert single token to ip address */
- if ( (addr.s_addr = inet_addr(token_str)) == INADDR_NONE )
+ if ( (addr.s_addr = sys_inet_addr(token_str)) == INADDR_NONE )
break;
/* prepare place for another in_addr structure */
- *ip_list = Realloc(*ip_list, (count + 1) * sizeof(struct in_addr));
+ *ip_list = Realloc(*ip_list, (count + 1) * sizeof(struct ipv4_addr));
if (!*ip_list) return -1;
(*ip_list)[count] = addr;
diff --git a/source4/lib/wins_srv.c b/source4/lib/wins_srv.c
index eb7f280e6f..d8be9e61d6 100644
--- a/source4/lib/wins_srv.c
+++ b/source4/lib/wins_srv.c
@@ -68,12 +68,12 @@
#define WINS_SRV_FMT "WINS_SRV_DEAD/%s,%s" /* wins_ip,src_ip */
-static char *wins_srv_keystr(struct in_addr wins_ip, struct in_addr src_ip)
+static char *wins_srv_keystr(struct ipv4_addr wins_ip, struct ipv4_addr src_ip)
{
char *keystr;
- if (asprintf(&keystr, WINS_SRV_FMT, inet_ntoa(wins_ip),
- inet_ntoa(src_ip)) == -1) {
+ if (asprintf(&keystr, WINS_SRV_FMT, sys_inet_ntoa(wins_ip),
+ sys_inet_ntoa(src_ip)) == -1) {
DEBUG(0, ("wins_srv_is_dead: malloc error\n"));
return NULL;
}
@@ -85,7 +85,7 @@ static char *wins_srv_keystr(struct in_addr wins_ip, struct in_addr src_ip)
see if an ip is on the dead list
*/
-BOOL wins_srv_is_dead(struct in_addr wins_ip, struct in_addr src_ip)
+BOOL wins_srv_is_dead(struct ipv4_addr wins_ip, struct ipv4_addr src_ip)
{
char *keystr = wins_srv_keystr(wins_ip, src_ip);
BOOL result;
@@ -95,7 +95,7 @@ BOOL wins_srv_is_dead(struct in_addr wins_ip, struct in_addr src_ip)
result = gencache_get(keystr, NULL, NULL);
SAFE_FREE(keystr);
- DEBUG(4, ("wins_srv_is_dead: %s is %s\n", inet_ntoa(wins_ip),
+ DEBUG(4, ("wins_srv_is_dead: %s is %s\n", sys_inet_ntoa(wins_ip),
result ? "dead" : "alive"));
return result;
@@ -105,7 +105,7 @@ BOOL wins_srv_is_dead(struct in_addr wins_ip, struct in_addr src_ip)
/*
mark a wins server as being alive (for the moment)
*/
-void wins_srv_alive(struct in_addr wins_ip, struct in_addr src_ip)
+void wins_srv_alive(struct ipv4_addr wins_ip, struct ipv4_addr src_ip)
{
char *keystr = wins_srv_keystr(wins_ip, src_ip);
@@ -113,13 +113,13 @@ void wins_srv_alive(struct in_addr wins_ip, struct in_addr src_ip)
SAFE_FREE(keystr);
DEBUG(4, ("wins_srv_alive: marking wins server %s alive\n",
- inet_ntoa(wins_ip)));
+ sys_inet_ntoa(wins_ip)));
}
/*
mark a wins server as temporarily dead
*/
-void wins_srv_died(struct in_addr wins_ip, struct in_addr src_ip)
+void wins_srv_died(struct ipv4_addr wins_ip, struct ipv4_addr src_ip)
{
char *keystr;
@@ -133,7 +133,7 @@ void wins_srv_died(struct in_addr wins_ip, struct in_addr src_ip)
SAFE_FREE(keystr);
DEBUG(4,("Marking wins server %s dead for %u seconds from source %s\n",
- inet_ntoa(wins_ip), DEATH_TIME, inet_ntoa(src_ip)));
+ sys_inet_ntoa(wins_ip), DEATH_TIME, sys_inet_ntoa(src_ip)));
}
/*
@@ -160,7 +160,7 @@ uint_t wins_srv_count(void)
attached */
struct tagged_ip {
fstring tag;
- struct in_addr ip;
+ struct ipv4_addr ip;
};
/*
@@ -267,7 +267,7 @@ void wins_srv_tags_free(char **list)
return the IP of the currently active wins server for the given tag,
or the zero IP otherwise
*/
-struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip)
+struct ipv4_addr wins_srv_ip_tag(const char *tag, struct ipv4_addr src_ip)
{
const char **list;
int i;
@@ -276,13 +276,13 @@ struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip)
/* if we are a wins server then we always just talk to ourselves */
if (lp_wins_support()) {
- extern struct in_addr loopback_ip;
+ extern struct ipv4_addr loopback_ip;
return loopback_ip;
}
list = lp_wins_server_list();
if (!list || !list[0]) {
- struct in_addr ip;
+ struct ipv4_addr ip;
zero_ip(&ip);
return ip;
}
@@ -297,11 +297,11 @@ struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip)
}
if (!wins_srv_is_dead(t_ip.ip, src_ip)) {
char *src_name;
- src_name = talloc_strdup(mem_ctx, inet_ntoa(src_ip));
+ src_name = talloc_strdup(mem_ctx, sys_inet_ntoa(src_ip));
DEBUG(6,("Current wins server for tag '%s' with source %s is %s\n",
tag,
src_name,
- inet_ntoa(t_ip.ip)));
+ sys_inet_ntoa(t_ip.ip)));
goto exit;
}
}