Contiki 3.x
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 /* We need definitions from tsch-private.h for TSCH-specific information elements */
46 
47 #define FRAME802154E_IE_MAX_LINKS 4
48 
49 /* Structures used for the Slotframe and Links information element */
50 struct tsch_slotframe_and_links_link {
51  uint16_t timeslot;
52  uint16_t channel_offset;
53  uint8_t link_options;
54 };
55 struct tsch_slotframe_and_links {
56  uint8_t num_slotframes; /* We support only 0 or 1 slotframe in this IE */
57  uint8_t slotframe_handle;
58  uint16_t slotframe_size;
59  uint8_t num_links;
60  struct tsch_slotframe_and_links_link links[FRAME802154E_IE_MAX_LINKS];
61 };
62 
63 /* The information elements that we currently support */
64 struct ieee802154_ies {
65  /* Header IEs */
66  int16_t ie_time_correction;
67  uint8_t ie_is_nack;
68  /* Payload MLME */
69  uint8_t ie_payload_ie_offset;
70  uint16_t ie_mlme_len;
71  /* Payload Short MLME IEs */
72  uint8_t ie_tsch_synchronization_offset;
73  struct asn_t ie_asn;
74  uint8_t ie_join_priority;
75  uint8_t ie_tsch_timeslot_id;
76  uint16_t ie_tsch_timeslot[tsch_ts_elements_count];
77  struct tsch_slotframe_and_links ie_tsch_slotframe_and_link;
78  /* Payload Long MLME IEs */
79  uint8_t ie_channel_hopping_sequence_id;
80  /* We include and parse only the sequence len and list and omit unused fields */
81  uint16_t ie_hopping_sequence_len;
82  uint8_t ie_hopping_sequence_list[TSCH_HOPPING_SEQUENCE_MAX_LEN];
83 };
84 
85 /** Insert various Information Elements **/
86 /* Header IE. ACK/NACK time correction. Used in enhanced ACKs */
88  struct ieee802154_ies *ies);
89 /* Header IE. List termination 1 (Signals the end of the Header IEs when
90  * followed by payload IEs) */
91 int frame80215e_create_ie_header_list_termination_1(uint8_t *buf, int len,
92  struct ieee802154_ies *ies);
93 /* Header IE. List termination 2 (Signals the end of the Header IEs when
94  * followed by an unformatted payload) */
95 int frame80215e_create_ie_header_list_termination_2(uint8_t *buf, int len,
96  struct ieee802154_ies *ies);
97 /* Payload IE. List termination */
98 int frame80215e_create_ie_payload_list_termination(uint8_t *buf, int len,
99  struct ieee802154_ies *ies);
100 /* Payload IE. MLME. Used to nest sub-IEs */
101 int frame80215e_create_ie_mlme(uint8_t *buf, int len,
102  struct ieee802154_ies *ies);
103 /* MLME sub-IE. TSCH synchronization. Used in EBs: ASN and join priority */
104 int frame80215e_create_ie_tsch_synchronization(uint8_t *buf, int len,
105  struct ieee802154_ies *ies);
106 /* MLME sub-IE. TSCH slotframe and link. Used in EBs: initial schedule */
107 int frame80215e_create_ie_tsch_slotframe_and_link(uint8_t *buf, int len,
108  struct ieee802154_ies *ies);
109 /* MLME sub-IE. TSCH timeslot. Used in EBs: timeslot template (timing) */
110 int frame80215e_create_ie_tsch_timeslot(uint8_t *buf, int len,
111  struct ieee802154_ies *ies);
112 /* MLME sub-IE. TSCH channel hopping sequence. Used in EBs: hopping sequence */
113 int frame80215e_create_ie_tsch_channel_hopping_sequence(uint8_t *buf, int len,
114  struct ieee802154_ies *ies);
115 
116 /* Parse all Information Elements of a frame */
117 int frame802154e_parse_information_elements(const uint8_t *buf, uint8_t buf_size,
118  struct ieee802154_ies *ies);
119 
120 #endif /* FRAME_802154E_H */
Private TSCH definitions (meant for use by TSCH implementation files only) ...
int frame80215e_create_ie_header_ack_nack_time_correction(uint8_t *buf, int len, struct ieee802154_ies *ies)
Insert various Information Elements.