switch (pfx_un1.family) {
case AF_INET:
- if (!IPV4_ADDR_SAME(&pfx_un1.u.prefix4.s_addr,
- &pfx_un2.u.prefix4.s_addr))
+ if (!IPV4_ADDR_SAME(&pfx_un1.u.prefix4,
+ &pfx_un2.u.prefix4))
return 0;
break;
case AF_INET6:
/* Self-originated packet should be discarded silently. */
if (eigrp_if_lookup_by_local_addr(eigrp, NULL, iph->ip_src)
- || (IPV4_ADDR_SAME(&iph->ip_src.s_addr, &ei->address->u.prefix4))) {
+ || (IPV4_ADDR_SAME(&iph->ip_src, &ei->address->u.prefix4))) {
if (IS_DEBUG_EIGRP_TRANSMIT(0, RECV))
zlog_debug(
"eigrp_read[%s]: Dropping self-originated packet",
if (p1->family == p2->family && p1->prefixlen == p2->prefixlen) {
if (p1->family == AF_INET)
- if (IPV4_ADDR_SAME(&p1->u.prefix4.s_addr,
- &p2->u.prefix4.s_addr))
+ if (IPV4_ADDR_SAME(&p1->u.prefix4, &p2->u.prefix4))
return 1;
if (p1->family == AF_INET6)
if (IPV6_ADDR_SAME(&p1->u.prefix6.s6_addr,
#define IPV4_MAX_BITLEN 32
#define IPV4_MAX_PREFIXLEN 32
#define IPV4_ADDR_CMP(D,S) memcmp ((D), (S), IPV4_MAX_BYTELEN)
-#define IPV4_ADDR_SAME(D,S) (memcmp ((D), (S), IPV4_MAX_BYTELEN) == 0)
-#define IPV4_ADDR_COPY(D,S) memcpy ((D), (S), IPV4_MAX_BYTELEN)
+
+static inline bool ipv4_addr_same(const struct in_addr *a,
+ const struct in_addr *b)
+{
+ return (a->s_addr == b->s_addr);
+}
+#define IPV4_ADDR_SAME(A,B) ipv4_addr_same((A), (B))
+
+static inline void ipv4_addr_copy(struct in_addr *dst,
+ const struct in_addr *src)
+{
+ dst->s_addr = src->s_addr;
+}
+#define IPV4_ADDR_COPY(D,S) ipv4_addr_copy((D), (S))
#define IPV4_NET0(a) ((((u_int32_t) (a)) & 0xff000000) == 0x00000000)
#define IPV4_NET127(a) ((((u_int32_t) (a)) & 0xff000000) == 0x7f000000)
if (flag == OSPF_SEND_PACKET_INDIRECT)
zlog_warn(
"* LS-Update is directly sent on NBMA network.");
- if (IPV4_ADDR_SAME(&oi->address->u.prefix4, &p.prefix.s_addr))
+ if (IPV4_ADDR_SAME(&oi->address->u.prefix4, &p.prefix))
zlog_warn("* LS-Update is sent to myself.");
}
break;
}
for (ALL_NEXTHOPS(re->nexthop, nexthop))
- if (IPV4_ADDR_SAME(&nexthop->gate.ipv4, gate)
+ if (IPV4_ADDR_SAME(&nexthop->gate.ipv4, &gate->ipv4)
|| IPV6_ADDR_SAME(&nexthop->gate.ipv6,
gate)) {
same = re;
for (si = rn->info; si; si = si->next) {
if (type == si->type
&& (!gate || ((afi == AFI_IP
- && IPV4_ADDR_SAME(gate, &si->addr.ipv4))
+ && IPV4_ADDR_SAME(&gate->ipv4, &si->addr.ipv4))
|| (afi == AFI_IP6
&& IPV6_ADDR_SAME(gate, &si->addr.ipv6))))
&& (!strcmp (ifname ? ifname : "", si->ifname))) {
for (si = rn->info; si; si = si->next)
if (type == si->type
&& (!gate || ((afi == AFI_IP
- && IPV4_ADDR_SAME(gate, &si->addr.ipv4))
+ && IPV4_ADDR_SAME(&gate->ipv4, &si->addr.ipv4))
|| (afi == AFI_IP6
&& IPV6_ADDR_SAME(gate, &si->addr.ipv6))))
&& (!strcmp(ifname ? ifname : "", si->ifname))