85 uint8_t dest_addr_len;
96 case FRAME802154_SHORTADDRMODE:
98 case FRAME802154_LONGADDRMODE:
105#if LLSEC802154_USES_AUX_HEADER && LLSEC802154_USES_EXPLICIT_KEYS
107get_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:
124frame802154_get_pan_id(
void)
131frame802154_set_pan_id(uint16_t pan_id)
139frame802154_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)) {
225frame802154_is_broadcast_addr(uint8_t mode,
const 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));
311 frame802154_has_panid(&p->
fcf, &has_src_panid, &has_dest_panid);
314 flen->src_pid_len = 2;
318 flen->dest_pid_len = 2;
325#if LLSEC802154_USES_AUX_HEADER
328 flen->aux_sec_len = 1;
331 flen->aux_sec_len += 5;
333 flen->aux_sec_len += 4;
336#if LLSEC802154_USES_EXPLICIT_KEYS
357 return 2 + flen.seqno_len + flen.dest_pid_len + flen.dest_addr_len +
358 flen.src_pid_len + flen.src_addr_len + flen.aux_sec_len;
391#if LLSEC802154_USES_EXPLICIT_KEYS
399 frame802154_create_fcf(&p->
fcf, buf);
400 unsigned int pos = 2;
403 if(flen.seqno_len == 1) {
408 if(flen.dest_pid_len == 2) {
410 buf[pos++] = (p->
dest_pid >> 8) & 0xff;
414 for(c = flen.dest_addr_len; c > 0; c--) {
419 if(flen.src_pid_len == 2) {
420 buf[pos++] = p->
src_pid & 0xff;
421 buf[pos++] = (p->
src_pid >> 8) & 0xff;
425 for(c = flen.src_addr_len; c > 0; c--) {
428#if LLSEC802154_USES_AUX_HEADER
430 if(flen.aux_sec_len) {
432#if LLSEC802154_USES_EXPLICIT_KEYS
447#if LLSEC802154_USES_EXPLICIT_KEYS
450 c = (key_id_mode - 1) * 4;
501#if LLSEC802154_USES_EXPLICIT_KEYS
512 frame802154_parse_fcf(p, &fcf);
521 frame802154_has_panid(&fcf, &has_src_panid, &has_dest_panid);
540 for(c = 0; c < 8; c++) {
554 pf->
src_pid = p[0] + (p[1] << 8);
556 if(!has_dest_panid) {
570 for(c = 0; c < 8; c++) {
580#if LLSEC802154_USES_AUX_HEADER
583#if LLSEC802154_USES_EXPLICIT_KEYS
598#if LLSEC802154_USES_EXPLICIT_KEYS
601 c = (key_id_mode - 1) * 4;
619 return c > len ? 0 : c;
Default definitions of C compiler quirk work-arounds.
802.15.4 frame creation and parsing functions
int frame802154_parse(uint8_t *data, int len, frame802154_t *pf)
Parses an input frame.
#define FRAME802154_NOADDR
Only valid for ACK or Beacon frames.
int frame802154_create(frame802154_t *p, uint8_t *buf)
Creates a frame for transmission over the air.
int frame802154_hdrlen(frame802154_t *p)
Calculates the length of the frame header.
static uint16_t mac_pan_id
The 16-bit identifier of the PAN on which the device is operating.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a link-layer address.
const linkaddr_t linkaddr_null
The null link-layer address.
Header file for the link-layer address representation.
Common functionality of 802.15.4-compliant llsec_drivers.
frame802154_scf_t security_control
Security control bitfield.
frame802154_frame_counter_t frame_counter
Frame counter, used for security.
uint8_t key_index
Key Index subfield.
frame802154_key_source_t key_source
Key Source subfield.
The IEEE 802.15.4 frame has a number of constant/fixed fields that can be counted to make frame const...
uint8_t frame_version
2 bit.
uint8_t ie_list_present
1 bit.
uint8_t security_enabled
1 bit.
uint8_t sequence_number_suppression
< 1 bit.
uint8_t src_addr_mode
2 bit.
uint8_t panid_compression
1 bit.
uint8_t ack_required
1 bit.
uint8_t dest_addr_mode
2 bit.
uint8_t frame_pending
1 bit.
uint8_t key_id_mode
2 bit.
uint8_t frame_counter_size
1 bit.
uint8_t frame_counter_suppression
1 bit.
uint8_t security_level
3 bit.
Parameters used by the frame802154_create() function.
uint8_t seq
Sequence number.
uint8_t dest_addr[8]
Destination address.
frame802154_aux_hdr_t aux_hdr
Aux security header.
uint8_t * payload
Pointer to 802.15.4 payload.
uint8_t src_addr[8]
Source address.
uint16_t src_pid
Source PAN ID.
frame802154_fcf_t fcf
Frame control field
uint16_t dest_pid
Destination PAN ID.
int payload_len
Length of payload field.
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.