linux kernel - Access IF_RA_MANAGED and IF_RA_OTHERCONF from userspace -
i need access if_ra_managed
, if_ra_otherconf
(in6_dev->if_flags
) userspace.
does know how can it?
thanks
i think can pf_netlink
socket.
the ip
utility, part of iproute2
has monitor mode appears show information, example:
ajw@rapunzel:/tmp/iproute-20100519/ip > ip -6 monitor 2: eth0 inet6 2001:xxxx:xxxx:0:xxxx:xxxx:xxxx:xxxx/64 scope global dynamic valid_lft 86400sec preferred_lft 14400sec prefix 2001:xxxx:xxxx::x/64 dev eth0 onlink autoconf valid 14400 preferred 131084
(some exact addresses removed paranoia's sake). don't have ras flags set on lan, i'm 99% sure show there too.
poking around strace
shows interesting calls seem be:
socket(pf_netlink, sock_raw, 0) = 3 setsockopt(3, sol_socket, so_sndbuf, [32768], 4) = 0 setsockopt(3, sol_socket, so_rcvbuf, [1048576], 4) = 0 bind(3, {sa_family=af_netlink, pid=0, groups=fffffff7}, 12) = 0 getsockname(3, {sa_family=af_netlink, pid=7151, groups=fffffff7}, [12]) = 0 time(null) = 1309595579 send(3, "...", 20, 0) = 20 recvmsg(3, {msg_name(12)={sa_family=af_netlink, pid=0, groups=00000000}, msg_iov(1)=[{"...", 16384}], msg_controllen=0, msg_flags=0}, 0) = 864
the source iproute2
has file, ip/ipmonitor.c
, seems of work:
int print_prefix(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg); int accept_msg(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) { // snipped unrelated stuff if (n->nlmsg_type == rtm_newprefix) { if (prefix_banner) fprintf(fp, "[prefix]"); print_prefix(who, n, arg); return 0; } }
so think should able put solution using this.
Comments
Post a Comment