BOOL global_machine_password_needs_changing = False;
-extern struct in_addr ipzero;
-
extern pstring global_myname;
/***********************************************************************
* Ignore addresses we have already tried.
*/
- if (ip_equal(ipzero, *ip))
+ if (is_zero_ip(*ip))
return False;
if (!lookup_pdc_name(global_myname, lp_workgroup(), ip, dc_name))
if((connected_ok = attempt_connect_to_dc(pcli, &ip_list[i], trust_passwd)))
break;
- ip_list[i] = ipzero; /* Tried and failed. */
+ zero_ip(&ip_list[i]); /* Tried and failed. */
}
/*
i = (sys_random() % count);
if (!(connected_ok = attempt_connect_to_dc(pcli, &ip_list[i], trust_passwd)))
- ip_list[i] = ipzero; /* Tried and failed. */
+ zero_ip(&ip_list[i]); /* Tried and failed. */
}
/*
static BOOL got_pass;
static int io_bufsize = 64512;
static BOOL use_kerberos;
-extern struct in_addr ipzero;
static int name_type = 0x20;
static int max_protocol = PROTOCOL_NT1;
struct nmb_name called, calling;
const char *server_n;
struct in_addr ip;
- extern struct in_addr ipzero;
fstring servicename;
char *sharename;
server_n = server;
- ip = ipzero;
+ zero_ip(&ip);
make_nmb_name(&calling, global_myname, 0x0);
make_nmb_name(&called , server, name_type);
again:
- ip = ipzero;
+ zero_ip(&ip);
if (have_ip) ip = dest_ip;
/* have to open a new connection */
struct in_addr ip;
struct nmb_name called, calling;
- ip = ipzero;
+ zero_ip(&ip);
make_nmb_name(&calling, global_myname, 0x0);
make_nmb_name(&called , desthost, name_type);
- ip = ipzero;
+ zero_ip(&ip);
if (have_ip) ip = dest_ip;
if (!(cli=cli_initialise(NULL)) || (cli_set_port(cli, port) != port) || !cli_connect(cli, desthost, &ip)) {
case 'I':
{
dest_ip = *interpret_addr2(optarg);
- if (zero_ip(dest_ip))
+ if (is_zero_ip(dest_ip))
exit(1);
have_ip = True;
}
#include <asm/types.h>
#include <linux/smb_fs.h>
-extern struct in_addr ipzero;
-
extern BOOL in_client;
extern pstring user_socket_options;
extern BOOL append_log;
struct nmb_name called, calling;
char *server_n;
struct in_addr ip;
- extern struct in_addr ipzero;
pstring server;
char *share;
make_nmb_name(&called , server, 0x20);
again:
- ip = ipzero;
+ zero_ip(&ip);
if (have_ip) ip = dest_ip;
/* have to open a new connection */
DEBUGLEVEL = val;
} else if(!strcmp(opts, "ip")) {
dest_ip = *interpret_addr2(opteq+1);
- if (zero_ip(dest_ip)) {
+ if (is_zero_ip(dest_ip)) {
fprintf(stderr,"Can't resolve address %s\n", opteq+1);
exit(1);
}
*/
extern BOOL in_client; /* Boolean for client library */
-extern struct in_addr ipzero; /* Any address */
/*
get_myname(myname);
- ip = ipzero;
+ zero_ip(&ip);
make_nmb_name(&calling, myname, 0x0);
make_nmb_name(&called, server, 0x20);
static struct iface_struct *probed_ifaces;
static int total_probed;
-struct in_addr ipzero;
struct in_addr allones_ip;
struct in_addr loopback_ip;
static struct interface *iface_find(struct in_addr ip, BOOL CheckMask)
{
struct interface *i;
- if (zero_ip(ip)) return local_interfaces;
+ if (is_zero_ip(ip)) return local_interfaces;
for (i=local_interfaces;i;i=i->next)
if (CheckMask) {
char *p;
int i, added=0;
- ip = ipzero;
- nmask = ipzero;
+ zero_ip(&ip);
+ zero_ip(&nmask);
/* first check if it is an interface name */
for (i=0;i<total_probed;i++) {
ptr = lp_interfaces();
- ipzero = *interpret_addr2("0.0.0.0");
allones_ip = *interpret_addr2("255.255.255.255");
loopback_ip = *interpret_addr2("127.0.0.1");
/*******************************************************************
check if an IP is the 0.0.0.0
******************************************************************/
-BOOL zero_ip(struct in_addr ip)
+BOOL is_zero_ip(struct in_addr ip)
{
uint32 a;
putip((char *)&a,(char *)&ip);
return(a == 0);
}
+/* Set an IP to 0.0.0.0 */
+
+void zero_ip(struct in_addr *ip)
+{
+ static BOOL init;
+ static struct in_addr ipzero;
+
+ if (!init) {
+ ipzero = *interpret_addr2("0.0.0.0");
+ init = True;
+ }
+
+ *ip = ipzero;
+}
#if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
/******************************************************************
if( now >= entry->mourning ) /* Found a live one. */
{
/* If we don't have the IP, look it up. */
- if( zero_ip( entry->ip_addr ) )
+ if( is_zero_ip( entry->ip_addr ) )
entry->ip_addr = *interpret_addr2( entry->server );
/* If we still don't have the IP then kill it, else return it. */
- if( zero_ip( entry->ip_addr ) )
+ if( is_zero_ip( entry->ip_addr ) )
entry->mourning = now + NECROMANCYCLE;
else
return( entry->ip_addr );
{
list_entry *entry;
- if( zero_ip( boothill_ip ) )
+ if( is_zero_ip( boothill_ip ) )
{
DEBUG( 4, ("wins_srv_died(): Invalid request to mark zero IP down.\n") );
return;
****************************************************************************/
BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip)
{
- extern struct in_addr ipzero;
extern pstring user_socket_options;
fstrcpy(cli->desthost, host);
- if (!ip || ip_equal(*ip, ipzero)) {
+ if (!ip || is_zero_ip(*ip)) {
if (!resolve_name( cli->desthost, &cli->dest_ip, 0x20)) {
return False;
}
fstring group;
pstring ipenv;
struct in_addr ip;
- extern struct in_addr ipzero;
- ip = ipzero;
+ zero_ip(&ip);
ZERO_STRUCT(c);
/* try to use an existing connection */
again:
slprintf(ipenv,sizeof(ipenv)-1,"HOST_%s", server_n);
- ip = ipzero;
+ zero_ip(&ip);
/* have to open a new connection */
if (!cli_initialise(&c) || !cli_connect(&c, server_n, &ip)) {
time_t StartupTime = 0;
-extern struct in_addr ipzero;
-
/**************************************************************************** **
catch a sigterm
**************************************************************************** */
extern pstring global_myname;
extern fstring global_myworkgroup;
extern char **my_netbios_names;
-extern struct in_addr ipzero;
extern struct in_addr allones_ip;
extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
/* BUG note. Samba 1.9.16p11 servers seem to return the broadcast
address or zero ip for this query. Pretend this is ok. */
- if(ismyip(ip) || ip_equal(allones_ip, ip) || ip_equal(ipzero, ip))
+ if(ismyip(ip) || ip_equal(allones_ip, ip) || is_zero_ip(ip))
{
if( DEBUGLVL( 3 ) )
{
#include "includes.h"
#include "smb.h"
-extern struct in_addr ipzero;
extern pstring global_myname;
extern fstring global_myworkgroup;
/* First check if we already have a dmb for this workgroup. */
- if(!ip_equal(work->dmb_addr, ipzero) && ip_equal(work->dmb_addr, answer_ip))
+ if(!is_zero_ip(work->dmb_addr) && ip_equal(work->dmb_addr, answer_ip))
{
/* Do the local master browser announcement to the domain
master browser name and IP. */
return;
}
else
- putip((char *)&work->dmb_addr, &ipzero);
+ zero_ip(&work->dmb_addr);
/* Now initiate the node status request. */
make_nmb_name(&nmbname,"*",0x0);
extern pstring global_myname;
extern fstring global_myworkgroup;
extern char **my_netbios_names;
-extern struct in_addr ipzero;
extern struct in_addr allones_ip;
extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
#include "includes.h"
-extern struct in_addr ipzero;
-
/****************************************************************************
Deal with a response packet when querying a name.
****************************************************************************/
BOOL success = False;
struct nmb_name *question_name =
&rrec->packet->packet.nmb.question.question_name;
- struct in_addr answer_ip = ipzero;
+ struct in_addr answer_ip;
+
+ zero_ip(&answer_ip);
/* Ensure we don't retry the query but leave the response record cleanup
to the timeout code. We may get more answer responses in which case
extern int ClientNMB;
-extern struct in_addr ipzero;
-
int num_response_packets = 0;
/***************************************************************************
extern fstring myworkgroup;
extern char **my_netbios_names;
-extern struct in_addr ipzero;
/* This is the broadcast subnets database. */
struct subnet_record *subnetlist = NULL;
{
int num_interfaces = iface_count();
int i;
- struct in_addr unicast_ip;
+ struct in_addr unicast_ip, ipzero;
extern struct in_addr loopback_ip;
if(num_interfaces == 0)
struct in_addr real_wins_ip;
real_wins_ip = wins_srv_ip();
- if (!zero_ip(real_wins_ip))
+ if (!is_zero_ip(real_wins_ip))
{
unicast_ip = real_wins_ip;
}
{
/* We should not be using a WINS server at all. Set the
ip address of the subnet to be zero. */
- unicast_ip = ipzero;
+ zero_ip(&unicast_ip);
}
/*
unicast_subnet = make_subnet( "UNICAST_SUBNET", UNICAST_SUBNET,
unicast_ip, unicast_ip, unicast_ip);
+ zero_ip(&ipzero);
+
remote_broadcast_subnet = make_subnet( "REMOTE_BROADCAST_SUBNET",
REMOTE_BROADCAST_SUBNET,
ipzero, ipzero, ipzero);
static int cache_we_are_a_wins_client = -1;
if(cache_we_are_a_wins_client == -1)
- cache_we_are_a_wins_client = (ip_equal(ipzero, unicast_subnet->myip) ?
+ cache_we_are_a_wins_client = (is_zero_ip(unicast_subnet->myip) ?
False : True);
return cache_we_are_a_wins_client;
#define WINS_LIST "wins.dat"
#define WINS_VERSION 1
-extern struct in_addr ipzero;
-
/****************************************************************************
possibly call the WINS hook external program when a WINS change is made
*****************************************************************************/
extern fstring global_myworkgroup;
extern char **my_netbios_names;
extern uint16 samba_nb_type;
-extern struct in_addr ipzero;
int workgroup_count = 0; /* unique index key: one for each workgroup */
/* No known domain master browser as yet. */
*work->dmb_name.name = '\0';
- putip((char *)&work->dmb_addr, &ipzero);
+ zero_ip(&work->dmb_addr);
/* WfWg uses 01040b01 */
/* Win95 uses 01041501 */
/* The next four lines commented out by JHT
and replaced with the four lines following */
-/* if( !zero_ip( wins_ip ) ) {
+/* if( !is_zero_ip( wins_ip ) ) {
* ret = name_query( fd, name, 0x20, False, True, wins_src_ip(), count );
* goto out;
* }
*/
p = wins_srv_ip();
- if( !zero_ip(p) ) {
+ if( !is_zero_ip(p) ) {
ret = name_query(fd,name,0x20,False,True, p, count);
goto out;
}
#include "includes.h"
-extern struct in_addr ipzero;
-
/* users from session setup */
static pstring session_users="";
fstring group;
pstring ipenv;
struct in_addr ip;
- extern struct in_addr ipzero;
- ip = ipzero;
+ zero_ip(&ip);
ZERO_STRUCT(c);
get_auth_data_fn(server, share, &workgroup, &username, &password);
again:
slprintf(ipenv,sizeof(ipenv)-1,"HOST_%s", server_n);
- ip = ipzero;
+ zero_ip(&ip);
if ((p=smbw_getshared(ipenv))) {
ip = *(interpret_addr2(p));
}
char *server_n;
fstring server;
struct in_addr ip;
- extern struct in_addr ipzero;
fstring myname;
static int count;
server_n = server;
- ip = ipzero;
+ zero_ip(&ip);
slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++);
make_nmb_name(&called , server, 0x20);
again:
- ip = ipzero;
+ zero_ip(&ip);
/* have to open a new connection */
if (!(c=cli_initialise(NULL)) || !cli_connect(c, server_n, &ip)) {
char *server_n;
fstring server;
struct in_addr ip;
- extern struct in_addr ipzero;
fstring myname;
static int count;
server_n = server;
- ip = ipzero;
+ zero_ip(&ip);
slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++);
make_nmb_name(&called , server, 0x20);
again:
- ip = ipzero;
+ zero_ip(&ip);
/* have to open a new connection */
if (!(c=cli_initialise(NULL)) || !cli_connect(c, server_n, &ip)) {
char *server_n;
char *server;
struct in_addr ip;
- extern struct in_addr ipzero;
server = share+2;
share = strchr_m(server,'\\');
server_n = server;
- ip = ipzero;
+ zero_ip(&ip);
make_nmb_name(&calling, "masktest", 0x0);
make_nmb_name(&called , server, 0x20);
again:
- ip = ipzero;
+ zero_ip(&ip);
/* have to open a new connection */
if (!(c=cli_initialise(NULL)) || !cli_connect(c, server_n, &ip)) {
case 'I':
{
cli_info.dest_ip = *interpret_addr2(optarg);
- if (zero_ip(cli_info.dest_ip))
+ if (is_zero_ip(cli_info.dest_ip))
{
exit(1);
}
{
struct nmb_name called, calling;
struct in_addr ip;
- extern struct in_addr ipzero;
ZERO_STRUCTP(c);
make_nmb_name(&calling, myname, 0x0);
make_nmb_name(&called , host, 0x20);
- ip = ipzero;
+ zero_ip(&ip);
if (!cli_initialise(c) || !cli_connect(c, host, &ip)) {
printf("Failed to connect with %s\n", host);
/************************************************************************************/
extern int optind, opterr, optopt;
-extern struct in_addr ipzero;
static struct cli_state *cli;
static char *opt_requester_name;
server_n = server;
- ip = ipzero;
+ zero_ip(&ip);
make_nmb_name(&calling, opt_requester_name, 0x0);
make_nmb_name(&called , server, 0x20);
again:
if (have_ip)
ip = dest_ip;
- else ip = ipzero;
+ else
+ zero_ip(&ip);
DEBUG(3,("Connecting to host=%s\\share=%s\n\n",
server, "IPC$"));
};
got_pass = 0;
- dest_ip = ipzero;
+ zero_ip(&dest_ip);
dbf = x_stdout;
break;
case 'I':
dest_ip = *interpret_addr2(poptGetOptArg(pc));
- if (zero_ip(dest_ip))
+ if (is_zero_ip(dest_ip))
d_printf(ERRMSG_INVALID_IPADDRESS);
else
have_ip = True;
#include "includes.h"
-extern struct in_addr ipzero;
-
static BOOL use_bcast = True;
static BOOL got_bcast = False;
static struct in_addr bcast_addr;
struct cli_state *c;
struct nmb_name called, calling;
struct in_addr ip;
- extern struct in_addr ipzero;
extern pstring global_myname;
fstrcpy(server,share+2);
*share = 0;
share++;
- ip = ipzero;
+ zero_ip(&ip);
make_nmb_name(&calling, global_myname, 0x0);
make_nmb_name(&called , server, 0x20);
again:
- ip = ipzero;
+ zero_ip(&ip);
/* have to open a new connection */
if (!(c=cli_initialise(NULL)) || !cli_connect(c, server, &ip)) {
struct user_auth_info *user_info)
{
struct nmb_name calling, called;
- extern struct in_addr ipzero;
- struct in_addr server_ip = ipzero;
+ struct in_addr server_ip;
struct cli_state *cli;
pstring myname;
+ zero_ip(&server_ip);
+
get_myname(myname);
make_nmb_name(&called, myname, 0x0);