1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

r3443: the next stage in the include files re-organisation.

I have created the include/system/ directory, which will contain the
wrappers for the system includes for logical subsystems. So far I have
created include/system/kerberos.h and include/system/network.h, which
contain all the system includes for kerberos code and networking code.
These are the included in subsystems that need kerberos or networking
respectively.

Note that this method avoids the mess of #ifdef HAVE_XXX_H in every C
file, instead each C module includes the include/system/XXX.h file for
the logical system support it needs, and the details are kept isolated
in include/system/

This patch also creates a "struct ipv4_addr" which replaces "struct
in_addr" in our code. That avoids every C file needing to import all
the system networking headers.
(This used to be commit 2e25c71853)
This commit is contained in:
Andrew Tridgell
2004-11-01 22:48:25 +00:00
committed by Gerald (Jerry) Carter
parent 9f14afa12c
commit 284349482f
46 changed files with 420 additions and 291 deletions

View File

@ -35,7 +35,7 @@ BOOL global_machine_password_needs_changing = False;
the 'ADS server' smb.conf parameter, which is what we really want anyway the 'ADS server' smb.conf parameter, which is what we really want anyway
*/ */
static NTSTATUS ads_resolve_dc(fstring remote_machine, static NTSTATUS ads_resolve_dc(fstring remote_machine,
struct in_addr *dest_ip) struct ipv4_addr *dest_ip)
{ {
ADS_STRUCT *ads; ADS_STRUCT *ads;
ads = ads_init_simple(); ads = ads_init_simple();
@ -76,10 +76,10 @@ static NTSTATUS ads_resolve_dc(fstring remote_machine,
*/ */
static NTSTATUS rpc_resolve_dc(const char *server, static NTSTATUS rpc_resolve_dc(const char *server,
fstring remote_machine, fstring remote_machine,
struct in_addr *dest_ip) struct ipv4_addr *dest_ip)
{ {
if (is_ipaddress(server)) { 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 /* 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 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, const uint8_t *trust_passwd,
BOOL *retry) BOOL *retry)
{ {
struct in_addr dest_ip; struct ipv4_addr dest_ip;
fstring remote_machine; fstring remote_machine;
NTSTATUS result; NTSTATUS result;
uint32_t neg_flags = 0x000001ff; 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, static NTSTATUS attempt_connect_to_dc(struct smbcli_state **cli,
const char *domain, const char *domain,
struct in_addr *ip, struct ipv4_addr *ip,
const char *setup_creds_as, const char *setup_creds_as,
uint16_t sec_chan, uint16_t sec_chan,
const uint8_t *trust_passwd) const uint8_t *trust_passwd)
@ -267,7 +267,7 @@ static NTSTATUS find_connect_dc(struct smbcli_state **cli,
uint8_t *trust_passwd, uint8_t *trust_passwd,
time_t last_change_time) time_t last_change_time)
{ {
struct in_addr dc_ip; struct ipv4_addr dc_ip;
fstring srv_name; fstring srv_name;
if ( !rpc_find_dc(lp_workgroup(), srv_name, &dc_ip) ) { if ( !rpc_find_dc(lp_workgroup(), srv_name, &dc_ip) ) {

View File

@ -32,7 +32,7 @@ static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
{ {
struct smbcli_state *cli = NULL; struct smbcli_state *cli = NULL;
fstring desthost; fstring desthost;
struct in_addr dest_ip; struct ipv4_addr dest_ip;
const char *p; const char *p;
char *pserver; char *pserver;
BOOL connected_ok = False; BOOL connected_ok = False;

View File

@ -1065,7 +1065,8 @@ AC_TRY_RUN([
#define HAVE_IFACE_AIX 1 #define HAVE_IFACE_AIX 1
#define AUTOCONF_TEST 1 #define AUTOCONF_TEST 1
#include "confdefs.h" #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)]) 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 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) 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 HAVE_IFACE_IFCONF 1
#define AUTOCONF_TEST 1 #define AUTOCONF_TEST 1
#include "confdefs.h" #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)]) 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 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) 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 HAVE_IFACE_IFREQ 1
#define AUTOCONF_TEST 1 #define AUTOCONF_TEST 1
#include "confdefs.h" #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)]) 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 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])

View File

@ -197,7 +197,7 @@ char * parse_server(char * unc_name)
char * share; char * share;
char * ipaddress_string = NULL; char * ipaddress_string = NULL;
struct hostent * host_entry; struct hostent * host_entry;
struct in_addr server_ipaddr; struct ipv4_addr server_ipaddr;
int rc,j; int rc,j;
char temp[64]; char temp[64];

View File

@ -35,7 +35,7 @@ static pstring mpoint;
static pstring service; static pstring service;
static pstring options; static pstring options;
static struct in_addr dest_ip; static struct ipv4_addr dest_ip;
static BOOL have_ip; static BOOL have_ip;
static int smb_port = 0; static int smb_port = 0;
static BOOL got_user; static BOOL got_user;
@ -118,7 +118,7 @@ static struct smbcli_state *do_connection(char *the_service)
struct smbcli_state *c; struct smbcli_state *c;
struct nmb_name called, calling; struct nmb_name called, calling;
char *server_n; char *server_n;
struct in_addr ip; struct ipv4_addr ip;
pstring server; pstring server;
char *share; char *share;

View File

@ -22,7 +22,7 @@
typedef struct { typedef struct {
void *ld; /* the active ldap structure */ 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 */ time_t last_attempt; /* last attempt to reconnect */
int ldap_port; int ldap_port;

View File

@ -83,6 +83,7 @@
#endif /* RELIANTUNIX */ #endif /* RELIANTUNIX */
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#ifdef TIME_WITH_SYS_TIME #ifdef TIME_WITH_SYS_TIME
#include <sys/time.h> #include <sys/time.h>
@ -114,14 +115,6 @@
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_UNIXSOCKET
#include <sys/un.h>
#endif
#ifdef HAVE_SYS_SYSCALL_H #ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h> #include <sys/syscall.h>
#elif HAVE_SYSCALL_H #elif HAVE_SYSCALL_H
@ -213,10 +206,6 @@
#include <varargs.h> #include <varargs.h>
#endif #endif
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#ifdef HAVE_SYSLOG_H #ifdef HAVE_SYSLOG_H
#include <syslog.h> #include <syslog.h>
#else #else
@ -227,27 +216,6 @@
#include <sys/file.h> #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) #if defined(HAVE_TERMIOS_H)
/* POSIX terminal handling. */ /* POSIX terminal handling. */
#include <termios.h> #include <termios.h>
@ -280,11 +248,6 @@
#include <sys/mman.h> #include <sys/mman.h>
#endif #endif
#ifdef HAVE_NET_IF_H
#include <net/if.h>
#endif
#ifdef HAVE_SYS_MOUNT_H #ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h> #include <sys/mount.h>
#endif #endif
@ -374,28 +337,6 @@
#endif #endif
#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 */ /* we support ADS if we want it and have krb5 and ldap libs */
#if defined(WITH_ADS) && defined(HAVE_KRB5) && defined(HAVE_LDAP) #if defined(WITH_ADS) && defined(HAVE_KRB5) && defined(HAVE_LDAP)
#define HAVE_ADS #define HAVE_ADS
@ -466,6 +407,14 @@ typedef int socklen_t;
#define uint64 uint64_t #define uint64 uint64_t
#endif #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 #ifndef UINT8_MAX
#define UINT8_MAX 255 #define UINT8_MAX 255
#endif #endif
@ -518,7 +467,6 @@ extern int errno;
#include "talloc.h" #include "talloc.h"
#include "db_wrap.h" #include "db_wrap.h"
#include "nt_status.h" #include "nt_status.h"
#include "interfaces.h"
#include "trans2.h" #include "trans2.h"
#include "ioctl.h" #include "ioctl.h"
#include "nterr.h" #include "nterr.h"
@ -557,7 +505,6 @@ extern int errno;
#include "libcli/auth/ntlmssp.h" #include "libcli/auth/ntlmssp.h"
#include "libcli/auth/credentials.h" #include "libcli/auth/credentials.h"
#include "libcli/auth/kerberos.h"
#include "libcli/auth/gensec.h" #include "libcli/auth/gensec.h"
#include "libcli/auth/spnego.h" #include "libcli/auth/spnego.h"
#include "auth/auth.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); int setenv(const char *name, const char *value, int overwrite);
#endif #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 #ifndef HAVE_VASPRINTF_DECL
int vasprintf(char **ptr, const char *format, va_list ap); int vasprintf(char **ptr, const char *format, va_list ap);
#endif #endif

View File

@ -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;
};

View File

@ -206,7 +206,7 @@ struct nmb_data
{ {
uint16_t nb_flags; /* Netbios flags. */ uint16_t nb_flags; /* Netbios flags. */
int num_ips; /* Number of ip entries. */ 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. */ 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. */ time_t refresh_time; /* The time the record should be refreshed. */
uint64_t id; /* unique id */ 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 ! */ int wins_flags; /* similar to the netbios flags but different ! */
}; };
@ -238,7 +238,7 @@ struct browse_cache_record
#endif #endif
pstring lmb_name; pstring lmb_name;
pstring work_group; pstring work_group;
struct in_addr ip; struct ipv4_addr ip;
time_t sync_time; time_t sync_time;
time_t death_time; /* The time the record must be removed. */ 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. */ /* Domain master browser info. Used for efficient syncs. */
struct nmb_name dmb_name; struct nmb_name dmb_name;
struct in_addr dmb_addr; struct ipv4_addr dmb_addr;
}; };
/* typedefs needed to define copy & free functions for userdata. */ /* 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 *, struct nmb_name *,
uint16_t, uint16_t,
int, int,
struct in_addr); struct ipv4_addr);
typedef void (*register_name_fail_function)( struct subnet_record *, typedef void (*register_name_fail_function)( struct subnet_record *,
struct response_record *, struct response_record *,
struct nmb_name *); 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 *, typedef void (*release_name_success_function)( struct subnet_record *,
struct userdata_struct *, struct userdata_struct *,
struct nmb_name *, struct nmb_name *,
struct in_addr); struct ipv4_addr);
typedef void (*release_name_fail_function)( struct subnet_record *, typedef void (*release_name_fail_function)( struct subnet_record *,
struct response_record *, struct response_record *,
struct nmb_name *); struct nmb_name *);
@ -371,7 +371,7 @@ typedef void (*refresh_name_success_function)( struct subnet_record *,
struct nmb_name *, struct nmb_name *,
uint16_t, uint16_t,
int, int,
struct in_addr); struct ipv4_addr);
typedef void (*refresh_name_fail_function)( struct subnet_record *, typedef void (*refresh_name_fail_function)( struct subnet_record *,
struct response_record *, struct response_record *,
struct nmb_name *); 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 *, typedef void (*query_name_success_function)( struct subnet_record *,
struct userdata_struct *, struct userdata_struct *,
struct nmb_name *, struct nmb_name *,
struct in_addr, struct ipv4_addr,
struct res_rec *answers); struct res_rec *answers);
typedef void (*query_name_fail_function)( struct subnet_record *, 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 *, typedef void (*node_status_success_function)( struct subnet_record *,
struct userdata_struct *, struct userdata_struct *,
struct res_rec *, struct res_rec *,
struct in_addr); struct ipv4_addr);
typedef void (*node_status_fail_function)( struct subnet_record *, typedef void (*node_status_fail_function)( struct subnet_record *,
struct response_record *); struct response_record *);
@ -457,9 +457,9 @@ struct subnet_record
BOOL namelist_changed; BOOL namelist_changed;
BOOL work_changed; BOOL work_changed;
struct in_addr bcast_ip; struct ipv4_addr bcast_ip;
struct in_addr mask_ip; struct ipv4_addr mask_ip;
struct in_addr myip; struct ipv4_addr myip;
int nmb_sock; /* socket to listen for unicast 137. */ int nmb_sock; /* socket to listen for unicast 137. */
int dgram_sock; /* socket to listen for unicast 138. */ int dgram_sock; /* socket to listen for unicast 138. */
}; };
@ -535,7 +535,7 @@ struct dgram_packet {
BOOL more; BOOL more;
} flags; } flags;
int dgm_id; int dgm_id;
struct in_addr source_ip; struct ipv4_addr source_ip;
int source_port; int source_port;
int dgm_length; int dgm_length;
int packet_offset; int packet_offset;
@ -554,7 +554,7 @@ struct packet_struct
struct packet_struct *next; struct packet_struct *next;
struct packet_struct *prev; struct packet_struct *prev;
BOOL locked; BOOL locked;
struct in_addr ip; struct ipv4_addr ip;
int port; int port;
int fd; int fd;
time_t timestamp; time_t timestamp;
@ -642,8 +642,8 @@ typedef struct _WINS_RECORD {
int wins_flags; int wins_flags;
uint64_t id; uint64_t id;
int num_ips; int num_ips;
struct in_addr ip[25]; struct ipv4_addr ip[25];
struct in_addr wins_ip; struct ipv4_addr wins_ip;
} WINS_RECORD; } WINS_RECORD;
/* To be removed. */ /* To be removed. */

View File

@ -48,3 +48,4 @@ struct samr_CryptPasswordEx;
struct netr_SamInfo3; struct netr_SamInfo3;
struct netr_Authenticator; struct netr_Authenticator;
struct iface_struct;

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -34,11 +34,11 @@ static void ldapsrv_terminate_connection(struct ldapsrv_connection *ldap_conn, c
*/ */
static void add_socket(struct server_service *service, static void add_socket(struct server_service *service,
const struct model_ops *model_ops, const struct model_ops *model_ops,
struct in_addr *ifip) struct ipv4_addr *ifip)
{ {
struct server_socket *srv_sock; struct server_socket *srv_sock;
uint16_t port = 389; 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); 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. socket per interface and bind to only these.
*/ */
for(i = 0; i < num_interfaces; 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) { if (ifip == NULL) {
DEBUG(0,("ldapsrv_init: interface %d has 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); add_socket(service, model_ops, ifip);
} }
} else { } else {
struct in_addr ifip; struct ipv4_addr ifip;
/* Just bind to lp_socket_address() (usually 0.0.0.0) */ /* Just bind to lp_socket_address() (usually 0.0.0.0) */
ifip = interpret_addr2(lp_socket_address()); ifip = interpret_addr2(lp_socket_address());

View File

@ -1,4 +1,5 @@
dnl # LIB BASIC subsystem dnl # LIB BASIC subsystem
SMB_SUBSYSTEM_MK(LIBREPLACE,lib/basic.mk) SMB_SUBSYSTEM_MK(LIBREPLACE,lib/basic.mk)
SMB_SUBSYSTEM_MK(LIBNETIF,lib/basic.mk)
SMB_SUBSYSTEM_MK(LIBBASIC,lib/basic.mk) SMB_SUBSYSTEM_MK(LIBBASIC,lib/basic.mk)

View File

@ -9,6 +9,16 @@ ADD_OBJ_FILES = \
# End SUBSYSTEM LIBREPLACE # End SUBSYSTEM LIBREPLACE
############################## ##############################
##############################
# 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 # Start SUBSYSTEM LIBBASIC
[SUBSYSTEM::LIBBASIC] [SUBSYSTEM::LIBBASIC]
@ -17,8 +27,6 @@ ADD_OBJ_FILES = \
lib/debug.o \ lib/debug.o \
lib/fault.o \ lib/fault.o \
lib/getsmbpass.o \ lib/getsmbpass.o \
lib/interface.o \
lib/interfaces.o \
lib/pidfile.o \ lib/pidfile.o \
lib/signal.o \ lib/signal.o \
lib/system.o \ lib/system.o \
@ -57,6 +65,6 @@ ADD_OBJ_FILES = \
lib/server_mutex.o \ lib/server_mutex.o \
lib/idtree.o lib/idtree.o
REQUIRED_SUBSYSTEMS = \ REQUIRED_SUBSYSTEMS = \
LIBTDB CHARSET LIBREPLACE LIBTDB CHARSET LIBREPLACE LIBNETIF
# End SUBSYSTEM LIBBASIC # End SUBSYSTEM LIBBASIC
############################## ##############################

View File

@ -19,19 +19,21 @@
*/ */
#include "includes.h" #include "includes.h"
#include "system/network.h"
#include "lib/netif/netif.h"
static struct iface_struct *probed_ifaces; static struct iface_struct *probed_ifaces;
static int total_probed; static int total_probed;
static struct in_addr allones_ip; static struct ipv4_addr allones_ip;
struct in_addr loopback_ip; struct ipv4_addr loopback_ip;
/* used for network interfaces */ /* used for network interfaces */
struct interface { struct interface {
struct interface *next, *prev; struct interface *next, *prev;
struct in_addr ip; struct ipv4_addr ip;
struct in_addr bcast; struct ipv4_addr bcast;
struct in_addr nmask; struct ipv4_addr nmask;
}; };
static struct interface *local_interfaces; static struct interface *local_interfaces;
@ -40,17 +42,24 @@ static struct interface *local_interfaces;
#define MKBCADDR(_IP, _NM) ((_IP & _NM) | (_NM ^ ALLONES)) #define MKBCADDR(_IP, _NM) ((_IP & _NM) | (_NM ^ ALLONES))
#define MKNETADDR(_IP, _NM) (_IP & _NM) #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 Try and find an interface that matches an ip. If we cannot, return NULL
**************************************************************************/ **************************************************************************/
static struct interface *iface_find(struct in_addr ip, BOOL CheckMask) static struct interface *iface_find(struct in_addr ip, BOOL CheckMask)
{ {
struct interface *i; 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) for (i=local_interfaces;i;i=i->next)
if (CheckMask) { 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; } else if ((i->ip).s_addr == ip.s_addr) return i;
return NULL; return NULL;
@ -78,15 +87,15 @@ static void add_interface(struct in_addr ip, struct in_addr nmask)
ZERO_STRUCTPN(iface); ZERO_STRUCTPN(iface);
iface->ip = ip; iface->ip = tov4(ip);
iface->nmask = nmask; iface->nmask = tov4(nmask);
iface->bcast.s_addr = MKBCADDR(iface->ip.s_addr, iface->nmask.s_addr); iface->bcast.s_addr = MKBCADDR(iface->ip.s_addr, iface->nmask.s_addr);
DLIST_ADD(local_interfaces, iface); DLIST_ADD(local_interfaces, iface);
DEBUG(2,("added interface ip=%s ",inet_ntoa(iface->ip))); DEBUG(2,("added interface ip=%s ",sys_inet_ntoa(iface->ip)));
DEBUG(2,("bcast=%s ",inet_ntoa(iface->bcast))); DEBUG(2,("bcast=%s ",sys_inet_ntoa(iface->bcast)));
DEBUG(2,("nmask=%s\n",inet_ntoa(iface->nmask))); 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; char *p;
int i, added=0; int i, added=0;
zero_ip(&ip); ip.s_addr = 0;
zero_ip(&nmask); nmask.s_addr = 0;
/* first check if it is an interface name */ /* first check if it is an interface name */
for (i=0;i<total_probed;i++) { 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 */ /* maybe it is a DNS name */
p = strchr_m(token,'/'); p = strchr_m(token,'/');
if (!p) { if (!p) {
ip = interpret_addr2(token); ip.s_addr = interpret_addr2(token).s_addr;
for (i=0;i<total_probed;i++) { for (i=0;i<total_probed;i++) {
if (ip.s_addr == probed_ifaces[i].ip.s_addr && if (ip.s_addr == probed_ifaces[i].ip.s_addr &&
!ip_equal(allones_ip, probed_ifaces[i].netmask)) { !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 */ /* parse it into an IP address/netmasklength pair */
*p++ = 0; *p++ = 0;
ip = interpret_addr2(token); ip.s_addr = interpret_addr2(token).s_addr;
if (strlen(p) > 2) { if (strlen(p) > 2) {
nmask = interpret_addr2(p); nmask.s_addr = interpret_addr2(p).s_addr;
} else { } else {
nmask.s_addr = htonl(((ALLONES >> atoi(p)) ^ ALLONES)); 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) || if (ip.s_addr == MKBCADDR(ip.s_addr, nmask.s_addr) ||
ip.s_addr == MKNETADDR(ip.s_addr, nmask.s_addr)) { ip.s_addr == MKNETADDR(ip.s_addr, nmask.s_addr)) {
for (i=0;i<total_probed;i++) { 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); add_interface(probed_ifaces[i].ip, nmask);
return; return;
} }
@ -257,7 +266,7 @@ BOOL interfaces_changed(void)
/**************************************************************************** /****************************************************************************
check if an IP is one of mine check if an IP is one of mine
**************************************************************************/ **************************************************************************/
BOOL ismyip(struct in_addr ip) BOOL ismyip(struct ipv4_addr ip)
{ {
struct interface *i; struct interface *i;
for (i=local_interfaces;i;i=i->next) 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 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; struct interface *i;
for (i=local_interfaces;i;i=i->next) { for (i=local_interfaces;i;i=i->next) {
@ -295,7 +304,7 @@ int iface_count(void)
/**************************************************************************** /****************************************************************************
return IP of the Nth interface 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; struct interface *i;
@ -309,7 +318,7 @@ struct in_addr *iface_n_ip(int n)
/**************************************************************************** /****************************************************************************
return bcast of the Nth interface 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; 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 an appropriate interface they return the requested field of the
first known interface. */ 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(i ? &i->ip : &local_interfaces->ip);
} }
/* /*
return True if a IP is directly reachable on one of our interfaces 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;
} }

View File

@ -33,23 +33,18 @@
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <netdb.h>
#include <netinet/in.h> #include <sys/ioctl.h>
#include <arpa/inet.h> #include <sys/time.h>
#include <net/if.h>
#include <netdb.h> #include <netdb.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/time.h> #include <sys/time.h>
#include <net/if.h> #include <net/if.h>
#ifdef AUTOCONF_TEST #ifndef AUTOCONF_TEST
struct iface_struct { #include "lib/netif/netif.h"
char name[16];
struct in_addr ip;
struct in_addr netmask;
};
#else
#include "config.h" #include "config.h"
#include "interfaces.h"
#endif #endif
#ifdef HAVE_SYS_TIME_H #ifdef HAVE_SYS_TIME_H
@ -386,8 +381,6 @@ int get_interfaces(struct iface_struct *ifaces, int max_interfaces)
#ifdef AUTOCONF_TEST #ifdef AUTOCONF_TEST
/* this is the autoconf driver to test get_interfaces() */ /* this is the autoconf driver to test get_interfaces() */
#define MAX_INTERFACES 128
int main() int main()
{ {
struct iface_struct ifaces[MAX_INTERFACES]; struct iface_struct ifaces[MAX_INTERFACES];

34
source4/lib/netif/netif.h Normal file
View File

@ -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

View File

@ -326,7 +326,7 @@ duplicate a string
#ifndef WITH_PTHREADS #ifndef WITH_PTHREADS
/* REWRITE: not thread safe */ /* REWRITE: not thread safe */
#ifdef REPLACE_INET_NTOA #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; uint8_t *p = (uint8_t *)&ip.s_addr;
static char buf[18]; static char buf[18];

View File

@ -32,6 +32,7 @@
*/ */
#include "includes.h" #include "includes.h"
#include "system/network.h"
#define FAIL (-1) #define FAIL (-1)
#define ALLONES ((uint32_t)0xFFFFFFFF) #define ALLONES ((uint32_t)0xFFFFFFFF)

View File

@ -19,6 +19,7 @@
*/ */
#include "includes.h" #include "includes.h"
#include "system/network.h"
static NTSTATUS ipv4_tcp_init(struct socket_context *sock) 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) uint32_t flags)
{ {
struct sockaddr_in srv_addr; struct sockaddr_in srv_addr;
struct in_addr my_ip; struct ipv4_addr my_ip;
struct in_addr srv_ip; struct ipv4_addr srv_ip;
int ret; int ret;
my_ip = interpret_addr2(my_address); my_ip = interpret_addr2(my_address);
@ -53,7 +54,7 @@ static NTSTATUS ipv4_tcp_connect(struct socket_context *sock,
#ifdef HAVE_SOCK_SIN_LEN #ifdef HAVE_SOCK_SIN_LEN
my_addr.sin_len = sizeof(my_addr); my_addr.sin_len = sizeof(my_addr);
#endif #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_port = htons(my_port);
my_addr.sin_family = PF_INET; my_addr.sin_family = PF_INET;
@ -69,7 +70,7 @@ static NTSTATUS ipv4_tcp_connect(struct socket_context *sock,
#ifdef HAVE_SOCK_SIN_LEN #ifdef HAVE_SOCK_SIN_LEN
srv_addr.sin_len = sizeof(srv_addr); srv_addr.sin_len = sizeof(srv_addr);
#endif #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_port = htons(srv_port);
srv_addr.sin_family = PF_INET; 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) int queue_size, uint32_t flags)
{ {
struct sockaddr_in my_addr; struct sockaddr_in my_addr;
struct in_addr ip_addr; struct ipv4_addr ip_addr;
int ret; int ret;
ip_addr = interpret_addr2(my_address); ip_addr = interpret_addr2(my_address);
@ -104,7 +105,7 @@ static NTSTATUS ipv4_tcp_listen(struct socket_context *sock,
#ifdef HAVE_SOCK_SIN_LEN #ifdef HAVE_SOCK_SIN_LEN
my_addr.sin_len = sizeof(my_addr); my_addr.sin_len = sizeof(my_addr);
#endif #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_port = htons(port);
my_addr.sin_family = PF_INET; my_addr.sin_family = PF_INET;

View File

@ -20,6 +20,7 @@
*/ */
#include "includes.h" #include "includes.h"
#include "system/network.h"
static struct in6_addr interpret_addr6(const char *name) static struct in6_addr interpret_addr6(const char *name)
{ {

View File

@ -20,6 +20,7 @@
*/ */
#include "includes.h" #include "includes.h"
#include "system/network.h"
/* /*
The idea is that this file will eventually have wrappers around all The idea is that this file will eventually have wrappers around all
@ -533,3 +534,24 @@ int sys_dup2(int oldfd, int newfd)
#endif #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;
}

View File

@ -23,6 +23,7 @@
*/ */
#include "includes.h" #include "includes.h"
#include "system/network.h"
/**************************************************************************n /**************************************************************************n
Find a suitable temporary directory. The result should be copied immediately 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 it's in the form of an IP address then get the lib to interpret it */
if (is_ipaddress(str)) { if (is_ipaddress(str)) {
res = inet_addr(str); res = sys_inet_addr(str);
} else { } else {
/* otherwise assume it's a network name of some sort and use /* otherwise assume it's a network name of some sort and use
sys_gethostbyname */ sys_gethostbyname */
@ -446,9 +447,9 @@ uint32_t interpret_addr(const char *str)
/******************************************************************* /*******************************************************************
A convenient addition to interpret_addr(). 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); uint32_t a = interpret_addr(str);
ret.s_addr = a; ret.s_addr = a;
return ret; return ret;
@ -458,7 +459,7 @@ struct in_addr interpret_addr2(const char *str)
Check if an IP is the 0.0.0.0. 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; uint32_t a;
putip((char *)&a,(char *)&ip); 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. 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; return;
} }
@ -480,7 +481,7 @@ void zero_ip(struct in_addr *ip)
Are two IPs on the same subnet? 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; uint32_t net1,net2,nmask;

View File

@ -20,6 +20,7 @@
*/ */
#include "includes.h" #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, 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; ssize_t ret;
struct sockaddr_in sock; struct sockaddr_in sock;
@ -169,7 +170,7 @@ ssize_t read_udp_socket(int fd, char *buf, size_t len,
} }
if (from_addr) { if (from_addr) {
*from_addr = sock.sin_addr; from_addr->s_addr = sock.sin_addr.s_addr;
} }
if (from_port) { if (from_port) {
*from_port = ntohs(sock.sin_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. 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; struct sockaddr_in sock_out;
int res,ret; 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 it non-blocking */
set_blocking(res,False); 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 */ /* and connect it to the destination */
connect_again: connect_again:
@ -375,7 +376,7 @@ connect_again:
if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY || if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY ||
errno == EAGAIN)) { 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); close(res);
return -1; return -1;
} }
@ -389,7 +390,7 @@ connect_again:
if (ret < 0) { if (ret < 0) {
DEBUG(2,("error connecting to %s:%d (%s)\n", DEBUG(2,("error connecting to %s:%d (%s)\n",
inet_ntoa(*addr),port,strerror(errno))); sys_inet_ntoa(*addr),port,strerror(errno)));
close(res); close(res);
return -1; return -1;
} }
@ -408,7 +409,7 @@ int open_udp_socket(const char *host, int port)
int type = SOCK_DGRAM; int type = SOCK_DGRAM;
struct sockaddr_in sock_out; struct sockaddr_in sock_out;
int res; int res;
struct in_addr addr; struct ipv4_addr addr;
TALLOC_CTX *mem_ctx; TALLOC_CTX *mem_ctx;
mem_ctx = talloc_init("open_udp_socket"); 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 matchname - determine if host name matches IP address. Used to
confirm a hostname lookup to prevent spoof attacks 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; struct hostent *hp;
int i; int i;
@ -480,7 +481,7 @@ static BOOL matchname(char *remotehost, struct in_addr addr)
*/ */
DEBUG(0,("host name/address mismatch: %s != %s\n", DEBUG(0,("host name/address mismatch: %s != %s\n",
inet_ntoa(addr), hp->h_name)); sys_inet_ntoa(addr), hp->h_name));
return False; return False;
} }
@ -492,7 +493,7 @@ char *get_socket_name(TALLOC_CTX *mem_ctx, int fd, BOOL force_lookup)
{ {
char *name_buf; char *name_buf;
struct hostent *hp; struct hostent *hp;
struct in_addr addr; struct ipv4_addr addr;
char *p; char *p;
/* reverse lookups can be *very* expensive, and in many /* reverse lookups can be *very* expensive, and in many

View File

@ -228,7 +228,7 @@ BOOL str_list_substitute(char **list, const char *pattern, const char *insert)
* reallocated to new length * 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; 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 */ /* attempt to convert ip to a string and append colon separator to it */
if (*ipstr_list) { 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); SAFE_FREE(*ipstr_list);
} else { } else {
asprintf(&new_ipstr, "%s", inet_ntoa(*ip)); asprintf(&new_ipstr, "%s", sys_inet_ntoa(*ip));
} }
*ipstr_list = new_ipstr; *ipstr_list = new_ipstr;
return *ipstr_list; 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 * @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; 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 * @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; fstring token_str;
int count; 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); next_token(&ipstr_list, token_str, IPSTR_LIST_SEP, FSTRING_LEN);
count++) { count++) {
struct in_addr addr; struct ipv4_addr addr;
/* convert single token to ip address */ /* 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; break;
/* prepare place for another in_addr structure */ /* 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; if (!*ip_list) return -1;
(*ip_list)[count] = addr; (*ip_list)[count] = addr;

View File

@ -68,12 +68,12 @@
#define WINS_SRV_FMT "WINS_SRV_DEAD/%s,%s" /* wins_ip,src_ip */ #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; char *keystr;
if (asprintf(&keystr, WINS_SRV_FMT, inet_ntoa(wins_ip), if (asprintf(&keystr, WINS_SRV_FMT, sys_inet_ntoa(wins_ip),
inet_ntoa(src_ip)) == -1) { sys_inet_ntoa(src_ip)) == -1) {
DEBUG(0, ("wins_srv_is_dead: malloc error\n")); DEBUG(0, ("wins_srv_is_dead: malloc error\n"));
return NULL; 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 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); char *keystr = wins_srv_keystr(wins_ip, src_ip);
BOOL result; 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); result = gencache_get(keystr, NULL, NULL);
SAFE_FREE(keystr); 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")); result ? "dead" : "alive"));
return result; 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) 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); 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); SAFE_FREE(keystr);
DEBUG(4, ("wins_srv_alive: marking wins server %s alive\n", 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 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; char *keystr;
@ -133,7 +133,7 @@ void wins_srv_died(struct in_addr wins_ip, struct in_addr src_ip)
SAFE_FREE(keystr); SAFE_FREE(keystr);
DEBUG(4,("Marking wins server %s dead for %u seconds from source %s\n", 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 */ attached */
struct tagged_ip { struct tagged_ip {
fstring tag; 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, return the IP of the currently active wins server for the given tag,
or the zero IP otherwise 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; const char **list;
int i; 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 we are a wins server then we always just talk to ourselves */
if (lp_wins_support()) { if (lp_wins_support()) {
extern struct in_addr loopback_ip; extern struct ipv4_addr loopback_ip;
return loopback_ip; return loopback_ip;
} }
list = lp_wins_server_list(); list = lp_wins_server_list();
if (!list || !list[0]) { if (!list || !list[0]) {
struct in_addr ip; struct ipv4_addr ip;
zero_ip(&ip); zero_ip(&ip);
return 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)) { if (!wins_srv_is_dead(t_ip.ip, src_ip)) {
char *src_name; 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", DEBUG(6,("Current wins server for tag '%s' with source %s is %s\n",
tag, tag,
src_name, src_name,
inet_ntoa(t_ip.ip))); sys_inet_ntoa(t_ip.ip)));
goto exit; goto exit;
} }
} }

View File

@ -20,6 +20,8 @@
*/ */
#include "includes.h" #include "includes.h"
#include "system/network.h"
#include "system/kerberos.h"
#ifdef HAVE_KRB5 #ifdef HAVE_KRB5

View File

@ -24,6 +24,8 @@
*/ */
#include "includes.h" #include "includes.h"
#include "system/kerberos.h"
#include "libcli/auth/kerberos.h"
#include "librpc/gen_ndr/ndr_krb5pac.h" #include "librpc/gen_ndr/ndr_krb5pac.h"
#undef DBGC_CLASS #undef DBGC_CLASS

View File

@ -21,6 +21,7 @@
*/ */
#include "includes.h" #include "includes.h"
#include "system/kerberos.h"
#ifdef HAVE_KRB5 #ifdef HAVE_KRB5

View File

@ -23,6 +23,8 @@
*/ */
#include "includes.h" #include "includes.h"
#include "system/kerberos.h"
#include "libcli/auth/kerberos.h"
#ifdef HAVE_KRB5 #ifdef HAVE_KRB5

View File

@ -154,7 +154,7 @@ NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx,
struct smbcli_state **ret_cli, struct smbcli_state **ret_cli,
const char *myname, const char *myname,
const char *host, const char *host,
struct in_addr *ip, struct ipv4_addr *ip,
const char *sharename, const char *sharename,
const char *devtype, const char *devtype,
const char *username, const char *username,

View File

@ -24,6 +24,7 @@
*/ */
#include "includes.h" #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) BOOL ldap_connect(struct ldap_connection *conn, const char *url)
{ {
struct hostent *hp; struct hostent *hp;
struct in_addr ip; struct ipv4_addr ip;
if (!ldap_parse_basic_url(conn->mem_ctx, url, &conn->host, if (!ldap_parse_basic_url(conn->mem_ctx, url, &conn->host,
&conn->port, &conn->ldaps)) &conn->port, &conn->ldaps))

View File

@ -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, 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; time_t expiry;
char *key, *value_string; 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)); num_names, num_names == 1 ? "": "es", name, name_type));
for (i = 0; i < num_names; i++) 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) ? "" : ", ")); i == (num_names - 1) ? "" : ", "));
DEBUGADD(5, ("\n")); 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 * 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) int *num_names)
{ {
char *key, *value; char *key, *value;

View File

@ -20,6 +20,7 @@
*/ */
#include "includes.h" #include "includes.h"
#include "system/network.h"
/* A netbios node status array element. */ /* A netbios node status array element. */
struct node_status { 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 structures holding the returned names or NULL if the query failed
**************************************************************************/ **************************************************************************/
struct node_status *node_status_query(int fd,struct nmb_name *name, 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; BOOL found=False;
int retries = 2; int retries = 2;
@ -170,7 +171,7 @@ a servers name given its IP
return the matched name in *name 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 node_status *status = NULL;
struct nmb_name nname; 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, 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); sock = open_socket_in(SOCK_DGRAM, 0, 3, interpret_addr(lp_socket_address()), True);
if (sock == -1) 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 ")); DEBUG(10, ("name_status_find: name %sfound", result ? "" : "not "));
if (result) 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")); 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 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 max_bits1=0, max_bits2=0;
int num_interfaces = iface_count(); int num_interfaces = iface_count();
int i; int i;
for (i=0;i<num_interfaces;i++) { for (i=0;i<num_interfaces;i++) {
struct in_addr ip; struct ipv4_addr ip;
int bits1, bits2; int bits1, bits2;
ip = *iface_n_bcast(i); ip = *iface_n_bcast(i);
bits1 = matching_quad_bits((uint8_t *)&ip1->s_addr, (uint8_t *)&ip.s_addr); 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 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 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) { if (count <= 1) {
return; 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. *count will be set to the number of addresses returned.
*timed_out is set if we failed by timing out *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, 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 *timed_out)
{ {
BOOL found=False; 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 p;
struct packet_struct *p2; struct packet_struct *p2;
struct nmb_packet *nmb = &p.packet.nmb; struct nmb_packet *nmb = &p.packet.nmb;
struct in_addr *ip_list = NULL; struct ipv4_addr *ip_list = NULL;
if (lp_disable_netbios()) { if (lp_disable_netbios()) {
DEBUG(5,("name_query(%s#%02x): netbios is disabled\n", name, name_type)); 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) { while (1) {
struct timeval tval2; struct timeval tval2;
struct in_addr *tmp_ip_list; struct ipv4_addr *tmp_ip_list;
GetTimeOfDay(&tval2); GetTimeOfDay(&tval2);
if (TvalDiff(&tval,&tval2) > retry_time) { if (TvalDiff(&tval,&tval2) > retry_time) {
@ -398,7 +399,7 @@ struct in_addr *name_query(int fd,const char *name,int name_type,
continue; 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 ) ); * ( (*count) + nmb2->answers->rdlength/6 ) );
if (!tmp_ip_list) { 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; ip_list = tmp_ip_list;
if (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++) { for (i=0;i<nmb2->answers->rdlength/6;i++) {
putip((char *)&ip_list[(*count)],&nmb2->answers->rdata[2+i*6]); 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)++; (*count)++;
} }
DEBUGADD(2,(")\n")); DEBUGADD(2,(")\n"));
@ -474,7 +475,7 @@ XFILE *startlmhosts(char *fname)
*********************************************************/ *********************************************************/
BOOL getlmhostsent( TALLOC_CTX *mem_ctx, 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; pstring line;
@ -571,7 +572,7 @@ void endlmhosts(XFILE *fp)
*********************************************************/ *********************************************************/
BOOL name_resolve_bcast(const char *name, int name_type, 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 sock, i;
int num_interfaces = iface_count(); int num_interfaces = iface_count();
@ -601,7 +602,7 @@ BOOL name_resolve_bcast(const char *name, int name_type,
* the first successful match. * the first successful match.
*/ */
for( i = num_interfaces-1; i >= 0; i--) { for( i = num_interfaces-1; i >= 0; i--) {
struct in_addr sendto_ip; struct ipv4_addr sendto_ip;
int flags; int flags;
/* Done this way to fix compiler error on IRIX 5.x */ /* Done this way to fix compiler error on IRIX 5.x */
sendto_ip = *iface_n_bcast(i); sendto_ip = *iface_n_bcast(i);
@ -621,11 +622,11 @@ BOOL name_resolve_bcast(const char *name, int name_type,
Resolve via "wins" method. Resolve via "wins" method.
*********************************************************/ *********************************************************/
BOOL resolve_wins(TALLOC_CTX *mem_ctx, const char *name, int name_type, 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; int sock, t, i;
char **wins_tags; char **wins_tags;
struct in_addr src_ip; struct ipv4_addr src_ip;
if (lp_disable_netbios()) { if (lp_disable_netbios()) {
DEBUG(5,("resolve_wins(%s#%02x): netbios is disabled\n", name, name_type)); 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++) { for (t=0; wins_tags && wins_tags[t]; t++) {
int srv_count = wins_srv_count_tag(wins_tags[t]); int srv_count = wins_srv_count_tag(wins_tags[t]);
for (i=0; i<srv_count; i++) { for (i=0; i<srv_count; i++) {
struct in_addr wins_ip; struct ipv4_addr wins_ip;
int flags; int flags;
BOOL timed_out; BOOL timed_out;
@ -674,7 +675,7 @@ BOOL resolve_wins(TALLOC_CTX *mem_ctx, const char *name, int name_type,
continue; 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); sock = open_socket_in(SOCK_DGRAM, 0, 3, src_ip.s_addr, True);
if (sock == -1) { if (sock == -1) {
@ -714,7 +715,7 @@ success:
*********************************************************/ *********************************************************/
static BOOL resolve_hosts(const char *name, 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. * "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)); DEBUG(3,("resolve_hosts: Attempting host lookup for name %s<0x20>\n", name));
if (((hp = sys_gethostbyname(name)) != NULL) && (hp->h_addr != NULL)) { 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); 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) { if(*return_iplist == NULL) {
DEBUG(3,("resolve_hosts: malloc fail !\n")); DEBUG(3,("resolve_hosts: malloc fail !\n"));
return False; 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, 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; char *name_resolve_list;
fstring tok; 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 allzeros = (strcmp(name,"0.0.0.0") == 0);
BOOL is_address = is_ipaddress(name); BOOL is_address = is_ipaddress(name);
BOOL result = False; BOOL result = False;
struct in_addr *nodupes_iplist; struct ipv4_addr *nodupes_iplist;
int i; int i;
*return_iplist = NULL; *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)); DEBUG(10, ("internal_resolve_name: looking up %s#%x\n", name, name_type));
if (allzeros || allones || is_address) { 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) { if(*return_iplist == NULL) {
DEBUG(3,("internal_resolve_name: malloc fail !\n")); DEBUG(3,("internal_resolve_name: malloc fail !\n"));
return False; 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 controllers including the PDC in iplist[1..n]. Iterating over
the iplist when the PDC is down will cause two sets of timeouts. */ the iplist when the PDC is down will cause two sets of timeouts. */
if (*return_count && (nodupes_iplist = (struct in_addr *) if (*return_count && (nodupes_iplist = (struct ipv4_addr *)
malloc(sizeof(struct in_addr) * (*return_count)))) { malloc(sizeof(struct ipv4_addr) * (*return_count)))) {
int nodupes_count = 0; int nodupes_count = 0;
/* Iterate over return_iplist looking for duplicates */ /* 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 */ /* Save in name cache */
for (i = 0; i < *return_count && DEBUGLEVEL == 100; i++) for (i = 0; i < *return_count && DEBUGLEVEL == 100; i++)
DEBUG(100, ("Storing name %s of type %d (ip: %s)\n", name, 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); 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)); *return_count));
for (i = 0; i < *return_count; i++) 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")); 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 or host name or NetBIOS name. This uses the name switch in the
smb.conf to determine the order of name resolution. 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; int count = 0;
if (is_ipaddress(name)) { if (is_ipaddress(name)) {
@ -916,7 +917,7 @@ BOOL resolve_name(TALLOC_CTX *mem_ctx, const char *name, struct in_addr *return_
int i; int i;
/* only return valid addresses for TCP connections */ /* only return valid addresses for TCP connections */
for (i=0; i<count; i++) { 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 && if (ip_str &&
strcmp(ip_str, "255.255.255.255") != 0 && strcmp(ip_str, "255.255.255.255") != 0 &&
strcmp(ip_str, "0.0.0.0") != 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. 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; int count = 0;
if (lp_disable_netbios()) { 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, 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) #if !defined(I_HATE_WINDOWS_REPLY_CODE)
fstring dc_name; 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", 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), 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) { if(SVAL(buf2,0) != QUERYFORPDC_R) {
DEBUG(0,("lookup_pdc_name: datagram type (%u) != QUERYFORPDC_R(%u)\n", 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. 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 count;
int i = 0; int i = 0;
@ -1217,7 +1218,7 @@ BOOL get_pdc_ip(TALLOC_CTX *mem_ctx, const char *domain, struct in_addr *ip)
a domain. 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; *ordered = False;
@ -1230,8 +1231,8 @@ BOOL get_dc_list(TALLOC_CTX *mem_ctx, const char *domain, struct in_addr **ip_li
fstring name; fstring name;
int num_addresses = 0; int num_addresses = 0;
int local_count, i, j; int local_count, i, j;
struct in_addr *return_iplist = NULL; struct ipv4_addr *return_iplist = NULL;
struct in_addr *auto_ip_list = NULL; struct ipv4_addr *auto_ip_list = NULL;
BOOL done_auto_lookup = False; BOOL done_auto_lookup = False;
int auto_count = 0; 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 ) if ( (num_addresses == 0) && !done_auto_lookup )
return internal_resolve_name(mem_ctx, domain, 0x1C, ip_list, count); 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) { if (return_iplist == NULL) {
DEBUG(3,("get_dc_list: malloc fail !\n")); 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 */ /* fill in the return list now with real IP's */
while ( (local_count<num_addresses) && next_token(&p,name,LIST_SEP,sizeof(name)) ) { 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 */ /* copy any addersses from the auto lookup */

View File

@ -28,9 +28,9 @@
/* /*
find the DC for a domain using methods appropriate for a RPC domain 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; int count, i;
BOOL list_ordered; BOOL list_ordered;
BOOL use_pdc_only; 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 */ /* Pick a nice close server, but only if the list was not ordered */
if (!list_ordered && (count > 1) ) { 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++) { for (i = 0; i < count; i++) {

View File

@ -20,6 +20,7 @@
*/ */
#include "includes.h" #include "includes.h"
#include "system/network.h"
static const struct opcode_names { static const struct opcode_names {
const char *nmb_opcode_name; const char *nmb_opcode_name;
@ -102,7 +103,7 @@ void debug_nmb_packet(struct packet_struct *p)
if (DEBUGLVL(4)) { if (DEBUGLVL(4)) {
DEBUG(4, ("nmb packet from %s(%d) header: id=%d opcode=%s(%d) response=%s\n", 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, nmb->header.name_trn_id,
lookup_opcode_name(nmb->header.opcode), lookup_opcode_name(nmb->header.opcode),
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; struct packet_struct *packet;
char buf[MAX_DGRAM_SIZE]; char buf[MAX_DGRAM_SIZE];
int length; int length;
struct in_addr addr; struct ipv4_addr addr;
int port; int port;
length = read_udp_socket(fd, buf, sizeof(buf), &addr, &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; packet->port = port;
DEBUG(5,("Received a packet of len %d from (%s) port %d\n", 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; 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 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; BOOL ret = False;
int i; 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; sock_out.sin_family = AF_INET;
DEBUG( 5, ( "Sending a packet of len %d to (%s) on port %d\n", 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. * 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) if (!ret)
DEBUG(0,("Packet send failed to %s(%d) ERRNO=%s\n", 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); 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 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 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; if (n <= 1) return;

View File

@ -49,7 +49,7 @@ struct smbcli_socket *smbcli_sock_init(TALLOC_CTX *mem_ctx)
connect a smbcli_socket context to an IP/port pair connect a smbcli_socket context to an IP/port pair
if port is 0 then choose 445 then 139 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; 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); 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)) { if (!NT_STATUS_IS_OK(status)) {
talloc_free(sock->sock); talloc_free(sock->sock);
sock->sock = NULL; 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) BOOL smbcli_sock_connect_byname(struct smbcli_socket *sock, const char *host, int port)
{ {
int name_type = 0x20; int name_type = 0x20;
struct in_addr ip; struct ipv4_addr ip;
char *name, *p; char *name, *p;
BOOL ret; BOOL ret;

View File

@ -60,7 +60,7 @@ struct smbcli_negotiate {
/* this is the context for a SMB socket associated with the socket itself */ /* this is the context for a SMB socket associated with the socket itself */
struct smbcli_socket { struct smbcli_socket {
struct in_addr dest_ip; struct ipv4_addr dest_ip;
/* dest hostname (which may or may not be a DNS name) */ /* dest hostname (which may or may not be a DNS name) */
char *hostname; char *hostname;

View File

@ -24,7 +24,7 @@
static NTSTATUS libnet_find_pdc_generic(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_find_pdc *r) static NTSTATUS libnet_find_pdc_generic(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_find_pdc *r)
{ {
BOOL ret; BOOL ret;
struct in_addr ip; struct ipv4_addr ip;
if (is_ipaddress(r->generic.in.domain_name)) { if (is_ipaddress(r->generic.in.domain_name)) {
r->generic.out.pdc_name = 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; return NT_STATUS_OK;
} }

View File

@ -22,6 +22,7 @@
*/ */
#include "includes.h" #include "includes.h"
#include "system/network.h"
#include "librpc/gen_ndr/ndr_epmapper.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); 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: case EPM_PROTOCOL_NCACN:

View File

@ -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 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, static void add_socket_rpc_tcp_iface(struct server_service *service,
const struct model_ops *model_ops, const struct model_ops *model_ops,
struct dcesrv_context *dce_ctx, struct dcesrv_context *dce_ctx,
struct dcesrv_endpoint *e, struct dcesrv_endpoint *e,
struct in_addr *ifip) struct ipv4_addr *ifip)
{ {
struct server_socket *sock; struct server_socket *sock;
struct dcesrv_socket_context *dcesrv_sock; struct dcesrv_socket_context *dcesrv_sock;
uint16_t port = 0; 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) if (e->ep_description.endpoint)
port = atoi(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 num_interfaces = iface_count();
int i; int i;
for(i = 0; i < num_interfaces; 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) { if (ifip == NULL) {
continue; continue;
} }
add_socket_rpc_tcp_iface(service, model_ops, dce_ctx, e, ifip); add_socket_rpc_tcp_iface(service, model_ops, dce_ctx, e, ifip);
} }
} else { } else {
struct in_addr ifip; struct ipv4_addr ifip;
ifip = interpret_addr2(lp_socket_address()); ifip = interpret_addr2(lp_socket_address());
add_socket_rpc_tcp_iface(service, model_ops, dce_ctx, e, &ifip); add_socket_rpc_tcp_iface(service, model_ops, dce_ctx, e, &ifip);
} }

View File

@ -728,11 +728,11 @@ static void smbsrv_exit(struct server_service *service, const char *reason)
static void add_socket(struct server_service *service, static void add_socket(struct server_service *service,
const struct model_ops *model_ops, const struct model_ops *model_ops,
struct socket_context *socket_ctx, struct socket_context *socket_ctx,
struct in_addr *ifip) struct ipv4_addr *ifip)
{ {
const char **ports = lp_smb_ports(); const char **ports = lp_smb_ports();
int i; 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++) { for (i=0;ports[i];i++) {
uint16_t port = atoi(ports[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. socket per interface and bind to only these.
*/ */
for(i = 0; i < num_interfaces; 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) { if (ifip == NULL) {
DEBUG(0,("open_sockets_smbd: interface %d has NULL IP address !\n", i)); 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); add_socket(service, model_ops, NULL, ifip);
} }
} else { } else {
struct in_addr ifip; struct ipv4_addr ifip;
/* Just bind to lp_socket_address() (usually 0.0.0.0) */ /* Just bind to lp_socket_address() (usually 0.0.0.0) */
ifip = interpret_addr2(lp_socket_address()); ifip = interpret_addr2(lp_socket_address());
add_socket(service, model_ops, NULL, &ifip); add_socket(service, model_ops, NULL, &ifip);

View File

@ -20,6 +20,7 @@
*/ */
#include "includes.h" #include "includes.h"
#include "system/network.h"
#include "librpc/gen_ndr/ndr_epmapper.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: case EPM_PROTOCOL_IP:
printf(" IP:"); printf(" IP:");
{ {
struct in_addr in; struct ipv4_addr in;
in.s_addr = htonl(rhs->ip.address); in.s_addr = htonl(rhs->ip.address);
printf("%s", inet_ntoa(in)); printf("%s", sys_inet_ntoa(in));
} }
break; break;

View File

@ -26,7 +26,7 @@ extern BOOL AllowDebugChange;
static BOOL give_flags = False; static BOOL give_flags = False;
static BOOL use_bcast = True; static BOOL use_bcast = True;
static BOOL got_bcast = False; static BOOL got_bcast = False;
static struct in_addr bcast_addr; static struct ipv4_addr bcast_addr;
static BOOL recursion_desired = False; static BOOL recursion_desired = False;
static BOOL translate_addresses = False; static BOOL translate_addresses = False;
static int ServerFD= -1; static int ServerFD= -1;
@ -119,7 +119,7 @@ static char *query_flags(int flags)
/**************************************************************************** /****************************************************************************
do a node status query 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; struct nmb_name nname;
int count, i, j; int count, i, j;
@ -151,7 +151,7 @@ send out one query
static BOOL query_one(const char *lookup, uint_t lookup_type) static BOOL query_one(const char *lookup, uint_t lookup_type)
{ {
int j, count, flags = 0; int j, count, flags = 0;
struct in_addr *ip_list=NULL; struct ipv4_addr *ip_list=NULL;
if (got_bcast) { if (got_bcast) {
d_printf("querying %s on %s\n", lookup, inet_ntoa(bcast_addr)); 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, use_bcast?True:recursion_desired,
bcast_addr,&count, &flags, NULL); bcast_addr,&count, &flags, NULL);
} else { } else {
struct in_addr *bcast; struct ipv4_addr *bcast;
for (j=iface_count() - 1; for (j=iface_count() - 1;
!ip_list && j >= 0; !ip_list && j >= 0;
j--) { j--) {
@ -299,7 +299,7 @@ int main(int argc,char *argv[])
for (i=optind;i<argc;i++) for (i=optind;i<argc;i++)
{ {
char *p; char *p;
struct in_addr ip; struct ipv4_addr ip;
fstrcpy(lookup,argv[i]); fstrcpy(lookup,argv[i]);