Add nl_sendgetaddr and nl_sendgetaddrs variants for v4/v6.
This commit is contained in:
parent
77ce7b9a6c
commit
704e414171
@ -421,7 +421,7 @@ static int ipbcpfx_clear_others(int fd, uint32_t ipaddr, uint32_t bcast,
|
||||
.prefixlen = prefixlen, .already_ok = false };
|
||||
ssize_t ret;
|
||||
uint32_t seq = ifset_nl_seq++;
|
||||
if (nl_sendgetaddr(fd, seq, client_config.ifindex) < 0)
|
||||
if (nl_sendgetaddr4(fd, seq, client_config.ifindex) < 0)
|
||||
return -1;
|
||||
|
||||
do {
|
||||
|
34
ndhc/nl.c
34
ndhc/nl.c
@ -197,7 +197,8 @@ int nl_sendgetlink(int fd, int seq, int ifindex)
|
||||
return nl_sendgetlink_do(fd, seq, ifindex, 1);
|
||||
}
|
||||
|
||||
int nl_sendgetaddr(int fd, int seq, int ifindex)
|
||||
static int nl_sendgetaddr_do(int fd, int seq, int ifindex, int by_ifindex,
|
||||
int afamily, int by_afamily)
|
||||
{
|
||||
char nlbuf[512];
|
||||
struct nlmsghdr *nlh = (struct nlmsghdr *)nlbuf;
|
||||
@ -211,8 +212,10 @@ int nl_sendgetaddr(int fd, int seq, int ifindex)
|
||||
nlh->nlmsg_seq = seq;
|
||||
|
||||
ifaddrmsg = NLMSG_DATA(nlh);
|
||||
ifaddrmsg->ifa_family = AF_INET;
|
||||
ifaddrmsg->ifa_index = ifindex;
|
||||
if (by_afamily)
|
||||
ifaddrmsg->ifa_family = afamily;
|
||||
if (by_ifindex)
|
||||
ifaddrmsg->ifa_index = ifindex;
|
||||
|
||||
struct sockaddr_nl addr = {
|
||||
.nl_family = AF_NETLINK,
|
||||
@ -232,6 +235,31 @@ retry_sendto:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nl_sendgetaddrs(int fd, int seq)
|
||||
{
|
||||
return nl_sendgetaddr_do(fd, seq, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
int nl_sendgetaddrs4(int fd, int seq)
|
||||
{
|
||||
return nl_sendgetaddr_do(fd, seq, 0, 0, AF_INET, 1);
|
||||
}
|
||||
|
||||
int nl_sendgetaddrs6(int fd, int seq)
|
||||
{
|
||||
return nl_sendgetaddr_do(fd, seq, 0, 0, AF_INET6, 1);
|
||||
}
|
||||
|
||||
int nl_sendgetaddr4(int fd, int seq, int ifindex)
|
||||
{
|
||||
return nl_sendgetaddr_do(fd, seq, ifindex, 1, AF_INET, 1);
|
||||
}
|
||||
|
||||
int nl_sendgetaddr6(int fd, int seq, int ifindex)
|
||||
{
|
||||
return nl_sendgetaddr_do(fd, seq, ifindex, 1, AF_INET6, 1);
|
||||
}
|
||||
|
||||
int nl_open(int nltype, int nlgroup, int *nlportid)
|
||||
{
|
||||
int fd;
|
||||
|
@ -56,7 +56,11 @@ int nl_foreach_nlmsg(char *buf, size_t blen, uint32_t seq,
|
||||
nlmsg_foreach_fn pfn, void *fnarg);
|
||||
int nl_sendgetlinks(int fd, int seq);
|
||||
int nl_sendgetlink(int fd, int seq, int ifindex);
|
||||
int nl_sendgetaddr(int fd, int seq, int ifindex);
|
||||
int nl_sendgetaddr4(int fd, int seq, int ifindex);
|
||||
int nl_sendgetaddr6(int fd, int seq, int ifindex);
|
||||
int nl_sendgetaddrs(int fd, int seq);
|
||||
int nl_sendgetaddrs4(int fd, int seq);
|
||||
int nl_sendgetaddrs6(int fd, int seq);
|
||||
|
||||
int nl_open(int nltype, int nlgroup, int *nlportid);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user