1 /** @file
2  @brief 6lowpan handler
3 
4  This is not to be included by the application.
5  */
6 
7 /*
8  * Copyright (c) 2016 Intel Corporation
9  *
10  * SPDX-License-Identifier: Apache-2.0
11  */
12 
13 #ifndef __NET_6LO_H
14 #define __NET_6LO_H
15 
16 #include <zephyr/sys/slist.h>
17 #include <zephyr/types.h>
18 
19 #include <zephyr/net/net_pkt.h>
20 #include "icmpv6.h"
21 
22 /**
23  *  @brief Compress IPv6 packet as per RFC 6282
24  *
25  *  @details After this IPv6 packet and next header(if UDP), headers
26  *  are compressed as per RFC 6282. After header compression data
27  *  will be adjusted according to remaining space in fragments.
28  *
29  *  @param Pointer to network packet
30  *  @param iphc true for IPHC compression, false for IPv6 dispatch header
31  *
32  *  @return header size difference on success (>= 0), negative errno otherwise
33  */
34 #if defined(CONFIG_NET_6LO)
35 int net_6lo_compress(struct net_pkt *pkt, bool iphc);
36 #else
net_6lo_compress(struct net_pkt * pkt,bool iphc)37 static inline int net_6lo_compress(struct net_pkt *pkt, bool iphc)
38 {
39 	ARG_UNUSED(pkt);
40 	ARG_UNUSED(iphc);
41 
42 	return 0;
43 }
44 #endif
45 
46 /**
47  *  @brief Uncompress IPv6 packet as per RFC 6282
48  *
49  *  @details After this IPv6 packet and next header(if UDP), headers
50  *  are uncompressed as per RFC 6282. After header uncompression data
51  *  will be adjusted according to remaining space in fragments.
52  *
53  *  @param Pointer to network packet
54  *
55  *  @return True on success, false otherwise
56  */
57 #if defined(CONFIG_NET_6LO)
58 bool net_6lo_uncompress(struct net_pkt *pkt);
59 #else
net_6lo_uncompress(struct net_pkt * pkt)60 static inline bool net_6lo_uncompress(struct net_pkt *pkt)
61 {
62 	ARG_UNUSED(pkt);
63 
64 	return true;
65 }
66 #endif
67 
68 /**
69  *  @brief Set 6lowpan context information
70  *
71  *  @details Set 6lowpan context information. This context information
72  *  will be used in IPv6 header compression and uncompression.
73  *
74  *  @return True on success, false otherwise
75  */
76 #if defined(CONFIG_NET_6LO_CONTEXT)
77 void net_6lo_set_context(struct net_if *iface,
78 			 struct net_icmpv6_nd_opt_6co *context);
79 #endif
80 
81 /**
82  *  @brief Return the header size difference after uncompression
83  *
84  * @details This will do a dry-run on uncompressing the headers.
85  *          The point is only to calculate the difference.
86  *
87  * @param Pointer to network packet
88  *
89  * @return header difference or INT_MAX in case of error.
90  */
91 #if defined(CONFIG_NET_6LO)
92 int net_6lo_uncompress_hdr_diff(struct net_pkt *pkt);
93 #endif
94 
95 #endif /* __NET_6LO_H */
96