diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-08-24 08:20:47 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-09-01 13:20:18 +0200 |
commit | 3b1098beed5c294746a9203b5de3c9da82c25d76 (patch) | |
tree | 3699ec6b1ddfce59ed491c795731b1b6d305f497 /zebra/rtread_getmsg.c | |
parent | zebra: Refactor rib_delete_ipv[4|6] (diff) | |
download | frr-3b1098beed5c294746a9203b5de3c9da82c25d76.tar.xz frr-3b1098beed5c294746a9203b5de3c9da82c25d76.zip |
zebra: Refactor rib_add_ipv[4|6] to a common function
rib_add_ipv[4|6] both were essentially the same function
combine and refactor everywhere.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'zebra/rtread_getmsg.c')
-rw-r--r-- | zebra/rtread_getmsg.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/zebra/rtread_getmsg.c b/zebra/rtread_getmsg.c index 9defa49bf..0facc1a19 100644 --- a/zebra/rtread_getmsg.c +++ b/zebra/rtread_getmsg.c @@ -70,28 +70,30 @@ static void handle_route_entry (mib2_ipRouteEntry_t *routeEntry) { - struct prefix_ipv4 prefix; - struct in_addr tmpaddr, gateway; - u_char zebra_flags = 0; + struct prefix prefix; + struct in_addr tmpaddr, gateway; + union g_addr *ggateway; + u_char zebra_flags = 0; - if (routeEntry->ipRouteInfo.re_ire_type & IRE_CACHETABLE) - return; + if (routeEntry->ipRouteInfo.re_ire_type & IRE_CACHETABLE) + return; - if (routeEntry->ipRouteInfo.re_ire_type & IRE_HOST_REDIRECT) - zebra_flags |= ZEBRA_FLAG_SELFROUTE; + if (routeEntry->ipRouteInfo.re_ire_type & IRE_HOST_REDIRECT) + zebra_flags |= ZEBRA_FLAG_SELFROUTE; - prefix.family = AF_INET; + prefix.family = AF_INET; - tmpaddr.s_addr = routeEntry->ipRouteDest; - prefix.prefix = tmpaddr; + tmpaddr.s_addr = routeEntry->ipRouteDest; + prefix.u.prefix4 = tmpaddr; - tmpaddr.s_addr = routeEntry->ipRouteMask; - prefix.prefixlen = ip_masklen (tmpaddr); + tmpaddr.s_addr = routeEntry->ipRouteMask; + prefix.prefixlen = ip_masklen (tmpaddr); - gateway.s_addr = routeEntry->ipRouteNextHop; + gateway.s_addr = routeEntry->ipRouteNextHop; + ggateway = (union g_addr *)&gateway; - rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &prefix, - &gateway, NULL, 0, VRF_DEFAULT, 0, 0, 0, 0, SAFI_UNICAST); + rib_add (AFI_IP, SAFI_UNICAST, VRF_DEFAULT, ZEBRA_ROUTE_KERNEL, 0, + zebra_flags, &prefix, ggateway, NULL, 0, 0, 0, 0, 0); } void |