xref: /linux/include/net/6lowpan.h (revision 8788a1ee)
1cefc8c8aSAlexander Aring /*
2cefc8c8aSAlexander Aring  * Copyright 2011, Siemens AG
3cefc8c8aSAlexander Aring  * written by Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
4cefc8c8aSAlexander Aring  */
5cefc8c8aSAlexander Aring 
6cefc8c8aSAlexander Aring /*
7cefc8c8aSAlexander Aring  * Based on patches from Jon Smirl <jonsmirl@gmail.com>
8cefc8c8aSAlexander Aring  * Copyright (c) 2011 Jon Smirl <jonsmirl@gmail.com>
9cefc8c8aSAlexander Aring  *
10cefc8c8aSAlexander Aring  * This program is free software; you can redistribute it and/or modify
11cefc8c8aSAlexander Aring  * it under the terms of the GNU General Public License version 2
12cefc8c8aSAlexander Aring  * as published by the Free Software Foundation.
13cefc8c8aSAlexander Aring  *
14cefc8c8aSAlexander Aring  * This program is distributed in the hope that it will be useful,
15cefc8c8aSAlexander Aring  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16cefc8c8aSAlexander Aring  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17cefc8c8aSAlexander Aring  * GNU General Public License for more details.
18cefc8c8aSAlexander Aring  *
19cefc8c8aSAlexander Aring  * You should have received a copy of the GNU General Public License along
20cefc8c8aSAlexander Aring  * with this program; if not, write to the Free Software Foundation, Inc.,
21cefc8c8aSAlexander Aring  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22cefc8c8aSAlexander Aring  */
23cefc8c8aSAlexander Aring 
24cefc8c8aSAlexander Aring /* Jon's code is based on 6lowpan implementation for Contiki which is:
25cefc8c8aSAlexander Aring  * Copyright (c) 2008, Swedish Institute of Computer Science.
26cefc8c8aSAlexander Aring  * All rights reserved.
27cefc8c8aSAlexander Aring  *
28cefc8c8aSAlexander Aring  * Redistribution and use in source and binary forms, with or without
29cefc8c8aSAlexander Aring  * modification, are permitted provided that the following conditions
30cefc8c8aSAlexander Aring  * are met:
31cefc8c8aSAlexander Aring  * 1. Redistributions of source code must retain the above copyright
32cefc8c8aSAlexander Aring  *    notice, this list of conditions and the following disclaimer.
33cefc8c8aSAlexander Aring  * 2. Redistributions in binary form must reproduce the above copyright
34cefc8c8aSAlexander Aring  *    notice, this list of conditions and the following disclaimer in the
35cefc8c8aSAlexander Aring  *    documentation and/or other materials provided with the distribution.
36cefc8c8aSAlexander Aring  * 3. Neither the name of the Institute nor the names of its contributors
37cefc8c8aSAlexander Aring  *    may be used to endorse or promote products derived from this software
38cefc8c8aSAlexander Aring  *    without specific prior written permission.
39cefc8c8aSAlexander Aring  *
40cefc8c8aSAlexander Aring  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
41cefc8c8aSAlexander Aring  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42cefc8c8aSAlexander Aring  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43cefc8c8aSAlexander Aring  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
44cefc8c8aSAlexander Aring  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45cefc8c8aSAlexander Aring  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46cefc8c8aSAlexander Aring  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47cefc8c8aSAlexander Aring  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48cefc8c8aSAlexander Aring  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49cefc8c8aSAlexander Aring  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50cefc8c8aSAlexander Aring  * SUCH DAMAGE.
51cefc8c8aSAlexander Aring  */
52cefc8c8aSAlexander Aring 
53cefc8c8aSAlexander Aring #ifndef __6LOWPAN_H__
54cefc8c8aSAlexander Aring #define __6LOWPAN_H__
55cefc8c8aSAlexander Aring 
56b1815fd9SAlexander Aring #include <linux/debugfs.h>
57b1815fd9SAlexander Aring 
58cefc8c8aSAlexander Aring #include <net/ipv6.h>
5917d8ecb8SLuis R. Rodriguez #include <net/net_namespace.h>
60cefc8c8aSAlexander Aring 
61edc73417SAlexander Aring /* special link-layer handling */
62edc73417SAlexander Aring #include <net/mac802154.h>
63edc73417SAlexander Aring 
644d6a6aedSAlexander Aring #define EUI64_ADDR_LEN		8
654d6a6aedSAlexander Aring 
6687a93e4eSAlexander Aring #define LOWPAN_NHC_MAX_ID_LEN	1
67bf513fd6SAlexander Aring /* Maximum next header compression length which we currently support inclusive
68bf513fd6SAlexander Aring  * possible inline data.
69bf513fd6SAlexander Aring  */
70bf513fd6SAlexander Aring #define LOWPAN_NHC_MAX_HDR_LEN	(sizeof(struct udphdr))
7187a93e4eSAlexander Aring /* Max IPHC Header len without IPv6 hdr specific inline data.
7287a93e4eSAlexander Aring  * Useful for getting the "extra" bytes we need at worst case compression.
7387a93e4eSAlexander Aring  *
7487a93e4eSAlexander Aring  * LOWPAN_IPHC + CID + LOWPAN_NHC_MAX_ID_LEN
7587a93e4eSAlexander Aring  */
7687a93e4eSAlexander Aring #define LOWPAN_IPHC_MAX_HEADER_LEN	(2 + 1 + LOWPAN_NHC_MAX_ID_LEN)
77bf513fd6SAlexander Aring /* Maximum worst case IPHC header buffer size */
78bf513fd6SAlexander Aring #define LOWPAN_IPHC_MAX_HC_BUF_LEN	(sizeof(struct ipv6hdr) +	\
79bf513fd6SAlexander Aring 					 LOWPAN_IPHC_MAX_HEADER_LEN +	\
80bf513fd6SAlexander Aring 					 LOWPAN_NHC_MAX_HDR_LEN)
815609c185SAlexander Aring /* SCI/DCI is 4 bit width, so we have maximum 16 entries */
825609c185SAlexander Aring #define LOWPAN_IPHC_CTX_TABLE_SIZE	(1 << 4)
8387a93e4eSAlexander Aring 
84cefc8c8aSAlexander Aring #define LOWPAN_DISPATCH_IPV6		0x41 /* 01000001 = 65 */
85cefc8c8aSAlexander Aring #define LOWPAN_DISPATCH_IPHC		0x60 /* 011xxxxx = ... */
8672a5e6bbSAlexander Aring #define LOWPAN_DISPATCH_IPHC_MASK	0xe0
87cefc8c8aSAlexander Aring 
lowpan_is_ipv6(u8 dispatch)8872a5e6bbSAlexander Aring static inline bool lowpan_is_ipv6(u8 dispatch)
8972a5e6bbSAlexander Aring {
9072a5e6bbSAlexander Aring 	return dispatch == LOWPAN_DISPATCH_IPV6;
9172a5e6bbSAlexander Aring }
9272a5e6bbSAlexander Aring 
lowpan_is_iphc(u8 dispatch)9372a5e6bbSAlexander Aring static inline bool lowpan_is_iphc(u8 dispatch)
9472a5e6bbSAlexander Aring {
9572a5e6bbSAlexander Aring 	return (dispatch & LOWPAN_DISPATCH_IPHC_MASK) == LOWPAN_DISPATCH_IPHC;
9672a5e6bbSAlexander Aring }
97cefc8c8aSAlexander Aring 
98b72f6f51SAlexander Aring #define LOWPAN_PRIV_SIZE(llpriv_size)	\
992e4d60cbSAlexander Aring 	(sizeof(struct lowpan_dev) + llpriv_size)
100b72f6f51SAlexander Aring 
101b72f6f51SAlexander Aring enum lowpan_lltypes {
102b72f6f51SAlexander Aring 	LOWPAN_LLTYPE_BTLE,
103b72f6f51SAlexander Aring 	LOWPAN_LLTYPE_IEEE802154,
104b72f6f51SAlexander Aring };
105b72f6f51SAlexander Aring 
1065609c185SAlexander Aring enum lowpan_iphc_ctx_flags {
1075609c185SAlexander Aring 	LOWPAN_IPHC_CTX_FLAG_ACTIVE,
1085609c185SAlexander Aring 	LOWPAN_IPHC_CTX_FLAG_COMPRESSION,
1095609c185SAlexander Aring };
1105609c185SAlexander Aring 
1115609c185SAlexander Aring struct lowpan_iphc_ctx {
1125609c185SAlexander Aring 	u8 id;
1135609c185SAlexander Aring 	struct in6_addr pfx;
1145609c185SAlexander Aring 	u8 plen;
1155609c185SAlexander Aring 	unsigned long flags;
1165609c185SAlexander Aring };
1175609c185SAlexander Aring 
1185609c185SAlexander Aring struct lowpan_iphc_ctx_table {
1195609c185SAlexander Aring 	spinlock_t lock;
1205609c185SAlexander Aring 	const struct lowpan_iphc_ctx_ops *ops;
1215609c185SAlexander Aring 	struct lowpan_iphc_ctx table[LOWPAN_IPHC_CTX_TABLE_SIZE];
1225609c185SAlexander Aring };
1235609c185SAlexander Aring 
lowpan_iphc_ctx_is_active(const struct lowpan_iphc_ctx * ctx)1245609c185SAlexander Aring static inline bool lowpan_iphc_ctx_is_active(const struct lowpan_iphc_ctx *ctx)
1255609c185SAlexander Aring {
1265609c185SAlexander Aring 	return test_bit(LOWPAN_IPHC_CTX_FLAG_ACTIVE, &ctx->flags);
1275609c185SAlexander Aring }
1285609c185SAlexander Aring 
1295609c185SAlexander Aring static inline bool
lowpan_iphc_ctx_is_compression(const struct lowpan_iphc_ctx * ctx)1305609c185SAlexander Aring lowpan_iphc_ctx_is_compression(const struct lowpan_iphc_ctx *ctx)
1315609c185SAlexander Aring {
1325609c185SAlexander Aring 	return test_bit(LOWPAN_IPHC_CTX_FLAG_COMPRESSION, &ctx->flags);
1335609c185SAlexander Aring }
1345609c185SAlexander Aring 
1352e4d60cbSAlexander Aring struct lowpan_dev {
136b72f6f51SAlexander Aring 	enum lowpan_lltypes lltype;
137b1815fd9SAlexander Aring 	struct dentry *iface_debugfs;
1385609c185SAlexander Aring 	struct lowpan_iphc_ctx_table ctx;
139b72f6f51SAlexander Aring 
140b72f6f51SAlexander Aring 	/* must be last */
141*8788a1eeSGustavo A. R. Silva 	u8 priv[] __aligned(sizeof(void *));
142b72f6f51SAlexander Aring };
143b72f6f51SAlexander Aring 
1448626a0c8SAlexander Aring struct lowpan_802154_neigh {
1458626a0c8SAlexander Aring 	__le16 short_addr;
1468626a0c8SAlexander Aring };
1478626a0c8SAlexander Aring 
1488626a0c8SAlexander Aring static inline
lowpan_802154_neigh(void * neigh_priv)1498626a0c8SAlexander Aring struct lowpan_802154_neigh *lowpan_802154_neigh(void *neigh_priv)
1508626a0c8SAlexander Aring {
1518626a0c8SAlexander Aring 	return neigh_priv;
1528626a0c8SAlexander Aring }
1538626a0c8SAlexander Aring 
154b72f6f51SAlexander Aring static inline
lowpan_dev(const struct net_device * dev)1552e4d60cbSAlexander Aring struct lowpan_dev *lowpan_dev(const struct net_device *dev)
156b72f6f51SAlexander Aring {
157b72f6f51SAlexander Aring 	return netdev_priv(dev);
158b72f6f51SAlexander Aring }
159b72f6f51SAlexander Aring 
160353c224eSAlexander Aring /* private device info */
161353c224eSAlexander Aring struct lowpan_802154_dev {
162353c224eSAlexander Aring 	struct net_device	*wdev; /* wpan device ptr */
163353c224eSAlexander Aring 	u16			fragment_tag;
164353c224eSAlexander Aring };
165353c224eSAlexander Aring 
166353c224eSAlexander Aring static inline struct
lowpan_802154_dev(const struct net_device * dev)167353c224eSAlexander Aring lowpan_802154_dev *lowpan_802154_dev(const struct net_device *dev)
168353c224eSAlexander Aring {
169353c224eSAlexander Aring 	return (struct lowpan_802154_dev *)lowpan_dev(dev)->priv;
170353c224eSAlexander Aring }
171353c224eSAlexander Aring 
17272a5e6bbSAlexander Aring struct lowpan_802154_cb {
17372a5e6bbSAlexander Aring 	u16 d_tag;
17472a5e6bbSAlexander Aring 	unsigned int d_size;
17572a5e6bbSAlexander Aring 	u8 d_offset;
17672a5e6bbSAlexander Aring };
17772a5e6bbSAlexander Aring 
17872a5e6bbSAlexander Aring static inline
lowpan_802154_cb(const struct sk_buff * skb)17972a5e6bbSAlexander Aring struct lowpan_802154_cb *lowpan_802154_cb(const struct sk_buff *skb)
18072a5e6bbSAlexander Aring {
18172a5e6bbSAlexander Aring 	BUILD_BUG_ON(sizeof(struct lowpan_802154_cb) > sizeof(skb->cb));
18272a5e6bbSAlexander Aring 	return (struct lowpan_802154_cb *)skb->cb;
18372a5e6bbSAlexander Aring }
18472a5e6bbSAlexander Aring 
lowpan_iphc_uncompress_eui64_lladdr(struct in6_addr * ipaddr,const void * lladdr)185a5862f2aSAlexander Aring static inline void lowpan_iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
186a5862f2aSAlexander Aring 						       const void *lladdr)
187a5862f2aSAlexander Aring {
188a5862f2aSAlexander Aring 	/* fe:80::XXXX:XXXX:XXXX:XXXX
189a5862f2aSAlexander Aring 	 *        \_________________/
190a5862f2aSAlexander Aring 	 *              hwaddr
191a5862f2aSAlexander Aring 	 */
192a5862f2aSAlexander Aring 	ipaddr->s6_addr[0] = 0xFE;
193a5862f2aSAlexander Aring 	ipaddr->s6_addr[1] = 0x80;
194a5862f2aSAlexander Aring 	memcpy(&ipaddr->s6_addr[8], lladdr, EUI64_ADDR_LEN);
195a5862f2aSAlexander Aring 	/* second bit-flip (Universe/Local)
196a5862f2aSAlexander Aring 	 * is done according RFC2464
197a5862f2aSAlexander Aring 	 */
198a5862f2aSAlexander Aring 	ipaddr->s6_addr[8] ^= 0x02;
199a5862f2aSAlexander Aring }
200a5862f2aSAlexander Aring 
lowpan_iphc_uncompress_eui48_lladdr(struct in6_addr * ipaddr,const void * lladdr)201fa09ae66SLuiz Augusto von Dentz static inline void lowpan_iphc_uncompress_eui48_lladdr(struct in6_addr *ipaddr,
202fa09ae66SLuiz Augusto von Dentz 						       const void *lladdr)
203fa09ae66SLuiz Augusto von Dentz {
204fa09ae66SLuiz Augusto von Dentz 	/* fe:80::XXXX:XXff:feXX:XXXX
205fa09ae66SLuiz Augusto von Dentz 	 *        \_________________/
206fa09ae66SLuiz Augusto von Dentz 	 *              hwaddr
207fa09ae66SLuiz Augusto von Dentz 	 */
208fa09ae66SLuiz Augusto von Dentz 	ipaddr->s6_addr[0] = 0xFE;
209fa09ae66SLuiz Augusto von Dentz 	ipaddr->s6_addr[1] = 0x80;
210fa09ae66SLuiz Augusto von Dentz 	memcpy(&ipaddr->s6_addr[8], lladdr, 3);
211fa09ae66SLuiz Augusto von Dentz 	ipaddr->s6_addr[11] = 0xFF;
212fa09ae66SLuiz Augusto von Dentz 	ipaddr->s6_addr[12] = 0xFE;
213fa09ae66SLuiz Augusto von Dentz 	memcpy(&ipaddr->s6_addr[13], lladdr + 3, 3);
214fa09ae66SLuiz Augusto von Dentz }
215fa09ae66SLuiz Augusto von Dentz 
216cefc8c8aSAlexander Aring #ifdef DEBUG
217cefc8c8aSAlexander Aring /* print data in line */
raw_dump_inline(const char * caller,char * msg,const unsigned char * buf,int len)218cefc8c8aSAlexander Aring static inline void raw_dump_inline(const char *caller, char *msg,
219a6f77389SAlexander Aring 				   const unsigned char *buf, int len)
220cefc8c8aSAlexander Aring {
221cefc8c8aSAlexander Aring 	if (msg)
222cefc8c8aSAlexander Aring 		pr_debug("%s():%s: ", caller, msg);
223cefc8c8aSAlexander Aring 
224cefc8c8aSAlexander Aring 	print_hex_dump_debug("", DUMP_PREFIX_NONE, 16, 1, buf, len, false);
225cefc8c8aSAlexander Aring }
226cefc8c8aSAlexander Aring 
227cefc8c8aSAlexander Aring /* print data in a table format:
228cefc8c8aSAlexander Aring  *
229cefc8c8aSAlexander Aring  * addr: xx xx xx xx xx xx
230cefc8c8aSAlexander Aring  * addr: xx xx xx xx xx xx
231cefc8c8aSAlexander Aring  * ...
232cefc8c8aSAlexander Aring  */
raw_dump_table(const char * caller,char * msg,const unsigned char * buf,int len)233cefc8c8aSAlexander Aring static inline void raw_dump_table(const char *caller, char *msg,
234a6f77389SAlexander Aring 				  const unsigned char *buf, int len)
235cefc8c8aSAlexander Aring {
236cefc8c8aSAlexander Aring 	if (msg)
237cefc8c8aSAlexander Aring 		pr_debug("%s():%s:\n", caller, msg);
238cefc8c8aSAlexander Aring 
239cefc8c8aSAlexander Aring 	print_hex_dump_debug("\t", DUMP_PREFIX_OFFSET, 16, 1, buf, len, false);
240cefc8c8aSAlexander Aring }
241cefc8c8aSAlexander Aring #else
raw_dump_table(const char * caller,char * msg,const unsigned char * buf,int len)242cefc8c8aSAlexander Aring static inline void raw_dump_table(const char *caller, char *msg,
243a6f77389SAlexander Aring 				  const unsigned char *buf, int len) { }
raw_dump_inline(const char * caller,char * msg,const unsigned char * buf,int len)244cefc8c8aSAlexander Aring static inline void raw_dump_inline(const char *caller, char *msg,
245a6f77389SAlexander Aring 				   const unsigned char *buf, int len) { }
246cefc8c8aSAlexander Aring #endif
247cefc8c8aSAlexander Aring 
248478208e3SAlexander Aring /**
249478208e3SAlexander Aring  * lowpan_fetch_skb - getting inline data from 6LoWPAN header
250478208e3SAlexander Aring  *
251478208e3SAlexander Aring  * This function will pull data from sk buffer and put it into data to
252478208e3SAlexander Aring  * remove the 6LoWPAN inline data. This function returns true if the
253478208e3SAlexander Aring  * sk buffer is too small to pull the amount of data which is specified
254478208e3SAlexander Aring  * by len.
255478208e3SAlexander Aring  *
256478208e3SAlexander Aring  * @skb: the buffer where the inline data should be pulled from.
257478208e3SAlexander Aring  * @data: destination buffer for the inline data.
258478208e3SAlexander Aring  * @len: amount of data which should be pulled in bytes.
259478208e3SAlexander Aring  */
lowpan_fetch_skb(struct sk_buff * skb,void * data,unsigned int len)260478208e3SAlexander Aring static inline bool lowpan_fetch_skb(struct sk_buff *skb, void *data,
261478208e3SAlexander Aring 				    unsigned int len)
262cefc8c8aSAlexander Aring {
263cefc8c8aSAlexander Aring 	if (unlikely(!pskb_may_pull(skb, len)))
264cefc8c8aSAlexander Aring 		return true;
265cefc8c8aSAlexander Aring 
266cefc8c8aSAlexander Aring 	skb_copy_from_linear_data(skb, data, len);
267cefc8c8aSAlexander Aring 	skb_pull(skb, len);
268cefc8c8aSAlexander Aring 
269cefc8c8aSAlexander Aring 	return false;
270cefc8c8aSAlexander Aring }
271cefc8c8aSAlexander Aring 
lowpan_802154_is_valid_src_short_addr(__le16 addr)2722ad3ed59SAlexander Aring static inline bool lowpan_802154_is_valid_src_short_addr(__le16 addr)
2732ad3ed59SAlexander Aring {
2742ad3ed59SAlexander Aring 	/* First bit of addr is multicast, reserved or 802.15.4 specific */
2752ad3ed59SAlexander Aring 	return !(addr & cpu_to_le16(0x8000));
2762ad3ed59SAlexander Aring }
2772ad3ed59SAlexander Aring 
lowpan_push_hc_data(u8 ** hc_ptr,const void * data,const size_t len)278cefc8c8aSAlexander Aring static inline void lowpan_push_hc_data(u8 **hc_ptr, const void *data,
279cefc8c8aSAlexander Aring 				       const size_t len)
280cefc8c8aSAlexander Aring {
281cefc8c8aSAlexander Aring 	memcpy(*hc_ptr, data, len);
282cefc8c8aSAlexander Aring 	*hc_ptr += len;
283cefc8c8aSAlexander Aring }
284cefc8c8aSAlexander Aring 
28500f59314SAlexander Aring int lowpan_register_netdevice(struct net_device *dev,
28600f59314SAlexander Aring 			      enum lowpan_lltypes lltype);
28700f59314SAlexander Aring int lowpan_register_netdev(struct net_device *dev,
28800f59314SAlexander Aring 			   enum lowpan_lltypes lltype);
28900f59314SAlexander Aring void lowpan_unregister_netdevice(struct net_device *dev);
29000f59314SAlexander Aring void lowpan_unregister_netdev(struct net_device *dev);
291b72f6f51SAlexander Aring 
2928911d774SAlexander Aring /**
2938911d774SAlexander Aring  * lowpan_header_decompress - replace 6LoWPAN header with IPv6 header
2948911d774SAlexander Aring  *
2958911d774SAlexander Aring  * This function replaces the IPHC 6LoWPAN header which should be pointed at
2968911d774SAlexander Aring  * skb->data and skb_network_header, with the IPv6 header.
2978911d774SAlexander Aring  * It would be nice that the caller have the necessary headroom of IPv6 header
2988911d774SAlexander Aring  * and greatest Transport layer header, this would reduce the overhead for
2998911d774SAlexander Aring  * reallocate headroom.
3008911d774SAlexander Aring  *
3018911d774SAlexander Aring  * @skb: the buffer which should be manipulate.
3028911d774SAlexander Aring  * @dev: the lowpan net device pointer.
3038911d774SAlexander Aring  * @daddr: destination lladdr of mac header which is used for compression
3048911d774SAlexander Aring  *	methods.
3058911d774SAlexander Aring  * @saddr: source lladdr of mac header which is used for compression
3068911d774SAlexander Aring  *	methods.
3078911d774SAlexander Aring  */
3088911d774SAlexander Aring int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
3098911d774SAlexander Aring 			     const void *daddr, const void *saddr);
310a6f77389SAlexander Aring 
311a6f77389SAlexander Aring /**
312a6f77389SAlexander Aring  * lowpan_header_compress - replace IPv6 header with 6LoWPAN header
313a6f77389SAlexander Aring  *
314a6f77389SAlexander Aring  * This function replaces the IPv6 header which should be pointed at
315a6f77389SAlexander Aring  * skb->data and skb_network_header, with the IPHC 6LoWPAN header.
316a6f77389SAlexander Aring  * The caller need to be sure that the sk buffer is not shared and at have
317a6f77389SAlexander Aring  * at least a headroom which is smaller or equal LOWPAN_IPHC_MAX_HEADER_LEN,
318a6f77389SAlexander Aring  * which is the IPHC "more bytes than IPv6 header" at worst case.
319a6f77389SAlexander Aring  *
320a6f77389SAlexander Aring  * @skb: the buffer which should be manipulate.
321a6f77389SAlexander Aring  * @dev: the lowpan net device pointer.
322a6f77389SAlexander Aring  * @daddr: destination lladdr of mac header which is used for compression
323a6f77389SAlexander Aring  *	methods.
324a6f77389SAlexander Aring  * @saddr: source lladdr of mac header which is used for compression
325a6f77389SAlexander Aring  *	methods.
326a6f77389SAlexander Aring  */
327a6f77389SAlexander Aring int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev,
328a6f77389SAlexander Aring 			   const void *daddr, const void *saddr);
329cefc8c8aSAlexander Aring 
330cefc8c8aSAlexander Aring #endif /* __6LOWPAN_H__ */
331