~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/6lowpan/nhc.h

Version: ~ [ linux-5.7-rc7 ] ~ [ linux-5.6.14 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.42 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.124 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.181 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.224 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.224 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.84 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __6LOWPAN_NHC_H
  3 #define __6LOWPAN_NHC_H
  4 
  5 #include <linux/skbuff.h>
  6 #include <linux/rbtree.h>
  7 #include <linux/module.h>
  8 
  9 #include <net/6lowpan.h>
 10 #include <net/ipv6.h>
 11 
 12 /**
 13  * LOWPAN_NHC - helper macro to generate nh id fields and lowpan_nhc struct
 14  *
 15  * @__nhc: variable name of the lowpan_nhc struct.
 16  * @_name: const char * of common header compression name.
 17  * @_nexthdr: ipv6 nexthdr field for the header compression.
 18  * @_nexthdrlen: ipv6 nexthdr len for the reserved space.
 19  * @_idsetup: callback to setup id and mask values.
 20  * @_idlen: len for the next header id and mask, should be always the same.
 21  * @_uncompress: callback for uncompression call.
 22  * @_compress: callback for compression call.
 23  */
 24 #define LOWPAN_NHC(__nhc, _name, _nexthdr,      \
 25                    _hdrlen, _idsetup, _idlen,   \
 26                    _uncompress, _compress)      \
 27 static u8 __nhc##_val[_idlen];                  \
 28 static u8 __nhc##_mask[_idlen];                 \
 29 static struct lowpan_nhc __nhc = {              \
 30         .name           = _name,                \
 31         .nexthdr        = _nexthdr,             \
 32         .nexthdrlen     = _hdrlen,              \
 33         .id             = __nhc##_val,          \
 34         .idmask         = __nhc##_mask,         \
 35         .idlen          = _idlen,               \
 36         .idsetup        = _idsetup,             \
 37         .uncompress     = _uncompress,          \
 38         .compress       = _compress,            \
 39 }
 40 
 41 #define module_lowpan_nhc(__nhc)                \
 42 static int __init __nhc##_init(void)            \
 43 {                                               \
 44         return lowpan_nhc_add(&(__nhc));        \
 45 }                                               \
 46 module_init(__nhc##_init);                      \
 47 static void __exit __nhc##_exit(void)           \
 48 {                                               \
 49         lowpan_nhc_del(&(__nhc));               \
 50 }                                               \
 51 module_exit(__nhc##_exit);
 52 
 53 /**
 54  * struct lowpan_nhc - hold 6lowpan next hdr compression ifnformation
 55  *
 56  * @node: holder for the rbtree.
 57  * @name: name of the specific next header compression
 58  * @nexthdr: next header value of the protocol which should be compressed.
 59  * @nexthdrlen: ipv6 nexthdr len for the reserved space.
 60  * @id: array for nhc id. Note this need to be in network byteorder.
 61  * @mask: array for nhc id mask. Note this need to be in network byteorder.
 62  * @len: the length of the next header id and mask.
 63  * @setup: callback to setup fill the next header id value and mask.
 64  * @compress: callback to do the header compression.
 65  * @uncompress: callback to do the header uncompression.
 66  */
 67 struct lowpan_nhc {
 68         struct rb_node  node;
 69         const char      *name;
 70         const u8        nexthdr;
 71         const size_t    nexthdrlen;
 72         u8              *id;
 73         u8              *idmask;
 74         const size_t    idlen;
 75 
 76         void            (*idsetup)(struct lowpan_nhc *nhc);
 77         int             (*uncompress)(struct sk_buff *skb, size_t needed);
 78         int             (*compress)(struct sk_buff *skb, u8 **hc_ptr);
 79 };
 80 
 81 /**
 82  * lowpan_nhc_by_nexthdr - return the 6lowpan nhc by ipv6 nexthdr.
 83  *
 84  * @nexthdr: ipv6 nexthdr value.
 85  */
 86 struct lowpan_nhc *lowpan_nhc_by_nexthdr(u8 nexthdr);
 87 
 88 /**
 89  * lowpan_nhc_check_compression - checks if we support compression format. If
 90  *      we support the nhc by nexthdr field, the function will return 0. If we
 91  *      don't support the nhc by nexthdr this function will return -ENOENT.
 92  *
 93  * @skb: skb of 6LoWPAN header to read nhc and replace header.
 94  * @hdr: ipv6hdr to check the nexthdr value
 95  * @hc_ptr: pointer for 6LoWPAN header which should increment at the end of
 96  *          replaced header.
 97  */
 98 int lowpan_nhc_check_compression(struct sk_buff *skb,
 99                                  const struct ipv6hdr *hdr, u8 **hc_ptr);
100 
101 /**
102  * lowpan_nhc_do_compression - calling compress callback for nhc
103  *
104  * @skb: skb of 6LoWPAN header to read nhc and replace header.
105  * @hdr: ipv6hdr to set the nexthdr value
106  * @hc_ptr: pointer for 6LoWPAN header which should increment at the end of
107  *          replaced header.
108  */
109 int lowpan_nhc_do_compression(struct sk_buff *skb, const struct ipv6hdr *hdr,
110                               u8 **hc_ptr);
111 
112 /**
113  * lowpan_nhc_do_uncompression - calling uncompress callback for nhc
114  *
115  * @nhc: 6LoWPAN nhc context, get by lowpan_nhc_by_ functions.
116  * @skb: skb of 6LoWPAN header, skb->data should be pointed to nhc id value.
117  * @dev: netdevice for print logging information.
118  * @hdr: ipv6hdr for setting nexthdr value.
119  */
120 int lowpan_nhc_do_uncompression(struct sk_buff *skb,
121                                 const struct net_device *dev,
122                                 struct ipv6hdr *hdr);
123 
124 /**
125  * lowpan_nhc_add - register a next header compression to framework
126  *
127  * @nhc: nhc which should be add.
128  */
129 int lowpan_nhc_add(struct lowpan_nhc *nhc);
130 
131 /**
132  * lowpan_nhc_del - delete a next header compression from framework
133  *
134  * @nhc: nhc which should be delete.
135  */
136 void lowpan_nhc_del(struct lowpan_nhc *nhc);
137 
138 /**
139  * lowpan_nhc_init - adding all default nhcs
140  */
141 void lowpan_nhc_init(void);
142 
143 #endif /* __6LOWPAN_NHC_H */
144 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp