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)
196 if(has_src_pan_id != NULL) {
197 *has_src_pan_id = src_pan_id;
199 if(has_dest_pan_id != NULL) {
200 *has_dest_pan_id = dest_pan_id;
208 int has_dest_panid = 0;
213 frame802154_has_panid(&frame->
fcf, NULL, &has_dest_panid);
214 if(!has_dest_panid ||
215 (frame->
dest_pid != frame802154_get_pan_id()
216 && frame->
dest_pid != FRAME802154_BROADCASTPANDID)) {
225 frame802154_is_broadcast_addr(uint8_t mode, uint8_t *
addr)
227 int i = mode == FRAME802154_SHORTADDRMODE ? 2 : 8;
229 if(addr[i] != 0xff) {
239 linkaddr_t *source_address, linkaddr_t *dest_address)
252 if(source_address != NULL) {
257 if(src_addr_len != LINKADDR_SIZE) {
261 if(source_address != NULL) {
271 if(dest_address != NULL) {
276 if(dest_addr_len != LINKADDR_SIZE) {
280 if(dest_address != NULL) {
295 memset(flen, 0,
sizeof(field_length_t));
315 frame802154_has_panid(&p->
fcf, &has_src_panid, &has_dest_panid);
318 flen->src_pid_len = 2;
322 flen->dest_pid_len = 2;
329 #if LLSEC802154_USES_AUX_HEADER 332 flen->aux_sec_len = 1;
335 flen->aux_sec_len += 5;
337 flen->aux_sec_len += 4;
340 #if LLSEC802154_USES_EXPLICIT_KEYS 362 return 2 + flen.seqno_len + flen.dest_pid_len + flen.dest_addr_len +
363 flen.src_pid_len + flen.src_addr_len + flen.aux_sec_len;
397 #if LLSEC802154_USES_EXPLICIT_KEYS 405 frame802154_create_fcf(&p->
fcf, buf);
409 if(flen.seqno_len == 1) {
414 if(flen.dest_pid_len == 2) {
416 buf[pos++] = (p->
dest_pid >> 8) & 0xff;
420 for(c = flen.dest_addr_len; c > 0; c--) {
425 if(flen.src_pid_len == 2) {
426 buf[pos++] = p->
src_pid & 0xff;
427 buf[pos++] = (p->
src_pid >> 8) & 0xff;
431 for(c = flen.src_addr_len; c > 0; c--) {
434 #if LLSEC802154_USES_AUX_HEADER 436 if(flen.aux_sec_len) {
438 #if LLSEC802154_USES_EXPLICIT_KEYS 453 #if LLSEC802154_USES_EXPLICIT_KEYS 456 c = (key_id_mode - 1) * 4;
507 #if LLSEC802154_USES_EXPLICIT_KEYS 518 frame802154_parse_fcf(p, &fcf);
527 frame802154_has_panid(&fcf, &has_src_panid, &has_dest_panid);
551 for(c = 0; c < 8; c++) {
565 pf->
src_pid = p[0] + (p[1] << 8);
567 if(!has_dest_panid) {
586 for(c = 0; c < 8; c++) {
596 #if LLSEC802154_USES_AUX_HEADER 599 #if LLSEC802154_USES_EXPLICIT_KEYS 614 #if LLSEC802154_USES_EXPLICIT_KEYS 617 c = (key_id_mode - 1) * 4;
635 return c > len ? 0 : c;
frame802154_frame_counter_t frame_counter
Frame counter, used for security.
uint16_t src_pid
Source PAN ID.
frame802154_scf_t security_control
Security control bitfield.
uint8_t dest_addr_mode
2 bit.
uint8_t sequence_number_suppression
< 1 bit.
frame802154_fcf_t fcf
Frame control field.
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
#define FRAME802154_NOADDR
Only valid for ACK or Beacon frames.
uint8_t security_level
3 bit.
uint8_t security_enabled
1 bit.
Header file for the link-layer address representation
int frame802154_parse(uint8_t *data, int len, frame802154_t *pf)
Parses an input frame.
int payload_len
Length of payload field.
Common functionality of 802.15.4-compliant llsec_drivers.
uint8_t frame_pending
1 bit.
uint8_t src_addr[8]
Source address.
int frame802154_hdrlen(frame802154_t *p)
Calculates the length of the frame header.
const linkaddr_t linkaddr_null
The null link-layer address.
frame802154_key_source_t key_source
Key Source subfield.
uint8_t key_id_mode
2 bit.
uint8_t key_index
Key Index subfield.
uint8_t frame_counter_suppression
1 bit.
uint8_t frame_version
2 bit.
The IEEE 802.15.4 frame has a number of constant/fixed fields that can be counted to make frame const...
uint8_t src_addr_mode
2 bit.
802.15.4 frame creation and parsing functions
uint16_t dest_pid
Destination PAN ID.
Parameters used by the frame802154_create() function.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a link-layer address.
uint8_t ie_list_present
1 bit.
uint8_t seq
Sequence number.
uint8_t panid_compression
1 bit.
Default definitions of C compiler quirk work-arounds.
uint8_t * payload
Pointer to 802.15.4 payload.
uint8_t dest_addr[8]
Destination address.
uint8_t ack_required
1 bit.
uint8_t frame_counter_size
1 bit.
static uint16_t mac_pan_id
The 16-bit identifier of the PAN on which the device is operating.
frame802154_aux_hdr_t aux_hdr
Aux security header.
int frame802154_create(frame802154_t *p, uint8_t *buf)
Creates a frame for transmission over the air.