18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2011, Siemens AG
38c2ecf20Sopenharmony_ci * written by Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci/*
78c2ecf20Sopenharmony_ci * Based on patches from Jon Smirl <jonsmirl@gmail.com>
88c2ecf20Sopenharmony_ci * Copyright (c) 2011 Jon Smirl <jonsmirl@gmail.com>
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
118c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License version 2
128c2ecf20Sopenharmony_ci * as published by the Free Software Foundation.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful,
158c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
168c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
178c2ecf20Sopenharmony_ci * GNU General Public License for more details.
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License along
208c2ecf20Sopenharmony_ci * with this program; if not, write to the Free Software Foundation, Inc.,
218c2ecf20Sopenharmony_ci * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/* Jon's code is based on 6lowpan implementation for Contiki which is:
258c2ecf20Sopenharmony_ci * Copyright (c) 2008, Swedish Institute of Computer Science.
268c2ecf20Sopenharmony_ci * All rights reserved.
278c2ecf20Sopenharmony_ci *
288c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
298c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions
308c2ecf20Sopenharmony_ci * are met:
318c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
328c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer.
338c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright
348c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in the
358c2ecf20Sopenharmony_ci *    documentation and/or other materials provided with the distribution.
368c2ecf20Sopenharmony_ci * 3. Neither the name of the Institute nor the names of its contributors
378c2ecf20Sopenharmony_ci *    may be used to endorse or promote products derived from this software
388c2ecf20Sopenharmony_ci *    without specific prior written permission.
398c2ecf20Sopenharmony_ci *
408c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
418c2ecf20Sopenharmony_ci * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
428c2ecf20Sopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
438c2ecf20Sopenharmony_ci * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
448c2ecf20Sopenharmony_ci * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
458c2ecf20Sopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
468c2ecf20Sopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
478c2ecf20Sopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
488c2ecf20Sopenharmony_ci * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
498c2ecf20Sopenharmony_ci * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
508c2ecf20Sopenharmony_ci * SUCH DAMAGE.
518c2ecf20Sopenharmony_ci */
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#ifndef __6LOWPAN_H__
548c2ecf20Sopenharmony_ci#define __6LOWPAN_H__
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#include <linux/debugfs.h>
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci#include <net/ipv6.h>
598c2ecf20Sopenharmony_ci#include <net/net_namespace.h>
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/* special link-layer handling */
628c2ecf20Sopenharmony_ci#include <net/mac802154.h>
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci#define EUI64_ADDR_LEN		8
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#define LOWPAN_NHC_MAX_ID_LEN	1
678c2ecf20Sopenharmony_ci/* Maximum next header compression length which we currently support inclusive
688c2ecf20Sopenharmony_ci * possible inline data.
698c2ecf20Sopenharmony_ci */
708c2ecf20Sopenharmony_ci#define LOWPAN_NHC_MAX_HDR_LEN	(sizeof(struct udphdr))
718c2ecf20Sopenharmony_ci/* Max IPHC Header len without IPv6 hdr specific inline data.
728c2ecf20Sopenharmony_ci * Useful for getting the "extra" bytes we need at worst case compression.
738c2ecf20Sopenharmony_ci *
748c2ecf20Sopenharmony_ci * LOWPAN_IPHC + CID + LOWPAN_NHC_MAX_ID_LEN
758c2ecf20Sopenharmony_ci */
768c2ecf20Sopenharmony_ci#define LOWPAN_IPHC_MAX_HEADER_LEN	(2 + 1 + LOWPAN_NHC_MAX_ID_LEN)
778c2ecf20Sopenharmony_ci/* Maximum worst case IPHC header buffer size */
788c2ecf20Sopenharmony_ci#define LOWPAN_IPHC_MAX_HC_BUF_LEN	(sizeof(struct ipv6hdr) +	\
798c2ecf20Sopenharmony_ci					 LOWPAN_IPHC_MAX_HEADER_LEN +	\
808c2ecf20Sopenharmony_ci					 LOWPAN_NHC_MAX_HDR_LEN)
818c2ecf20Sopenharmony_ci/* SCI/DCI is 4 bit width, so we have maximum 16 entries */
828c2ecf20Sopenharmony_ci#define LOWPAN_IPHC_CTX_TABLE_SIZE	(1 << 4)
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#define LOWPAN_DISPATCH_IPV6		0x41 /* 01000001 = 65 */
858c2ecf20Sopenharmony_ci#define LOWPAN_DISPATCH_IPHC		0x60 /* 011xxxxx = ... */
868c2ecf20Sopenharmony_ci#define LOWPAN_DISPATCH_IPHC_MASK	0xe0
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_cistatic inline bool lowpan_is_ipv6(u8 dispatch)
898c2ecf20Sopenharmony_ci{
908c2ecf20Sopenharmony_ci	return dispatch == LOWPAN_DISPATCH_IPV6;
918c2ecf20Sopenharmony_ci}
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_cistatic inline bool lowpan_is_iphc(u8 dispatch)
948c2ecf20Sopenharmony_ci{
958c2ecf20Sopenharmony_ci	return (dispatch & LOWPAN_DISPATCH_IPHC_MASK) == LOWPAN_DISPATCH_IPHC;
968c2ecf20Sopenharmony_ci}
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define LOWPAN_PRIV_SIZE(llpriv_size)	\
998c2ecf20Sopenharmony_ci	(sizeof(struct lowpan_dev) + llpriv_size)
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_cienum lowpan_lltypes {
1028c2ecf20Sopenharmony_ci	LOWPAN_LLTYPE_BTLE,
1038c2ecf20Sopenharmony_ci	LOWPAN_LLTYPE_IEEE802154,
1048c2ecf20Sopenharmony_ci};
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_cienum lowpan_iphc_ctx_flags {
1078c2ecf20Sopenharmony_ci	LOWPAN_IPHC_CTX_FLAG_ACTIVE,
1088c2ecf20Sopenharmony_ci	LOWPAN_IPHC_CTX_FLAG_COMPRESSION,
1098c2ecf20Sopenharmony_ci};
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_cistruct lowpan_iphc_ctx {
1128c2ecf20Sopenharmony_ci	u8 id;
1138c2ecf20Sopenharmony_ci	struct in6_addr pfx;
1148c2ecf20Sopenharmony_ci	u8 plen;
1158c2ecf20Sopenharmony_ci	unsigned long flags;
1168c2ecf20Sopenharmony_ci};
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_cistruct lowpan_iphc_ctx_table {
1198c2ecf20Sopenharmony_ci	spinlock_t lock;
1208c2ecf20Sopenharmony_ci	const struct lowpan_iphc_ctx_ops *ops;
1218c2ecf20Sopenharmony_ci	struct lowpan_iphc_ctx table[LOWPAN_IPHC_CTX_TABLE_SIZE];
1228c2ecf20Sopenharmony_ci};
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_cistatic inline bool lowpan_iphc_ctx_is_active(const struct lowpan_iphc_ctx *ctx)
1258c2ecf20Sopenharmony_ci{
1268c2ecf20Sopenharmony_ci	return test_bit(LOWPAN_IPHC_CTX_FLAG_ACTIVE, &ctx->flags);
1278c2ecf20Sopenharmony_ci}
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_cistatic inline bool
1308c2ecf20Sopenharmony_cilowpan_iphc_ctx_is_compression(const struct lowpan_iphc_ctx *ctx)
1318c2ecf20Sopenharmony_ci{
1328c2ecf20Sopenharmony_ci	return test_bit(LOWPAN_IPHC_CTX_FLAG_COMPRESSION, &ctx->flags);
1338c2ecf20Sopenharmony_ci}
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_cistruct lowpan_dev {
1368c2ecf20Sopenharmony_ci	enum lowpan_lltypes lltype;
1378c2ecf20Sopenharmony_ci	struct dentry *iface_debugfs;
1388c2ecf20Sopenharmony_ci	struct lowpan_iphc_ctx_table ctx;
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci	/* must be last */
1418c2ecf20Sopenharmony_ci	u8 priv[] __aligned(sizeof(void *));
1428c2ecf20Sopenharmony_ci};
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_cistruct lowpan_802154_neigh {
1458c2ecf20Sopenharmony_ci	__le16 short_addr;
1468c2ecf20Sopenharmony_ci};
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_cistatic inline
1498c2ecf20Sopenharmony_cistruct lowpan_802154_neigh *lowpan_802154_neigh(void *neigh_priv)
1508c2ecf20Sopenharmony_ci{
1518c2ecf20Sopenharmony_ci	return neigh_priv;
1528c2ecf20Sopenharmony_ci}
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_cistatic inline
1558c2ecf20Sopenharmony_cistruct lowpan_dev *lowpan_dev(const struct net_device *dev)
1568c2ecf20Sopenharmony_ci{
1578c2ecf20Sopenharmony_ci	return netdev_priv(dev);
1588c2ecf20Sopenharmony_ci}
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci/* private device info */
1618c2ecf20Sopenharmony_cistruct lowpan_802154_dev {
1628c2ecf20Sopenharmony_ci	struct net_device	*wdev; /* wpan device ptr */
1638c2ecf20Sopenharmony_ci	u16			fragment_tag;
1648c2ecf20Sopenharmony_ci};
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_cistatic inline struct
1678c2ecf20Sopenharmony_cilowpan_802154_dev *lowpan_802154_dev(const struct net_device *dev)
1688c2ecf20Sopenharmony_ci{
1698c2ecf20Sopenharmony_ci	return (struct lowpan_802154_dev *)lowpan_dev(dev)->priv;
1708c2ecf20Sopenharmony_ci}
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_cistruct lowpan_802154_cb {
1738c2ecf20Sopenharmony_ci	u16 d_tag;
1748c2ecf20Sopenharmony_ci	unsigned int d_size;
1758c2ecf20Sopenharmony_ci	u8 d_offset;
1768c2ecf20Sopenharmony_ci};
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_cistatic inline
1798c2ecf20Sopenharmony_cistruct lowpan_802154_cb *lowpan_802154_cb(const struct sk_buff *skb)
1808c2ecf20Sopenharmony_ci{
1818c2ecf20Sopenharmony_ci	BUILD_BUG_ON(sizeof(struct lowpan_802154_cb) > sizeof(skb->cb));
1828c2ecf20Sopenharmony_ci	return (struct lowpan_802154_cb *)skb->cb;
1838c2ecf20Sopenharmony_ci}
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_cistatic inline void lowpan_iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
1868c2ecf20Sopenharmony_ci						       const void *lladdr)
1878c2ecf20Sopenharmony_ci{
1888c2ecf20Sopenharmony_ci	/* fe:80::XXXX:XXXX:XXXX:XXXX
1898c2ecf20Sopenharmony_ci	 *        \_________________/
1908c2ecf20Sopenharmony_ci	 *              hwaddr
1918c2ecf20Sopenharmony_ci	 */
1928c2ecf20Sopenharmony_ci	ipaddr->s6_addr[0] = 0xFE;
1938c2ecf20Sopenharmony_ci	ipaddr->s6_addr[1] = 0x80;
1948c2ecf20Sopenharmony_ci	memcpy(&ipaddr->s6_addr[8], lladdr, EUI64_ADDR_LEN);
1958c2ecf20Sopenharmony_ci	/* second bit-flip (Universe/Local)
1968c2ecf20Sopenharmony_ci	 * is done according RFC2464
1978c2ecf20Sopenharmony_ci	 */
1988c2ecf20Sopenharmony_ci	ipaddr->s6_addr[8] ^= 0x02;
1998c2ecf20Sopenharmony_ci}
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_cistatic inline void lowpan_iphc_uncompress_eui48_lladdr(struct in6_addr *ipaddr,
2028c2ecf20Sopenharmony_ci						       const void *lladdr)
2038c2ecf20Sopenharmony_ci{
2048c2ecf20Sopenharmony_ci	/* fe:80::XXXX:XXff:feXX:XXXX
2058c2ecf20Sopenharmony_ci	 *        \_________________/
2068c2ecf20Sopenharmony_ci	 *              hwaddr
2078c2ecf20Sopenharmony_ci	 */
2088c2ecf20Sopenharmony_ci	ipaddr->s6_addr[0] = 0xFE;
2098c2ecf20Sopenharmony_ci	ipaddr->s6_addr[1] = 0x80;
2108c2ecf20Sopenharmony_ci	memcpy(&ipaddr->s6_addr[8], lladdr, 3);
2118c2ecf20Sopenharmony_ci	ipaddr->s6_addr[11] = 0xFF;
2128c2ecf20Sopenharmony_ci	ipaddr->s6_addr[12] = 0xFE;
2138c2ecf20Sopenharmony_ci	memcpy(&ipaddr->s6_addr[13], lladdr + 3, 3);
2148c2ecf20Sopenharmony_ci}
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci#ifdef DEBUG
2178c2ecf20Sopenharmony_ci/* print data in line */
2188c2ecf20Sopenharmony_cistatic inline void raw_dump_inline(const char *caller, char *msg,
2198c2ecf20Sopenharmony_ci				   const unsigned char *buf, int len)
2208c2ecf20Sopenharmony_ci{
2218c2ecf20Sopenharmony_ci	if (msg)
2228c2ecf20Sopenharmony_ci		pr_debug("%s():%s: ", caller, msg);
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci	print_hex_dump_debug("", DUMP_PREFIX_NONE, 16, 1, buf, len, false);
2258c2ecf20Sopenharmony_ci}
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci/* print data in a table format:
2288c2ecf20Sopenharmony_ci *
2298c2ecf20Sopenharmony_ci * addr: xx xx xx xx xx xx
2308c2ecf20Sopenharmony_ci * addr: xx xx xx xx xx xx
2318c2ecf20Sopenharmony_ci * ...
2328c2ecf20Sopenharmony_ci */
2338c2ecf20Sopenharmony_cistatic inline void raw_dump_table(const char *caller, char *msg,
2348c2ecf20Sopenharmony_ci				  const unsigned char *buf, int len)
2358c2ecf20Sopenharmony_ci{
2368c2ecf20Sopenharmony_ci	if (msg)
2378c2ecf20Sopenharmony_ci		pr_debug("%s():%s:\n", caller, msg);
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci	print_hex_dump_debug("\t", DUMP_PREFIX_OFFSET, 16, 1, buf, len, false);
2408c2ecf20Sopenharmony_ci}
2418c2ecf20Sopenharmony_ci#else
2428c2ecf20Sopenharmony_cistatic inline void raw_dump_table(const char *caller, char *msg,
2438c2ecf20Sopenharmony_ci				  const unsigned char *buf, int len) { }
2448c2ecf20Sopenharmony_cistatic inline void raw_dump_inline(const char *caller, char *msg,
2458c2ecf20Sopenharmony_ci				   const unsigned char *buf, int len) { }
2468c2ecf20Sopenharmony_ci#endif
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci/**
2498c2ecf20Sopenharmony_ci * lowpan_fetch_skb - getting inline data from 6LoWPAN header
2508c2ecf20Sopenharmony_ci *
2518c2ecf20Sopenharmony_ci * This function will pull data from sk buffer and put it into data to
2528c2ecf20Sopenharmony_ci * remove the 6LoWPAN inline data. This function returns true if the
2538c2ecf20Sopenharmony_ci * sk buffer is too small to pull the amount of data which is specified
2548c2ecf20Sopenharmony_ci * by len.
2558c2ecf20Sopenharmony_ci *
2568c2ecf20Sopenharmony_ci * @skb: the buffer where the inline data should be pulled from.
2578c2ecf20Sopenharmony_ci * @data: destination buffer for the inline data.
2588c2ecf20Sopenharmony_ci * @len: amount of data which should be pulled in bytes.
2598c2ecf20Sopenharmony_ci */
2608c2ecf20Sopenharmony_cistatic inline bool lowpan_fetch_skb(struct sk_buff *skb, void *data,
2618c2ecf20Sopenharmony_ci				    unsigned int len)
2628c2ecf20Sopenharmony_ci{
2638c2ecf20Sopenharmony_ci	if (unlikely(!pskb_may_pull(skb, len)))
2648c2ecf20Sopenharmony_ci		return true;
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci	skb_copy_from_linear_data(skb, data, len);
2678c2ecf20Sopenharmony_ci	skb_pull(skb, len);
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_ci	return false;
2708c2ecf20Sopenharmony_ci}
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_cistatic inline bool lowpan_802154_is_valid_src_short_addr(__le16 addr)
2738c2ecf20Sopenharmony_ci{
2748c2ecf20Sopenharmony_ci	/* First bit of addr is multicast, reserved or 802.15.4 specific */
2758c2ecf20Sopenharmony_ci	return !(addr & cpu_to_le16(0x8000));
2768c2ecf20Sopenharmony_ci}
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_cistatic inline void lowpan_push_hc_data(u8 **hc_ptr, const void *data,
2798c2ecf20Sopenharmony_ci				       const size_t len)
2808c2ecf20Sopenharmony_ci{
2818c2ecf20Sopenharmony_ci	memcpy(*hc_ptr, data, len);
2828c2ecf20Sopenharmony_ci	*hc_ptr += len;
2838c2ecf20Sopenharmony_ci}
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ciint lowpan_register_netdevice(struct net_device *dev,
2868c2ecf20Sopenharmony_ci			      enum lowpan_lltypes lltype);
2878c2ecf20Sopenharmony_ciint lowpan_register_netdev(struct net_device *dev,
2888c2ecf20Sopenharmony_ci			   enum lowpan_lltypes lltype);
2898c2ecf20Sopenharmony_civoid lowpan_unregister_netdevice(struct net_device *dev);
2908c2ecf20Sopenharmony_civoid lowpan_unregister_netdev(struct net_device *dev);
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci/**
2938c2ecf20Sopenharmony_ci * lowpan_header_decompress - replace 6LoWPAN header with IPv6 header
2948c2ecf20Sopenharmony_ci *
2958c2ecf20Sopenharmony_ci * This function replaces the IPHC 6LoWPAN header which should be pointed at
2968c2ecf20Sopenharmony_ci * skb->data and skb_network_header, with the IPv6 header.
2978c2ecf20Sopenharmony_ci * It would be nice that the caller have the necessary headroom of IPv6 header
2988c2ecf20Sopenharmony_ci * and greatest Transport layer header, this would reduce the overhead for
2998c2ecf20Sopenharmony_ci * reallocate headroom.
3008c2ecf20Sopenharmony_ci *
3018c2ecf20Sopenharmony_ci * @skb: the buffer which should be manipulate.
3028c2ecf20Sopenharmony_ci * @dev: the lowpan net device pointer.
3038c2ecf20Sopenharmony_ci * @daddr: destination lladdr of mac header which is used for compression
3048c2ecf20Sopenharmony_ci *	methods.
3058c2ecf20Sopenharmony_ci * @saddr: source lladdr of mac header which is used for compression
3068c2ecf20Sopenharmony_ci *	methods.
3078c2ecf20Sopenharmony_ci */
3088c2ecf20Sopenharmony_ciint lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
3098c2ecf20Sopenharmony_ci			     const void *daddr, const void *saddr);
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci/**
3128c2ecf20Sopenharmony_ci * lowpan_header_compress - replace IPv6 header with 6LoWPAN header
3138c2ecf20Sopenharmony_ci *
3148c2ecf20Sopenharmony_ci * This function replaces the IPv6 header which should be pointed at
3158c2ecf20Sopenharmony_ci * skb->data and skb_network_header, with the IPHC 6LoWPAN header.
3168c2ecf20Sopenharmony_ci * The caller need to be sure that the sk buffer is not shared and at have
3178c2ecf20Sopenharmony_ci * at least a headroom which is smaller or equal LOWPAN_IPHC_MAX_HEADER_LEN,
3188c2ecf20Sopenharmony_ci * which is the IPHC "more bytes than IPv6 header" at worst case.
3198c2ecf20Sopenharmony_ci *
3208c2ecf20Sopenharmony_ci * @skb: the buffer which should be manipulate.
3218c2ecf20Sopenharmony_ci * @dev: the lowpan net device pointer.
3228c2ecf20Sopenharmony_ci * @daddr: destination lladdr of mac header which is used for compression
3238c2ecf20Sopenharmony_ci *	methods.
3248c2ecf20Sopenharmony_ci * @saddr: source lladdr of mac header which is used for compression
3258c2ecf20Sopenharmony_ci *	methods.
3268c2ecf20Sopenharmony_ci */
3278c2ecf20Sopenharmony_ciint lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev,
3288c2ecf20Sopenharmony_ci			   const void *daddr, const void *saddr);
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci#endif /* __6LOWPAN_H__ */
331