summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/cliconnect.c8
-rw-r--r--source3/libsmb/clidfs.c4
-rw-r--r--source3/libsmb/dsgetdcname.c2
-rw-r--r--source3/libsmb/libsmbclient.c10
-rw-r--r--source3/libsmb/namequery.c35
-rw-r--r--source3/libsmb/namequery_dc.c6
6 files changed, 39 insertions, 26 deletions
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 78cc63de50..16c3bed438 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -1421,7 +1421,7 @@ NTSTATUS cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip
*p = 0;
}
- if (!ip || is_zero_ip(*ip)) {
+ if (!ip || is_zero_ip_v4(*ip)) {
if (!resolve_name(cli->desthost, &cli->dest_ip, name_type)) {
return NT_STATUS_BAD_NETWORK_NAME;
}
@@ -1522,7 +1522,7 @@ again:
char *p;
DEBUG(1,("session request to %s failed (%s)\n",
called.name, cli_errstr(cli)));
- if ((p=strchr(called.name, '.')) && !is_ipaddress(called.name)) {
+ if ((p=strchr(called.name, '.')) && !is_ipaddress_v4(called.name)) {
*p = 0;
goto again;
}
@@ -1650,7 +1650,7 @@ BOOL attempt_netbios_session_request(struct cli_state **ppcli, const char *srcho
* then use *SMBSERVER immediately.
*/
- if(is_ipaddress(desthost)) {
+ if(is_ipaddress_v4(desthost)) {
make_nmb_name(&called, "*SMBSERVER", 0x20);
} else {
make_nmb_name(&called, desthost, 0x20);
@@ -1764,7 +1764,7 @@ struct cli_state *get_ipc_connect(char *server, struct in_addr *server_ip,
if (NT_STATUS_IS_OK(nt_status)) {
return cli;
- } else if (is_ipaddress(server)) {
+ } else if (is_ipaddress_v4(server)) {
/* windows 9* needs a correct NMB name for connections */
fstring remote_name;
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index d32629b139..db4a9dfbd5 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -83,13 +83,13 @@ static struct cli_state *do_connect( const char *server, const char *share,
server_n = server;
- zero_ip(&ip);
+ zero_ip_v4(&ip);
make_nmb_name(&calling, global_myname(), 0x0);
make_nmb_name(&called , server, name_type);
again:
- zero_ip(&ip);
+ zero_ip_v4(&ip);
if (have_ip)
ip = dest_ip;
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index 384b9ec48d..89bb65006d 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -650,7 +650,7 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx,
* back to netbios lookups is that our DNS server doesn't know
* anything about the DC's -- jerry */
- if (!is_zero_ip(r->ip)) {
+ if (!is_zero_ip_v4(r->ip)) {
(*return_count)++;
continue;
}
diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c
index 45226a028c..49384e2728 100644
--- a/source3/libsmb/libsmbclient.c
+++ b/source3/libsmb/libsmbclient.c
@@ -654,7 +654,7 @@ smbc_server(SMBCCTX *context,
const char *username_used;
NTSTATUS status;
- zero_ip(&ip);
+ zero_ip_v4(&ip);
ZERO_STRUCT(c);
if (server[0] == 0) {
@@ -742,7 +742,7 @@ smbc_server(SMBCCTX *context,
again:
slprintf(ipenv,sizeof(ipenv)-1,"HOST_%s", server_n);
- zero_ip(&ip);
+ zero_ip_v4(&ip);
/* have to open a new connection */
if ((c = cli_initialise()) == NULL) {
@@ -796,7 +796,7 @@ smbc_server(SMBCCTX *context,
/* Only try this if server is an IP address ... */
- if (is_ipaddress(server) && !tried_reverse) {
+ if (is_ipaddress_v4(server) && !tried_reverse) {
fstring remote_name;
struct in_addr rem_ip;
@@ -962,7 +962,7 @@ smbc_attr_server(SMBCCTX *context,
flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
}
- zero_ip(&ip);
+ zero_ip_v4(&ip);
nt_status = cli_full_connection(&ipc_cli,
global_myname(), server,
&ip, 0, "IPC$", "?????",
@@ -2761,7 +2761,7 @@ smbc_opendir_ctx(SMBCCTX *context,
* LMB or DMB
*/
if (!srv &&
- !is_ipaddress(server) &&
+ !is_ipaddress_v4(server) &&
(resolve_name(server, &rem_ip, 0x1d) || /* LMB */
resolve_name(server, &rem_ip, 0x1b) )) { /* DMB */
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 49e3375f50..182d3641f7 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -352,12 +352,18 @@ static int ip_compare(struct in_addr *ip1, struct in_addr *ip2)
{
int max_bits1=0, max_bits2=0;
int num_interfaces = iface_count();
+ struct sockaddr_storage ss;
int i;
for (i=0;i<num_interfaces;i++) {
+ const struct sockaddr_storage *pss = iface_n_bcast(i);
struct in_addr ip;
int bits1, bits2;
- ip = *iface_n_bcast(i);
+
+ if (pss->ss_family != AF_INET) {
+ continue;
+ }
+ ip = ((const struct sockaddr_in *)pss)->sin_addr;
bits1 = matching_quad_bits((uchar *)&ip1->s_addr, (uchar *)&ip.s_addr);
bits2 = matching_quad_bits((uchar *)&ip2->s_addr, (uchar *)&ip.s_addr);
max_bits1 = MAX(bits1, max_bits1);
@@ -365,10 +371,12 @@ static int ip_compare(struct in_addr *ip1, struct in_addr *ip2)
}
/* bias towards directly reachable IPs */
- if (iface_local(*ip1)) {
+ in_addr_to_sockaddr_storage(&ss, *ip1);
+ if (iface_local(&ss)) {
max_bits1 += 32;
}
- if (iface_local(*ip2)) {
+ in_addr_to_sockaddr_storage(&ss, *ip1);
+ if (iface_local(&ss)) {
max_bits2 += 32;
}
@@ -431,19 +439,19 @@ static int remove_duplicate_addrs2( struct ip_service *iplist, int count )
/* one loop to remove duplicates */
for ( i=0; i<count; i++ ) {
- if ( is_zero_ip(iplist[i].ip) )
+ if ( is_zero_ip_v4(iplist[i].ip) )
continue;
for ( j=i+1; j<count; j++ ) {
if ( ip_service_equal(iplist[i], iplist[j]) )
- zero_ip(&iplist[j].ip);
+ zero_ip_v4(&iplist[j].ip);
}
}
/* one loop to clean up any holes we left */
/* first ip should never be a zero_ip() */
for (i = 0; i<count; ) {
- if ( is_zero_ip(iplist[i].ip) ) {
+ if ( is_zero_ip_v4(iplist[i].ip) ) {
if (i != count-1 )
memmove(&iplist[i], &iplist[i+1], (count - i - 1)*sizeof(iplist[i]));
count--;
@@ -812,9 +820,14 @@ NTSTATUS name_resolve_bcast(const char *name, int name_type,
*/
for( i = num_interfaces-1; i >= 0; i--) {
struct in_addr sendto_ip;
+ const struct sockaddr_storage *ss = iface_n_bcast(i);
int flags;
+
/* Done this way to fix compiler error on IRIX 5.x */
- sendto_ip = *iface_n_bcast(i);
+ if (!ss || ss->ss_family != AF_INET) {
+ continue;
+ }
+ sendto_ip = ((const struct sockaddr_in *)ss)->sin_addr;
ip_list = name_query(sock, name, name_type, True,
True, sendto_ip, return_count, &flags, NULL);
if( ip_list )
@@ -886,7 +899,7 @@ NTSTATUS resolve_wins(const char *name, int name_type,
wins_ip = wins_srv_ip_tag(wins_tags[t], src_ip);
- if (global_in_nmbd && ismyip(wins_ip)) {
+ if (global_in_nmbd && ismyip_v4(wins_ip)) {
/* yikes! we'll loop forever */
continue;
}
@@ -1144,7 +1157,7 @@ NTSTATUS resolve_ads(const char *name, int name_type,
The standard reason for falling back to netbios lookups is that
our DNS server doesn't know anything about the DC's -- jerry */
- if ( ! is_zero_ip(r->ip) )
+ if ( ! is_zero_ip_v4(r->ip) )
(*return_count)++;
}
@@ -1173,7 +1186,7 @@ NTSTATUS internal_resolve_name(const char *name, int name_type,
const char *ptr;
BOOL allones = (strcmp(name,"255.255.255.255") == 0);
BOOL allzeros = (strcmp(name,"0.0.0.0") == 0);
- BOOL is_address = is_ipaddress(name);
+ BOOL is_address = is_ipaddress_v4(name);
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
int i;
@@ -1347,7 +1360,7 @@ BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
char *sitename = sitename_fetch(lp_realm()); /* wild guess */
int count = 0;
- if (is_ipaddress(name)) {
+ if (is_ipaddress_v4(name)) {
*return_ip = *interpret_addr2(name);
SAFE_FREE(sitename);
return True;
diff --git a/source3/libsmb/namequery_dc.c b/source3/libsmb/namequery_dc.c
index bdac833d13..39215aaa8f 100644
--- a/source3/libsmb/namequery_dc.c
+++ b/source3/libsmb/namequery_dc.c
@@ -155,7 +155,7 @@ static BOOL rpc_dc_name(const char *domain, fstring srv_name, struct in_addr *ip
int count, i;
NTSTATUS result;
- zero_ip(&exclude_ip);
+ zero_ip_v4(&exclude_ip);
/* get a list of all domain controllers */
@@ -168,7 +168,7 @@ static BOOL rpc_dc_name(const char *domain, fstring srv_name, struct in_addr *ip
/* Remove the entry we've already failed with (should be the PDC). */
for (i = 0; i < count; i++) {
- if (is_zero_ip(ip_list[i].ip))
+ if (is_zero_ip_v4(ip_list[i].ip))
continue;
if (name_status_find(domain, 0x1c, 0x20, ip_list[i].ip, srv_name)) {
@@ -212,7 +212,7 @@ BOOL get_dc_name(const char *domain, const char *realm, fstring srv_name, struct
BOOL ret;
BOOL our_domain = False;
- zero_ip(&dc_ip);
+ zero_ip_v4(&dc_ip);
ret = False;