[support] How do we ensure the route_add() function do correctly?
Jong-Hyouk Lee
jonghyouk at gmail.com
Tue Oct 20 22:40:35 JST 2009
Hi, all.
UMIP code involves and uses functions defined in rtnl.h in order to
control routing tables. I have a simple question about the functions.
For instance, when we use "route_add()" in order to add a routing
entry, how can we ensure it has been done successfully? I know the
function has a return value to check its operation. However, it is
only true when the root account executes it. I mean if a normal user
executes it, there is no error mechanism as I know. Is there any other
ways to do it?
I used the following code for test it.
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "libnetlink.c"
#include "debug.c"
#include "rtnl.c"
int main(void)
{
int result = 0;
char addr[128];
const struct in6_addr *st_dest;
memset(addr, 0x00, sizeof(addr));
inet_pton(AF_INET6, "2010:1:2:3::77", (void *)&addr);
st_dest = (void *)&addr;
result = route_add(2, RT_TABLE_MAIN, RTPROT_STATIC, 0, 99, NULL,
0, st_dest, 64, NULL);
if(result)
printf("Done: route_add()\n");
return(0);
}
Many thanks.
--
IMARA Team, INRIA, France.
Jong-Hyouk Lee.
#email: jonghyouk (at) gmail (dot) com || jong-hyouk.lee (at) inria (dot) fr
#webpage: http://hurryon.googlepages.com/
More information about the Support
mailing list