Skip to content

Commit

Permalink
6top: refactoring
Browse files Browse the repository at this point in the history
- untangle 6P message manipulation and the sample schedule function
  - sixtop.c: 6P core part, newly introduced
  - sixtop-6p.c : 6P message manipulation code, based on the former sixtop.c
  - sixtop-sf-simple.c : Sample SF code,based on the former sixtop.c
- maintain a sequence number per neighbor to be used for request
- rename variables and constants
- comply more with draft-ietf-6tisch-6top-protocol-02
  • Loading branch information
yatch committed Dec 1, 2016
1 parent da828dc commit d827592
Show file tree
Hide file tree
Showing 14 changed files with 1,462 additions and 846 deletions.
30 changes: 20 additions & 10 deletions core/net/mac/frame802154e-ie.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ enum ieee802154e_header_ie_id {
enum ieee802154e_payload_ie_id {
PAYLOAD_IE_ESDU = 0,
PAYLOAD_IE_MLME,
PAYLOAD_IE_SIXTOP,
PAYLOAD_IE_VENDOR,
PAYLOAD_IE_IANA_IETF,
PAYLOAD_IE_LIST_TERMINATION = 0xf,
};

Expand All @@ -80,6 +81,10 @@ enum ieee802154e_mlme_long_subie_id {
MLME_LONG_IE_TSCH_CHANNEL_HOPPING_SEQUENCE = 0x9,
};

enum ieee802154e_iana_ietf_subie_id {
IANA_IETF_IE_6TOP = 0x00,
};

#define WRITE16(buf, val) \
do { ((uint8_t *)(buf))[0] = (val) & 0xff; \
((uint8_t *)(buf))[1] = ((val) >> 8) & 0xff; } while(0);
Expand Down Expand Up @@ -195,12 +200,11 @@ frame80215e_create_ie_payload_list_termination(uint8_t *buf, int len,

/* Payload IE. 6top. Used to nest sub-IEs */
int
frame80215e_create_ie_sixtop(uint8_t *buf, int len,
struct ieee802154_ies *ies)
frame80215e_create_ie_iana_ietf(uint8_t *buf, int len, struct ieee802154_ies *ies)
{
int ie_len = 0;
int ie_len = ies->sixtop_ie_content_len;
if(len >= 2 + ie_len && ies != NULL) {
create_payload_ie_descriptor(buf, PAYLOAD_IE_SIXTOP, ies->ie_mlme_len);
create_payload_ie_descriptor(buf, PAYLOAD_IE_IANA_IETF, ie_len);
return 2 + ie_len;
} else {
return -1;
Expand Down Expand Up @@ -544,11 +548,17 @@ frame802154e_parse_information_elements(const uint8_t *buf, uint8_t buf_size,
len = 0; /* Reset len as we want to read subIEs and not jump over them */
PRINTF("frame802154e: entering MLME ie with len %u\n", nested_mlme_len);
break;
case PAYLOAD_IE_SIXTOP:
PRINTF("frame802154e: entering Sixtop ie with len %u\n", len);
/* Sixtop IE detected, return success(0)
* Further parsing of Sixtop IE is carried out at Sixtop layer */
return 0;
case PAYLOAD_IE_IANA_IETF:
/* Now expect 'len' bytes of Sixtop sub-IEs */
switch(*buf) {
case IANA_IETF_IE_6TOP:
ies->sixtop_ie_content_ptr = buf + 1;
ies->sixtop_ie_content_len = len - 1;
break;
default:
PRINTF("frame802154e: unsupported IANA-IETF sub-IE %u\n", *buf);
}
break;
case PAYLOAD_IE_LIST_TERMINATION:
PRINTF("frame802154e: payload ie list termination %u\n", len);
return (len == 0) ? buf + len - start : -1;
Expand Down
23 changes: 3 additions & 20 deletions core/net/mac/frame802154e-ie.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include "net/mac/tsch/tsch-private.h"

#define FRAME802154E_IE_MAX_LINKS 4
#define SIXTOP_IE_MAX_LINKS 3

/* Structures used for the Slotframe and Links information element */
struct tsch_slotframe_and_links_link {
Expand All @@ -61,23 +60,6 @@ struct tsch_slotframe_and_links {
struct tsch_slotframe_and_links_link links[FRAME802154E_IE_MAX_LINKS];
};

/* Structures used for the Sixtop information element */
struct sixtop_link {
uint16_t timeslot;
uint16_t channel_offset;
uint8_t link_option;
};
struct sixtop {
/* Sixtop IEs */
uint8_t subIE_id;
uint8_t version_code;
uint8_t schedule_fn_id;
struct sixtop_link linkList[SIXTOP_IE_MAX_LINKS];
/* Link Request IE */
uint8_t num_links;
uint8_t frame_id;
};

/* The information elements that we currently support */
struct ieee802154_ies {
/* Header IEs */
Expand All @@ -99,7 +81,8 @@ struct ieee802154_ies {
uint16_t ie_hopping_sequence_len;
uint8_t ie_hopping_sequence_list[TSCH_HOPPING_SEQUENCE_MAX_LEN];
/* Payload Sixtop IE */
struct sixtop ie_sixtop;
const uint8_t *sixtop_ie_content_ptr;
uint16_t sixtop_ie_content_len;
};

/** Insert various Information Elements **/
Expand All @@ -118,7 +101,7 @@ int frame80215e_create_ie_header_list_termination_2(uint8_t *buf, int len,
int frame80215e_create_ie_payload_list_termination(uint8_t *buf, int len,
struct ieee802154_ies *ies);
/* Payload IE. 6top. Used to nest sub-IEs */
int frame80215e_create_ie_sixtop(uint8_t *buf, int len,
int frame80215e_create_ie_iana_ietf(uint8_t *buf, int len,
struct ieee802154_ies *ies);
/* Payload IE. MLME. Used to nest sub-IEs */
int frame80215e_create_ie_mlme(uint8_t *buf, int len,
Expand Down
3 changes: 3 additions & 0 deletions core/net/mac/framer-802154.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ create_frame(int type, int do_create)
* source nor destination address, we have dest PAN ID iff compression is *set*. */
params.fcf.panid_compression = 0;

/* Set IE Present bit */
params.fcf.ie_list_present = packetbuf_attr(PACKETBUF_ATTR_MAC_METADATA);

/* Insert IEEE 802.15.4 version bits. */
params.fcf.frame_version = FRAME802154_VERSION;

Expand Down
Loading

0 comments on commit d827592

Please sign in to comment.