mirror of
https://github.com/apache/nuttx.git
synced 2026-06-11 05:03:47 +08:00
net/procfs: Simplify logic for tcp/udp stats
By: 1. Take out net_ip_binding_laddr/raddr macro 2. INET6_ADDRSTRLEN is long enough for all address buffer and no need to add 0 to the end of buffer since inet_ntop will do so Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
@@ -421,6 +421,33 @@ extern "C"
|
||||
(ipv6addr)->s6_addr16[4] == 0 && \
|
||||
(ipv6addr)->s6_addr16[5] == 0xffff)
|
||||
|
||||
/****************************************************************************
|
||||
* Macro: net_ip_binding_laddr, net_ip_binding_raddr
|
||||
*
|
||||
* Description:
|
||||
* Get the laddr/raddr pointer form an ip_binding_u.
|
||||
*
|
||||
* Input Parameters:
|
||||
* u - The union of address binding.
|
||||
* domain - The domain of address.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
|
||||
# define net_ip_binding_laddr(u, domain) \
|
||||
(((domain) == PF_INET) ? (FAR void *)(&(u)->ipv4.laddr) : \
|
||||
(FAR void *)(&(u)->ipv6.laddr))
|
||||
# define net_ip_binding_raddr(u, domain) \
|
||||
(((domain) == PF_INET) ? (FAR void *)(&(u)->ipv4.raddr) : \
|
||||
(FAR void *)(&(u)->ipv6.raddr))
|
||||
#elif defined(CONFIG_NET_IPv4)
|
||||
# define net_ip_binding_laddr(u, domain) ((FAR void *)(&(u)->ipv4.laddr))
|
||||
# define net_ip_binding_raddr(u, domain) ((FAR void *)(&(u)->ipv4.raddr))
|
||||
#else
|
||||
# define net_ip_binding_laddr(u, domain) ((FAR void *)(&(u)->ipv6.laddr))
|
||||
# define net_ip_binding_raddr(u, domain) ((FAR void *)(&(u)->ipv6.raddr))
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Macro: net_ipv4addr_copy, net_ipv4addr_hdrcopy, net_ipv6addr_copy, and
|
||||
* net_ipv6addr_hdrcopy
|
||||
|
||||
Reference in New Issue
Block a user