![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 #ifndef __6LOWPAN_NHC_H 0003 #define __6LOWPAN_NHC_H 0004 0005 #include <linux/skbuff.h> 0006 #include <linux/rbtree.h> 0007 #include <linux/module.h> 0008 0009 #include <net/6lowpan.h> 0010 #include <net/ipv6.h> 0011 0012 /** 0013 * LOWPAN_NHC - helper macro to generate nh id fields and lowpan_nhc struct 0014 * 0015 * @__nhc: variable name of the lowpan_nhc struct. 0016 * @_name: const char * of common header compression name. 0017 * @_nexthdr: ipv6 nexthdr field for the header compression. 0018 * @_nexthdrlen: ipv6 nexthdr len for the reserved space. 0019 * @_id: one byte nhc id value. 0020 * @_idmask: one byte nhc id mask value. 0021 * @_uncompress: callback for uncompression call. 0022 * @_compress: callback for compression call. 0023 */ 0024 #define LOWPAN_NHC(__nhc, _name, _nexthdr, \ 0025 _hdrlen, _id, _idmask, \ 0026 _uncompress, _compress) \ 0027 static const struct lowpan_nhc __nhc = { \ 0028 .name = _name, \ 0029 .nexthdr = _nexthdr, \ 0030 .nexthdrlen = _hdrlen, \ 0031 .id = _id, \ 0032 .idmask = _idmask, \ 0033 .uncompress = _uncompress, \ 0034 .compress = _compress, \ 0035 } 0036 0037 #define module_lowpan_nhc(__nhc) \ 0038 static int __init __nhc##_init(void) \ 0039 { \ 0040 return lowpan_nhc_add(&(__nhc)); \ 0041 } \ 0042 module_init(__nhc##_init); \ 0043 static void __exit __nhc##_exit(void) \ 0044 { \ 0045 lowpan_nhc_del(&(__nhc)); \ 0046 } \ 0047 module_exit(__nhc##_exit); 0048 0049 /** 0050 * struct lowpan_nhc - hold 6lowpan next hdr compression ifnformation 0051 * 0052 * @name: name of the specific next header compression 0053 * @nexthdr: next header value of the protocol which should be compressed. 0054 * @nexthdrlen: ipv6 nexthdr len for the reserved space. 0055 * @id: one byte nhc id value. 0056 * @idmask: one byte nhc id mask value. 0057 * @compress: callback to do the header compression. 0058 * @uncompress: callback to do the header uncompression. 0059 */ 0060 struct lowpan_nhc { 0061 const char *name; 0062 u8 nexthdr; 0063 size_t nexthdrlen; 0064 u8 id; 0065 u8 idmask; 0066 0067 int (*uncompress)(struct sk_buff *skb, size_t needed); 0068 int (*compress)(struct sk_buff *skb, u8 **hc_ptr); 0069 }; 0070 0071 /** 0072 * lowpan_nhc_by_nexthdr - return the 6lowpan nhc by ipv6 nexthdr. 0073 * 0074 * @nexthdr: ipv6 nexthdr value. 0075 */ 0076 struct lowpan_nhc *lowpan_nhc_by_nexthdr(u8 nexthdr); 0077 0078 /** 0079 * lowpan_nhc_check_compression - checks if we support compression format. If 0080 * we support the nhc by nexthdr field, the function will return 0. If we 0081 * don't support the nhc by nexthdr this function will return -ENOENT. 0082 * 0083 * @skb: skb of 6LoWPAN header to read nhc and replace header. 0084 * @hdr: ipv6hdr to check the nexthdr value 0085 * @hc_ptr: pointer for 6LoWPAN header which should increment at the end of 0086 * replaced header. 0087 */ 0088 int lowpan_nhc_check_compression(struct sk_buff *skb, 0089 const struct ipv6hdr *hdr, u8 **hc_ptr); 0090 0091 /** 0092 * lowpan_nhc_do_compression - calling compress callback for nhc 0093 * 0094 * @skb: skb of 6LoWPAN header to read nhc and replace header. 0095 * @hdr: ipv6hdr to set the nexthdr value 0096 * @hc_ptr: pointer for 6LoWPAN header which should increment at the end of 0097 * replaced header. 0098 */ 0099 int lowpan_nhc_do_compression(struct sk_buff *skb, const struct ipv6hdr *hdr, 0100 u8 **hc_ptr); 0101 0102 /** 0103 * lowpan_nhc_do_uncompression - calling uncompress callback for nhc 0104 * 0105 * @nhc: 6LoWPAN nhc context, get by lowpan_nhc_by_ functions. 0106 * @skb: skb of 6LoWPAN header, skb->data should be pointed to nhc id value. 0107 * @dev: netdevice for print logging information. 0108 * @hdr: ipv6hdr for setting nexthdr value. 0109 */ 0110 int lowpan_nhc_do_uncompression(struct sk_buff *skb, 0111 const struct net_device *dev, 0112 struct ipv6hdr *hdr); 0113 0114 /** 0115 * lowpan_nhc_add - register a next header compression to framework 0116 * 0117 * @nhc: nhc which should be add. 0118 */ 0119 int lowpan_nhc_add(const struct lowpan_nhc *nhc); 0120 0121 /** 0122 * lowpan_nhc_del - delete a next header compression from framework 0123 * 0124 * @nhc: nhc which should be delete. 0125 */ 0126 void lowpan_nhc_del(const struct lowpan_nhc *nhc); 0127 0128 /** 0129 * lowpan_nhc_init - adding all default nhcs 0130 */ 0131 void lowpan_nhc_init(void); 0132 0133 #endif /* __6LOWPAN_NHC_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |