blob: 5ac778962e4ee4895903f707c00d7750a104b3bd [file] [log] [blame]
Alexander Aring8691ee52015-01-04 17:10:54 +01001#ifndef __IEEE802154_6LOWPAN_I_H__
2#define __IEEE802154_6LOWPAN_I_H__
Alexander Aring7240cde2014-02-28 07:32:50 +01003
Alexander Aring4662a0d2015-01-04 17:10:55 +01004#include <linux/list.h>
5
Alexander Aring4dc315e2015-01-04 17:10:56 +01006#include <net/ieee802154_netdev.h>
Alexander Aring7240cde2014-02-28 07:32:50 +01007#include <net/inet_frag.h>
Alexander Aringb72f6f52015-08-11 21:44:08 +02008#include <net/6lowpan.h>
Alexander Aring7240cde2014-02-28 07:32:50 +01009
Alexander Aring72a5e6b2015-09-02 14:21:25 +020010typedef unsigned __bitwise__ lowpan_rx_result;
11#define RX_CONTINUE ((__force lowpan_rx_result) 0u)
12#define RX_DROP_UNUSABLE ((__force lowpan_rx_result) 1u)
13#define RX_DROP ((__force lowpan_rx_result) 2u)
14#define RX_QUEUED ((__force lowpan_rx_result) 3u)
15
16#define LOWPAN_DISPATCH_FRAG1 0xc0
17#define LOWPAN_DISPATCH_FRAGN 0xe0
18
Alexander Aring7240cde2014-02-28 07:32:50 +010019struct lowpan_create_arg {
Alexander Aringf870b8c2014-10-06 11:00:51 +020020 u16 tag;
Alexander Aring7240cde2014-02-28 07:32:50 +010021 u16 d_size;
Phoebe Buckheisterae531b92014-03-14 21:24:02 +010022 const struct ieee802154_addr *src;
23 const struct ieee802154_addr *dst;
Alexander Aring7240cde2014-02-28 07:32:50 +010024};
25
26/* Equivalent of ipv4 struct ip
27 */
28struct lowpan_frag_queue {
29 struct inet_frag_queue q;
30
Alexander Aringf870b8c2014-10-06 11:00:51 +020031 u16 tag;
Alexander Aring7240cde2014-02-28 07:32:50 +010032 u16 d_size;
Phoebe Buckheisterae531b92014-03-14 21:24:02 +010033 struct ieee802154_addr saddr;
34 struct ieee802154_addr daddr;
Alexander Aring7240cde2014-02-28 07:32:50 +010035};
36
Phoebe Buckheisterae531b92014-03-14 21:24:02 +010037static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a)
Alexander Aring7240cde2014-02-28 07:32:50 +010038{
Phoebe Buckheisterae531b92014-03-14 21:24:02 +010039 switch (a->mode) {
Alexander Aring7240cde2014-02-28 07:32:50 +010040 case IEEE802154_ADDR_LONG:
Phoebe Buckheisterae531b92014-03-14 21:24:02 +010041 return (((__force u64)a->extended_addr) >> 32) ^
42 (((__force u64)a->extended_addr) & 0xffffffff);
Alexander Aring7240cde2014-02-28 07:32:50 +010043 case IEEE802154_ADDR_SHORT:
Alexander Aring5a7f97e2016-04-11 11:04:17 +020044 return (__force u32)(a->short_addr + (a->pan_id << 16));
Alexander Aring7240cde2014-02-28 07:32:50 +010045 default:
46 return 0;
47 }
48}
49
Alexander Aring7240cde2014-02-28 07:32:50 +010050int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type);
51void lowpan_net_frag_exit(void);
52int lowpan_net_frag_init(void);
53
Alexander Aring4662a0d2015-01-04 17:10:55 +010054void lowpan_rx_init(void);
55void lowpan_rx_exit(void);
56
Alexander Aring4dc315e2015-01-04 17:10:56 +010057int lowpan_header_create(struct sk_buff *skb, struct net_device *dev,
58 unsigned short type, const void *_daddr,
59 const void *_saddr, unsigned int len);
60netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *dev);
61
Alexander Aring72a5e6b2015-09-02 14:21:25 +020062int lowpan_iphc_decompress(struct sk_buff *skb);
63lowpan_rx_result lowpan_rx_h_ipv6(struct sk_buff *skb);
64
Alexander Aring8691ee52015-01-04 17:10:54 +010065#endif /* __IEEE802154_6LOWPAN_I_H__ */