/* RIPd to zebra command interface. */ void rip_zebra_ipv4_add (struct prefix_ipv4 *p, struct in_addr *nexthop, u_int32_t metric, u_char distance) { struct zapi_ipv4 api; if (zclient->redist[ZEBRA_ROUTE_RIP]) { api.type = ZEBRA_ROUTE_RIP; api.flags = 0; api.message = 0; SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP); api.nexthop_num = 1; api.nexthop = &nexthop; api.ifindex_num = 0; SET_FLAG (api.message, ZAPI_MESSAGE_METRIC); api.metric = metric; if (distance && distance != ZEBRA_RIP_DISTANCE_DEFAULT) { SET_FLAG (api.message, ZAPI_MESSAGE_DISTANCE); api.distance = distance; } zapi_ipv4_add (zclient, p, &api); rip_global_route_changes++; } }
/* RIPd to zebra command interface. */ void rip_zebra_ipv4_add (struct prefix_ipv4 *p, struct in_addr *nexthop, u_int32_t metric, u_char distance) { struct zapi_ipv4 api; if (zclient->redist[ZEBRA_ROUTE_RIP]) { api.type = ZEBRA_ROUTE_RIP; api.flags = 0; api.message = 0; SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP); api.nexthop_num = 1; api.nexthop = &nexthop; api.ifindex_num = 0; SET_FLAG (api.message, ZAPI_MESSAGE_METRIC); /* This modify is for the routing table hop count show on web, actually we should use "api.metric = metric - ifp->metric", but it is too complicated(^..^) and "- 1" is enough to use for now! Lili. 2007-07-06 */ #if 0 api.metric = metric; #else api.metric = metric - 1; #endif if (distance && distance != ZEBRA_RIP_DISTANCE_DEFAULT) { SET_FLAG (api.message, ZAPI_MESSAGE_DISTANCE); api.distance = distance; } zapi_ipv4_add (zclient, p, &api); rip_global_route_changes++; } }
/* IPv4 route add and delete test. */ void zebra_test_ipv4 (int command, int type, char *prefix, char *gateway, u_char distance) { struct zapi_ipv4 api; struct prefix_ipv4 p; struct in_addr gate; struct in_addr *gpnt; str2prefix_ipv4 (prefix, &p); inet_aton (gateway, &gate); gpnt = &gate; api.type = type; api.flags = 0; api.message = 0; SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP); api.nexthop_num = 1; api.nexthop = &gpnt; api.ifindex_num = 0; if (distance) { SET_FLAG (api.message, ZAPI_MESSAGE_DISTANCE); api.distance = distance; } switch (command) { case ZEBRA_IPV4_ROUTE_ADD: zapi_ipv4_add (zclient, &p, &api); break; case ZEBRA_IPV4_ROUTE_DELETE: zapi_ipv4_delete (zclient, &p, &api); break; } }