add nodad argument to ifc_act_on_address() and add it to header file
Test: atest Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ia45f00ecc5eae035ed2e25d5b73008acb77fa6c2
This commit is contained in:
parent
d66e442c21
commit
9943ed2597
2 changed files with 9 additions and 5 deletions
|
@ -257,8 +257,8 @@ int ifc_set_addr(const char *name, in_addr_t addr)
|
|||
*
|
||||
* Returns zero on success and negative errno on failure.
|
||||
*/
|
||||
int ifc_act_on_address(int action, const char *name, const char *address,
|
||||
int prefixlen) {
|
||||
int ifc_act_on_address(int action, const char* name, const char* address, int prefixlen,
|
||||
bool nodad) {
|
||||
int ifindex, s, len, ret;
|
||||
struct sockaddr_storage ss;
|
||||
int saved_errno;
|
||||
|
@ -311,6 +311,7 @@ int ifc_act_on_address(int action, const char *name, const char *address,
|
|||
|
||||
// Interface address message header.
|
||||
req.r.ifa_family = ss.ss_family;
|
||||
req.r.ifa_flags = nodad ? IFA_F_NODAD : 0;
|
||||
req.r.ifa_prefixlen = prefixlen;
|
||||
req.r.ifa_index = ifindex;
|
||||
|
||||
|
@ -363,12 +364,12 @@ int ifc_act_on_address(int action, const char *name, const char *address,
|
|||
|
||||
// Returns zero on success and negative errno on failure.
|
||||
int ifc_add_address(const char *name, const char *address, int prefixlen) {
|
||||
return ifc_act_on_address(RTM_NEWADDR, name, address, prefixlen);
|
||||
return ifc_act_on_address(RTM_NEWADDR, name, address, prefixlen, /*nodad*/ false);
|
||||
}
|
||||
|
||||
// Returns zero on success and negative errno on failure.
|
||||
int ifc_del_address(const char *name, const char * address, int prefixlen) {
|
||||
return ifc_act_on_address(RTM_DELADDR, name, address, prefixlen);
|
||||
return ifc_act_on_address(RTM_DELADDR, name, address, prefixlen, /*nodad*/ false);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
#ifndef _NETUTILS_IFC_H_
|
||||
#define _NETUTILS_IFC_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
|
@ -42,6 +43,8 @@ extern int ifc_reset_connections(const char *ifname, const int reset_mask);
|
|||
|
||||
extern int ifc_get_addr(const char *name, in_addr_t *addr);
|
||||
extern int ifc_set_addr(const char *name, in_addr_t addr);
|
||||
extern int ifc_act_on_address(int action, const char* name, const char* address, int prefixlen,
|
||||
bool nodad);
|
||||
extern int ifc_add_address(const char *name, const char *address,
|
||||
int prefixlen);
|
||||
extern int ifc_del_address(const char *name, const char *address,
|
||||
|
|
Loading…
Reference in a new issue