Contiki-NG
frame802154e-ie.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, SICS Swedish ICT.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  *
31  */
32 
33 /**
34  * \file
35  * IEEE 802.15.4e Information Element (IE) creation and parsing.
36  * \author
37  * Simon Duquennoy <simonduq@sics.se>
38  */
39 
40 #ifndef FRAME_802154E_H
41 #define FRAME_802154E_H
42 
43 #include "contiki.h"
44 #include "net/mac/mac.h"
45 #include "net/linkaddr.h"
46 /* We need definitions from tsch.h for TSCH-specific information elements */
47 #include "net/mac/tsch/tsch-conf.h"
50 #include "net/mac/tsch/tsch-asn.h"
51 
52 #define FRAME802154E_IE_MAX_LINKS 4
53 
54 /* Structures used for the Slotframe and Links information element */
55 struct tsch_slotframe_and_links_link {
56  uint16_t timeslot;
57  uint16_t channel_offset;
58  uint8_t link_options;
59 };
60 struct tsch_slotframe_and_links {
61  uint8_t num_slotframes; /* We support only 0 or 1 slotframe in this IE */
62  uint8_t slotframe_handle;
63  uint16_t slotframe_size;
64  uint8_t num_links;
65  struct tsch_slotframe_and_links_link links[FRAME802154E_IE_MAX_LINKS];
66 };
67 
68 /* The information elements that we currently support */
69 struct ieee802154_ies {
70  /* Header IEs */
71  int16_t ie_time_correction;
72  uint8_t ie_is_nack;
73  /* Payload MLME */
74  uint8_t ie_payload_ie_offset;
75  uint16_t ie_mlme_len;
76  /* Payload Short MLME IEs */
77  uint8_t ie_tsch_synchronization_offset;
78  struct tsch_asn_t ie_asn;
79  uint8_t ie_join_priority;
80  uint8_t ie_tsch_timeslot_id;
81  uint16_t ie_tsch_timeslot[tsch_ts_elements_count];
82  struct tsch_slotframe_and_links ie_tsch_slotframe_and_link;
83  /* Payload Long MLME IEs */
84  uint8_t ie_channel_hopping_sequence_id;
85  /* We include and parse only the sequence len and list and omit unused fields */
86  uint16_t ie_hopping_sequence_len;
87  uint8_t ie_hopping_sequence_list[TSCH_HOPPING_SEQUENCE_MAX_LEN];
88 #if TSCH_WITH_SIXTOP
89  /* Payload Sixtop IE */
90  const uint8_t *sixtop_ie_content_ptr;
91  uint16_t sixtop_ie_content_len;
92 #endif /* TSCH_WITH_SIXTOP */
93 };
94 
95 /** Insert various Information Elements **/
96 /* Header IE. ACK/NACK time correction. Used in enhanced ACKs */
98  struct ieee802154_ies *ies);
99 /* Header IE. List termination 1 (Signals the end of the Header IEs when
100  * followed by payload IEs) */
101 int frame80215e_create_ie_header_list_termination_1(uint8_t *buf, int len,
102  struct ieee802154_ies *ies);
103 /* Header IE. List termination 2 (Signals the end of the Header IEs when
104  * followed by an unformatted payload) */
105 int frame80215e_create_ie_header_list_termination_2(uint8_t *buf, int len,
106  struct ieee802154_ies *ies);
107 /* Payload IE. List termination */
108 int frame80215e_create_ie_payload_list_termination(uint8_t *buf, int len,
109  struct ieee802154_ies *ies);
110 #if TSCH_WITH_SIXTOP
111 /* Payload IE. 6top. Used to nest sub-IEs */
112 int frame80215e_create_ie_ietf(uint8_t *buf, int len,
113  struct ieee802154_ies *ies);
114 #endif /* TSCH_WITH_SIXTOP */
115 /* Payload IE. MLME. Used to nest sub-IEs */
116 int frame80215e_create_ie_mlme(uint8_t *buf, int len,
117  struct ieee802154_ies *ies);
118 /* MLME sub-IE. TSCH synchronization. Used in EBs: ASN and join priority */
119 int frame80215e_create_ie_tsch_synchronization(uint8_t *buf, int len,
120  struct ieee802154_ies *ies);
121 /* MLME sub-IE. TSCH slotframe and link. Used in EBs: initial schedule */
122 int frame80215e_create_ie_tsch_slotframe_and_link(uint8_t *buf, int len,
123  struct ieee802154_ies *ies);
124 /* MLME sub-IE. TSCH timeslot. Used in EBs: timeslot template (timing) */
125 int frame80215e_create_ie_tsch_timeslot(uint8_t *buf, int len,
126  struct ieee802154_ies *ies);
127 /* MLME sub-IE. TSCH channel hopping sequence. Used in EBs: hopping sequence */
128 int frame80215e_create_ie_tsch_channel_hopping_sequence(uint8_t *buf, int len,
129  struct ieee802154_ies *ies);
130 
131 /* Parse all Information Elements of a frame */
132 int frame802154e_parse_information_elements(const uint8_t *buf, uint8_t buf_size,
133  struct ieee802154_ies *ies);
134 
135 #endif /* FRAME_802154E_H */
TSCH constants.
TSCH configuration.
TSCH types.
Header file for the link-layer address representation
int frame80215e_create_ie_header_ack_nack_time_correction(uint8_t *buf, int len, struct ieee802154_ies *ies)
Insert various Information Elements.
The ASN is an absolute slot number over 5 bytes.
Definition: tsch-asn.h:48
TSCH 5-Byte Absolute Slot Number (ASN) management.
MAC driver header file