[quagga-dev 8484] Query regarding zapi_ipv4_route(ZEBRA_IPV4_ROUTE_DELETE, .. , .. , .. )

subin manoj subinmanoj at gmail.com
Tue Jan 25 14:46:25 GMT 2011


Hello Quagga Team,

I am creating a daemon which tries to add and delete routes from the
Zebra/Quagga daemon. I have follwed the process thats used in other daemons
like RIP, OSPF to make my daemon. But now I am facing an issue in which I am
able to add routes to the zebra daemon using the
zapi_ipv4_route(ZEBRA_IPV4_ROUTE_ADD, .. , .. , .. ) but I am not able to
delete the route using the zapi_ipv4_route(ZEBRA_IPV4_ROUTE_DELETE, .. , ..
, .. ) function. Please find the extract of the code below. I have also
attached the code. I tried many ways but still unclear of the issue. It
would be really helpful if you can give me any pointers to solve this issue.
Thanks.

int my_ip_addr_delete(struct zclient *zclient) {
    my_ip_addr_modify(zclient, ZEBRA_IPV4_ROUTE_DELETE);
}

int my_ip_addr_add(struct zclient *zclient) {
    my_ip_addr_modify(zclient, ZEBRA_IPV4_ROUTE_ADD);
}

/*
here I am trying to add/ delete 10.34.45.56/8 with gateway 10.3.4.5 based on
ZEBRA_IPV4_ROUTE_ADD and ZEBRA_IPV4_ROUTE_DELETE
*/
int my_ip_addr_modify(struct zclient *zclient, int operation) {

    struct zapi_ipv4 zr;
    struct prefix_ipv4 p;
    struct in_addr newly_added_address;
    struct in_addr newly_added_nexthop_address;
    struct in_addr *ptr_newly_added_nexthop_address;
    unsigned int ifindex_value;
    int ret;

    memset((void*) &zr, 0, sizeof(zr));
    memset((void*) &p, 0, sizeof(p));

    p.family = AF_INET;
    p.prefixlen = 8;
    inet_pton(AF_INET, "10.34.45.56", &newly_added_address);
    inet_pton(AF_INET, "10.3.4.5", &newly_added_nexthop_address);

    p.prefix = newly_added_address;
    zr.type = ZEBRA_ROUTE_STATIC;
    zr.flags = 0;
    SET_FLAG (zr.message, ZAPI_MESSAGE_NEXTHOP);
    zr.nexthop_num = 1;
    ptr_newly_added_nexthop_address = &newly_added_nexthop_address;

    ret = zapi_ipv4_route(operation, zclient, &p, &zr);
    printf("Return val from %s is: %d \n",
            operation == ZEBRA_IPV4_ROUTE_ADD ? "ZEBRA_IPV4_ROUTE_ADD"
                    : "ZEBRA_IPV4_ROUTE_DELETE", ret);
    printf("Return val %d \n", ret);
    return 0;
}

void my_init() {
    int i;
    int ret_client_start;
    struct interface *ifp;

    /* Set default value to the zebra client structure. */
    zclient = zclient_new();
    zclient_init(zclient, ZEBRA_ROUTE_MY);
    /*
     * ret_client_start = zclient_start(zclient);
     *
     */

    /*    for (i = 0; i++ < ZEBRA_ROUTE_MAX;)
     if (i != ZEBRA_ROUTE_MY)
     zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, i);
*/

    /* zclient->ipv4_route_add = my_ip_addr_add;
    zclient->ipv4_route_delete = my_ip_addr_delete; */

    // Here I try to add and delete the route
    my_ip_addr_add(zclient);
    my_ip_addr_delete(zclient);

}

*Regards,*
*Subin*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quagga.net/pipermail/quagga-dev/attachments/20110125/c3087888/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: quagga_dev_src.c
Type: text/x-csrc
Size: 5372 bytes
Desc: not available
URL: <http://lists.quagga.net/pipermail/quagga-dev/attachments/20110125/c3087888/attachment-0001.bin>


More information about the Quagga-dev mailing list