mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
r3457: s_addr is a macro on solaris, so we can't use it in structure names. arrgh.
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
7e94d5bd3d
commit
7842b23d01
@ -169,7 +169,7 @@ typedef int socklen_t;
|
||||
system networking headers everywhere
|
||||
*/
|
||||
struct ipv4_addr {
|
||||
uint32_t s_addr;
|
||||
uint32_t addr;
|
||||
};
|
||||
|
||||
#ifndef MIN
|
||||
|
@ -130,6 +130,7 @@ true if two IP addresses are equal
|
||||
****************************************************************************/
|
||||
|
||||
#define ip_equal(ip1,ip2) ((ip1).s_addr == (ip2).s_addr)
|
||||
#define ipv4_equal(ip1,ip2) ((ip1).addr == (ip2).addr)
|
||||
|
||||
/*****************************************************************
|
||||
splits out the last subkey of a key
|
||||
|
@ -45,7 +45,7 @@ static struct interface *local_interfaces;
|
||||
static struct ipv4_addr tov4(struct in_addr in)
|
||||
{
|
||||
struct ipv4_addr in2;
|
||||
in2.s_addr = in.s_addr;
|
||||
in2.addr = in.s_addr;
|
||||
return in2;
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ static struct interface *iface_find(struct in_addr ip, BOOL CheckMask)
|
||||
for (i=local_interfaces;i;i=i->next)
|
||||
if (CheckMask) {
|
||||
if (same_net(i->ip,tov4(ip),i->nmask)) return i;
|
||||
} else if ((i->ip).s_addr == ip.s_addr) return i;
|
||||
} else if (i->ip.addr == ip.s_addr) return i;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -77,7 +77,7 @@ static void add_interface(struct in_addr ip, struct in_addr nmask)
|
||||
return;
|
||||
}
|
||||
|
||||
if (ip_equal(nmask, allones_ip)) {
|
||||
if (nmask.s_addr == allones_ip.addr) {
|
||||
DEBUG(3,("not adding non-broadcast interface %s\n",inet_ntoa(ip)));
|
||||
return;
|
||||
}
|
||||
@ -89,7 +89,7 @@ static void add_interface(struct in_addr ip, struct in_addr nmask)
|
||||
|
||||
iface->ip = tov4(ip);
|
||||
iface->nmask = tov4(nmask);
|
||||
iface->bcast.s_addr = MKBCADDR(iface->ip.s_addr, iface->nmask.s_addr);
|
||||
iface->bcast.addr = MKBCADDR(iface->ip.addr, iface->nmask.addr);
|
||||
|
||||
DLIST_ADD(local_interfaces, iface);
|
||||
|
||||
@ -133,10 +133,10 @@ static void interpret_interface(TALLOC_CTX *mem_ctx, const char *token)
|
||||
/* maybe it is a DNS name */
|
||||
p = strchr_m(token,'/');
|
||||
if (!p) {
|
||||
ip.s_addr = interpret_addr2(token).s_addr;
|
||||
ip.s_addr = interpret_addr2(token).addr;
|
||||
for (i=0;i<total_probed;i++) {
|
||||
if (ip.s_addr == probed_ifaces[i].ip.s_addr &&
|
||||
!ip_equal(allones_ip, probed_ifaces[i].netmask)) {
|
||||
allones_ip.addr != probed_ifaces[i].netmask.s_addr) {
|
||||
add_interface(probed_ifaces[i].ip,
|
||||
probed_ifaces[i].netmask);
|
||||
return;
|
||||
@ -149,10 +149,10 @@ static void interpret_interface(TALLOC_CTX *mem_ctx, const char *token)
|
||||
/* parse it into an IP address/netmasklength pair */
|
||||
*p++ = 0;
|
||||
|
||||
ip.s_addr = interpret_addr2(token).s_addr;
|
||||
ip.s_addr = interpret_addr2(token).addr;
|
||||
|
||||
if (strlen(p) > 2) {
|
||||
nmask.s_addr = interpret_addr2(p).s_addr;
|
||||
nmask.s_addr = interpret_addr2(p).addr;
|
||||
} else {
|
||||
nmask.s_addr = htonl(((ALLONES >> atoi(p)) ^ ALLONES));
|
||||
}
|
||||
@ -219,8 +219,8 @@ void load_interfaces(void)
|
||||
exit(1);
|
||||
}
|
||||
for (i=0;i<total_probed;i++) {
|
||||
if (probed_ifaces[i].netmask.s_addr != allones_ip.s_addr &&
|
||||
probed_ifaces[i].ip.s_addr != loopback_ip.s_addr) {
|
||||
if (probed_ifaces[i].netmask.s_addr != allones_ip.addr &&
|
||||
probed_ifaces[i].ip.s_addr != loopback_ip.addr) {
|
||||
add_interface(probed_ifaces[i].ip,
|
||||
probed_ifaces[i].netmask);
|
||||
}
|
||||
@ -270,7 +270,7 @@ BOOL ismyip(struct ipv4_addr ip)
|
||||
{
|
||||
struct interface *i;
|
||||
for (i=local_interfaces;i;i=i->next)
|
||||
if (ip_equal(i->ip,ip)) return True;
|
||||
if (ipv4_equal(i->ip,ip)) return True;
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -281,8 +281,8 @@ BOOL is_local_net(struct ipv4_addr from)
|
||||
{
|
||||
struct interface *i;
|
||||
for (i=local_interfaces;i;i=i->next) {
|
||||
if((from.s_addr & i->nmask.s_addr) ==
|
||||
(i->ip.s_addr & i->nmask.s_addr))
|
||||
if((from.addr & i->nmask.addr) ==
|
||||
(i->ip.addr & i->nmask.addr))
|
||||
return True;
|
||||
}
|
||||
return False;
|
||||
@ -339,7 +339,7 @@ struct ipv4_addr *iface_ip(struct ipv4_addr ip)
|
||||
{
|
||||
struct in_addr in;
|
||||
struct interface *i;
|
||||
in.s_addr = ip.s_addr;
|
||||
in.s_addr = ip.addr;
|
||||
i = iface_find(in, True);
|
||||
return(i ? &i->ip : &local_interfaces->ip);
|
||||
}
|
||||
@ -350,6 +350,6 @@ struct ipv4_addr *iface_ip(struct ipv4_addr ip)
|
||||
BOOL iface_local(struct ipv4_addr ip)
|
||||
{
|
||||
struct in_addr in;
|
||||
in.s_addr = ip.s_addr;
|
||||
in.s_addr = ip.addr;
|
||||
return iface_find(in, True) ? True : False;
|
||||
}
|
||||
|
@ -48,13 +48,13 @@ static NTSTATUS ipv4_tcp_connect(struct socket_context *sock,
|
||||
|
||||
my_ip = interpret_addr2(my_address);
|
||||
|
||||
if (my_ip.s_addr != 0 || my_port != 0) {
|
||||
if (my_ip.addr != 0 || my_port != 0) {
|
||||
struct sockaddr_in my_addr;
|
||||
ZERO_STRUCT(my_addr);
|
||||
#ifdef HAVE_SOCK_SIN_LEN
|
||||
my_addr.sin_len = sizeof(my_addr);
|
||||
#endif
|
||||
my_addr.sin_addr.s_addr = my_ip.s_addr;
|
||||
my_addr.sin_addr.s_addr = my_ip.addr;
|
||||
my_addr.sin_port = htons(my_port);
|
||||
my_addr.sin_family = PF_INET;
|
||||
|
||||
@ -70,7 +70,7 @@ static NTSTATUS ipv4_tcp_connect(struct socket_context *sock,
|
||||
#ifdef HAVE_SOCK_SIN_LEN
|
||||
srv_addr.sin_len = sizeof(srv_addr);
|
||||
#endif
|
||||
srv_addr.sin_addr.s_addr= srv_ip.s_addr;
|
||||
srv_addr.sin_addr.s_addr= srv_ip.addr;
|
||||
srv_addr.sin_port = htons(srv_port);
|
||||
srv_addr.sin_family = PF_INET;
|
||||
|
||||
@ -105,7 +105,7 @@ static NTSTATUS ipv4_tcp_listen(struct socket_context *sock,
|
||||
#ifdef HAVE_SOCK_SIN_LEN
|
||||
my_addr.sin_len = sizeof(my_addr);
|
||||
#endif
|
||||
my_addr.sin_addr.s_addr = ip_addr.s_addr;
|
||||
my_addr.sin_addr.s_addr = ip_addr.addr;
|
||||
my_addr.sin_port = htons(port);
|
||||
my_addr.sin_family = PF_INET;
|
||||
|
||||
|
@ -540,7 +540,7 @@ int sys_dup2(int oldfd, int newfd)
|
||||
const char *sys_inet_ntoa(struct ipv4_addr in)
|
||||
{
|
||||
struct in_addr in2;
|
||||
in2.s_addr = in.s_addr;
|
||||
in2.s_addr = in.addr;
|
||||
return inet_ntoa(in2);
|
||||
}
|
||||
|
||||
@ -554,7 +554,7 @@ 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;
|
||||
in2.addr = in.s_addr;
|
||||
return in2;
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,7 @@ struct ipv4_addr interpret_addr2(const char *str)
|
||||
{
|
||||
struct ipv4_addr ret;
|
||||
uint32_t a = interpret_addr(str);
|
||||
ret.s_addr = a;
|
||||
ret.addr = a;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -486,9 +486,9 @@ BOOL same_net(struct ipv4_addr ip1,struct ipv4_addr ip2,struct ipv4_addr mask)
|
||||
{
|
||||
uint32_t net1,net2,nmask;
|
||||
|
||||
nmask = ntohl(mask.s_addr);
|
||||
net1 = ntohl(ip1.s_addr);
|
||||
net2 = ntohl(ip2.s_addr);
|
||||
nmask = ntohl(mask.addr);
|
||||
net1 = ntohl(ip1.addr);
|
||||
net2 = ntohl(ip2.addr);
|
||||
|
||||
return((net1 & nmask) == (net2 & nmask));
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ ssize_t read_udp_socket(int fd, char *buf, size_t len,
|
||||
}
|
||||
|
||||
if (from_addr) {
|
||||
from_addr->s_addr = sock.sin_addr.s_addr;
|
||||
from_addr->addr = sock.sin_addr.s_addr;
|
||||
}
|
||||
if (from_port) {
|
||||
*from_port = ntohs(sock.sin_port);
|
||||
@ -512,7 +512,7 @@ char *get_socket_name(TALLOC_CTX *mem_ctx, int fd, BOOL force_lookup)
|
||||
addr = interpret_addr2(p);
|
||||
|
||||
/* Look up the remote host name. */
|
||||
if ((hp = gethostbyaddr((char *)&addr.s_addr, sizeof(addr.s_addr), AF_INET)) == 0) {
|
||||
if ((hp = gethostbyaddr((char *)&addr.addr, sizeof(addr.addr), AF_INET)) == 0) {
|
||||
DEBUG(1,("Gethostbyaddr failed for %s\n",p));
|
||||
name_buf = talloc_strdup(mem_ctx, p);
|
||||
} else {
|
||||
|
@ -297,7 +297,7 @@ int ipstr_list_parse(const char* ipstr_list, struct ipv4_addr** ip_list)
|
||||
struct ipv4_addr addr;
|
||||
|
||||
/* convert single token to ip address */
|
||||
if ( (addr.s_addr = sys_inet_addr(token_str)) == INADDR_NONE )
|
||||
if ( (addr.addr = sys_inet_addr(token_str)) == INADDR_NONE )
|
||||
break;
|
||||
|
||||
/* prepare place for another in_addr structure */
|
||||
|
@ -236,8 +236,8 @@ int ip_compare(struct ipv4_addr *ip1, struct ipv4_addr *ip2)
|
||||
struct ipv4_addr ip;
|
||||
int bits1, bits2;
|
||||
ip = *iface_n_bcast(i);
|
||||
bits1 = matching_quad_bits((uint8_t *)&ip1->s_addr, (uint8_t *)&ip.s_addr);
|
||||
bits2 = matching_quad_bits((uint8_t *)&ip2->s_addr, (uint8_t *)&ip.s_addr);
|
||||
bits1 = matching_quad_bits((uint8_t *)&ip1->addr, (uint8_t *)&ip.addr);
|
||||
bits2 = matching_quad_bits((uint8_t *)&ip2->addr, (uint8_t *)&ip.addr);
|
||||
max_bits1 = MAX(bits1, max_bits1);
|
||||
max_bits2 = MAX(bits2, max_bits2);
|
||||
}
|
||||
@ -678,7 +678,7 @@ BOOL resolve_wins(TALLOC_CTX *mem_ctx, const char *name, int name_type,
|
||||
|
||||
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.addr, True);
|
||||
if (sock == -1) {
|
||||
continue;
|
||||
}
|
||||
@ -776,12 +776,12 @@ static BOOL internal_resolve_name(TALLOC_CTX *mem_ctx, const char *name, int nam
|
||||
}
|
||||
if(is_address) {
|
||||
/* if it's in the form of an IP address then get the lib to interpret it */
|
||||
if (((*return_iplist)->s_addr = inet_addr(name)) == 0xFFFFFFFF ){
|
||||
if (((*return_iplist)->addr = inet_addr(name)) == 0xFFFFFFFF ){
|
||||
DEBUG(1,("internal_resolve_name: inet_addr failed on %s\n", name));
|
||||
return False;
|
||||
}
|
||||
} else {
|
||||
(*return_iplist)->s_addr = allones ? 0xFFFFFFFF : 0;
|
||||
(*return_iplist)->addr = allones ? 0xFFFFFFFF : 0;
|
||||
*return_count = 1;
|
||||
}
|
||||
return True;
|
||||
@ -854,7 +854,7 @@ static BOOL internal_resolve_name(TALLOC_CTX *mem_ctx, const char *name, int nam
|
||||
int j;
|
||||
|
||||
for (j = i + 1; j < *return_count; j++) {
|
||||
if (ip_equal((*return_iplist)[i],
|
||||
if (ipv4_equal((*return_iplist)[i],
|
||||
(*return_iplist)[j])) {
|
||||
is_dupe = True;
|
||||
break;
|
||||
@ -1312,7 +1312,7 @@ BOOL get_dc_list(TALLOC_CTX *mem_ctx, const char *domain, struct ipv4_addr **ip_
|
||||
continue;
|
||||
|
||||
for ( j=i+1; j<local_count; j++ ) {
|
||||
if ( ip_equal( return_iplist[i], return_iplist[j]) )
|
||||
if ( ipv4_equal( return_iplist[i], return_iplist[j]) )
|
||||
zero_ip(&return_iplist[j]);
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ BOOL rpc_find_dc(const char *domain, fstring srv_name, struct ipv4_addr *ip_out)
|
||||
|
||||
if ( use_pdc_only ) {
|
||||
for (i = 0; i < count; i++) {
|
||||
if (ip_equal( exclude_ip, ip_list[i]))
|
||||
if (ipv4_equal( exclude_ip, ip_list[i]))
|
||||
zero_ip(&ip_list[i]);
|
||||
}
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *flo
|
||||
|
||||
{
|
||||
struct ipv4_addr in;
|
||||
in.s_addr = htonl(floor->rhs.ip.address);
|
||||
in.addr = htonl(floor->rhs.ip.address);
|
||||
return talloc_strdup(mem_ctx, sys_inet_ntoa(in));
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ static void display_tower(TALLOC_CTX *mem_ctx, struct epm_tower *twr)
|
||||
printf(" IP:");
|
||||
{
|
||||
struct ipv4_addr in;
|
||||
in.s_addr = htonl(rhs->ip.address);
|
||||
in.addr = htonl(rhs->ip.address);
|
||||
printf("%s", sys_inet_ntoa(in));
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user