diff options
Diffstat (limited to 'net/ieee802154/6lowpan.h')
-rw-r--r-- | net/ieee802154/6lowpan.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/net/ieee802154/6lowpan.h b/net/ieee802154/6lowpan.h index 2869c0526dad..2b835db3bda8 100644 --- a/net/ieee802154/6lowpan.h +++ b/net/ieee802154/6lowpan.h | |||
@@ -231,6 +231,61 @@ | |||
231 | #define LOWPAN_NHC_UDP_CS_P_10 0xF2 /* source = 0xF0 + 8bit inline, | 231 | #define LOWPAN_NHC_UDP_CS_P_10 0xF2 /* source = 0xF0 + 8bit inline, |
232 | dest = 16 bit inline */ | 232 | dest = 16 bit inline */ |
233 | #define LOWPAN_NHC_UDP_CS_P_11 0xF3 /* source & dest = 0xF0B + 4bit inline */ | 233 | #define LOWPAN_NHC_UDP_CS_P_11 0xF3 /* source & dest = 0xF0B + 4bit inline */ |
234 | #define LOWPAN_NHC_UDP_CS_C 0x04 /* checksum elided */ | ||
235 | |||
236 | #ifdef DEBUG | ||
237 | /* print data in line */ | ||
238 | static inline void raw_dump_inline(const char *caller, char *msg, | ||
239 | unsigned char *buf, int len) | ||
240 | { | ||
241 | if (msg) | ||
242 | pr_debug("%s():%s: ", caller, msg); | ||
243 | |||
244 | print_hex_dump_debug("", DUMP_PREFIX_NONE, 16, 1, buf, len, false); | ||
245 | } | ||
246 | |||
247 | /* print data in a table format: | ||
248 | * | ||
249 | * addr: xx xx xx xx xx xx | ||
250 | * addr: xx xx xx xx xx xx | ||
251 | * ... | ||
252 | */ | ||
253 | static inline void raw_dump_table(const char *caller, char *msg, | ||
254 | unsigned char *buf, int len) | ||
255 | { | ||
256 | if (msg) | ||
257 | pr_debug("%s():%s:\n", caller, msg); | ||
258 | |||
259 | print_hex_dump_debug("\t", DUMP_PREFIX_OFFSET, 16, 1, buf, len, false); | ||
260 | } | ||
261 | #else | ||
262 | static inline void raw_dump_table(const char *caller, char *msg, | ||
263 | unsigned char *buf, int len) { } | ||
264 | static inline void raw_dump_inline(const char *caller, char *msg, | ||
265 | unsigned char *buf, int len) { } | ||
266 | #endif | ||
267 | |||
268 | static inline int lowpan_fetch_skb_u8(struct sk_buff *skb, u8 *val) | ||
269 | { | ||
270 | if (unlikely(!pskb_may_pull(skb, 1))) | ||
271 | return -EINVAL; | ||
272 | |||
273 | *val = skb->data[0]; | ||
274 | skb_pull(skb, 1); | ||
275 | |||
276 | return 0; | ||
277 | } | ||
278 | |||
279 | static inline int lowpan_fetch_skb_u16(struct sk_buff *skb, u16 *val) | ||
280 | { | ||
281 | if (unlikely(!pskb_may_pull(skb, 2))) | ||
282 | return -EINVAL; | ||
283 | |||
284 | *val = (skb->data[0] << 8) | skb->data[1]; | ||
285 | skb_pull(skb, 2); | ||
286 | |||
287 | return 0; | ||
288 | } | ||
234 | 289 | ||
235 | static inline bool lowpan_fetch_skb(struct sk_buff *skb, | 290 | static inline bool lowpan_fetch_skb(struct sk_buff *skb, |
236 | void *data, const unsigned int len) | 291 | void *data, const unsigned int len) |
@@ -244,4 +299,21 @@ static inline bool lowpan_fetch_skb(struct sk_buff *skb, | |||
244 | return false; | 299 | return false; |
245 | } | 300 | } |
246 | 301 | ||
302 | static inline void lowpan_push_hc_data(u8 **hc_ptr, const void *data, | ||
303 | const size_t len) | ||
304 | { | ||
305 | memcpy(*hc_ptr, data, len); | ||
306 | *hc_ptr += len; | ||
307 | } | ||
308 | |||
309 | typedef int (*skb_delivery_cb)(struct sk_buff *skb, struct net_device *dev); | ||
310 | |||
311 | int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, | ||
312 | const u8 *saddr, const u8 saddr_type, const u8 saddr_len, | ||
313 | const u8 *daddr, const u8 daddr_type, const u8 daddr_len, | ||
314 | u8 iphc0, u8 iphc1, skb_delivery_cb skb_deliver); | ||
315 | int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, | ||
316 | unsigned short type, const void *_daddr, | ||
317 | const void *_saddr, unsigned int len); | ||
318 | |||
247 | #endif /* __6LOWPAN_H__ */ | 319 | #endif /* __6LOWPAN_H__ */ |