summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/auth/auth_domain.c12
-rw-r--r--source4/auth/auth_server.c2
-rw-r--r--source4/build/m4/rewrite.m49
-rw-r--r--source4/client/mount.cifs.c2
-rw-r--r--source4/client/smbmount.c4
-rw-r--r--source4/include/ads.h2
-rw-r--r--source4/include/includes.h78
-rw-r--r--source4/include/interfaces.h12
-rw-r--r--source4/include/nameserv.h32
-rw-r--r--source4/include/structs.h1
-rw-r--r--source4/include/system/README4
-rw-r--r--source4/include/system/kerberos.h44
-rw-r--r--source4/include/system/network.h60
-rw-r--r--source4/ldap_server/ldap_server.c8
-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
-rw-r--r--source4/libcli/auth/clikrb5.c2
-rw-r--r--source4/libcli/auth/gensec_krb5.c2
-rw-r--r--source4/libcli/auth/kerberos.c1
-rw-r--r--source4/libcli/auth/kerberos_verify.c2
-rw-r--r--source4/libcli/cliconnect.c2
-rw-r--r--source4/libcli/ldap/ldap.c3
-rw-r--r--source4/libcli/namecache.c6
-rw-r--r--source4/libcli/namequery.c93
-rw-r--r--source4/libcli/namequery_dc.c6
-rw-r--r--source4/libcli/nmblib.c15
-rw-r--r--source4/libcli/raw/clisocket.c6
-rw-r--r--source4/libcli/raw/libcliraw.h2
-rw-r--r--source4/libnet/libnet_rpc.c4
-rw-r--r--source4/librpc/rpc/dcerpc_util.c5
-rw-r--r--source4/rpc_server/dcerpc_sock.c14
-rw-r--r--source4/smb_server/smb_server.c8
-rw-r--r--source4/torture/rpc/epmapper.c5
-rw-r--r--source4/utils/nmblookup.c10
46 files changed, 420 insertions, 291 deletions
diff --git a/source4/auth/auth_domain.c b/source4/auth/auth_domain.c
index 028bfc550b..2452f8f65d 100644
--- a/source4/auth/auth_domain.c
+++ b/source4/auth/auth_domain.c
@@ -35,7 +35,7 @@ BOOL global_machine_password_needs_changing = False;
the 'ADS server' smb.conf parameter, which is what we really want anyway
*/
static NTSTATUS ads_resolve_dc(fstring remote_machine,
- struct in_addr *dest_ip)
+ struct ipv4_addr *dest_ip)
{
ADS_STRUCT *ads;
ads = ads_init_simple();
@@ -76,10 +76,10 @@ static NTSTATUS ads_resolve_dc(fstring remote_machine,
*/
static NTSTATUS rpc_resolve_dc(const char *server,
fstring remote_machine,
- struct in_addr *dest_ip)
+ struct ipv4_addr *dest_ip)
{
if (is_ipaddress(server)) {
- struct in_addr to_ip = interpret_addr2(server);
+ struct ipv4_addr to_ip = interpret_addr2(server);
/* we need to know the machines netbios name - this is a lousy
way to find it, but until we have a RPC call that does this
@@ -125,7 +125,7 @@ static NTSTATUS connect_to_domain_password_server(struct smbcli_state **cli,
const uint8_t *trust_passwd,
BOOL *retry)
{
- struct in_addr dest_ip;
+ struct ipv4_addr dest_ip;
fstring remote_machine;
NTSTATUS result;
uint32_t neg_flags = 0x000001ff;
@@ -230,7 +230,7 @@ machine %s. Error was : %s.\n", remote_machine, smbcli_errstr(*cli)));
static NTSTATUS attempt_connect_to_dc(struct smbcli_state **cli,
const char *domain,
- struct in_addr *ip,
+ struct ipv4_addr *ip,
const char *setup_creds_as,
uint16_t sec_chan,
const uint8_t *trust_passwd)
@@ -267,7 +267,7 @@ static NTSTATUS find_connect_dc(struct smbcli_state **cli,
uint8_t *trust_passwd,
time_t last_change_time)
{
- struct in_addr dc_ip;
+ struct ipv4_addr dc_ip;
fstring srv_name;
if ( !rpc_find_dc(lp_workgroup(), srv_name, &dc_ip) ) {
diff --git a/source4/auth/auth_server.c b/source4/auth/auth_server.c
index d0c4bfc902..8e1c712f5e 100644
--- a/source4/auth/auth_server.c
+++ b/source4/auth/auth_server.c
@@ -32,7 +32,7 @@ static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
{
struct smbcli_state *cli = NULL;
fstring desthost;
- struct in_addr dest_ip;
+ struct ipv4_addr dest_ip;
const char *p;
char *pserver;
BOOL connected_ok = False;
diff --git a/source4/build/m4/rewrite.m4 b/source4/build/m4/rewrite.m4
index 7fecd0b265..48c6c6627a 100644
--- a/source4/build/m4/rewrite.m4
+++ b/source4/build/m4/rewrite.m4
@@ -1065,7 +1065,8 @@ AC_TRY_RUN([
#define HAVE_IFACE_AIX 1
#define AUTOCONF_TEST 1
#include "confdefs.h"
-#include "${srcdir-.}/lib/interfaces.c"],
+#include "${srcdir-.}/lib/netif/netif.h"
+#include "${srcdir-.}/lib/netif/netif.c"],
samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
@@ -1077,7 +1078,8 @@ AC_TRY_RUN([
#define HAVE_IFACE_IFCONF 1
#define AUTOCONF_TEST 1
#include "confdefs.h"
-#include "${srcdir-.}/lib/interfaces.c"],
+#include "${srcdir-.}/lib/netif/netif.h"
+#include "${srcdir-.}/lib/netif/netif.c"],
samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
@@ -1090,7 +1092,8 @@ AC_TRY_RUN([
#define HAVE_IFACE_IFREQ 1
#define AUTOCONF_TEST 1
#include "confdefs.h"
-#include "${srcdir-.}/lib/interfaces.c"],
+#include "${srcdir-.}/lib/netif/netif.h"
+#include "${srcdir-.}/lib/netif/netif.c"],
samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
diff --git a/source4/client/mount.cifs.c b/source4/client/mount.cifs.c
index 7167859d7b..8290403815 100644
--- a/source4/client/mount.cifs.c
+++ b/source4/client/mount.cifs.c
@@ -197,7 +197,7 @@ char * parse_server(char * unc_name)
char * share;
char * ipaddress_string = NULL;
struct hostent * host_entry;
- struct in_addr server_ipaddr;
+ struct ipv4_addr server_ipaddr;
int rc,j;
char temp[64];
diff --git a/source4/client/smbmount.c b/source4/client/smbmount.c
index 358fad6ae1..5e6d0209f2 100644
--- a/source4/client/smbmount.c
+++ b/source4/client/smbmount.c
@@ -35,7 +35,7 @@ static pstring mpoint;
static pstring service;
static pstring options;
-static struct in_addr dest_ip;
+static struct ipv4_addr dest_ip;
static BOOL have_ip;
static int smb_port = 0;
static BOOL got_user;
@@ -118,7 +118,7 @@ static struct smbcli_state *do_connection(char *the_service)
struct smbcli_state *c;
struct nmb_name called, calling;
char *server_n;
- struct in_addr ip;
+ struct ipv4_addr ip;
pstring server;
char *share;
diff --git a/source4/include/ads.h b/source4/include/ads.h
index 71bca6eb71..8db0209573 100644
--- a/source4/include/ads.h
+++ b/source4/include/ads.h
@@ -22,7 +22,7 @@
typedef struct {
void *ld; /* the active ldap structure */
- struct in_addr ldap_ip; /* the ip of the active connection, if any */
+ struct ipv4_addr ldap_ip; /* the ip of the active connection, if any */
time_t last_attempt; /* last attempt to reconnect */
int ldap_port;
diff --git a/source4/include/includes.h b/source4/include/includes.h
index 374abc4c37..a9198dbc1d 100644
--- a/source4/include/includes.h
+++ b/source4/include/includes.h
@@ -83,6 +83,7 @@
#endif /* RELIANTUNIX */
#include <sys/types.h>
+#include <stdint.h>
#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
@@ -114,14 +115,6 @@
#include <stdlib.h>
#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#ifdef HAVE_UNIXSOCKET
-#include <sys/un.h>
-#endif
-
#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h>
#elif HAVE_SYSCALL_H
@@ -213,10 +206,6 @@
#include <varargs.h>
#endif
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#else
@@ -227,27 +216,6 @@
#include <sys/file.h>
-#ifdef HAVE_NETINET_TCP_H
-#include <netinet/tcp.h>
-#endif
-
-/*
- * The next three defines are needed to access the IPTOS_* options
- * on some systems.
- */
-
-#ifdef HAVE_NETINET_IN_SYSTM_H
-#include <netinet/in_systm.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_IP_H
-#include <netinet/in_ip.h>
-#endif
-
-#ifdef HAVE_NETINET_IP_H
-#include <netinet/ip.h>
-#endif
-
#if defined(HAVE_TERMIOS_H)
/* POSIX terminal handling. */
#include <termios.h>
@@ -280,11 +248,6 @@
#include <sys/mman.h>
#endif
-#ifdef HAVE_NET_IF_H
-#include <net/if.h>
-#endif
-
-
#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
@@ -374,28 +337,6 @@
#endif
#endif
-#ifdef HAVE_KRB5_H
-#include <krb5.h>
-#else
-#undef HAVE_KRB5
-#endif
-
-#ifdef HAVE_GSSAPI_H
-#include <gssapi.h>
-#endif
-
-#ifdef HAVE_GSSAPI_GSSAPI_H
-#include <gssapi/gssapi.h>
-#endif
-
-#ifdef HAVE_GSSAPI_GSSAPI_GENERIC_H
-#include <gssapi/gssapi_generic.h>
-#endif
-
-#ifdef HAVE_COM_ERR_H
-#include <com_err.h>
-#endif
-
/* we support ADS if we want it and have krb5 and ldap libs */
#if defined(WITH_ADS) && defined(HAVE_KRB5) && defined(HAVE_LDAP)
#define HAVE_ADS
@@ -466,6 +407,14 @@ typedef int socklen_t;
#define uint64 uint64_t
#endif
+/*
+ we use struct ipv4_addr to avoid having to include all the
+ system networking headers everywhere
+*/
+struct ipv4_addr {
+ uint32_t s_addr;
+};
+
#ifndef UINT8_MAX
#define UINT8_MAX 255
#endif
@@ -518,7 +467,6 @@ extern int errno;
#include "talloc.h"
#include "db_wrap.h"
#include "nt_status.h"
-#include "interfaces.h"
#include "trans2.h"
#include "ioctl.h"
#include "nterr.h"
@@ -557,7 +505,6 @@ extern int errno;
#include "libcli/auth/ntlmssp.h"
#include "libcli/auth/credentials.h"
-#include "libcli/auth/kerberos.h"
#include "libcli/auth/gensec.h"
#include "libcli/auth/spnego.h"
#include "auth/auth.h"
@@ -721,13 +668,6 @@ unsigned long strtoul(const char *nptr, char **endptr, int base);
int setenv(const char *name, const char *value, int overwrite);
#endif
-#if (defined(USE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
-/* stupid glibc */
-int setresuid(uid_t ruid, uid_t euid, uid_t suid);
-#endif
-#if (defined(USE_SETRESUID) && !defined(HAVE_SETRESGID_DECL))
-int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
-#endif
#ifndef HAVE_VASPRINTF_DECL
int vasprintf(char **ptr, const char *format, va_list ap);
#endif
diff --git a/source4/include/interfaces.h b/source4/include/interfaces.h
index 3b786f1ebc..e69de29bb2 100644
--- a/source4/include/interfaces.h
+++ b/source4/include/interfaces.h
@@ -1,12 +0,0 @@
-/*
- This structure is used by lib/interfaces.c to return the list of network
- interfaces on the machine
-*/
-
-#define MAX_INTERFACES 128
-
-struct iface_struct {
- char name[16];
- struct in_addr ip;
- struct in_addr netmask;
-};
diff --git a/source4/include/nameserv.h b/source4/include/nameserv.h
index 33ee8f99e6..9efee46466 100644
--- a/source4/include/nameserv.h
+++ b/source4/include/nameserv.h
@@ -206,7 +206,7 @@ struct nmb_data
{
uint16_t nb_flags; /* Netbios flags. */
int num_ips; /* Number of ip entries. */
- struct in_addr *ip; /* The ip list for this name. */
+ struct ipv4_addr *ip; /* The ip list for this name. */
enum name_source source; /* Where the name came from. */
@@ -214,7 +214,7 @@ struct nmb_data
time_t refresh_time; /* The time the record should be refreshed. */
uint64_t id; /* unique id */
- struct in_addr wins_ip; /* the adress of the wins server this record comes from */
+ struct ipv4_addr wins_ip; /* the adress of the wins server this record comes from */
int wins_flags; /* similar to the netbios flags but different ! */
};
@@ -238,7 +238,7 @@ struct browse_cache_record
#endif
pstring lmb_name;
pstring work_group;
- struct in_addr ip;
+ struct ipv4_addr ip;
time_t sync_time;
time_t death_time; /* The time the record must be removed. */
};
@@ -307,7 +307,7 @@ struct work_record
/* Domain master browser info. Used for efficient syncs. */
struct nmb_name dmb_name;
- struct in_addr dmb_addr;
+ struct ipv4_addr dmb_addr;
};
/* typedefs needed to define copy & free functions for userdata. */
@@ -353,7 +353,7 @@ typedef void (*register_name_success_function)( struct subnet_record *,
struct nmb_name *,
uint16_t,
int,
- struct in_addr);
+ struct ipv4_addr);
typedef void (*register_name_fail_function)( struct subnet_record *,
struct response_record *,
struct nmb_name *);
@@ -361,7 +361,7 @@ typedef void (*register_name_fail_function)( struct subnet_record *,
typedef void (*release_name_success_function)( struct subnet_record *,
struct userdata_struct *,
struct nmb_name *,
- struct in_addr);
+ struct ipv4_addr);
typedef void (*release_name_fail_function)( struct subnet_record *,
struct response_record *,
struct nmb_name *);
@@ -371,7 +371,7 @@ typedef void (*refresh_name_success_function)( struct subnet_record *,
struct nmb_name *,
uint16_t,
int,
- struct in_addr);
+ struct ipv4_addr);
typedef void (*refresh_name_fail_function)( struct subnet_record *,
struct response_record *,
struct nmb_name *);
@@ -379,7 +379,7 @@ typedef void (*refresh_name_fail_function)( struct subnet_record *,
typedef void (*query_name_success_function)( struct subnet_record *,
struct userdata_struct *,
struct nmb_name *,
- struct in_addr,
+ struct ipv4_addr,
struct res_rec *answers);
typedef void (*query_name_fail_function)( struct subnet_record *,
@@ -390,7 +390,7 @@ typedef void (*query_name_fail_function)( struct subnet_record *,
typedef void (*node_status_success_function)( struct subnet_record *,
struct userdata_struct *,
struct res_rec *,
- struct in_addr);
+ struct ipv4_addr);
typedef void (*node_status_fail_function)( struct subnet_record *,
struct response_record *);
@@ -457,9 +457,9 @@ struct subnet_record
BOOL namelist_changed;
BOOL work_changed;
- struct in_addr bcast_ip;
- struct in_addr mask_ip;
- struct in_addr myip;
+ struct ipv4_addr bcast_ip;
+ struct ipv4_addr mask_ip;
+ struct ipv4_addr myip;
int nmb_sock; /* socket to listen for unicast 137. */
int dgram_sock; /* socket to listen for unicast 138. */
};
@@ -535,7 +535,7 @@ struct dgram_packet {
BOOL more;
} flags;
int dgm_id;
- struct in_addr source_ip;
+ struct ipv4_addr source_ip;
int source_port;
int dgm_length;
int packet_offset;
@@ -554,7 +554,7 @@ struct packet_struct
struct packet_struct *next;
struct packet_struct *prev;
BOOL locked;
- struct in_addr ip;
+ struct ipv4_addr ip;
int port;
int fd;
time_t timestamp;
@@ -642,8 +642,8 @@ typedef struct _WINS_RECORD {
int wins_flags;
uint64_t id;
int num_ips;
- struct in_addr ip[25];
- struct in_addr wins_ip;
+ struct ipv4_addr ip[25];
+ struct ipv4_addr wins_ip;
} WINS_RECORD;
/* To be removed. */
diff --git a/source4/include/structs.h b/source4/include/structs.h
index 2757e6df57..e1e6de5d77 100644
--- a/source4/include/structs.h
+++ b/source4/include/structs.h
@@ -48,3 +48,4 @@ struct samr_CryptPasswordEx;
struct netr_SamInfo3;
struct netr_Authenticator;
+struct iface_struct;
diff --git a/source4/include/system/README b/source4/include/system/README
new file mode 100644
index 0000000000..69a2b80b56
--- /dev/null
+++ b/source4/include/system/README
@@ -0,0 +1,4 @@
+This directory contains wrappers around logical groups of system
+include files. The idea is to avoid #ifdef blocks in the main code,
+and instead put all the necessary conditional includes in subsystem
+specific header files in this directory.
diff --git a/source4/include/system/kerberos.h b/source4/include/system/kerberos.h
new file mode 100644
index 0000000000..85c635e223
--- /dev/null
+++ b/source4/include/system/kerberos.h
@@ -0,0 +1,44 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ kerberos system include wrappers
+
+ 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.
+*/
+
+
+#ifdef HAVE_KRB5_H
+#include <krb5.h>
+#else
+#undef HAVE_KRB5
+#endif
+
+#ifdef HAVE_GSSAPI_H
+#include <gssapi.h>
+#endif
+
+#ifdef HAVE_GSSAPI_GSSAPI_H
+#include <gssapi/gssapi.h>
+#endif
+
+#ifdef HAVE_GSSAPI_GSSAPI_GENERIC_H
+#include <gssapi/gssapi_generic.h>
+#endif
+
+#ifdef HAVE_COM_ERR_H
+#include <com_err.h>
+#endif
diff --git a/source4/include/system/network.h b/source4/include/system/network.h
new file mode 100644
index 0000000000..fcee0f7c24
--- /dev/null
+++ b/source4/include/system/network.h
@@ -0,0 +1,60 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ networking system include wrappers
+
+ 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.
+*/
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#ifdef HAVE_UNIXSOCKET
+#include <sys/un.h>
+#endif
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+
+#ifdef HAVE_NETINET_TCP_H
+#include <netinet/tcp.h>
+#endif
+
+/*
+ * The next three defines are needed to access the IPTOS_* options
+ * on some systems.
+ */
+
+#ifdef HAVE_NETINET_IN_SYSTM_H
+#include <netinet/in_systm.h>
+#endif
+
+#ifdef HAVE_NETINET_IN_IP_H
+#include <netinet/in_ip.h>
+#endif
+
+#ifdef HAVE_NETINET_IP_H
+#include <netinet/ip.h>
+#endif
+
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
+
+
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index a9aea2b449..6013b6ecf4 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -34,11 +34,11 @@ static void ldapsrv_terminate_connection(struct ldapsrv_connection *ldap_conn, c
*/
static void add_socket(struct server_service *service,
const struct model_ops *model_ops,
- struct in_addr *ifip)
+ struct ipv4_addr *ifip)
{
struct server_socket *srv_sock;
uint16_t port = 389;
- char *ip_str = talloc_strdup(service, inet_ntoa(*ifip));
+ char *ip_str = talloc_strdup(service, sys_inet_ntoa(*ifip));
srv_sock = service_setup_socket(service, model_ops, "ipv4", ip_str, &port);
@@ -99,7 +99,7 @@ static void ldapsrv_init(struct server_service *service,
socket per interface and bind to only these.
*/
for(i = 0; i < num_interfaces; i++) {
- struct in_addr *ifip = iface_n_ip(i);
+ struct ipv4_addr *ifip = iface_n_ip(i);
if (ifip == NULL) {
DEBUG(0,("ldapsrv_init: interface %d has NULL "
@@ -110,7 +110,7 @@ static void ldapsrv_init(struct server_service *service,
add_socket(service, model_ops, ifip);
}
} else {
- struct in_addr ifip;
+ struct ipv4_addr ifip;
/* Just bind to lp_socket_address() (usually 0.0.0.0) */
ifip = interpret_addr2(lp_socket_address());
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;
}
}
diff --git a/source4/libcli/auth/clikrb5.c b/source4/libcli/auth/clikrb5.c
index c3ea33aaec..6f17bddfa0 100644
--- a/source4/libcli/auth/clikrb5.c
+++ b/source4/libcli/auth/clikrb5.c
@@ -20,6 +20,8 @@
*/
#include "includes.h"
+#include "system/network.h"
+#include "system/kerberos.h"
#ifdef HAVE_KRB5
diff --git a/source4/libcli/auth/gensec_krb5.c b/source4/libcli/auth/gensec_krb5.c
index 95cc6bacbe..f393ce09c1 100644
--- a/source4/libcli/auth/gensec_krb5.c
+++ b/source4/libcli/auth/gensec_krb5.c
@@ -24,6 +24,8 @@
*/
#include "includes.h"
+#include "system/kerberos.h"
+#include "libcli/auth/kerberos.h"
#include "librpc/gen_ndr/ndr_krb5pac.h"
#undef DBGC_CLASS
diff --git a/source4/libcli/auth/kerberos.c b/source4/libcli/auth/kerberos.c
index b08c7f505c..06e89d4d33 100644
--- a/source4/libcli/auth/kerberos.c
+++ b/source4/libcli/auth/kerberos.c
@@ -21,6 +21,7 @@
*/
#include "includes.h"
+#include "system/kerberos.h"
#ifdef HAVE_KRB5
diff --git a/source4/libcli/auth/kerberos_verify.c b/source4/libcli/auth/kerberos_verify.c
index 8d050182f9..8e598e2a66 100644
--- a/source4/libcli/auth/kerberos_verify.c
+++ b/source4/libcli/auth/kerberos_verify.c
@@ -23,6 +23,8 @@
*/
#include "includes.h"
+#include "system/kerberos.h"
+#include "libcli/auth/kerberos.h"
#ifdef HAVE_KRB5
diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c
index c3bc43aa8c..2949633b86 100644
--- a/source4/libcli/cliconnect.c
+++ b/source4/libcli/cliconnect.c
@@ -154,7 +154,7 @@ NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx,
struct smbcli_state **ret_cli,
const char *myname,
const char *host,
- struct in_addr *ip,
+ struct ipv4_addr *ip,
const char *sharename,
const char *devtype,
const char *username,
diff --git a/source4/libcli/ldap/ldap.c b/source4/libcli/ldap/ldap.c
index 6e182c3843..1eb7888d41 100644
--- a/source4/libcli/ldap/ldap.c
+++ b/source4/libcli/ldap/ldap.c
@@ -24,6 +24,7 @@
*/
#include "includes.h"
+#include "system/network.h"
/****************************************************************************
*
@@ -1272,7 +1273,7 @@ struct ldap_connection *new_ldap_connection(void)
BOOL ldap_connect(struct ldap_connection *conn, const char *url)
{
struct hostent *hp;
- struct in_addr ip;
+ struct ipv4_addr ip;
if (!ldap_parse_basic_url(conn->mem_ctx, url, &conn->host,
&conn->port, &conn->ldaps))
diff --git a/source4/libcli/namecache.c b/source4/libcli/namecache.c
index 9f4796af1a..8a4dab7522 100644
--- a/source4/libcli/namecache.c
+++ b/source4/libcli/namecache.c
@@ -113,7 +113,7 @@ static char* namecache_key(TALLOC_CTX *mem_ctx, const char *name, int name_type)
**/
BOOL namecache_store(TALLOC_CTX *mem_ctx, const char *name, int name_type,
- int num_names, struct in_addr *ip_list)
+ int num_names, struct ipv4_addr *ip_list)
{
time_t expiry;
char *key, *value_string;
@@ -129,7 +129,7 @@ BOOL namecache_store(TALLOC_CTX *mem_ctx, const char *name, int name_type,
num_names, num_names == 1 ? "": "es", name, name_type));
for (i = 0; i < num_names; i++)
- DEBUGADD(5, ("%s%s", inet_ntoa(ip_list[i]),
+ DEBUGADD(5, ("%s%s", sys_inet_ntoa(ip_list[i]),
i == (num_names - 1) ? "" : ", "));
DEBUGADD(5, ("\n"));
@@ -172,7 +172,7 @@ BOOL namecache_store(TALLOC_CTX *mem_ctx, const char *name, int name_type,
* false if name isn't found in the cache or has expired
**/
-BOOL namecache_fetch(TALLOC_CTX *mem_ctx, const char *name, int name_type, struct in_addr **ip_list,
+BOOL namecache_fetch(TALLOC_CTX *mem_ctx, const char *name, int name_type, struct ipv4_addr **ip_list,
int *num_names)
{
char *key, *value;
diff --git a/source4/libcli/namequery.c b/source4/libcli/namequery.c
index a9464718c5..7a2d697797 100644
--- a/source4/libcli/namequery.c
+++ b/source4/libcli/namequery.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "system/network.h"
/* A netbios node status array element. */
struct node_status {
@@ -83,7 +84,7 @@ do a NBT node status query on an open socket and return an array of
structures holding the returned names or NULL if the query failed
**************************************************************************/
struct node_status *node_status_query(int fd,struct nmb_name *name,
- struct in_addr to_ip, int *num_names)
+ struct ipv4_addr to_ip, int *num_names)
{
BOOL found=False;
int retries = 2;
@@ -170,7 +171,7 @@ a servers name given its IP
return the matched name in *name
**************************************************************************/
-BOOL name_status_find(const char *q_name, int q_type, int type, struct in_addr to_ip, char *name)
+BOOL name_status_find(const char *q_name, int q_type, int type, struct ipv4_addr to_ip, char *name)
{
struct node_status *status = NULL;
struct nmb_name nname;
@@ -184,7 +185,7 @@ BOOL name_status_find(const char *q_name, int q_type, int type, struct in_addr t
}
DEBUG(10, ("name_status_find: looking up %s#%02x at %s\n", q_name,
- q_type, inet_ntoa(to_ip)));
+ q_type, sys_inet_ntoa(to_ip)));
sock = open_socket_in(SOCK_DGRAM, 0, 3, interpret_addr(lp_socket_address()), True);
if (sock == -1)
@@ -213,7 +214,7 @@ BOOL name_status_find(const char *q_name, int q_type, int type, struct in_addr t
DEBUG(10, ("name_status_find: name %sfound", result ? "" : "not "));
if (result)
- DEBUGADD(10, (", ip address is %s", inet_ntoa(to_ip)));
+ DEBUGADD(10, (", ip address is %s", sys_inet_ntoa(to_ip)));
DEBUG(10, ("\n"));
@@ -224,14 +225,14 @@ BOOL name_status_find(const char *q_name, int q_type, int type, struct in_addr t
/*
comparison function used by sort_ip_list
*/
-int ip_compare(struct in_addr *ip1, struct in_addr *ip2)
+int ip_compare(struct ipv4_addr *ip1, struct ipv4_addr *ip2)
{
int max_bits1=0, max_bits2=0;
int num_interfaces = iface_count();
int i;
for (i=0;i<num_interfaces;i++) {
- struct in_addr ip;
+ struct ipv4_addr ip;
int bits1, bits2;
ip = *iface_n_bcast(i);
bits1 = matching_quad_bits((uint8_t *)&ip1->s_addr, (uint8_t *)&ip.s_addr);
@@ -256,13 +257,13 @@ int ip_compare(struct in_addr *ip1, struct in_addr *ip2)
are at the top. This prevents the problem where a WINS server returns an IP that
is not reachable from our subnet as the first match
*/
-static void sort_ip_list(struct in_addr *iplist, int count)
+static void sort_ip_list(struct ipv4_addr *iplist, int count)
{
if (count <= 1) {
return;
}
- qsort(iplist, count, sizeof(struct in_addr), QSORT_CAST ip_compare);
+ qsort(iplist, count, sizeof(struct ipv4_addr), QSORT_CAST ip_compare);
}
@@ -272,9 +273,9 @@ static void sort_ip_list(struct in_addr *iplist, int count)
*count will be set to the number of addresses returned.
*timed_out is set if we failed by timing out
****************************************************************************/
-struct in_addr *name_query(int fd,const char *name,int name_type,
+struct ipv4_addr *name_query(int fd,const char *name,int name_type,
BOOL bcast,BOOL recurse,
- struct in_addr to_ip, int *count, int *flags,
+ struct ipv4_addr to_ip, int *count, int *flags,
BOOL *timed_out)
{
BOOL found=False;
@@ -284,7 +285,7 @@ struct in_addr *name_query(int fd,const char *name,int name_type,
struct packet_struct p;
struct packet_struct *p2;
struct nmb_packet *nmb = &p.packet.nmb;
- struct in_addr *ip_list = NULL;
+ struct ipv4_addr *ip_list = NULL;
if (lp_disable_netbios()) {
DEBUG(5,("name_query(%s#%02x): netbios is disabled\n", name, name_type));
@@ -333,7 +334,7 @@ struct in_addr *name_query(int fd,const char *name,int name_type,
while (1) {
struct timeval tval2;
- struct in_addr *tmp_ip_list;
+ struct ipv4_addr *tmp_ip_list;
GetTimeOfDay(&tval2);
if (TvalDiff(&tval,&tval2) > retry_time) {
@@ -398,7 +399,7 @@ struct in_addr *name_query(int fd,const char *name,int name_type,
continue;
}
- tmp_ip_list = (struct in_addr *)Realloc( ip_list, sizeof( ip_list[0] )
+ tmp_ip_list = (struct ipv4_addr *)Realloc( ip_list, sizeof( ip_list[0] )
* ( (*count) + nmb2->answers->rdlength/6 ) );
if (!tmp_ip_list) {
@@ -409,10 +410,10 @@ struct in_addr *name_query(int fd,const char *name,int name_type,
ip_list = tmp_ip_list;
if (ip_list) {
- DEBUG(2,("Got a positive name query response from %s ( ", inet_ntoa(p2->ip)));
+ DEBUG(2,("Got a positive name query response from %s ( ", sys_inet_ntoa(p2->ip)));
for (i=0;i<nmb2->answers->rdlength/6;i++) {
putip((char *)&ip_list[(*count)],&nmb2->answers->rdata[2+i*6]);
- DEBUGADD(2,("%s ",inet_ntoa(ip_list[(*count)])));
+ DEBUGADD(2,("%s ",sys_inet_ntoa(ip_list[(*count)])));
(*count)++;
}
DEBUGADD(2,(")\n"));
@@ -474,7 +475,7 @@ XFILE *startlmhosts(char *fname)
*********************************************************/
BOOL getlmhostsent( TALLOC_CTX *mem_ctx,
- XFILE *fp, pstring name, int *name_type, struct in_addr *ipaddr)
+ XFILE *fp, pstring name, int *name_type, struct ipv4_addr *ipaddr)
{
pstring line;
@@ -571,7 +572,7 @@ void endlmhosts(XFILE *fp)
*********************************************************/
BOOL name_resolve_bcast(const char *name, int name_type,
- struct in_addr **return_ip_list, int *return_count)
+ struct ipv4_addr **return_ip_list, int *return_count)
{
int sock, i;
int num_interfaces = iface_count();
@@ -601,7 +602,7 @@ BOOL name_resolve_bcast(const char *name, int name_type,
* the first successful match.
*/
for( i = num_interfaces-1; i >= 0; i--) {
- struct in_addr sendto_ip;
+ struct ipv4_addr sendto_ip;
int flags;
/* Done this way to fix compiler error on IRIX 5.x */
sendto_ip = *iface_n_bcast(i);
@@ -621,11 +622,11 @@ BOOL name_resolve_bcast(const char *name, int name_type,
Resolve via "wins" method.
*********************************************************/
BOOL resolve_wins(TALLOC_CTX *mem_ctx, const char *name, int name_type,
- struct in_addr **return_iplist, int *return_count)
+ struct ipv4_addr **return_iplist, int *return_count)
{
int sock, t, i;
char **wins_tags;
- struct in_addr src_ip;
+ struct ipv4_addr src_ip;
if (lp_disable_netbios()) {
DEBUG(5,("resolve_wins(%s#%02x): netbios is disabled\n", name, name_type));
@@ -658,7 +659,7 @@ BOOL resolve_wins(TALLOC_CTX *mem_ctx, const char *name, int name_type,
for (t=0; wins_tags && wins_tags[t]; t++) {
int srv_count = wins_srv_count_tag(wins_tags[t]);
for (i=0; i<srv_count; i++) {
- struct in_addr wins_ip;
+ struct ipv4_addr wins_ip;
int flags;
BOOL timed_out;
@@ -674,7 +675,7 @@ BOOL resolve_wins(TALLOC_CTX *mem_ctx, const char *name, int name_type,
continue;
}
- DEBUG(3,("resolve_wins: using WINS server %s and tag '%s'\n", inet_ntoa(wins_ip), wins_tags[t]));
+ DEBUG(3,("resolve_wins: using WINS server %s and tag '%s'\n", sys_inet_ntoa(wins_ip), wins_tags[t]));
sock = open_socket_in(SOCK_DGRAM, 0, 3, src_ip.s_addr, True);
if (sock == -1) {
@@ -714,7 +715,7 @@ success:
*********************************************************/
static BOOL resolve_hosts(const char *name,
- struct in_addr **return_iplist, int *return_count)
+ struct ipv4_addr **return_iplist, int *return_count)
{
/*
* "host" means do a localhost, or dns lookup.
@@ -727,9 +728,9 @@ static BOOL resolve_hosts(const char *name,
DEBUG(3,("resolve_hosts: Attempting host lookup for name %s<0x20>\n", name));
if (((hp = sys_gethostbyname(name)) != NULL) && (hp->h_addr != NULL)) {
- struct in_addr return_ip;
+ struct ipv4_addr return_ip;
putip((char *)&return_ip,(char *)hp->h_addr);
- *return_iplist = (struct in_addr *)malloc(sizeof(struct in_addr));
+ *return_iplist = (struct ipv4_addr *)malloc(sizeof(struct ipv4_addr));
if(*return_iplist == NULL) {
DEBUG(3,("resolve_hosts: malloc fail !\n"));
return False;
@@ -749,7 +750,7 @@ static BOOL resolve_hosts(const char *name,
*********************************************************/
static BOOL internal_resolve_name(TALLOC_CTX *mem_ctx, const char *name, int name_type,
- struct in_addr **return_iplist, int *return_count)
+ struct ipv4_addr **return_iplist, int *return_count)
{
char *name_resolve_list;
fstring tok;
@@ -758,7 +759,7 @@ static BOOL internal_resolve_name(TALLOC_CTX *mem_ctx, const char *name, int nam
BOOL allzeros = (strcmp(name,"0.0.0.0") == 0);
BOOL is_address = is_ipaddress(name);
BOOL result = False;
- struct in_addr *nodupes_iplist;
+ struct ipv4_addr *nodupes_iplist;
int i;
*return_iplist = NULL;
@@ -767,7 +768,7 @@ static BOOL internal_resolve_name(TALLOC_CTX *mem_ctx, const char *name, int nam
DEBUG(10, ("internal_resolve_name: looking up %s#%x\n", name, name_type));
if (allzeros || allones || is_address) {
- *return_iplist = (struct in_addr *)malloc(sizeof(struct in_addr));
+ *return_iplist = (struct ipv4_addr *)malloc(sizeof(struct ipv4_addr));
if(*return_iplist == NULL) {
DEBUG(3,("internal_resolve_name: malloc fail !\n"));
return False;
@@ -841,8 +842,8 @@ static BOOL internal_resolve_name(TALLOC_CTX *mem_ctx, const char *name, int nam
controllers including the PDC in iplist[1..n]. Iterating over
the iplist when the PDC is down will cause two sets of timeouts. */
- if (*return_count && (nodupes_iplist = (struct in_addr *)
- malloc(sizeof(struct in_addr) * (*return_count)))) {
+ if (*return_count && (nodupes_iplist = (struct ipv4_addr *)
+ malloc(sizeof(struct ipv4_addr) * (*return_count)))) {
int nodupes_count = 0;
/* Iterate over return_iplist looking for duplicates */
@@ -879,7 +880,7 @@ static BOOL internal_resolve_name(TALLOC_CTX *mem_ctx, const char *name, int nam
/* Save in name cache */
for (i = 0; i < *return_count && DEBUGLEVEL == 100; i++)
DEBUG(100, ("Storing name %s of type %d (ip: %s)\n", name,
- name_type, inet_ntoa((*return_iplist)[i])));
+ name_type, sys_inet_ntoa((*return_iplist)[i])));
namecache_store(mem_ctx, name, name_type, *return_count, *return_iplist);
@@ -889,7 +890,7 @@ static BOOL internal_resolve_name(TALLOC_CTX *mem_ctx, const char *name, int nam
*return_count));
for (i = 0; i < *return_count; i++)
- DEBUGADD(10, ("%s ", inet_ntoa((*return_iplist)[i])));
+ DEBUGADD(10, ("%s ", sys_inet_ntoa((*return_iplist)[i])));
DEBUG(10, ("\n"));
@@ -902,9 +903,9 @@ static BOOL internal_resolve_name(TALLOC_CTX *mem_ctx, const char *name, int nam
or host name or NetBIOS name. This uses the name switch in the
smb.conf to determine the order of name resolution.
*********************************************************/
-BOOL resolve_name(TALLOC_CTX *mem_ctx, const char *name, struct in_addr *return_ip, int name_type)
+BOOL resolve_name(TALLOC_CTX *mem_ctx, const char *name, struct ipv4_addr *return_ip, int name_type)
{
- struct in_addr *ip_list = NULL;
+ struct ipv4_addr *ip_list = NULL;
int count = 0;
if (is_ipaddress(name)) {
@@ -916,7 +917,7 @@ BOOL resolve_name(TALLOC_CTX *mem_ctx, const char *name, struct in_addr *return_
int i;
/* only return valid addresses for TCP connections */
for (i=0; i<count; i++) {
- char *ip_str = inet_ntoa(ip_list[i]);
+ const char *ip_str = sys_inet_ntoa(ip_list[i]);
if (ip_str &&
strcmp(ip_str, "255.255.255.255") != 0 &&
strcmp(ip_str, "0.0.0.0") != 0) {
@@ -934,9 +935,9 @@ BOOL resolve_name(TALLOC_CTX *mem_ctx, const char *name, struct in_addr *return_
Find the IP address of the master browser or DMB for a workgroup.
*********************************************************/
-BOOL find_master_ip(TALLOC_CTX *mem_ctx, const char *group, struct in_addr *master_ip)
+BOOL find_master_ip(TALLOC_CTX *mem_ctx, const char *group, struct ipv4_addr *master_ip)
{
- struct in_addr *ip_list = NULL;
+ struct ipv4_addr *ip_list = NULL;
int count = 0;
if (lp_disable_netbios()) {
@@ -964,7 +965,7 @@ BOOL find_master_ip(TALLOC_CTX *mem_ctx, const char *group, struct in_addr *mast
*********************************************************/
BOOL lookup_dc_name(const char *srcname, const char *domain,
- struct in_addr *dc_ip, char *ret_name)
+ struct ipv4_addr *dc_ip, char *ret_name)
{
#if !defined(I_HATE_WINDOWS_REPLY_CODE)
fstring dc_name;
@@ -1146,7 +1147,7 @@ NT GETDC call, UNICODE, NT domain SID and uncle tom cobbley and all...
DEBUG(4,("lookup_pdc_name: datagram reply from %s to %s IP %s for %s of type %d len=%d\n",
nmb_namestr(&dgram2->source_name),nmb_namestr(&dgram2->dest_name),
- inet_ntoa(p_ret->ip), smb_buf(buf),SVAL(buf2,0),len));
+ sys_inet_ntoa(p_ret->ip), smb_buf(buf),SVAL(buf2,0),len));
if(SVAL(buf2,0) != QUERYFORPDC_R) {
DEBUG(0,("lookup_pdc_name: datagram type (%u) != QUERYFORPDC_R(%u)\n",
@@ -1175,9 +1176,9 @@ NT GETDC call, UNICODE, NT domain SID and uncle tom cobbley and all...
for a domain.
*********************************************************/
-BOOL get_pdc_ip(TALLOC_CTX *mem_ctx, const char *domain, struct in_addr *ip)
+BOOL get_pdc_ip(TALLOC_CTX *mem_ctx, const char *domain, struct ipv4_addr *ip)
{
- struct in_addr *ip_list;
+ struct ipv4_addr *ip_list;
int count;
int i = 0;
@@ -1217,7 +1218,7 @@ BOOL get_pdc_ip(TALLOC_CTX *mem_ctx, const char *domain, struct in_addr *ip)
a domain.
*********************************************************/
-BOOL get_dc_list(TALLOC_CTX *mem_ctx, const char *domain, struct in_addr **ip_list, int *count, int *ordered)
+BOOL get_dc_list(TALLOC_CTX *mem_ctx, const char *domain, struct ipv4_addr **ip_list, int *count, int *ordered)
{
*ordered = False;
@@ -1230,8 +1231,8 @@ BOOL get_dc_list(TALLOC_CTX *mem_ctx, const char *domain, struct in_addr **ip_li
fstring name;
int num_addresses = 0;
int local_count, i, j;
- struct in_addr *return_iplist = NULL;
- struct in_addr *auto_ip_list = NULL;
+ struct ipv4_addr *return_iplist = NULL;
+ struct ipv4_addr *auto_ip_list = NULL;
BOOL done_auto_lookup = False;
int auto_count = 0;
@@ -1266,7 +1267,7 @@ BOOL get_dc_list(TALLOC_CTX *mem_ctx, const char *domain, struct in_addr **ip_li
if ( (num_addresses == 0) && !done_auto_lookup )
return internal_resolve_name(mem_ctx, domain, 0x1C, ip_list, count);
- return_iplist = (struct in_addr *)malloc(num_addresses * sizeof(struct in_addr));
+ return_iplist = (struct ipv4_addr *)malloc(num_addresses * sizeof(struct ipv4_addr));
if (return_iplist == NULL) {
DEBUG(3,("get_dc_list: malloc fail !\n"));
@@ -1279,7 +1280,7 @@ BOOL get_dc_list(TALLOC_CTX *mem_ctx, const char *domain, struct in_addr **ip_li
/* fill in the return list now with real IP's */
while ( (local_count<num_addresses) && next_token(&p,name,LIST_SEP,sizeof(name)) ) {
- struct in_addr name_ip;
+ struct ipv4_addr name_ip;
/* copy any addersses from the auto lookup */
diff --git a/source4/libcli/namequery_dc.c b/source4/libcli/namequery_dc.c
index 16e5282497..6c341af401 100644
--- a/source4/libcli/namequery_dc.c
+++ b/source4/libcli/namequery_dc.c
@@ -28,9 +28,9 @@
/*
find the DC for a domain using methods appropriate for a RPC domain
*/
-BOOL rpc_find_dc(const char *domain, fstring srv_name, struct in_addr *ip_out)
+BOOL rpc_find_dc(const char *domain, fstring srv_name, struct ipv4_addr *ip_out)
{
- struct in_addr *ip_list = NULL, dc_ip, exclude_ip;
+ struct ipv4_addr *ip_list = NULL, dc_ip, exclude_ip;
int count, i;
BOOL list_ordered;
BOOL use_pdc_only;
@@ -69,7 +69,7 @@ BOOL rpc_find_dc(const char *domain, fstring srv_name, struct in_addr *ip_out)
/* Pick a nice close server, but only if the list was not ordered */
if (!list_ordered && (count > 1) ) {
- qsort(ip_list, count, sizeof(struct in_addr), QSORT_CAST ip_compare);
+ qsort(ip_list, count, sizeof(struct ipv4_addr), QSORT_CAST ip_compare);
}
for (i = 0; i < count; i++) {
diff --git a/source4/libcli/nmblib.c b/source4/libcli/nmblib.c
index 5eeec48003..ef5210cf63 100644
--- a/source4/libcli/nmblib.c
+++ b/source4/libcli/nmblib.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "system/network.h"
static const struct opcode_names {
const char *nmb_opcode_name;
@@ -102,7 +103,7 @@ void debug_nmb_packet(struct packet_struct *p)
if (DEBUGLVL(4)) {
DEBUG(4, ("nmb packet from %s(%d) header: id=%d opcode=%s(%d) response=%s\n",
- inet_ntoa(p->ip), p->port,
+ sys_inet_ntoa(p->ip), p->port,
nmb->header.name_trn_id,
lookup_opcode_name(nmb->header.opcode),
nmb->header.opcode,
@@ -696,7 +697,7 @@ struct packet_struct *read_packet(int fd,enum packet_type packet_type)
struct packet_struct *packet;
char buf[MAX_DGRAM_SIZE];
int length;
- struct in_addr addr;
+ struct ipv4_addr addr;
int port;
length = read_udp_socket(fd, buf, sizeof(buf), &addr, &port);
@@ -710,7 +711,7 @@ struct packet_struct *read_packet(int fd,enum packet_type packet_type)
packet->port = port;
DEBUG(5,("Received a packet of len %d from (%s) port %d\n",
- length, inet_ntoa(packet->ip), packet->port));
+ length, sys_inet_ntoa(packet->ip), packet->port));
return packet;
}
@@ -719,7 +720,7 @@ struct packet_struct *read_packet(int fd,enum packet_type packet_type)
/*******************************************************************
send a udp packet on a already open socket
******************************************************************/
-static BOOL send_udp(int fd,char *buf,int len,struct in_addr ip,int port)
+static BOOL send_udp(int fd,char *buf,int len,struct ipv4_addr ip,int port)
{
BOOL ret = False;
int i;
@@ -732,7 +733,7 @@ static BOOL send_udp(int fd,char *buf,int len,struct in_addr ip,int port)
sock_out.sin_family = AF_INET;
DEBUG( 5, ( "Sending a packet of len %d to (%s) on port %d\n",
- len, inet_ntoa(ip), port ) );
+ len, sys_inet_ntoa(ip), port ) );
/*
* Patch to fix asynch error notifications from Linux kernel.
@@ -746,7 +747,7 @@ static BOOL send_udp(int fd,char *buf,int len,struct in_addr ip,int port)
if (!ret)
DEBUG(0,("Packet send failed to %s(%d) ERRNO=%s\n",
- inet_ntoa(ip),port,strerror(errno)));
+ sys_inet_ntoa(ip),port,strerror(errno)));
return(ret);
}
@@ -1069,7 +1070,7 @@ static int name_query_comp(uint8_t *p1, uint8_t *p2)
sort a set of 6 byte name query response records so that the IPs that
have the most leading bits in common with the specified address come first
***************************************************************************/
-void sort_query_replies(char *data, int n, struct in_addr ip)
+void sort_query_replies(char *data, int n, struct ipv4_addr ip)
{
if (n <= 1) return;
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index c641f8bf12..349b4b9a9c 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -49,7 +49,7 @@ struct smbcli_socket *smbcli_sock_init(TALLOC_CTX *mem_ctx)
connect a smbcli_socket context to an IP/port pair
if port is 0 then choose 445 then 139
*/
-BOOL smbcli_sock_connect(struct smbcli_socket *sock, struct in_addr *ip, int port)
+BOOL smbcli_sock_connect(struct smbcli_socket *sock, struct ipv4_addr *ip, int port)
{
NTSTATUS status;
@@ -71,7 +71,7 @@ BOOL smbcli_sock_connect(struct smbcli_socket *sock, struct in_addr *ip, int por
}
talloc_steal(sock, sock->sock);
- status = socket_connect(sock->sock, NULL, 0, inet_ntoa(*ip), port, 0);
+ status = socket_connect(sock->sock, NULL, 0, sys_inet_ntoa(*ip), port, 0);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(sock->sock);
sock->sock = NULL;
@@ -159,7 +159,7 @@ resolve a hostname and connect
BOOL smbcli_sock_connect_byname(struct smbcli_socket *sock, const char *host, int port)
{
int name_type = 0x20;
- struct in_addr ip;
+ struct ipv4_addr ip;
char *name, *p;
BOOL ret;
diff --git a/source4/libcli/raw/libcliraw.h b/source4/libcli/raw/libcliraw.h
index 48abc82a68..9bbdd8a222 100644
--- a/source4/libcli/raw/libcliraw.h
+++ b/source4/libcli/raw/libcliraw.h
@@ -60,7 +60,7 @@ struct smbcli_negotiate {
/* this is the context for a SMB socket associated with the socket itself */
struct smbcli_socket {
- struct in_addr dest_ip;
+ struct ipv4_addr dest_ip;
/* dest hostname (which may or may not be a DNS name) */
char *hostname;
diff --git a/source4/libnet/libnet_rpc.c b/source4/libnet/libnet_rpc.c
index 14f0ba0ad0..48a7f96774 100644
--- a/source4/libnet/libnet_rpc.c
+++ b/source4/libnet/libnet_rpc.c
@@ -24,7 +24,7 @@
static NTSTATUS libnet_find_pdc_generic(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_find_pdc *r)
{
BOOL ret;
- struct in_addr ip;
+ struct ipv4_addr ip;
if (is_ipaddress(r->generic.in.domain_name)) {
r->generic.out.pdc_name = r->generic.in.domain_name;
@@ -40,7 +40,7 @@ static NTSTATUS libnet_find_pdc_generic(struct libnet_context *ctx, TALLOC_CTX *
}
}
- r->generic.out.pdc_name = talloc_strdup(mem_ctx, inet_ntoa(ip));
+ r->generic.out.pdc_name = talloc_strdup(mem_ctx, sys_inet_ntoa(ip));
return NT_STATUS_OK;
}
diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c
index 55818e28fe..638b2e1c55 100644
--- a/source4/librpc/rpc/dcerpc_util.c
+++ b/source4/librpc/rpc/dcerpc_util.c
@@ -22,6 +22,7 @@
*/
#include "includes.h"
+#include "system/network.h"
#include "librpc/gen_ndr/ndr_epmapper.h"
/*
@@ -385,9 +386,9 @@ const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *flo
}
{
- struct in_addr in;
+ struct ipv4_addr in;
in.s_addr = htonl(floor->rhs.ip.address);
- return talloc_strdup(mem_ctx, inet_ntoa(in));
+ return talloc_strdup(mem_ctx, sys_inet_ntoa(in));
}
case EPM_PROTOCOL_NCACN:
diff --git a/source4/rpc_server/dcerpc_sock.c b/source4/rpc_server/dcerpc_sock.c
index 508f42d2fb..b131df5de2 100644
--- a/source4/rpc_server/dcerpc_sock.c
+++ b/source4/rpc_server/dcerpc_sock.c
@@ -123,15 +123,15 @@ static void add_socket_rpc_ncalrpc(struct server_service *service,
add a socket address to the list of events, one event per dcerpc endpoint
*/
static void add_socket_rpc_tcp_iface(struct server_service *service,
- const struct model_ops *model_ops,
- struct dcesrv_context *dce_ctx,
- struct dcesrv_endpoint *e,
- struct in_addr *ifip)
+ const struct model_ops *model_ops,
+ struct dcesrv_context *dce_ctx,
+ struct dcesrv_endpoint *e,
+ struct ipv4_addr *ifip)
{
struct server_socket *sock;
struct dcesrv_socket_context *dcesrv_sock;
uint16_t port = 0;
- char *ip_str = talloc_strdup(service, inet_ntoa(*ifip));
+ char *ip_str = talloc_strdup(service, sys_inet_ntoa(*ifip));
if (e->ep_description.endpoint)
port = atoi(e->ep_description.endpoint);
@@ -173,14 +173,14 @@ static void add_socket_rpc_tcp(struct server_service *service,
int num_interfaces = iface_count();
int i;
for(i = 0; i < num_interfaces; i++) {
- struct in_addr *ifip = iface_n_ip(i);
+ struct ipv4_addr *ifip = iface_n_ip(i);
if (ifip == NULL) {
continue;
}
add_socket_rpc_tcp_iface(service, model_ops, dce_ctx, e, ifip);
}
} else {
- struct in_addr ifip;
+ struct ipv4_addr ifip;
ifip = interpret_addr2(lp_socket_address());
add_socket_rpc_tcp_iface(service, model_ops, dce_ctx, e, &ifip);
}
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c
index de3d60a6bd..a1a90852a1 100644
--- a/source4/smb_server/smb_server.c
+++ b/source4/smb_server/smb_server.c
@@ -728,11 +728,11 @@ static void smbsrv_exit(struct server_service *service, const char *reason)
static void add_socket(struct server_service *service,
const struct model_ops *model_ops,
struct socket_context *socket_ctx,
- struct in_addr *ifip)
+ struct ipv4_addr *ifip)
{
const char **ports = lp_smb_ports();
int i;
- char *ip_str = talloc_strdup(service, inet_ntoa(*ifip));
+ char *ip_str = talloc_strdup(service, sys_inet_ntoa(*ifip));
for (i=0;ports[i];i++) {
uint16_t port = atoi(ports[i]);
@@ -759,7 +759,7 @@ static void smbsrv_init(struct server_service *service, const struct model_ops *
socket per interface and bind to only these.
*/
for(i = 0; i < num_interfaces; i++) {
- struct in_addr *ifip = iface_n_ip(i);
+ struct ipv4_addr *ifip = iface_n_ip(i);
if (ifip == NULL) {
DEBUG(0,("open_sockets_smbd: interface %d has NULL IP address !\n", i));
@@ -769,7 +769,7 @@ static void smbsrv_init(struct server_service *service, const struct model_ops *
add_socket(service, model_ops, NULL, ifip);
}
} else {
- struct in_addr ifip;
+ struct ipv4_addr ifip;
/* Just bind to lp_socket_address() (usually 0.0.0.0) */
ifip = interpret_addr2(lp_socket_address());
add_socket(service, model_ops, NULL, &ifip);
diff --git a/source4/torture/rpc/epmapper.c b/source4/torture/rpc/epmapper.c
index fa0199a3c6..78721d075e 100644
--- a/source4/torture/rpc/epmapper.c
+++ b/source4/torture/rpc/epmapper.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "system/network.h"
#include "librpc/gen_ndr/ndr_epmapper.h"
@@ -64,9 +65,9 @@ static void display_tower(TALLOC_CTX *mem_ctx, struct epm_tower *twr)
case EPM_PROTOCOL_IP:
printf(" IP:");
{
- struct in_addr in;
+ struct ipv4_addr in;
in.s_addr = htonl(rhs->ip.address);
- printf("%s", inet_ntoa(in));
+ printf("%s", sys_inet_ntoa(in));
}
break;
diff --git a/source4/utils/nmblookup.c b/source4/utils/nmblookup.c
index 8c9eccf424..2ef1470ee4 100644
--- a/source4/utils/nmblookup.c
+++ b/source4/utils/nmblookup.c
@@ -26,7 +26,7 @@ extern BOOL AllowDebugChange;
static BOOL give_flags = False;
static BOOL use_bcast = True;
static BOOL got_bcast = False;
-static struct in_addr bcast_addr;
+static struct ipv4_addr bcast_addr;
static BOOL recursion_desired = False;
static BOOL translate_addresses = False;
static int ServerFD= -1;
@@ -119,7 +119,7 @@ static char *query_flags(int flags)
/****************************************************************************
do a node status query
****************************************************************************/
-static void do_node_status(int fd, const char *name, int type, struct in_addr ip)
+static void do_node_status(int fd, const char *name, int type, struct ipv4_addr ip)
{
struct nmb_name nname;
int count, i, j;
@@ -151,7 +151,7 @@ send out one query
static BOOL query_one(const char *lookup, uint_t lookup_type)
{
int j, count, flags = 0;
- struct in_addr *ip_list=NULL;
+ struct ipv4_addr *ip_list=NULL;
if (got_bcast) {
d_printf("querying %s on %s\n", lookup, inet_ntoa(bcast_addr));
@@ -159,7 +159,7 @@ static BOOL query_one(const char *lookup, uint_t lookup_type)
use_bcast?True:recursion_desired,
bcast_addr,&count, &flags, NULL);
} else {
- struct in_addr *bcast;
+ struct ipv4_addr *bcast;
for (j=iface_count() - 1;
!ip_list && j >= 0;
j--) {
@@ -299,7 +299,7 @@ int main(int argc,char *argv[])
for (i=optind;i<argc;i++)
{
char *p;
- struct in_addr ip;
+ struct ipv4_addr ip;
fstrcpy(lookup,argv[i]);