]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib, zebra: extend use of sockunion2ip macro
authorJorge Boncompte [DTI2] <jorge@dti2.net>
Tue, 10 Apr 2012 14:57:25 +0000 (16:57 +0200)
committerDavid Lamparter <equinox@diac24.net>
Wed, 2 May 2012 15:03:28 +0000 (17:03 +0200)
  * lib/sockunion.c,
  * zebra/zebra_rib.c: replace ->sin.sin_addr.s_addr with sockunion2ip

Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
[reworded commit message]
Signed-off-by: David Lamparter <equinox@diac24.net>
lib/sockunion.c
zebra/zebra_rib.c

index 4c2837b12d1fb8ee8e39fd695124ee9eb75dc7f9..37dc3f90b0871a108721fa2ed9b6844e1ca0f7f1 100644 (file)
@@ -370,7 +370,7 @@ sockunion_bind (int sock, union sockunion *su, unsigned short port,
       su->sin.sin_len = size;
 #endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
       if (su_addr == NULL)
-       su->sin.sin_addr.s_addr = htonl (INADDR_ANY);
+       sockunion2ip (su) = htonl (INADDR_ANY);
     }
 #ifdef HAVE_IPV6
   else if (su->sa.sa_family == AF_INET6)
@@ -727,9 +727,9 @@ sockunion_cmp (union sockunion *su1, union sockunion *su2)
 
   if (su1->sa.sa_family == AF_INET)
     {
-      if (ntohl (su1->sin.sin_addr.s_addr) == ntohl (su2->sin.sin_addr.s_addr))
+      if (ntohl (sockunion2ip (su1)) == ntohl (sockunion2ip (su2)))
        return 0;
-      if (ntohl (su1->sin.sin_addr.s_addr) > ntohl (su2->sin.sin_addr.s_addr))
+      if (ntohl (sockunion2ip (su1)) > ntohl (sockunion2ip (su2)))
        return 1;
       else
        return -1;
index 154e8d5518ceab81244f0019a1b076f9e2ea22ce..50674ee889f9281fbe9abd387f19035835439cc5 100644 (file)
@@ -678,8 +678,8 @@ rib_lookup_ipv4_route (struct prefix_ipv4 *p, union sockunion * qgate)
     if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
     {
       /* We are happy with either direct or recursive hexthop */
-      if (nexthop->gate.ipv4.s_addr == qgate->sin.sin_addr.s_addr ||
-          nexthop->rgate.ipv4.s_addr == qgate->sin.sin_addr.s_addr)
+      if (nexthop->gate.ipv4.s_addr == sockunion2ip (qgate) ||
+          nexthop->rgate.ipv4.s_addr == sockunion2ip (qgate))
         return ZEBRA_RIB_FOUND_EXACT;
       else
       {
@@ -688,7 +688,7 @@ rib_lookup_ipv4_route (struct prefix_ipv4 *p, union sockunion * qgate)
           char gate_buf[INET_ADDRSTRLEN], rgate_buf[INET_ADDRSTRLEN], qgate_buf[INET_ADDRSTRLEN];
           inet_ntop (AF_INET, &nexthop->gate.ipv4.s_addr, gate_buf, INET_ADDRSTRLEN);
           inet_ntop (AF_INET, &nexthop->rgate.ipv4.s_addr, rgate_buf, INET_ADDRSTRLEN);
-          inet_ntop (AF_INET, &qgate->sin.sin_addr.s_addr, qgate_buf, INET_ADDRSTRLEN);
+          inet_ntop (AF_INET, &sockunion2ip (qgate), qgate_buf, INET_ADDRSTRLEN);
           zlog_debug ("%s: qgate == %s, gate == %s, rgate == %s", __func__, qgate_buf, gate_buf, rgate_buf);
         }
         return ZEBRA_RIB_FOUND_NOGATE;