From 1b58d970ca7e98ddfd582ca1d36e2954520aec33 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 8 Nov 2016 21:12:21 +0200 Subject: [PATCH] net: ipv6: Move unspecified address getter to ipv6.c More logical place for net_ipv6_unspecified_address() is in ipv6.c instead of net_if.c. Removing the net_if_ipv6_unspecified_addr() variant as it is no longer needed. Change-Id: Ib5b4f6748030a8bf50fb848a87eef2968e2bcbc8 Signed-off-by: Jukka Rissanen --- include/net/yaip/net_if.h | 7 ------- include/net/yaip/net_ip.h | 7 +------ net/yaip/ipv6.c | 9 ++++++++- net/yaip/net_if.c | 8 +------- net/yaip/rpl.c | 2 +- tests/net/ip-addr/src/main.c | 2 +- 6 files changed, 12 insertions(+), 23 deletions(-) diff --git a/include/net/yaip/net_if.h b/include/net/yaip/net_if.h index a42d95b3de0..ec429c4f971 100644 --- a/include/net/yaip/net_if.h +++ b/include/net/yaip/net_if.h @@ -806,13 +806,6 @@ static inline uint32_t net_if_ipv6_get_retrans_timer(struct net_if *iface) const struct in6_addr *net_if_ipv6_select_src_addr(struct net_if *iface, struct in6_addr *dst); -/** - * @brief Return IPv6 any address (all zeros, ::) - * - * @return IPv6 any address with all bits set to zero. - */ -const struct in6_addr *net_if_ipv6_unspecified_addr(void); - /** * @brief Get a IPv6 link local address in a given state. * diff --git a/include/net/yaip/net_ip.h b/include/net/yaip/net_ip.h index 78c5cc7c295..23970436a8c 100644 --- a/include/net/yaip/net_ip.h +++ b/include/net/yaip/net_ip.h @@ -471,17 +471,12 @@ static inline bool net_is_ipv6_ll_addr(const struct in6_addr *addr) ((addr->s6_addr[1]) == 0x80); } -const struct in6_addr *net_if_ipv6_unspecified_addr(void); - /** * @brief Return pointer to any (all bits zeros) IPv6 address. * * @return Any IPv6 address. */ -static inline const struct in6_addr *net_ipv6_unspecified_address(void) -{ - return net_if_ipv6_unspecified_addr(); -} +const struct in6_addr *net_ipv6_unspecified_address(void); /** * @brief Return pointer to any (all bits zeros) IPv4 address. diff --git a/net/yaip/ipv6.c b/net/yaip/ipv6.c index 8051d4ffb68..f04f3ef97aa 100644 --- a/net/yaip/ipv6.c +++ b/net/yaip/ipv6.c @@ -285,6 +285,13 @@ struct in6_addr *net_ipv6_nbr_lookup_by_index(struct net_if *iface, } #endif /* CONFIG_NET_IPV6_ND */ +const struct in6_addr *net_ipv6_unspecified_address(void) +{ + static const struct in6_addr addr = IN6ADDR_ANY_INIT; + + return &addr; +} + struct net_buf *net_ipv6_create_raw(struct net_buf *buf, uint16_t reserve, const struct in6_addr *src, @@ -1394,7 +1401,7 @@ int net_ipv6_send_ns(struct net_if *iface, if (is_my_address) { /* DAD */ net_ipaddr_copy(&NET_IPV6_BUF(buf)->src, - net_if_ipv6_unspecified_addr()); + net_ipv6_unspecified_address()); NET_IPV6_BUF(buf)->len[1] -= llao_len; diff --git a/net/yaip/net_if.c b/net/yaip/net_if.c index 913e0261463..ee7e1b82cec 100644 --- a/net/yaip/net_if.c +++ b/net/yaip/net_if.c @@ -695,12 +695,6 @@ struct net_if_router *net_if_ipv6_router_add(struct net_if *iface, return NULL; } -const struct in6_addr *net_if_ipv6_unspecified_addr(void) -{ - static const struct in6_addr addr = IN6ADDR_ANY_INIT; - - return &addr; -} struct in6_addr *net_if_ipv6_get_ll(struct net_if *iface, enum net_addr_state addr_state) { @@ -892,7 +886,7 @@ const struct in6_addr *net_if_ipv6_select_src_addr(struct net_if *dst_iface, } if (!src) { - return net_if_ipv6_unspecified_addr(); + return net_ipv6_unspecified_address(); } return src; diff --git a/net/yaip/rpl.c b/net/yaip/rpl.c index e3fb7c1db18..cbe6da6c3f1 100644 --- a/net/yaip/rpl.c +++ b/net/yaip/rpl.c @@ -2970,7 +2970,7 @@ int net_rpl_dao_send(struct net_if *iface, src = net_if_ipv6_select_src_addr(iface, dst); - if (net_ipv6_addr_cmp(src, net_if_ipv6_unspecified_addr())) { + if (net_ipv6_addr_cmp(src, net_ipv6_unspecified_address())) { NET_DBG("Invalid src addr %s found", net_sprint_ipv6_addr(src)); return -EINVAL; diff --git a/tests/net/ip-addr/src/main.c b/tests/net/ip-addr/src/main.c index b089eb510bc..3b3d2235230 100644 --- a/tests/net/ip-addr/src/main.c +++ b/tests/net/ip-addr/src/main.c @@ -328,7 +328,7 @@ static bool run_tests(void) return false; } - if (memcmp(net_if_ipv6_unspecified_addr(), &any, sizeof(any))) { + if (memcmp(net_ipv6_unspecified_address(), &any, sizeof(any))) { printk("My IPv6 unspecified address check failed\n"); return false; }