Commit 7230121b authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Make kernel_addresses take an interface name and index.

parent 1f3e1cba
......@@ -57,6 +57,6 @@ int kernel_route(int operation, const unsigned char *dest, unsigned short plen,
unsigned int newmetric);
int kernel_routes(struct kernel_route *routes, int maxroutes);
int kernel_callback(int (*fn)(int, void*), void *closure);
int kernel_addresses(struct kernel_route *routes, int maxroutes);
int kernel_addresses(char *ifname, int ifindex,
struct kernel_route *routes, int maxroutes);
int gettime(struct timeval *tv);
......@@ -1120,12 +1120,14 @@ filter_addresses(struct nlmsghdr *nh, void *data)
int len;
struct ifaddrmsg *ifa;
char ifname[IFNAMSIZ];
int ifindex = 0;
if (data) {
void **args = (void **)data;
maxroutes = *(int *)args[0];
routes = (struct kernel_route*)args[1];
found = (int *)args[2];
ifindex = args[3] ? 0 : *(int*)args[3];
}
len = nh->nlmsg_len;
......@@ -1147,6 +1149,9 @@ filter_addresses(struct nlmsghdr *nh, void *data)
if (IN6_IS_ADDR_LINKLOCAL(&addr))
return 0;
if (ifindex && ifa->ifa_index != ifindex)
return 0;
kdebugf("found address on interface %s(%d): %s\n",
if_indextoname(ifa->ifa_index, ifname), ifa->ifa_index,
format_address(addr.s6_addr));
......@@ -1199,11 +1204,12 @@ filter_netlink(struct nlmsghdr *nh, void *data)
}
int
kernel_addresses(struct kernel_route *routes, int maxroutes)
kernel_addresses(char *ifname, int ifindex,
struct kernel_route *routes, int maxroutes)
{
int maxr = maxroutes;
int found = 0;
void *data[] = { &maxr, routes, &found, NULL};
void *data[] = { &maxr, routes, &found, &ifindex, NULL};
struct rtgenmsg g;
int rc;
......
/*
Copyright (c) 2007 by Grégoire Henry
Copyright (c) 2008 by Juliusz Chroboczek
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......@@ -600,7 +601,8 @@ socket_read(int sock)
}
int
kernel_addresses(struct kernel_route *routes, int maxroutes)
kernel_addresses(char *ifname, int ifindex,
struct kernel_route *routes, int maxroutes)
{
errno = ENOSYS;
return -1;
......
......@@ -135,7 +135,7 @@ check_xroutes(int send_updates)
if(routes == NULL)
return -1;
rc = kernel_addresses(routes, maxroutes);
rc = kernel_addresses(NULL, 0, routes, maxroutes);
if(rc < 0) {
perror("kernel_addresses");
numroutes = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment