r3457: s_addr is a macro on solaris, so we can't use it in structure names. arrgh.
authorAndrew Tridgell <tridge@samba.org>
Tue, 2 Nov 2004 03:58:27 +0000 (03:58 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:05:15 +0000 (13:05 -0500)
(This used to be commit 7842b23d01c53009259a2461600bd01159cecebf)

12 files changed:
source4/include/includes.h
source4/include/smb_macros.h
source4/lib/netif/interface.c
source4/lib/socket/socket_ipv4.c
source4/lib/system.c
source4/lib/util.c
source4/lib/util_sock.c
source4/lib/util_strlist.c
source4/libcli/namequery.c
source4/libcli/namequery_dc.c
source4/librpc/rpc/dcerpc_util.c
source4/torture/rpc/epmapper.c

index ce8f81c53971653bdba50854e8dcd8caf60ad583..dca1824b2288c64062b7fafd6d72a478ad609b26 100644 (file)
@@ -169,7 +169,7 @@ typedef int socklen_t;
   system networking headers everywhere
 */
 struct ipv4_addr {
-       uint32_t s_addr;
+       uint32_t addr;
 };
 
 #ifndef MIN
index 84978f4f7094b333166b878a004a65983868f878..02c8fc3af4df067ffb193f25e4c2e736250bd3e2 100644 (file)
@@ -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
index 75fdf8c97624e0a47a6fcd8affeb7b220d774106..1db0f5caee5f0d7792f0e2bc49835626e7975e90 100644 (file)
@@ -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;
 }
index 263f5aa2550bb011a799e7b2d903174c08ef13c8..eebbd61219b3064ba02c51e7f65d7ac443289b3e 100644 (file)
@@ -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;
 
index 5e106c96eb5aa1bd144e5400bd626ae83d34b3c7..d50005e8c8b26545f8c9ff663e98ca40eff0a729 100644 (file)
@@ -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;
 }
 
index 2ce34f58d99f0bb3355787f90435d16d1456957e..5385174ce4589b5183de5e561127434bc72f4e51 100644 (file)
@@ -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));
 }
index dbd71b58b6f31b7e98e647a1f309ce8b7e9f9376..876698535bacb0ee39cd88dfc0f6e6d591b27e2c 100644 (file)
@@ -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 {
index 0b32955ac20888d86e0fe0369bde85f93b4e07ea..db459b2f0fc9d5e825c16b7b846fc29d530ccad9 100644 (file)
@@ -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 */
index 8dae5e1206dbca459e2e705b1b2d6e3ae71d321c..2a67df5ffd21e85a42f730105559af4255d1022b 100644 (file)
@@ -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]);
                                }
                        }
index 6c341af4010ccec91e4e349db1661af0c92fd505..130a924b0e8bd5e47995e52c340857e839cc01d6 100644 (file)
@@ -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]);
                }
        }
index db30354609e9f2c57e3aac4a754c0ac17c29d9d3..af92743ccb1de06d926c8be63a5f4068c3117098 100644 (file)
@@ -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));
                }
 
index 78721d075e0585cbab1f7579456b7a12f0e65aaa..714e6f3f8c1597ec9b2f3ca630fca3f2764a2256 100644 (file)
@@ -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;