xref: /openbmc/linux/include/net/rpl.h (revision a7a29f9c361f8542604ef959ae6627f423b7a412)
18610c7c6SAlexander Aring /* SPDX-License-Identifier: GPL-2.0-or-later */
28610c7c6SAlexander Aring /*
38610c7c6SAlexander Aring  *  RPL implementation
48610c7c6SAlexander Aring  *
58610c7c6SAlexander Aring  *  Author:
68610c7c6SAlexander Aring  *  (C) 2020 Alexander Aring <alex.aring@gmail.com>
78610c7c6SAlexander Aring  */
88610c7c6SAlexander Aring 
98610c7c6SAlexander Aring #ifndef _NET_RPL_H
108610c7c6SAlexander Aring #define _NET_RPL_H
118610c7c6SAlexander Aring 
128610c7c6SAlexander Aring #include <linux/rpl.h>
138610c7c6SAlexander Aring 
14*a7a29f9cSAlexander Aring #if IS_ENABLED(CONFIG_IPV6_RPL_LWTUNNEL)
15*a7a29f9cSAlexander Aring extern int rpl_init(void);
16*a7a29f9cSAlexander Aring extern void rpl_exit(void);
17*a7a29f9cSAlexander Aring #else
18*a7a29f9cSAlexander Aring static inline int rpl_init(void)
19*a7a29f9cSAlexander Aring {
20*a7a29f9cSAlexander Aring 	return 0;
21*a7a29f9cSAlexander Aring }
22*a7a29f9cSAlexander Aring 
23*a7a29f9cSAlexander Aring static inline void rpl_exit(void) {}
24*a7a29f9cSAlexander Aring #endif
25*a7a29f9cSAlexander Aring 
268610c7c6SAlexander Aring /* Worst decompression memory usage ipv6 address (16) + pad 7 */
278610c7c6SAlexander Aring #define IPV6_RPL_SRH_WORST_SWAP_SIZE (sizeof(struct in6_addr) + 7)
288610c7c6SAlexander Aring 
298610c7c6SAlexander Aring static inline size_t ipv6_rpl_srh_alloc_size(unsigned char n)
308610c7c6SAlexander Aring {
318610c7c6SAlexander Aring 	return sizeof(struct ipv6_rpl_sr_hdr) +
328610c7c6SAlexander Aring 		((n + 1) * sizeof(struct in6_addr));
338610c7c6SAlexander Aring }
348610c7c6SAlexander Aring 
358610c7c6SAlexander Aring size_t ipv6_rpl_srh_size(unsigned char n, unsigned char cmpri,
368610c7c6SAlexander Aring 			 unsigned char cmpre);
378610c7c6SAlexander Aring 
388610c7c6SAlexander Aring void ipv6_rpl_srh_decompress(struct ipv6_rpl_sr_hdr *outhdr,
398610c7c6SAlexander Aring 			     const struct ipv6_rpl_sr_hdr *inhdr,
408610c7c6SAlexander Aring 			     const struct in6_addr *daddr, unsigned char n);
418610c7c6SAlexander Aring 
428610c7c6SAlexander Aring void ipv6_rpl_srh_compress(struct ipv6_rpl_sr_hdr *outhdr,
438610c7c6SAlexander Aring 			   const struct ipv6_rpl_sr_hdr *inhdr,
448610c7c6SAlexander Aring 			   const struct in6_addr *daddr, unsigned char n);
458610c7c6SAlexander Aring 
468610c7c6SAlexander Aring #endif /* _NET_RPL_H */
47