Commit 6cbd05b2 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge tag 'ieee802154-for-net-next-2022-06-09' of...

Merge tag 'ieee802154-for-net-next-2022-06-09' of git://git.kernel.org/pub/scm/linux/kernel/git/sschmidt/wpan-next

Stefan Schmidt says:

====================
pull-request: ieee802154-next 2022-06-09

This is a separate pull request for 6lowpan changes. We agreed with the
bluetooth maintainers to switch the trees these changing are going into
from bluetooth to ieee802154.

Jukka Rissanen stepped down as a co-maintainer of 6lowpan (Thanks for the
work!). Alexander is staying as maintainer.

Alexander reworked the nhc_id lookup in 6lowpan to be way simpler.
Moved the data structure from rb to an array, which is all we need in this
case.

* tag 'ieee802154-for-net-next-2022-06-09' of git://git.kernel.org/pub/scm/linux/kernel/git/sschmidt/wpan-next:
  MAINTAINERS: Remove Jukka Rissanen as 6lowpan maintainer
  net: 6lowpan: constify lowpan_nhc structures
  net: 6lowpan: use array for find nhc id
  net: 6lowpan: remove const from scalars
====================

Link: https://lore.kernel.org/r/20220609202956.1512156-1-stefan@datenfreihafen.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 70b1f299 260b5c69
...@@ -171,7 +171,6 @@ F: drivers/scsi/53c700* ...@@ -171,7 +171,6 @@ F: drivers/scsi/53c700*
6LOWPAN GENERIC (BTLE/IEEE 802.15.4) 6LOWPAN GENERIC (BTLE/IEEE 802.15.4)
M: Alexander Aring <alex.aring@gmail.com> M: Alexander Aring <alex.aring@gmail.com>
M: Jukka Rissanen <jukka.rissanen@linux.intel.com>
L: linux-bluetooth@vger.kernel.org L: linux-bluetooth@vger.kernel.org
L: linux-wpan@vger.kernel.org L: linux-wpan@vger.kernel.org
S: Maintained S: Maintained
......
...@@ -12,77 +12,26 @@ ...@@ -12,77 +12,26 @@
#include "nhc.h" #include "nhc.h"
static struct rb_root rb_root = RB_ROOT; static const struct lowpan_nhc *lowpan_nexthdr_nhcs[NEXTHDR_MAX + 1];
static struct lowpan_nhc *lowpan_nexthdr_nhcs[NEXTHDR_MAX + 1];
static DEFINE_SPINLOCK(lowpan_nhc_lock); static DEFINE_SPINLOCK(lowpan_nhc_lock);
static int lowpan_nhc_insert(struct lowpan_nhc *nhc) static const struct lowpan_nhc *lowpan_nhc_by_nhcid(struct sk_buff *skb)
{ {
struct rb_node **new = &rb_root.rb_node, *parent = NULL; const struct lowpan_nhc *nhc;
int i;
/* Figure out where to put new node */ u8 id;
while (*new) {
struct lowpan_nhc *this = rb_entry(*new, struct lowpan_nhc,
node);
int result, len_dif, len;
len_dif = nhc->idlen - this->idlen;
if (nhc->idlen < this->idlen)
len = nhc->idlen;
else
len = this->idlen;
result = memcmp(nhc->id, this->id, len);
if (!result)
result = len_dif;
parent = *new;
if (result < 0)
new = &((*new)->rb_left);
else if (result > 0)
new = &((*new)->rb_right);
else
return -EEXIST;
}
/* Add new node and rebalance tree. */ if (!pskb_may_pull(skb, 1))
rb_link_node(&nhc->node, parent, new); return NULL;
rb_insert_color(&nhc->node, &rb_root);
return 0; id = *skb->data;
}
static void lowpan_nhc_remove(struct lowpan_nhc *nhc) for (i = 0; i < NEXTHDR_MAX + 1; i++) {
{ nhc = lowpan_nexthdr_nhcs[i];
rb_erase(&nhc->node, &rb_root); if (!nhc)
} continue;
static struct lowpan_nhc *lowpan_nhc_by_nhcid(const struct sk_buff *skb) if ((id & nhc->idmask) == nhc->id)
{
struct rb_node *node = rb_root.rb_node;
const u8 *nhcid_skb_ptr = skb->data;
while (node) {
struct lowpan_nhc *nhc = rb_entry(node, struct lowpan_nhc,
node);
u8 nhcid_skb_ptr_masked[LOWPAN_NHC_MAX_ID_LEN];
int result, i;
if (nhcid_skb_ptr + nhc->idlen > skb->data + skb->len)
return NULL;
/* copy and mask afterwards the nhid value from skb */
memcpy(nhcid_skb_ptr_masked, nhcid_skb_ptr, nhc->idlen);
for (i = 0; i < nhc->idlen; i++)
nhcid_skb_ptr_masked[i] &= nhc->idmask[i];
result = memcmp(nhcid_skb_ptr_masked, nhc->id, nhc->idlen);
if (result < 0)
node = node->rb_left;
else if (result > 0)
node = node->rb_right;
else
return nhc; return nhc;
} }
...@@ -92,7 +41,7 @@ static struct lowpan_nhc *lowpan_nhc_by_nhcid(const struct sk_buff *skb) ...@@ -92,7 +41,7 @@ static struct lowpan_nhc *lowpan_nhc_by_nhcid(const struct sk_buff *skb)
int lowpan_nhc_check_compression(struct sk_buff *skb, int lowpan_nhc_check_compression(struct sk_buff *skb,
const struct ipv6hdr *hdr, u8 **hc_ptr) const struct ipv6hdr *hdr, u8 **hc_ptr)
{ {
struct lowpan_nhc *nhc; const struct lowpan_nhc *nhc;
int ret = 0; int ret = 0;
spin_lock_bh(&lowpan_nhc_lock); spin_lock_bh(&lowpan_nhc_lock);
...@@ -110,7 +59,7 @@ int lowpan_nhc_do_compression(struct sk_buff *skb, const struct ipv6hdr *hdr, ...@@ -110,7 +59,7 @@ int lowpan_nhc_do_compression(struct sk_buff *skb, const struct ipv6hdr *hdr,
u8 **hc_ptr) u8 **hc_ptr)
{ {
int ret; int ret;
struct lowpan_nhc *nhc; const struct lowpan_nhc *nhc;
spin_lock_bh(&lowpan_nhc_lock); spin_lock_bh(&lowpan_nhc_lock);
...@@ -153,7 +102,7 @@ int lowpan_nhc_do_uncompression(struct sk_buff *skb, ...@@ -153,7 +102,7 @@ int lowpan_nhc_do_uncompression(struct sk_buff *skb,
const struct net_device *dev, const struct net_device *dev,
struct ipv6hdr *hdr) struct ipv6hdr *hdr)
{ {
struct lowpan_nhc *nhc; const struct lowpan_nhc *nhc;
int ret; int ret;
spin_lock_bh(&lowpan_nhc_lock); spin_lock_bh(&lowpan_nhc_lock);
...@@ -189,18 +138,9 @@ int lowpan_nhc_do_uncompression(struct sk_buff *skb, ...@@ -189,18 +138,9 @@ int lowpan_nhc_do_uncompression(struct sk_buff *skb,
return 0; return 0;
} }
int lowpan_nhc_add(struct lowpan_nhc *nhc) int lowpan_nhc_add(const struct lowpan_nhc *nhc)
{ {
int ret; int ret = 0;
if (!nhc->idlen || !nhc->idsetup)
return -EINVAL;
WARN_ONCE(nhc->idlen > LOWPAN_NHC_MAX_ID_LEN,
"LOWPAN_NHC_MAX_ID_LEN should be updated to %zd.\n",
nhc->idlen);
nhc->idsetup(nhc);
spin_lock_bh(&lowpan_nhc_lock); spin_lock_bh(&lowpan_nhc_lock);
...@@ -209,10 +149,6 @@ int lowpan_nhc_add(struct lowpan_nhc *nhc) ...@@ -209,10 +149,6 @@ int lowpan_nhc_add(struct lowpan_nhc *nhc)
goto out; goto out;
} }
ret = lowpan_nhc_insert(nhc);
if (ret < 0)
goto out;
lowpan_nexthdr_nhcs[nhc->nexthdr] = nhc; lowpan_nexthdr_nhcs[nhc->nexthdr] = nhc;
out: out:
spin_unlock_bh(&lowpan_nhc_lock); spin_unlock_bh(&lowpan_nhc_lock);
...@@ -220,11 +156,10 @@ int lowpan_nhc_add(struct lowpan_nhc *nhc) ...@@ -220,11 +156,10 @@ int lowpan_nhc_add(struct lowpan_nhc *nhc)
} }
EXPORT_SYMBOL(lowpan_nhc_add); EXPORT_SYMBOL(lowpan_nhc_add);
void lowpan_nhc_del(struct lowpan_nhc *nhc) void lowpan_nhc_del(const struct lowpan_nhc *nhc)
{ {
spin_lock_bh(&lowpan_nhc_lock); spin_lock_bh(&lowpan_nhc_lock);
lowpan_nhc_remove(nhc);
lowpan_nexthdr_nhcs[nhc->nexthdr] = NULL; lowpan_nexthdr_nhcs[nhc->nexthdr] = NULL;
spin_unlock_bh(&lowpan_nhc_lock); spin_unlock_bh(&lowpan_nhc_lock);
......
...@@ -16,24 +16,20 @@ ...@@ -16,24 +16,20 @@
* @_name: const char * of common header compression name. * @_name: const char * of common header compression name.
* @_nexthdr: ipv6 nexthdr field for the header compression. * @_nexthdr: ipv6 nexthdr field for the header compression.
* @_nexthdrlen: ipv6 nexthdr len for the reserved space. * @_nexthdrlen: ipv6 nexthdr len for the reserved space.
* @_idsetup: callback to setup id and mask values. * @_id: one byte nhc id value.
* @_idlen: len for the next header id and mask, should be always the same. * @_idmask: one byte nhc id mask value.
* @_uncompress: callback for uncompression call. * @_uncompress: callback for uncompression call.
* @_compress: callback for compression call. * @_compress: callback for compression call.
*/ */
#define LOWPAN_NHC(__nhc, _name, _nexthdr, \ #define LOWPAN_NHC(__nhc, _name, _nexthdr, \
_hdrlen, _idsetup, _idlen, \ _hdrlen, _id, _idmask, \
_uncompress, _compress) \ _uncompress, _compress) \
static u8 __nhc##_val[_idlen]; \ static const struct lowpan_nhc __nhc = { \
static u8 __nhc##_mask[_idlen]; \
static struct lowpan_nhc __nhc = { \
.name = _name, \ .name = _name, \
.nexthdr = _nexthdr, \ .nexthdr = _nexthdr, \
.nexthdrlen = _hdrlen, \ .nexthdrlen = _hdrlen, \
.id = __nhc##_val, \ .id = _id, \
.idmask = __nhc##_mask, \ .idmask = _idmask, \
.idlen = _idlen, \
.idsetup = _idsetup, \
.uncompress = _uncompress, \ .uncompress = _uncompress, \
.compress = _compress, \ .compress = _compress, \
} }
...@@ -53,27 +49,21 @@ module_exit(__nhc##_exit); ...@@ -53,27 +49,21 @@ module_exit(__nhc##_exit);
/** /**
* struct lowpan_nhc - hold 6lowpan next hdr compression ifnformation * struct lowpan_nhc - hold 6lowpan next hdr compression ifnformation
* *
* @node: holder for the rbtree.
* @name: name of the specific next header compression * @name: name of the specific next header compression
* @nexthdr: next header value of the protocol which should be compressed. * @nexthdr: next header value of the protocol which should be compressed.
* @nexthdrlen: ipv6 nexthdr len for the reserved space. * @nexthdrlen: ipv6 nexthdr len for the reserved space.
* @id: array for nhc id. Note this need to be in network byteorder. * @id: one byte nhc id value.
* @mask: array for nhc id mask. Note this need to be in network byteorder. * @idmask: one byte nhc id mask value.
* @len: the length of the next header id and mask.
* @setup: callback to setup fill the next header id value and mask.
* @compress: callback to do the header compression. * @compress: callback to do the header compression.
* @uncompress: callback to do the header uncompression. * @uncompress: callback to do the header uncompression.
*/ */
struct lowpan_nhc { struct lowpan_nhc {
struct rb_node node;
const char *name; const char *name;
const u8 nexthdr; u8 nexthdr;
const size_t nexthdrlen; size_t nexthdrlen;
u8 *id; u8 id;
u8 *idmask; u8 idmask;
const size_t idlen;
void (*idsetup)(struct lowpan_nhc *nhc);
int (*uncompress)(struct sk_buff *skb, size_t needed); int (*uncompress)(struct sk_buff *skb, size_t needed);
int (*compress)(struct sk_buff *skb, u8 **hc_ptr); int (*compress)(struct sk_buff *skb, u8 **hc_ptr);
}; };
...@@ -126,14 +116,14 @@ int lowpan_nhc_do_uncompression(struct sk_buff *skb, ...@@ -126,14 +116,14 @@ int lowpan_nhc_do_uncompression(struct sk_buff *skb,
* *
* @nhc: nhc which should be add. * @nhc: nhc which should be add.
*/ */
int lowpan_nhc_add(struct lowpan_nhc *nhc); int lowpan_nhc_add(const struct lowpan_nhc *nhc);
/** /**
* lowpan_nhc_del - delete a next header compression from framework * lowpan_nhc_del - delete a next header compression from framework
* *
* @nhc: nhc which should be delete. * @nhc: nhc which should be delete.
*/ */
void lowpan_nhc_del(struct lowpan_nhc *nhc); void lowpan_nhc_del(const struct lowpan_nhc *nhc);
/** /**
* lowpan_nhc_init - adding all default nhcs * lowpan_nhc_init - adding all default nhcs
......
...@@ -6,18 +6,11 @@ ...@@ -6,18 +6,11 @@
#include "nhc.h" #include "nhc.h"
#define LOWPAN_NHC_DEST_IDLEN 1
#define LOWPAN_NHC_DEST_ID_0 0xe6 #define LOWPAN_NHC_DEST_ID_0 0xe6
#define LOWPAN_NHC_DEST_MASK_0 0xfe #define LOWPAN_NHC_DEST_MASK_0 0xfe
static void dest_nhid_setup(struct lowpan_nhc *nhc)
{
nhc->id[0] = LOWPAN_NHC_DEST_ID_0;
nhc->idmask[0] = LOWPAN_NHC_DEST_MASK_0;
}
LOWPAN_NHC(nhc_dest, "RFC6282 Destination Options", NEXTHDR_DEST, 0, LOWPAN_NHC(nhc_dest, "RFC6282 Destination Options", NEXTHDR_DEST, 0,
dest_nhid_setup, LOWPAN_NHC_DEST_IDLEN, NULL, NULL); LOWPAN_NHC_DEST_ID_0, LOWPAN_NHC_DEST_MASK_0, NULL, NULL);
module_lowpan_nhc(nhc_dest); module_lowpan_nhc(nhc_dest);
MODULE_DESCRIPTION("6LoWPAN next header RFC6282 Destination Options compression"); MODULE_DESCRIPTION("6LoWPAN next header RFC6282 Destination Options compression");
......
...@@ -5,18 +5,11 @@ ...@@ -5,18 +5,11 @@
#include "nhc.h" #include "nhc.h"
#define LOWPAN_NHC_FRAGMENT_IDLEN 1
#define LOWPAN_NHC_FRAGMENT_ID_0 0xe4 #define LOWPAN_NHC_FRAGMENT_ID_0 0xe4
#define LOWPAN_NHC_FRAGMENT_MASK_0 0xfe #define LOWPAN_NHC_FRAGMENT_MASK_0 0xfe
static void fragment_nhid_setup(struct lowpan_nhc *nhc)
{
nhc->id[0] = LOWPAN_NHC_FRAGMENT_ID_0;
nhc->idmask[0] = LOWPAN_NHC_FRAGMENT_MASK_0;
}
LOWPAN_NHC(nhc_fragment, "RFC6282 Fragment", NEXTHDR_FRAGMENT, 0, LOWPAN_NHC(nhc_fragment, "RFC6282 Fragment", NEXTHDR_FRAGMENT, 0,
fragment_nhid_setup, LOWPAN_NHC_FRAGMENT_IDLEN, NULL, NULL); LOWPAN_NHC_FRAGMENT_ID_0, LOWPAN_NHC_FRAGMENT_MASK_0, NULL, NULL);
module_lowpan_nhc(nhc_fragment); module_lowpan_nhc(nhc_fragment);
MODULE_DESCRIPTION("6LoWPAN next header RFC6282 Fragment compression"); MODULE_DESCRIPTION("6LoWPAN next header RFC6282 Fragment compression");
......
...@@ -5,18 +5,11 @@ ...@@ -5,18 +5,11 @@
#include "nhc.h" #include "nhc.h"
#define LOWPAN_GHC_EXT_DEST_IDLEN 1
#define LOWPAN_GHC_EXT_DEST_ID_0 0xb6 #define LOWPAN_GHC_EXT_DEST_ID_0 0xb6
#define LOWPAN_GHC_EXT_DEST_MASK_0 0xfe #define LOWPAN_GHC_EXT_DEST_MASK_0 0xfe
static void dest_ghid_setup(struct lowpan_nhc *nhc)
{
nhc->id[0] = LOWPAN_GHC_EXT_DEST_ID_0;
nhc->idmask[0] = LOWPAN_GHC_EXT_DEST_MASK_0;
}
LOWPAN_NHC(ghc_ext_dest, "RFC7400 Destination Extension Header", NEXTHDR_DEST, LOWPAN_NHC(ghc_ext_dest, "RFC7400 Destination Extension Header", NEXTHDR_DEST,
0, dest_ghid_setup, LOWPAN_GHC_EXT_DEST_IDLEN, NULL, NULL); 0, LOWPAN_GHC_EXT_DEST_ID_0, LOWPAN_GHC_EXT_DEST_MASK_0, NULL, NULL);
module_lowpan_nhc(ghc_ext_dest); module_lowpan_nhc(ghc_ext_dest);
MODULE_DESCRIPTION("6LoWPAN generic header destination extension compression"); MODULE_DESCRIPTION("6LoWPAN generic header destination extension compression");
......
...@@ -5,19 +5,12 @@ ...@@ -5,19 +5,12 @@
#include "nhc.h" #include "nhc.h"
#define LOWPAN_GHC_EXT_FRAG_IDLEN 1
#define LOWPAN_GHC_EXT_FRAG_ID_0 0xb4 #define LOWPAN_GHC_EXT_FRAG_ID_0 0xb4
#define LOWPAN_GHC_EXT_FRAG_MASK_0 0xfe #define LOWPAN_GHC_EXT_FRAG_MASK_0 0xfe
static void frag_ghid_setup(struct lowpan_nhc *nhc)
{
nhc->id[0] = LOWPAN_GHC_EXT_FRAG_ID_0;
nhc->idmask[0] = LOWPAN_GHC_EXT_FRAG_MASK_0;
}
LOWPAN_NHC(ghc_ext_frag, "RFC7400 Fragmentation Extension Header", LOWPAN_NHC(ghc_ext_frag, "RFC7400 Fragmentation Extension Header",
NEXTHDR_FRAGMENT, 0, frag_ghid_setup, NEXTHDR_FRAGMENT, 0, LOWPAN_GHC_EXT_FRAG_ID_0,
LOWPAN_GHC_EXT_FRAG_IDLEN, NULL, NULL); LOWPAN_GHC_EXT_FRAG_MASK_0, NULL, NULL);
module_lowpan_nhc(ghc_ext_frag); module_lowpan_nhc(ghc_ext_frag);
MODULE_DESCRIPTION("6LoWPAN generic header fragmentation extension compression"); MODULE_DESCRIPTION("6LoWPAN generic header fragmentation extension compression");
......
...@@ -5,18 +5,11 @@ ...@@ -5,18 +5,11 @@
#include "nhc.h" #include "nhc.h"
#define LOWPAN_GHC_EXT_HOP_IDLEN 1
#define LOWPAN_GHC_EXT_HOP_ID_0 0xb0 #define LOWPAN_GHC_EXT_HOP_ID_0 0xb0
#define LOWPAN_GHC_EXT_HOP_MASK_0 0xfe #define LOWPAN_GHC_EXT_HOP_MASK_0 0xfe
static void hop_ghid_setup(struct lowpan_nhc *nhc)
{
nhc->id[0] = LOWPAN_GHC_EXT_HOP_ID_0;
nhc->idmask[0] = LOWPAN_GHC_EXT_HOP_MASK_0;
}
LOWPAN_NHC(ghc_ext_hop, "RFC7400 Hop-by-Hop Extension Header", NEXTHDR_HOP, 0, LOWPAN_NHC(ghc_ext_hop, "RFC7400 Hop-by-Hop Extension Header", NEXTHDR_HOP, 0,
hop_ghid_setup, LOWPAN_GHC_EXT_HOP_IDLEN, NULL, NULL); LOWPAN_GHC_EXT_HOP_ID_0, LOWPAN_GHC_EXT_HOP_MASK_0, NULL, NULL);
module_lowpan_nhc(ghc_ext_hop); module_lowpan_nhc(ghc_ext_hop);
MODULE_DESCRIPTION("6LoWPAN generic header hop-by-hop extension compression"); MODULE_DESCRIPTION("6LoWPAN generic header hop-by-hop extension compression");
......
...@@ -5,18 +5,11 @@ ...@@ -5,18 +5,11 @@
#include "nhc.h" #include "nhc.h"
#define LOWPAN_GHC_EXT_ROUTE_IDLEN 1
#define LOWPAN_GHC_EXT_ROUTE_ID_0 0xb2 #define LOWPAN_GHC_EXT_ROUTE_ID_0 0xb2
#define LOWPAN_GHC_EXT_ROUTE_MASK_0 0xfe #define LOWPAN_GHC_EXT_ROUTE_MASK_0 0xfe
static void route_ghid_setup(struct lowpan_nhc *nhc)
{
nhc->id[0] = LOWPAN_GHC_EXT_ROUTE_ID_0;
nhc->idmask[0] = LOWPAN_GHC_EXT_ROUTE_MASK_0;
}
LOWPAN_NHC(ghc_ext_route, "RFC7400 Routing Extension Header", NEXTHDR_ROUTING, LOWPAN_NHC(ghc_ext_route, "RFC7400 Routing Extension Header", NEXTHDR_ROUTING,
0, route_ghid_setup, LOWPAN_GHC_EXT_ROUTE_IDLEN, NULL, NULL); 0, LOWPAN_GHC_EXT_ROUTE_ID_0, LOWPAN_GHC_EXT_ROUTE_MASK_0, NULL, NULL);
module_lowpan_nhc(ghc_ext_route); module_lowpan_nhc(ghc_ext_route);
MODULE_DESCRIPTION("6LoWPAN generic header routing extension compression"); MODULE_DESCRIPTION("6LoWPAN generic header routing extension compression");
......
...@@ -5,18 +5,11 @@ ...@@ -5,18 +5,11 @@
#include "nhc.h" #include "nhc.h"
#define LOWPAN_GHC_ICMPV6_IDLEN 1
#define LOWPAN_GHC_ICMPV6_ID_0 0xdf #define LOWPAN_GHC_ICMPV6_ID_0 0xdf
#define LOWPAN_GHC_ICMPV6_MASK_0 0xff #define LOWPAN_GHC_ICMPV6_MASK_0 0xff
static void icmpv6_ghid_setup(struct lowpan_nhc *nhc)
{
nhc->id[0] = LOWPAN_GHC_ICMPV6_ID_0;
nhc->idmask[0] = LOWPAN_GHC_ICMPV6_MASK_0;
}
LOWPAN_NHC(ghc_icmpv6, "RFC7400 ICMPv6", NEXTHDR_ICMP, 0, LOWPAN_NHC(ghc_icmpv6, "RFC7400 ICMPv6", NEXTHDR_ICMP, 0,
icmpv6_ghid_setup, LOWPAN_GHC_ICMPV6_IDLEN, NULL, NULL); LOWPAN_GHC_ICMPV6_ID_0, LOWPAN_GHC_ICMPV6_MASK_0, NULL, NULL);
module_lowpan_nhc(ghc_icmpv6); module_lowpan_nhc(ghc_icmpv6);
MODULE_DESCRIPTION("6LoWPAN generic header ICMPv6 compression"); MODULE_DESCRIPTION("6LoWPAN generic header ICMPv6 compression");
......
...@@ -5,18 +5,11 @@ ...@@ -5,18 +5,11 @@
#include "nhc.h" #include "nhc.h"
#define LOWPAN_GHC_UDP_IDLEN 1
#define LOWPAN_GHC_UDP_ID_0 0xd0 #define LOWPAN_GHC_UDP_ID_0 0xd0
#define LOWPAN_GHC_UDP_MASK_0 0xf8 #define LOWPAN_GHC_UDP_MASK_0 0xf8
static void udp_ghid_setup(struct lowpan_nhc *nhc)
{
nhc->id[0] = LOWPAN_GHC_UDP_ID_0;
nhc->idmask[0] = LOWPAN_GHC_UDP_MASK_0;
}
LOWPAN_NHC(ghc_udp, "RFC7400 UDP", NEXTHDR_UDP, 0, LOWPAN_NHC(ghc_udp, "RFC7400 UDP", NEXTHDR_UDP, 0,
udp_ghid_setup, LOWPAN_GHC_UDP_IDLEN, NULL, NULL); LOWPAN_GHC_UDP_ID_0, LOWPAN_GHC_UDP_MASK_0, NULL, NULL);
module_lowpan_nhc(ghc_udp); module_lowpan_nhc(ghc_udp);
MODULE_DESCRIPTION("6LoWPAN generic header UDP compression"); MODULE_DESCRIPTION("6LoWPAN generic header UDP compression");
......
...@@ -5,18 +5,11 @@ ...@@ -5,18 +5,11 @@
#include "nhc.h" #include "nhc.h"
#define LOWPAN_NHC_HOP_IDLEN 1
#define LOWPAN_NHC_HOP_ID_0 0xe0 #define LOWPAN_NHC_HOP_ID_0 0xe0
#define LOWPAN_NHC_HOP_MASK_0 0xfe #define LOWPAN_NHC_HOP_MASK_0 0xfe
static void hop_nhid_setup(struct lowpan_nhc *nhc)
{
nhc->id[0] = LOWPAN_NHC_HOP_ID_0;
nhc->idmask[0] = LOWPAN_NHC_HOP_MASK_0;
}
LOWPAN_NHC(nhc_hop, "RFC6282 Hop-by-Hop Options", NEXTHDR_HOP, 0, LOWPAN_NHC(nhc_hop, "RFC6282 Hop-by-Hop Options", NEXTHDR_HOP, 0,
hop_nhid_setup, LOWPAN_NHC_HOP_IDLEN, NULL, NULL); LOWPAN_NHC_HOP_ID_0, LOWPAN_NHC_HOP_MASK_0, NULL, NULL);
module_lowpan_nhc(nhc_hop); module_lowpan_nhc(nhc_hop);
MODULE_DESCRIPTION("6LoWPAN next header RFC6282 Hop-by-Hop Options compression"); MODULE_DESCRIPTION("6LoWPAN next header RFC6282 Hop-by-Hop Options compression");
......
...@@ -5,18 +5,11 @@ ...@@ -5,18 +5,11 @@
#include "nhc.h" #include "nhc.h"
#define LOWPAN_NHC_IPV6_IDLEN 1
#define LOWPAN_NHC_IPV6_ID_0 0xee #define LOWPAN_NHC_IPV6_ID_0 0xee
#define LOWPAN_NHC_IPV6_MASK_0 0xfe #define LOWPAN_NHC_IPV6_MASK_0 0xfe
static void ipv6_nhid_setup(struct lowpan_nhc *nhc) LOWPAN_NHC(nhc_ipv6, "RFC6282 IPv6", NEXTHDR_IPV6, 0, LOWPAN_NHC_IPV6_ID_0,
{ LOWPAN_NHC_IPV6_MASK_0, NULL, NULL);
nhc->id[0] = LOWPAN_NHC_IPV6_ID_0;
nhc->idmask[0] = LOWPAN_NHC_IPV6_MASK_0;
}
LOWPAN_NHC(nhc_ipv6, "RFC6282 IPv6", NEXTHDR_IPV6, 0, ipv6_nhid_setup,
LOWPAN_NHC_IPV6_IDLEN, NULL, NULL);
module_lowpan_nhc(nhc_ipv6); module_lowpan_nhc(nhc_ipv6);
MODULE_DESCRIPTION("6LoWPAN next header RFC6282 IPv6 compression"); MODULE_DESCRIPTION("6LoWPAN next header RFC6282 IPv6 compression");
......
...@@ -5,18 +5,11 @@ ...@@ -5,18 +5,11 @@
#include "nhc.h" #include "nhc.h"
#define LOWPAN_NHC_MOBILITY_IDLEN 1
#define LOWPAN_NHC_MOBILITY_ID_0 0xe8 #define LOWPAN_NHC_MOBILITY_ID_0 0xe8
#define LOWPAN_NHC_MOBILITY_MASK_0 0xfe #define LOWPAN_NHC_MOBILITY_MASK_0 0xfe
static void mobility_nhid_setup(struct lowpan_nhc *nhc)
{
nhc->id[0] = LOWPAN_NHC_MOBILITY_ID_0;
nhc->idmask[0] = LOWPAN_NHC_MOBILITY_MASK_0;
}
LOWPAN_NHC(nhc_mobility, "RFC6282 Mobility", NEXTHDR_MOBILITY, 0, LOWPAN_NHC(nhc_mobility, "RFC6282 Mobility", NEXTHDR_MOBILITY, 0,
mobility_nhid_setup, LOWPAN_NHC_MOBILITY_IDLEN, NULL, NULL); LOWPAN_NHC_MOBILITY_ID_0, LOWPAN_NHC_MOBILITY_MASK_0, NULL, NULL);
module_lowpan_nhc(nhc_mobility); module_lowpan_nhc(nhc_mobility);
MODULE_DESCRIPTION("6LoWPAN next header RFC6282 Mobility compression"); MODULE_DESCRIPTION("6LoWPAN next header RFC6282 Mobility compression");
......
...@@ -5,18 +5,11 @@ ...@@ -5,18 +5,11 @@
#include "nhc.h" #include "nhc.h"
#define LOWPAN_NHC_ROUTING_IDLEN 1
#define LOWPAN_NHC_ROUTING_ID_0 0xe2 #define LOWPAN_NHC_ROUTING_ID_0 0xe2
#define LOWPAN_NHC_ROUTING_MASK_0 0xfe #define LOWPAN_NHC_ROUTING_MASK_0 0xfe
static void routing_nhid_setup(struct lowpan_nhc *nhc)
{
nhc->id[0] = LOWPAN_NHC_ROUTING_ID_0;
nhc->idmask[0] = LOWPAN_NHC_ROUTING_MASK_0;
}
LOWPAN_NHC(nhc_routing, "RFC6282 Routing", NEXTHDR_ROUTING, 0, LOWPAN_NHC(nhc_routing, "RFC6282 Routing", NEXTHDR_ROUTING, 0,
routing_nhid_setup, LOWPAN_NHC_ROUTING_IDLEN, NULL, NULL); LOWPAN_NHC_ROUTING_ID_0, LOWPAN_NHC_ROUTING_MASK_0, NULL, NULL);
module_lowpan_nhc(nhc_routing); module_lowpan_nhc(nhc_routing);
MODULE_DESCRIPTION("6LoWPAN next header RFC6282 Routing compression"); MODULE_DESCRIPTION("6LoWPAN next header RFC6282 Routing compression");
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#define LOWPAN_NHC_UDP_MASK 0xF8 #define LOWPAN_NHC_UDP_MASK 0xF8
#define LOWPAN_NHC_UDP_ID 0xF0 #define LOWPAN_NHC_UDP_ID 0xF0
#define LOWPAN_NHC_UDP_IDLEN 1
#define LOWPAN_NHC_UDP_4BIT_PORT 0xF0B0 #define LOWPAN_NHC_UDP_4BIT_PORT 0xF0B0
#define LOWPAN_NHC_UDP_4BIT_MASK 0xFFF0 #define LOWPAN_NHC_UDP_4BIT_MASK 0xFFF0
...@@ -169,14 +168,8 @@ static int udp_compress(struct sk_buff *skb, u8 **hc_ptr) ...@@ -169,14 +168,8 @@ static int udp_compress(struct sk_buff *skb, u8 **hc_ptr)
return 0; return 0;
} }
static void udp_nhid_setup(struct lowpan_nhc *nhc)
{
nhc->id[0] = LOWPAN_NHC_UDP_ID;
nhc->idmask[0] = LOWPAN_NHC_UDP_MASK;
}
LOWPAN_NHC(nhc_udp, "RFC6282 UDP", NEXTHDR_UDP, sizeof(struct udphdr), LOWPAN_NHC(nhc_udp, "RFC6282 UDP", NEXTHDR_UDP, sizeof(struct udphdr),
udp_nhid_setup, LOWPAN_NHC_UDP_IDLEN, udp_uncompress, udp_compress); LOWPAN_NHC_UDP_ID, LOWPAN_NHC_UDP_MASK, udp_uncompress, udp_compress);
module_lowpan_nhc(nhc_udp); module_lowpan_nhc(nhc_udp);
MODULE_DESCRIPTION("6LoWPAN next header RFC6282 UDP compression"); MODULE_DESCRIPTION("6LoWPAN next header RFC6282 UDP compression");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment