From: Simon Horman Date: Tue, 13 Aug 2024 13:33:47 +0000 (+0100) Subject: ipv6: Add ipv6_addr_{cpu_to_be32,be32_to_cpu} helpers X-Git-Tag: v6.12-rc1~232^2~244^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f40a455d01f80c6638be382d75cb1c4e7748d8af;p=thirdparty%2Fkernel%2Flinux.git ipv6: Add ipv6_addr_{cpu_to_be32,be32_to_cpu} helpers Add helpers to convert an ipv6 addr, expressed as an array of words, from CPU to big-endian byte order, and vice versa. No functional change intended. Compile tested only. Suggested-by: Andrew Lunn Link: https://lore.kernel.org/netdev/c7684349-535c-45a4-9a74-d47479a50020@lunn.ch/ Reviewed-by: Andrew Lunn Signed-off-by: Simon Horman Link: https://patch.msgid.link/20240813-ipv6_addr-helpers-v2-1-5c974f8cca3e@kernel.org Signed-off-by: Jakub Kicinski --- diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 88a8e554f7a12..e7113855a10fd 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -1365,4 +1365,16 @@ static inline void ip6_sock_set_recvpktinfo(struct sock *sk) release_sock(sk); } +#define IPV6_ADDR_WORDS 4 + +static inline void ipv6_addr_cpu_to_be32(__be32 *dst, const u32 *src) +{ + cpu_to_be32_array(dst, src, IPV6_ADDR_WORDS); +} + +static inline void ipv6_addr_be32_to_cpu(u32 *dst, const __be32 *src) +{ + be32_to_cpu_array(dst, src, IPV6_ADDR_WORDS); +} + #endif /* _NET_IPV6_H */