sixlowpan.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef NET_SIXLOWPAN_H
21 #define NET_SIXLOWPAN_H
22 
23 #include <stdbool.h>
24 #include <stddef.h>
25 #include <stdint.h>
26 
27 #include "byteorder.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
40 #define SIXLOWPAN_UNCOMP (0x41)
41 #define SIXLOWPAN_FRAG_DISP_MASK (0xf8)
43 #define SIXLOWPAN_FRAG_1_DISP (0xc0)
44 #define SIXLOWPAN_FRAG_N_DISP (0xe0)
46 #define SIXLOWPAN_FRAG_MAX_LEN (2047)
54 #define SIXLOWPAN_IPHC1_DISP_MASK (0xe0)
55 
62 #define SIXLOWPAN_IPHC1_DISP (0x60)
63 
72 static inline bool sixlowpan_nalp(uint8_t disp)
73 {
74  return ((disp & 0xc0) == 0);
75 }
82 #define SIXLOWPAN_FRAG_SIZE_MASK (0x07ff)
95 typedef struct __attribute__((packed)) {
96 
102  network_uint16_t disp_size;
103  network_uint16_t tag;
115 typedef struct __attribute__((packed)) {
122  network_uint16_t disp_size;
123  network_uint16_t tag;
124  uint8_t offset;
135 static inline bool sixlowpan_frag_is(sixlowpan_frag_t *hdr)
136 {
137  return ((hdr->disp_size.u8[0] & SIXLOWPAN_FRAG_DISP_MASK) ==
139  ((hdr->disp_size.u8[0] & SIXLOWPAN_FRAG_DISP_MASK) ==
141 }
155 #define SIXLOWPAN_IPHC1_TF (0x18)
156 
164 #define SIXLOWPAN_IPHC1_NH (0x04)
165 
172 #define SIXLOWPAN_IPHC1_HL (0x03)
173 
181 #define SIXLOWPAN_IPHC2_CID_EXT (0x80)
182 
190 #define SIXLOWPAN_IPHC2_SAC (0x40)
191 
199 #define SIXLOWPAN_IPHC2_SAM (0x30)
200 
208 #define SIXLOWPAN_IPHC2_DAC (0x04)
209 
217 #define SIXLOWPAN_IPHC2_DAM (0x03)
218 
226 #define SIXLOWPAN_IPHC2_M (0x08)
227 
231 #define SIXLOWPAN_IPHC_HDR_LEN (2)
232 
236 #define SIXLOWPAN_IPHC_CID_EXT_LEN (1)
237 
246 static inline bool sixlowpan_iphc_is(uint8_t *data)
247 {
249 }
258 void sixlowpan_print(uint8_t *data, size_t size);
259 
260 #ifdef __cplusplus
261 }
262 #endif
263 
264 #endif /* NET_SIXLOWPAN_H */
265 
static bool sixlowpan_iphc_is(uint8_t *data)
Checks if datagram is an IPHC datagram.
Definition: sixlowpan.h:248
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:76
#define SIXLOWPAN_IPHC1_DISP_MASK
Dispatch mask for LOWPAN_IPHC.
Definition: sixlowpan.h:56
#define SIXLOWPAN_FRAG_N_DISP
dispatch for subsequent fragments
Definition: sixlowpan.h:45
#define SIXLOWPAN_IPHC1_DISP
Dispatch for LOWPAN_IPHC.
Definition: sixlowpan.h:64
void sixlowpan_print(uint8_t *data, size_t size)
Prints 6LoWPAN dispatch to stdout.
static bool sixlowpan_nalp(uint8_t disp)
Checks if dispatch indicates that frame is not a 6LoWPAN (NALP) frame.
Definition: sixlowpan.h:74
General and 1st 6LoWPAN fragmentation header.
Definition: sixlowpan.h:97
Subsequent 6LoWPAN fragmentation header.
Definition: sixlowpan.h:117
Functions to work with different byte orders.
#define SIXLOWPAN_FRAG_DISP_MASK
mask for fragmentation dispatch
Definition: sixlowpan.h:41
static bool sixlowpan_frag_is(sixlowpan_frag_t *hdr)
Checks if a given fragment is a 6LoWPAN fragment.
Definition: sixlowpan.h:137
uint8_t u8[2]
8 bit representation
Definition: byteorder.h:78
#define SIXLOWPAN_FRAG_1_DISP
dispatch for 1st fragment
Definition: sixlowpan.h:44
network_uint16_t disp_size
Dispatch and datagram size.
Definition: sixlowpan.h:104