summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/include/ldb.h12
-rw-r--r--source4/lib/samba3/samba3.h2
-rw-r--r--source4/lib/samba3/winsdb.c3
-rw-r--r--source4/lib/socket/interface.c45
-rw-r--r--source4/lib/socket/socket_ip.c22
-rw-r--r--source4/lib/tdr/tdr.c8
-rw-r--r--source4/lib/util/system.c13
-rw-r--r--source4/lib/util/util.c18
-rw-r--r--source4/lib/util/util.h18
9 files changed, 62 insertions, 79 deletions
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 41d23b5d10..301db4dadc 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -735,12 +735,14 @@ struct ldb_register_partition {
struct ldb_dn *dn;
};
+enum ldb_sequence_type {
+ LDB_SEQ_HIGHEST_SEQ,
+ LDB_SEQ_HIGHEST_TIMESTAMP,
+ LDB_SEQ_NEXT
+};
+
struct ldb_sequence_number {
- enum ldb_sequence_type {
- LDB_SEQ_HIGHEST_SEQ,
- LDB_SEQ_HIGHEST_TIMESTAMP,
- LDB_SEQ_NEXT
- } type;
+ enum ldb_sequence_type type;
uint64_t seq_num;
uint32_t flags;
};
diff --git a/source4/lib/samba3/samba3.h b/source4/lib/samba3/samba3.h
index bc73e8941d..202ac767ec 100644
--- a/source4/lib/samba3/samba3.h
+++ b/source4/lib/samba3/samba3.h
@@ -98,7 +98,7 @@ struct samba3_winsdb_entry
int type;
time_t ttl;
uint32_t ip_count;
- struct ipv4_addr *ips;
+ struct in_addr *ips;
};
struct samba3_policy
diff --git a/source4/lib/samba3/winsdb.c b/source4/lib/samba3/winsdb.c
index 0a93dbb0e1..5bed3523ea 100644
--- a/source4/lib/samba3/winsdb.c
+++ b/source4/lib/samba3/winsdb.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "lib/samba3/samba3.h"
+#include "system/network.h"
#define WINS_VERSION 1
@@ -110,7 +111,7 @@ NTSTATUS samba3_read_winsdb( const char *fn, TALLOC_CTX *ctx, struct samba3_wins
}
/* Allocate the space for the ip_list. */
- if((entry.ips = talloc_array ( ctx, struct ipv4_addr, entry.ip_count)) == NULL) {
+ if((entry.ips = talloc_array ( ctx, struct in_addr, entry.ip_count)) == NULL) {
DEBUG(0,("initialise_wins: Malloc fail !\n"));
SAFE_FREE(line);
return NT_STATUS_NO_MEMORY;
diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c
index 9ca4450581..c220c4d890 100644
--- a/source4/lib/socket/interface.c
+++ b/source4/lib/socket/interface.c
@@ -28,8 +28,8 @@
/** used for network interfaces */
struct interface {
struct interface *next, *prev;
- struct ipv4_addr ip;
- struct ipv4_addr nmask;
+ struct in_addr ip;
+ struct in_addr nmask;
const char *ip_s;
const char *bcast_s;
const char *nmask_s;
@@ -44,25 +44,18 @@ 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.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(tov4(ip))) return local_interfaces;
+ if (is_zero_ip(ip)) return local_interfaces;
for (i=local_interfaces;i;i=i->next)
if (CheckMask) {
- if (same_net(i->ip,tov4(ip),i->nmask)) return i;
- } else if (i->ip.addr == ip.s_addr) return i;
+ if (same_net(i->ip,ip,i->nmask)) return i;
+ } else if (i->ip.s_addr == ip.s_addr) return i;
return NULL;
}
@@ -74,7 +67,7 @@ add an interface to the linked list of interfaces
static void add_interface(struct in_addr ip, struct in_addr nmask)
{
struct interface *iface;
- struct ipv4_addr bcast;
+ struct in_addr bcast;
if (iface_find(ip, false)) {
DEBUG(3,("not adding duplicate interface %s\n",inet_ntoa(ip)));
@@ -86,17 +79,17 @@ static void add_interface(struct in_addr ip, struct in_addr nmask)
ZERO_STRUCTPN(iface);
- iface->ip = tov4(ip);
- iface->nmask = tov4(nmask);
- bcast.addr = MKBCADDR(iface->ip.addr, iface->nmask.addr);
+ iface->ip = ip;
+ iface->nmask = nmask;
+ bcast.s_addr = MKBCADDR(iface->ip.s_addr, iface->nmask.s_addr);
/* keep string versions too, to avoid people tripping over the implied
- static in sys_inet_ntoa() */
- iface->ip_s = talloc_strdup(iface, sys_inet_ntoa(iface->ip));
- iface->nmask_s = talloc_strdup(iface, sys_inet_ntoa(iface->nmask));
+ static in inet_ntoa() */
+ iface->ip_s = talloc_strdup(iface, inet_ntoa(iface->ip));
+ iface->nmask_s = talloc_strdup(iface, inet_ntoa(iface->nmask));
if (nmask.s_addr != ~0) {
- iface->bcast_s = talloc_strdup(iface, sys_inet_ntoa(bcast));
+ iface->bcast_s = talloc_strdup(iface, inet_ntoa(bcast));
}
DLIST_ADD_END(local_interfaces, iface, struct interface *);
@@ -145,7 +138,7 @@ static void interpret_interface(const char *token,
if (strpbrk(token, "*?") != NULL) {
return;
}
- ip.s_addr = interpret_addr2(token).addr;
+ 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) {
add_interface(probed_ifaces[i].ip,
@@ -160,10 +153,10 @@ static void interpret_interface(const char *token,
/* parse it into an IP address/netmasklength pair */
*p++ = 0;
- ip.s_addr = interpret_addr2(token).addr;
+ ip.s_addr = interpret_addr2(token).s_addr;
if (strlen(p) > 2) {
- nmask.s_addr = interpret_addr2(p).addr;
+ nmask.s_addr = interpret_addr2(p).s_addr;
} else {
nmask.s_addr = htonl(((ALLONES >> atoi(p)) ^ ALLONES));
}
@@ -172,7 +165,7 @@ static void interpret_interface(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(tov4(ip), tov4(probed_ifaces[i].ip), tov4(nmask))) {
+ if (same_net(ip, probed_ifaces[i].ip, nmask)) {
add_interface(probed_ifaces[i].ip, nmask);
return;
}
@@ -193,7 +186,7 @@ static void load_interfaces(void)
const char **ptr;
int i;
struct iface_struct ifaces[MAX_INTERFACES];
- struct ipv4_addr loopback_ip;
+ struct in_addr loopback_ip;
int total_probed;
if (local_interfaces != NULL) {
@@ -213,7 +206,7 @@ static void load_interfaces(void)
DEBUG(0,("ERROR: Could not determine network interfaces, you must use a interfaces config line\n"));
}
for (i=0;i<total_probed;i++) {
- if (ifaces[i].ip.s_addr != loopback_ip.addr) {
+ if (ifaces[i].ip.s_addr != loopback_ip.s_addr) {
add_interface(ifaces[i].ip,
ifaces[i].netmask);
}
diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c
index 499dc93d7b..e3676ad71a 100644
--- a/source4/lib/socket/socket_ip.c
+++ b/source4/lib/socket/socket_ip.c
@@ -91,8 +91,8 @@ static NTSTATUS ipv4_connect(struct socket_context *sock,
uint32_t flags)
{
struct sockaddr_in srv_addr;
- struct ipv4_addr my_ip;
- struct ipv4_addr srv_ip;
+ struct in_addr my_ip;
+ struct in_addr srv_ip;
int ret;
if (my_address && my_address->sockaddr) {
@@ -103,13 +103,13 @@ static NTSTATUS ipv4_connect(struct socket_context *sock,
} else if (my_address) {
my_ip = interpret_addr2(my_address->addr);
- if (my_ip.addr != 0 || my_address->port != 0) {
+ if (my_ip.s_addr != 0 || my_address->port != 0) {
struct sockaddr_in my_addr;
ZERO_STRUCT(my_addr);
#ifdef HAVE_SOCK_SIN_LEN
my_addr.sin_len = sizeof(my_addr);
#endif
- my_addr.sin_addr.s_addr = my_ip.addr;
+ my_addr.sin_addr.s_addr = my_ip.s_addr;
my_addr.sin_port = htons(my_address->port);
my_addr.sin_family = PF_INET;
@@ -127,7 +127,7 @@ static NTSTATUS ipv4_connect(struct socket_context *sock,
}
} else {
srv_ip = interpret_addr2(srv_address->addr);
- if (!srv_ip.addr) {
+ if (!srv_ip.s_addr) {
return NT_STATUS_BAD_NETWORK_NAME;
}
@@ -135,7 +135,7 @@ static NTSTATUS ipv4_connect(struct socket_context *sock,
#ifdef HAVE_SOCK_SIN_LEN
srv_addr.sin_len = sizeof(srv_addr);
#endif
- srv_addr.sin_addr.s_addr= srv_ip.addr;
+ srv_addr.sin_addr.s_addr= srv_ip.s_addr;
srv_addr.sin_port = htons(srv_address->port);
srv_addr.sin_family = PF_INET;
@@ -158,7 +158,7 @@ static NTSTATUS ipv4_listen(struct socket_context *sock,
int queue_size, uint32_t flags)
{
struct sockaddr_in my_addr;
- struct ipv4_addr ip_addr;
+ struct in_addr ip_addr;
int ret;
socket_set_option(sock, "SO_REUSEADDR=1", NULL);
@@ -172,7 +172,7 @@ static NTSTATUS ipv4_listen(struct socket_context *sock,
#ifdef HAVE_SOCK_SIN_LEN
my_addr.sin_len = sizeof(my_addr);
#endif
- my_addr.sin_addr.s_addr = ip_addr.addr;
+ my_addr.sin_addr.s_addr = ip_addr.s_addr;
my_addr.sin_port = htons(my_address->port);
my_addr.sin_family = PF_INET;
@@ -355,17 +355,17 @@ static NTSTATUS ipv4_sendto(struct socket_context *sock,
dest_addr->sockaddr, dest_addr->sockaddrlen);
} else {
struct sockaddr_in srv_addr;
- struct ipv4_addr addr;
+ struct in_addr addr;
ZERO_STRUCT(srv_addr);
#ifdef HAVE_SOCK_SIN_LEN
srv_addr.sin_len = sizeof(srv_addr);
#endif
addr = interpret_addr2(dest_addr->addr);
- if (addr.addr == 0) {
+ if (addr.s_addr == 0) {
return NT_STATUS_HOST_UNREACHABLE;
}
- srv_addr.sin_addr.s_addr = addr.addr;
+ srv_addr.sin_addr.s_addr = addr.s_addr;
srv_addr.sin_port = htons(dest_addr->port);
srv_addr.sin_family = PF_INET;
diff --git a/source4/lib/tdr/tdr.c b/source4/lib/tdr/tdr.c
index 144cfa3e35..8037c6de0a 100644
--- a/source4/lib/tdr/tdr.c
+++ b/source4/lib/tdr/tdr.c
@@ -203,10 +203,10 @@ NTSTATUS tdr_print_charset(struct tdr_print *tdr, const char *name, const char *
NTSTATUS tdr_pull_ipv4address(struct tdr_pull *tdr, TALLOC_CTX *ctx,
const char **address)
{
- struct ipv4_addr in;
- TDR_CHECK(tdr_pull_uint32(tdr, ctx, &in.addr));
- in.addr = htonl(in.addr);
- *address = talloc_strdup(tdr, sys_inet_ntoa(in));
+ struct in_addr in;
+ TDR_CHECK(tdr_pull_uint32(tdr, ctx, &in.s_addr));
+ in.s_addr = htonl(in.s_addr);
+ *address = talloc_strdup(tdr, inet_ntoa(in));
NT_STATUS_HAVE_NO_MEMORY(*address);
return NT_STATUS_OK;
}
diff --git a/source4/lib/util/system.c b/source4/lib/util/system.c
index 1ebc6e7e0f..9bd1800233 100644
--- a/source4/lib/util/system.c
+++ b/source4/lib/util/system.c
@@ -79,19 +79,12 @@ _PUBLIC_ struct hostent *sys_gethostbyname(const char *name)
#endif /* REDUCE_ROOT_DNS_LOOKUPS */
}
-_PUBLIC_ const char *sys_inet_ntoa(struct ipv4_addr in)
-{
- struct in_addr in2;
- in2.s_addr = in.addr;
- return inet_ntoa(in2);
-}
-
-_PUBLIC_ struct ipv4_addr sys_inet_makeaddr(int net, int host)
+_PUBLIC_ struct in_addr sys_inet_makeaddr(int net, int host)
{
struct in_addr in;
- struct ipv4_addr in2;
+ struct in_addr in2;
in = inet_makeaddr(net, host);
- in2.addr = in.s_addr;
+ in2.s_addr = in.s_addr;
return in2;
}
diff --git a/source4/lib/util/util.c b/source4/lib/util/util.c
index 624315f99e..2a2813f9af 100644
--- a/source4/lib/util/util.c
+++ b/source4/lib/util/util.c
@@ -285,11 +285,11 @@ _PUBLIC_ uint32_t interpret_addr(const char *str)
/**
A convenient addition to interpret_addr().
**/
-_PUBLIC_ struct ipv4_addr interpret_addr2(const char *str)
+_PUBLIC_ struct in_addr interpret_addr2(const char *str)
{
- struct ipv4_addr ret;
+ struct in_addr ret;
uint32_t a = interpret_addr(str);
- ret.addr = a;
+ ret.s_addr = a;
return ret;
}
@@ -297,22 +297,22 @@ _PUBLIC_ struct ipv4_addr interpret_addr2(const char *str)
Check if an IP is the 0.0.0.0.
**/
-_PUBLIC_ bool is_zero_ip(struct ipv4_addr ip)
+_PUBLIC_ bool is_zero_ip(struct in_addr ip)
{
- return ip.addr == 0;
+ return ip.s_addr == 0;
}
/**
Are two IPs on the same subnet?
**/
-_PUBLIC_ bool same_net(struct ipv4_addr ip1,struct ipv4_addr ip2,struct ipv4_addr mask)
+_PUBLIC_ bool same_net(struct in_addr ip1, struct in_addr ip2, struct in_addr mask)
{
uint32_t net1,net2,nmask;
- nmask = ntohl(mask.addr);
- net1 = ntohl(ip1.addr);
- net2 = ntohl(ip2.addr);
+ nmask = ntohl(mask.s_addr);
+ net1 = ntohl(ip1.s_addr);
+ net2 = ntohl(ip2.s_addr);
return((net1 & nmask) == (net2 & nmask));
}
diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h
index 1960aa6196..71880c1c1a 100644
--- a/source4/lib/util/util.h
+++ b/source4/lib/util/util.h
@@ -254,13 +254,7 @@ void CatchChildLeaveStatus(void);
/* The following definitions come from lib/util/system.c */
-/*
- we use struct ipv4_addr to avoid having to include all the
- system networking headers everywhere
-*/
-struct ipv4_addr {
- uint32_t addr;
-};
+struct in_addr;
/**************************************************************************
A wrapper for gethostbyname() that tries avoids looking up hostnames
@@ -268,8 +262,8 @@ in the root domain, which can cause dial-on-demand links to come up for no
apparent reason.
****************************************************************************/
_PUBLIC_ struct hostent *sys_gethostbyname(const char *name);
-_PUBLIC_ const char *sys_inet_ntoa(struct ipv4_addr in);
-_PUBLIC_ struct ipv4_addr sys_inet_makeaddr(int net, int host);
+_PUBLIC_ const char *sys_inet_ntoa(struct in_addr in);
+_PUBLIC_ struct in_addr sys_inet_makeaddr(int net, int host);
/* The following definitions come from lib/util/genrand.c */
@@ -676,17 +670,17 @@ _PUBLIC_ uint32_t interpret_addr(const char *str);
/**
A convenient addition to interpret_addr().
**/
-_PUBLIC_ struct ipv4_addr interpret_addr2(const char *str);
+_PUBLIC_ struct in_addr interpret_addr2(const char *str);
/**
Check if an IP is the 0.0.0.0.
**/
-_PUBLIC_ bool is_zero_ip(struct ipv4_addr ip);
+_PUBLIC_ bool is_zero_ip(struct in_addr ip);
/**
Are two IPs on the same subnet?
**/
-_PUBLIC_ bool same_net(struct ipv4_addr ip1,struct ipv4_addr ip2,struct ipv4_addr mask);
+_PUBLIC_ bool same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
/**
Check if a process exists. Does this work on all unixes?