42#include "lib/assert.h"
55#define LOG_MODULE "6top"
56#define LOG_LEVEL LOG_LEVEL_6TOP
64strip_payload_termination_ie(
void)
67 if(ptr[0] == 0x00 && ptr[1] == 0xf8) {
80 LOG_INFO(
"6top: sixtop_add_sf() is adding a SF [SFID:%u]\n", sf->
sfid);
83 LOG_ERR(
"6top: sixtop_add_sf() fails because of duplicate SF\n");
88 if(scheduling_functions[i] == NULL) {
89 scheduling_functions[i] = sf;
90 if(sf->
init != NULL) {
98 LOG_ERR(
"6top: sixtop_add_sf() fails because of no memory\n");
102 if(sf->
init != NULL) {
105 LOG_INFO(
"6top: SF [SFID:%u] has been added and initialized\n", sf->
sfid);
115 if(scheduling_functions[i] != NULL &&
116 scheduling_functions[i]->sfid == sfid) {
117 return (
const sixtop_sf_t *)scheduling_functions[i];
125sixtop_output(
const linkaddr_t *dest_addr, mac_callback_t callback,
void *arg)
128 struct ieee802154_ies ies;
131 assert(dest_addr != NULL);
132 if(dest_addr == NULL) {
133 LOG_ERR(
"6top: sixtop_output() fails because dest_addr is NULL\n");
134 if(callback != NULL) {
142 LOG_ERR(
"6top: sixtop_output() fails because of no room for Sub-IE ID\n");
146 p[0] = SIXTOP_SUBIE_ID;
152 memset(&ies, 0,
sizeof(ies));
158 LOG_ERR(
"6top: sixtop_output() fails because of Payload IE Header\n");
159 if(callback != NULL) {
165#if SIXP_WITH_PAYLOAD_TERMINATION_IE
167 memset(&ies, 0,
sizeof(ies));
168 if((len = frame80215e_create_ie_payload_list_termination(
172 LOG_ERR(
"6top: sixtop_output() fails because of Payload Termination IE\n");
180 memset(&ies, 0,
sizeof(ies));
185 LOG_ERR(
"6top: sixtop_output() fails because of Header Termination 1 IE\n");
191 packetbuf_set_attr(PACKETBUF_ATTR_MAC_METADATA, 1);
194 packetbuf_set_attr(PACKETBUF_ATTR_FRAME_TYPE, FRAME802154_DATAFRAME);
196 packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, dest_addr);
199 NETSTACK_MAC.
send(callback, arg);
206 uint8_t *hdr_ptr, *payload_ptr;
207 uint16_t hdr_len, payload_len;
210 struct ieee802154_ies ies;
223 hdr_ptr = payload_ptr - hdr_len;
225 memcpy(&src_addr, packetbuf_addr(PACKETBUF_ADDR_SENDER),
sizeof(src_addr));
229 LOG_ERR(
"6top: frame802154_parse error\n");
240 memset(&ies, 0,
sizeof(ies));
242 frame802154e_parse_information_elements(payload_ptr,
243 payload_len, &ies) >= 0 &&
244 ies.sixtop_ie_content_ptr != NULL &&
245 ies.sixtop_ie_content_len > 0) {
247 sixp_input(ies.sixtop_ie_content_ptr, ies.sixtop_ie_content_len,
255 ies.sixtop_ie_content_len);
256 strip_payload_termination_ie();
268 scheduling_functions[i] = NULL;
280 if(scheduling_functions[i] != NULL &&
281 scheduling_functions[i]->init != NULL) {
282 scheduling_functions[i]->
init();
802.15.4 frame creation and parsing functions
IEEE 802.15.4e Information Element (IE) creation and parsing.
int frame802154_parse(uint8_t *data, int len, frame802154_t *pf)
Parses an input frame.
linkaddr_t linkaddr_node_addr
The link-layer address of the node.
void packetbuf_set_datalen(uint16_t len)
Set the length of the data in the packetbuf.
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
uint16_t packetbuf_totlen(void)
Get the total length of the header and data in the packetbuf.
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
uint8_t packetbuf_hdrlen(void)
Get the length of the header in the packetbuf.
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
#define PACKETBUF_SIZE
The size of the packetbuf, in bytes.
int packetbuf_hdralloc(int size)
Extend the header of the packetbuf, for outbound packets.
int packetbuf_hdrreduce(int size)
Reduce the header in the packetbuf, for incoming packets.
const sixtop_sf_t * sixtop_find_sf(uint8_t sfid)
Find a SF which has been added by SFID.
int sixtop_add_sf(const sixtop_sf_t *sf)
Add a Scheduling Function (SF) to 6top Sublayer.
#define SIXTOP_MAX_SCHEDULING_FUNCTIONS
The maximum number of Scheduling Functions in the system.
void sixtop_input(void)
Input a packet stored in packetbuf.
void sixtop_init(void)
Initialize 6top module This initialization function removes all the SFs which has been installed into...
void sixp_init(void)
Initialize 6P Module It invokes sixp_nbr_init() and sixp_trans_init().
void sixp_input(const uint8_t *buf, uint16_t len, const linkaddr_t *src_addr)
Input a 6P packet.
void sixtop_init_sf(void)
Initialize installed SFs which has been added in the system This function is supposed to be invoked e...
int sixtop_output(const linkaddr_t *dest_addr, mac_callback_t callback, void *arg)
Output a 6P packet which is supposestored in packetbuf.
Header file for the logging system.
@ MAC_TX_ERR_FATAL
The MAC layer transmission could not be performed because of insufficient queue space,...
Include file for the Contiki low-layer network stack (NETSTACK)
Header file for the Packet buffer (packetbuf) management.
6TiSCH Operation Sublayer (6top) APIs
uint8_t frame_version
2 bit.
uint8_t ie_list_present
1 bit.
Parameters used by the frame802154_create() function.
frame802154_fcf_t fcf
Frame control field
void(* send)(mac_callback_t sent_callback, void *ptr)
Send a packet from the packetbuf
/brief Scheduling Function Driver
void(* init)(void)
Init Function.