Example #1
0
/* 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;
    }
}
Example #2
0
void
rip_zebra_ipv4_delete (struct prefix_ipv4 *p, struct in_addr *nexthop, 
		       u_int32_t metric)
{
  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;

      zapi_ipv4_delete (zclient, p, &api);

      rip_global_route_changes++;
    }
}