diff options
author | Maciej Żenczykowski <maze@google.com> | 2020-01-21 23:47:42 -0800 |
---|---|---|
committer | Maciej Żenczykowski <maze@google.com> | 2020-01-26 06:35:30 -0800 |
commit | 9943ed2597a1589d39c9789f1ff16d86a5b75970 (patch) | |
tree | 31c5fb7e1d0688ce4b1ad6bfdaa3658e7d635634 /libnetutils | |
parent | d66e442c21cf5d0b06524551f7bf5db94487033b (diff) | |
download | core-9943ed2597a1589d39c9789f1ff16d86a5b75970.tar.gz |
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
Diffstat (limited to 'libnetutils')
-rw-r--r-- | libnetutils/ifc_utils.c | 9 | ||||
-rw-r--r-- | libnetutils/include/netutils/ifc.h | 5 |
2 files changed, 9 insertions, 5 deletions
diff --git a/libnetutils/ifc_utils.c b/libnetutils/ifc_utils.c index 8212eba29..5999e39ba 100644 --- a/libnetutils/ifc_utils.c +++ b/libnetutils/ifc_utils.c @@ -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); } /* diff --git a/libnetutils/include/netutils/ifc.h b/libnetutils/include/netutils/ifc.h index 3b272343d..ee896ac08 100644 --- a/libnetutils/include/netutils/ifc.h +++ b/libnetutils/include/netutils/ifc.h @@ -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, |