85 uint8_t dest_addr_len;
92 CC_INLINE
static uint8_t
93 addr_len(uint8_t mode)
96 case FRAME802154_SHORTADDRMODE:
98 case FRAME802154_LONGADDRMODE:
105 #if LLSEC802154_USES_AUX_HEADER && LLSEC802154_USES_EXPLICIT_KEYS
107 get_key_id_len(uint8_t key_id_mode)
109 switch(key_id_mode) {
110 case FRAME802154_1_BYTE_KEY_ID_MODE:
112 case FRAME802154_5_BYTE_KEY_ID_MODE:
114 case FRAME802154_9_BYTE_KEY_ID_MODE:
124 frame802154_get_pan_id(
void)
131 frame802154_set_pan_id(uint16_t pan_id)
139 frame802154_has_panid(
frame802154_fcf_t *fcf,
int *has_src_pan_id,
int *has_dest_pan_id)
187 if(has_src_pan_id !=
NULL) {
188 *has_src_pan_id = src_pan_id;
190 if(has_dest_pan_id !=
NULL) {
191 *has_dest_pan_id = dest_pan_id;
204 frame802154_has_panid(&frame->
fcf,
NULL, &has_dest_panid);
206 && frame->
dest_pid != frame802154_get_pan_id()
207 && frame->
dest_pid != FRAME802154_BROADCASTPANDID) {
216 frame802154_is_broadcast_addr(uint8_t mode, uint8_t *
addr)
218 int i = mode == FRAME802154_SHORTADDRMODE ? 2 : 8;
220 if(addr[i] != 0xff) {
230 linkaddr_t *source_address, linkaddr_t *dest_address)
243 if(source_address !=
NULL) {
248 if(src_addr_len != LINKADDR_SIZE) {
252 if(source_address !=
NULL) {
262 if(dest_address !=
NULL) {
267 if(dest_addr_len != LINKADDR_SIZE) {
271 if(dest_address !=
NULL) {
286 memset(flen, 0,
sizeof(field_length_t));
306 frame802154_has_panid(&p->
fcf, &has_src_panid, &has_dest_panid);
309 flen->src_pid_len = 2;
313 flen->dest_pid_len = 2;
320 #if LLSEC802154_USES_AUX_HEADER
323 flen->aux_sec_len = 1;
326 flen->aux_sec_len += 5;
328 flen->aux_sec_len += 4;
331 #if LLSEC802154_USES_EXPLICIT_KEYS
353 return 2 + flen.seqno_len + flen.dest_pid_len + flen.dest_addr_len +
354 flen.src_pid_len + flen.src_addr_len + flen.aux_sec_len;
374 #if LLSEC802154_USES_EXPLICIT_KEYS
396 if(flen.seqno_len == 1) {
401 if(flen.dest_pid_len == 2) {
403 buf[pos++] = (p->
dest_pid >> 8) & 0xff;
407 for(c = flen.dest_addr_len; c > 0; c--) {
412 if(flen.src_pid_len == 2) {
413 buf[pos++] = p->
src_pid & 0xff;
414 buf[pos++] = (p->
src_pid >> 8) & 0xff;
418 for(c = flen.src_addr_len; c > 0; c--) {
421 #if LLSEC802154_USES_AUX_HEADER
423 if(flen.aux_sec_len) {
425 #if LLSEC802154_USES_EXPLICIT_KEYS
440 #if LLSEC802154_USES_EXPLICIT_KEYS
443 c = (key_id_mode - 1) * 4;
472 #if LLSEC802154_USES_EXPLICIT_KEYS
504 frame802154_has_panid(&fcf, &has_src_panid, &has_dest_panid);
528 for(c = 0; c < 8; c++) {
542 pf->
src_pid = p[0] + (p[1] << 8);
544 if(!has_dest_panid) {
563 for(c = 0; c < 8; c++) {
573 #if LLSEC802154_USES_AUX_HEADER
576 #if LLSEC802154_USES_EXPLICIT_KEYS
591 #if LLSEC802154_USES_EXPLICIT_KEYS
594 c = (key_id_mode - 1) * 4;
612 return c > len ? 0 : c;
int frame802154_hdrlen(frame802154_t *p)
Calculates the length of the frame header.
uint8_t security_enabled
1 bit.
uint16_t src_pid
Source PAN ID.
frame802154_scf_t security_control
Security control bitfield.
uint8_t dest_addr[8]
Destination address.
uint8_t key_id_mode
2 bit.
uint16_t dest_pid
Destination PAN ID.
uint8_t key_index
Key Index subfield.
static uip_ds6_addr_t * addr
Pointer to a router list entry.
frame802154_fcf_t fcf
Frame control field.
uint8_t ie_list_present
1 bit.
static uint16_t mac_pan_id
The 16-bit identifier of the PAN on which the device is operating.
frame802154_frame_counter_t frame_counter
Frame counter, used for security.
int payload_len
Length of payload field.
Default definitions of C compiler quirk work-arounds.
uint8_t frame_pending
1 bit.
uint8_t src_addr[8]
Source address.
uint8_t seq
Sequence number.
const linkaddr_t linkaddr_null
The null Rime address.
uint8_t * payload
Pointer to 802.15.4 payload.
Common functionality of 802.15.4-compliant llsec_drivers.
int frame802154_create(frame802154_t *p, uint8_t *buf)
Creates a frame for transmission over the air.
Header file for the Rime address representation
The IEEE 802.15.4 frame has a number of constant/fixed fields that can be counted to make frame const...
frame802154_key_source_t key_source
Key Source subfield.
#define NULL
The null pointer.
802.15.4 frame creation and parsing functions
int frame802154_parse(uint8_t *data, int len, frame802154_t *pf)
Parses an input frame.
uint8_t security_level
3 bit.
uint8_t src_addr_mode
2 bit.
uint8_t frame_counter_size
1 bit.
frame802154_aux_hdr_t aux_hdr
Aux security header.
uint8_t dest_addr_mode
2 bit.
uint8_t panid_compression
1 bit.
uint8_t ack_required
1 bit.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
uint8_t frame_version
2 bit.
Parameters used by the frame802154_create() function.
uint8_t frame_counter_suppression
1 bit.
uint8_t sequence_number_suppression
< 1 bit.