diff options
Diffstat (limited to 'babeld/babel_interface.c')
| -rw-r--r-- | babeld/babel_interface.c | 83 |
1 files changed, 45 insertions, 38 deletions
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 41391c51ac..43ed97cf17 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -177,10 +177,11 @@ babel_interface_address_delete (ZAPI_CALLBACK_ARGS) if (prefix->family == AF_INET) { flush_interface_routes(ifc->ifp, 0); babel_ifp = babel_get_if_nfo(ifc->ifp); - if (babel_ifp->ipv4 != NULL - && memcmp(babel_ifp->ipv4, &prefix->u.prefix4, 4) == 0) { - free(babel_ifp->ipv4); - babel_ifp->ipv4 = NULL; + if (babel_ifp->ipv4 != NULL + && memcmp(babel_ifp->ipv4, &prefix->u.prefix4, IPV4_MAX_BYTELEN) + == 0) { + free(babel_ifp->ipv4); + babel_ifp->ipv4 = NULL; } } @@ -825,9 +826,11 @@ is_interface_ll_address(struct interface *ifp, const unsigned char *address) return 0; FOR_ALL_INTERFACES_ADDRESSES(ifp, connected, node) { - if(connected->address->family == AF_INET6 && - memcmp(&connected->address->u.prefix6, address, 16) == 0) - return 1; + if (connected->address->family == AF_INET6 + && memcmp(&connected->address->u.prefix6, address, + IPV6_MAX_BYTELEN) + == 0) + return 1; } return 0; @@ -941,13 +944,13 @@ static int babel_prefix_eq(struct prefix *prefix, unsigned char *p, int plen) { if(prefix->family == AF_INET6) { - if(prefix->prefixlen != plen || - memcmp(&prefix->u.prefix6, p, 16) != 0) - return 0; + if (prefix->prefixlen != plen + || memcmp(&prefix->u.prefix6, p, IPV6_MAX_BYTELEN) != 0) + return 0; } else if(prefix->family == AF_INET) { - if(plen < 96 || !v4mapped(p) || prefix->prefixlen != plen - 96 || - memcmp(&prefix->u.prefix4, p + 12, 4) != 0) - return 0; + if (plen < 96 || !v4mapped(p) || prefix->prefixlen != plen - 96 + || memcmp(&prefix->u.prefix4, p + 12, IPV4_MAX_BYTELEN) != 0) + return 0; } else { return 0; } @@ -959,31 +962,35 @@ static void show_babel_routes_sub(struct babel_route *route, struct vty *vty, struct prefix *prefix) { - const unsigned char *nexthop = - memcmp(route->nexthop, route->neigh->address, 16) == 0 ? - NULL : route->nexthop; - char channels[100]; - - if(prefix && !babel_prefix_eq(prefix, route->src->prefix, route->src->plen)) - return; - - if(route->channels[0] == 0) - channels[0] = '\0'; - else { - int k, j = 0; - snprintf(channels, sizeof(channels), " chan ("); - j = strlen(channels); - for(k = 0; k < DIVERSITY_HOPS; k++) { - if(route->channels[k] == 0) - break; - if(k > 0) - channels[j++] = ','; - snprintf(channels + j, 100 - j, "%u", route->channels[k]); - j = strlen(channels); - } - snprintf(channels + j, 100 - j, ")"); - if(k == 0) - channels[0] = '\0'; + const unsigned char *nexthop = + memcmp(route->nexthop, route->neigh->address, IPV6_MAX_BYTELEN) + == 0 + ? NULL + : route->nexthop; + char channels[100]; + + if (prefix + && !babel_prefix_eq(prefix, route->src->prefix, route->src->plen)) + return; + + if (route->channels[0] == 0) + channels[0] = '\0'; + else { + int k, j = 0; + snprintf(channels, sizeof(channels), " chan ("); + j = strlen(channels); + for (k = 0; k < DIVERSITY_HOPS; k++) { + if (route->channels[k] == 0) + break; + if (k > 0) + channels[j++] = ','; + snprintf(channels + j, 100 - j, "%u", + route->channels[k]); + j = strlen(channels); + } + snprintf(channels + j, 100 - j, ")"); + if (k == 0) + channels[0] = '\0'; } vty_out (vty, |
