1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-29 02:50:28 +03:00

Got medieval on another pointless extern. Removed extern struct ipzero

and replaced with two functions:

	void zero_ip(struct in_adder *ip);
	BOOL is_zero_ip(struct in_addr ip);
(This used to be commit 778f5f77a66cda76348a7c6f64cd63afe2bfe077)
This commit is contained in:
Tim Potter 2001-11-26 03:11:44 +00:00
parent 8b7434b2a0
commit 585d0efbc6
30 changed files with 70 additions and 86 deletions

View File

@ -24,8 +24,6 @@
BOOL global_machine_password_needs_changing = False;
extern struct in_addr ipzero;
extern pstring global_myname;
/***********************************************************************
@ -183,7 +181,7 @@ static BOOL attempt_connect_to_dc(struct cli_state *pcli, struct in_addr *ip,
* 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))
@ -232,7 +230,7 @@ static BOOL find_connect_pdc(struct cli_state *pcli,
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. */
}
/*
@ -242,7 +240,7 @@ static BOOL find_connect_pdc(struct cli_state *pcli,
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. */
}
/*

View File

@ -45,7 +45,6 @@ static char *cmdstr;
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;
@ -2085,7 +2084,6 @@ struct cli_state *do_connect(const char *server, const char *share)
struct nmb_name called, calling;
const char *server_n;
struct in_addr ip;
extern struct in_addr ipzero;
fstring servicename;
char *sharename;
@ -2102,13 +2100,13 @@ struct cli_state *do_connect(const char *server, const char *share)
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 */
@ -2366,12 +2364,12 @@ static int do_message_op(void)
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)) {
@ -2584,7 +2582,7 @@ static int do_message_op(void)
case 'I':
{
dest_ip = *interpret_addr2(optarg);
if (zero_ip(dest_ip))
if (is_zero_ip(dest_ip))
exit(1);
have_ip = True;
}

View File

@ -27,8 +27,6 @@
#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;
@ -119,7 +117,6 @@ static struct cli_state *do_connection(char *the_service)
struct nmb_name called, calling;
char *server_n;
struct in_addr ip;
extern struct in_addr ipzero;
pstring server;
char *share;
@ -143,7 +140,7 @@ static struct cli_state *do_connection(char *the_service)
make_nmb_name(&called , server, 0x20);
again:
ip = ipzero;
zero_ip(&ip);
if (have_ip) ip = dest_ip;
/* have to open a new connection */
@ -756,7 +753,7 @@ static void parse_mount_smb(int argc, char **argv)
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);
}

View File

@ -29,7 +29,6 @@
*/
extern BOOL in_client; /* Boolean for client library */
extern struct in_addr ipzero; /* Any address */
/*
@ -285,7 +284,7 @@ smb_connect(char *workgroup, /* I - Workgroup */
get_myname(myname);
ip = ipzero;
zero_ip(&ip);
make_nmb_name(&calling, myname, 0x0);
make_nmb_name(&called, server, 0x20);

View File

@ -26,7 +26,6 @@
static struct iface_struct *probed_ifaces;
static int total_probed;
struct in_addr ipzero;
struct in_addr allones_ip;
struct in_addr loopback_ip;
@ -42,7 +41,7 @@ Try and find an interface that matches an ip. If we cannot, return NULL
static struct interface *iface_find(struct in_addr ip, BOOL CheckMask)
{
struct interface *i;
if (zero_ip(ip)) return local_interfaces;
if (is_zero_ip(ip)) return local_interfaces;
for (i=local_interfaces;i;i=i->next)
if (CheckMask) {
@ -104,8 +103,8 @@ static void interpret_interface(char *token)
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++) {
@ -172,7 +171,6 @@ void load_interfaces(void)
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");

View File

@ -841,13 +841,27 @@ struct in_addr *interpret_addr2(const char *str)
/*******************************************************************
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))
/******************************************************************

View File

@ -209,11 +209,11 @@ struct in_addr wins_srv_ip( void )
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 );
@ -278,7 +278,7 @@ void wins_srv_died( struct in_addr boothill_ip )
{
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;

View File

@ -972,12 +972,11 @@ open the client sockets
****************************************************************************/
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;
}

View File

@ -246,9 +246,8 @@ struct smbc_server *smbc_server(char *server, char *share,
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 */
@ -306,7 +305,7 @@ struct smbc_server *smbc_server(char *server, char *share,
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)) {

View File

@ -48,8 +48,6 @@ BOOL found_lm_clients = False;
time_t StartupTime = 0;
extern struct in_addr ipzero;
/**************************************************************************** **
catch a sigterm
**************************************************************************** */

View File

@ -27,7 +27,6 @@
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. */
@ -214,7 +213,7 @@ static void become_domain_master_query_success(struct subnet_record *subrec,
/* 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 ) )
{

View File

@ -25,7 +25,6 @@
#include "includes.h"
#include "smb.h"
extern struct in_addr ipzero;
extern pstring global_myname;
extern fstring global_myworkgroup;
@ -308,7 +307,7 @@ static void find_domain_master_name_query_success(struct subnet_record *subrec,
/* 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. */
@ -319,7 +318,7 @@ static void find_domain_master_name_query_success(struct subnet_record *subrec,
return;
}
else
putip((char *)&work->dmb_addr, &ipzero);
zero_ip(&work->dmb_addr);
/* Now initiate the node status request. */
make_nmb_name(&nmbname,"*",0x0);

View File

@ -27,7 +27,6 @@
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. */

View File

@ -24,8 +24,6 @@
#include "includes.h"
extern struct in_addr ipzero;
/****************************************************************************
Deal with a response packet when querying a name.
****************************************************************************/
@ -38,7 +36,9 @@ static void query_name_response( struct subnet_record *subrec,
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

View File

@ -26,8 +26,6 @@
extern int ClientNMB;
extern struct in_addr ipzero;
int num_response_packets = 0;
/***************************************************************************

View File

@ -33,7 +33,6 @@ extern int global_nmb_port;
extern fstring myworkgroup;
extern char **my_netbios_names;
extern struct in_addr ipzero;
/* This is the broadcast subnets database. */
struct subnet_record *subnetlist = NULL;
@ -232,7 +231,7 @@ BOOL create_subnets(void)
{
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)
@ -280,7 +279,7 @@ BOOL create_subnets(void)
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;
}
@ -302,7 +301,7 @@ BOOL create_subnets(void)
{
/* 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);
}
/*
@ -315,6 +314,8 @@ BOOL create_subnets(void)
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);
@ -347,7 +348,7 @@ BOOL we_are_a_wins_client(void)
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;

View File

@ -26,8 +26,6 @@
#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
*****************************************************************************/

View File

@ -31,7 +31,6 @@ extern pstring global_myname;
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 */
@ -101,7 +100,7 @@ static struct work_record *create_workgroup(const char *name, int ttl)
/* 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 */

View File

@ -88,13 +88,13 @@ struct in_addr *lookup_backend(const char *name, int *count)
/* 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;
}

View File

@ -21,8 +21,6 @@
#include "includes.h"
extern struct in_addr ipzero;
/* users from session setup */
static pstring session_users="";

View File

@ -442,9 +442,8 @@ struct smbw_server *smbw_server(char *server, char *share)
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);
@ -495,7 +494,7 @@ struct smbw_server *smbw_server(char *server, char *share)
again:
slprintf(ipenv,sizeof(ipenv)-1,"HOST_%s", server_n);
ip = ipzero;
zero_ip(&ip);
if ((p=smbw_getshared(ipenv))) {
ip = *(interpret_addr2(p));
}

View File

@ -147,7 +147,6 @@ struct cli_state *connect_one(char *share)
char *server_n;
fstring server;
struct in_addr ip;
extern struct in_addr ipzero;
fstring myname;
static int count;
@ -159,7 +158,7 @@ struct cli_state *connect_one(char *share)
server_n = server;
ip = ipzero;
zero_ip(&ip);
slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++);
@ -167,7 +166,7 @@ struct cli_state *connect_one(char *share)
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)) {

View File

@ -157,7 +157,6 @@ struct cli_state *connect_one(char *share)
char *server_n;
fstring server;
struct in_addr ip;
extern struct in_addr ipzero;
fstring myname;
static int count;
@ -169,7 +168,7 @@ struct cli_state *connect_one(char *share)
server_n = server;
ip = ipzero;
zero_ip(&ip);
slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++);
@ -177,7 +176,7 @@ struct cli_state *connect_one(char *share)
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)) {

View File

@ -165,7 +165,6 @@ struct cli_state *connect_one(char *share)
char *server_n;
char *server;
struct in_addr ip;
extern struct in_addr ipzero;
server = share+2;
share = strchr_m(server,'\\');
@ -175,13 +174,13 @@ struct cli_state *connect_one(char *share)
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)) {

View File

@ -409,7 +409,7 @@ enum client_action
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);
}

View File

@ -93,14 +93,13 @@ static BOOL open_nbt_connection(struct cli_state *c)
{
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);

View File

@ -286,7 +286,6 @@ static const char *share_type[] = {
/************************************************************************************/
extern int optind, opterr, optopt;
extern struct in_addr ipzero;
static struct cli_state *cli;
static char *opt_requester_name;
@ -355,14 +354,15 @@ static struct cli_state *connect_to_ipc(char *server)
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$"));
@ -1276,7 +1276,7 @@ int main(int argc,char *argv[])
};
got_pass = 0;
dest_ip = ipzero;
zero_ip(&dest_ip);
dbf = x_stdout;
@ -1291,7 +1291,7 @@ int main(int argc,char *argv[])
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;

View File

@ -24,8 +24,6 @@
#include "includes.h"
extern struct in_addr ipzero;
static BOOL use_bcast = True;
static BOOL got_bcast = False;
static struct in_addr bcast_addr;

View File

@ -690,7 +690,6 @@ struct cli_state *connect_one(char *share)
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);
@ -699,13 +698,13 @@ struct cli_state *connect_one(char *share)
*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)) {

View File

@ -94,11 +94,12 @@ static struct cli_state *get_ipc_connect(char *server,
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);