1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 Dean Armstrong
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  * Author: Dean Armstrong <deanarm@gmail.com>
19  */
20 
21 #ifndef WIFI_INFORMATION_ELEMENT_H
22 #define WIFI_INFORMATION_ELEMENT_H
23 
24 #include "ns3/header.h"
25 
26 namespace ns3 {
27 
28 /**
29  * This type is used to represent an Information Element ID. An
30  * enumeration would be tidier, but doesn't provide for the
31  * inheritance that is currently preferable to cleanly support
32  * pre-standard modules such as mesh. Maybe there is a nice way of
33  * doing this with a class.
34  *
35  * Until such time as a better way of implementing this is dreamt up
36  * and applied, developers will need to be careful to avoid
37  * duplication of IE IDs in the defines below (and in files which
38  * declare "subclasses" of WifiInformationElement). Sorry.
39  */
40 typedef uint8_t WifiInformationElementId;
41 
42 
43 /**
44  * Here we have definition of all Information Element IDs in IEEE
45  * 802.11-2007. See the comments for WifiInformationElementId - this could
46  * probably be done in a considerably tidier manner.
47  */
48 #define IE_SSID                                 ((WifiInformationElementId)0)
49 #define IE_SUPPORTED_RATES                      ((WifiInformationElementId)1)
50 #define IE_FH_PARAMETER_SET                     ((WifiInformationElementId)2)
51 #define IE_DSSS_PARAMETER_SET                   ((WifiInformationElementId)3)
52 #define IE_CF_PARAMETER_SET                     ((WifiInformationElementId)4)
53 #define IE_TIM                                  ((WifiInformationElementId)5)
54 #define IE_IBSS_PARAMETER_SET                   ((WifiInformationElementId)6)
55 #define IE_COUNTRY                              ((WifiInformationElementId)7)
56 #define IE_HOPPING_PATTERN_PARAMETERS           ((WifiInformationElementId)8)
57 #define IE_HOPPING_PATTERN_TABLE                ((WifiInformationElementId)9)
58 #define IE_REQUEST                              ((WifiInformationElementId)10)
59 #define IE_BSS_LOAD                             ((WifiInformationElementId)11)
60 #define IE_EDCA_PARAMETER_SET                   ((WifiInformationElementId)12)
61 #define IE_TSPEC                                ((WifiInformationElementId)13)
62 #define IE_TCLAS                                ((WifiInformationElementId)14)
63 #define IE_SCHEDULE                             ((WifiInformationElementId)15)
64 #define IE_CHALLENGE_TEXT                       ((WifiInformationElementId)16)
65 // 17 to 31 are reserved
66 #define IE_POWER_CONSTRAINT                     ((WifiInformationElementId)32)
67 #define IE_POWER_CAPABILITY                     ((WifiInformationElementId)33)
68 #define IE_TPC_REQUEST                          ((WifiInformationElementId)34)
69 #define IE_TPC_REPORT                           ((WifiInformationElementId)35)
70 #define IE_SUPPORTED_CHANNELS                   ((WifiInformationElementId)36)
71 #define IE_CHANNEL_SWITCH_ANNOUNCEMENT          ((WifiInformationElementId)37)
72 #define IE_MEASUREMENT_REQUEST                  ((WifiInformationElementId)38)
73 #define IE_MEASUREMENT_REPORT                   ((WifiInformationElementId)39)
74 #define IE_QUIET                                ((WifiInformationElementId)40)
75 #define IE_IBSS_DFS                             ((WifiInformationElementId)41)
76 #define IE_ERP_INFORMATION                      ((WifiInformationElementId)42)
77 #define IE_TS_DELAY                             ((WifiInformationElementId)43)
78 #define IE_TCLAS_PROCESSING                     ((WifiInformationElementId)44)
79 #define IE_HT_CAPABILITIES                      ((WifiInformationElementId)45)
80 #define IE_QOS_CAPABILITY                       ((WifiInformationElementId)46)
81 // 47 is reserved
82 #define IE_RSN                                  ((WifiInformationElementId)48)
83 // 49 is reserved
84 #define IE_EXTENDED_SUPPORTED_RATES             ((WifiInformationElementId)50)
85 #define IE_AP_CHANNEL_REPORT                    ((WifiInformationElementId)51)
86 #define IE_NEIGHBOR_REPORT                      ((WifiInformationElementId)52)
87 #define IE_RCPI                                 ((WifiInformationElementId)53)
88 #define IE_MOBILITY_DOMAIN                      ((WifiInformationElementId)54)
89 #define IE_FAST_BSS_TRANSITION                  ((WifiInformationElementId)55)
90 #define IE_TIMEOUT_INTERVAL                     ((WifiInformationElementId)56)
91 #define IE_RIC_DATA                             ((WifiInformationElementId)57)
92 #define IE_DSE_REGISTERED_LOCATION              ((WifiInformationElementId)58)
93 #define IE_SUPPORTED_OPERATING_CLASSES          ((WifiInformationElementId)59)
94 #define IE_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT ((WifiInformationElementId)60)
95 #define IE_HT_OPERATION                         ((WifiInformationElementId)61)
96 #define IE_SECONDARY_CHANNEL_OFFSET             ((WifiInformationElementId)62)
97 #define IE_BSS_AVERAGE_ACCESS_DELAY             ((WifiInformationElementId)63)
98 #define IE_ANTENNA                              ((WifiInformationElementId)64)
99 #define IE_RSNI                                 ((WifiInformationElementId)65)
100 #define IE_MEASUREMENT_PILOT_TRANSMISSION       ((WifiInformationElementId)66)
101 #define IE_BSS_AVAILABLE_ADMISSION_CAPACITY     ((WifiInformationElementId)67)
102 #define IE_BSS_AC_ACCESS_DELAY                  ((WifiInformationElementId)68)
103 #define IE_TIME_ADVERTISEMENT                   ((WifiInformationElementId)69)
104 #define IE_RM_ENABLED_CAPACITIES                ((WifiInformationElementId)70)
105 #define IE_MULTIPLE_BSSID                       ((WifiInformationElementId)71)
106 #define IE_20_40_BSS_COEXISTENCE                ((WifiInformationElementId)72)
107 #define IE_20_40_BSS_INTOLERANT_CHANNEL_REPORT  ((WifiInformationElementId)73)
108 #define IE_OVERLAPPING_BSS_SCAN_PARAMETERS      ((WifiInformationElementId)74)
109 #define IE_RIC_DESCRIPTOR                       ((WifiInformationElementId)75)
110 #define IE_MANAGEMENT_MIC                       ((WifiInformationElementId)76)
111 // 77 is reserved
112 #define IE_EVENT_REQUEST                        ((WifiInformationElementId)78)
113 #define IE_EVENT_REPORT                         ((WifiInformationElementId)79)
114 #define IE_DIAGNOSTIC_REQUEST                   ((WifiInformationElementId)80)
115 #define IE_DIAGNOSTIC_REPORT                    ((WifiInformationElementId)81)
116 #define IE_LOCATION_PARAMETERS                  ((WifiInformationElementId)82)
117 #define IE_NONTRANSMITTED_BSSID_CAPABILITY      ((WifiInformationElementId)83)
118 #define IE_SSID_LIST                            ((WifiInformationElementId)84)
119 #define IE_MULTIPLE_BSSID_INDEX                 ((WifiInformationElementId)85)
120 #define IE_FMS_DESCRIPTOR                       ((WifiInformationElementId)86)
121 #define IE_FMS_REQUEST                          ((WifiInformationElementId)87)
122 #define IE_FMS_RESPONSE                         ((WifiInformationElementId)88)
123 #define IE_QOS_TRAFFIC_CAPABILITY               ((WifiInformationElementId)89)
124 #define IE_BSS_MAX_IDLE_PERIOD                  ((WifiInformationElementId)90)
125 #define IE_TFS_REQUEST                          ((WifiInformationElementId)91)
126 #define IE_TFS_RESPONSE                         ((WifiInformationElementId)92)
127 #define IE_WNM_SLEEP_MODE                       ((WifiInformationElementId)93)
128 #define IE_TIM_BROADCAST_REQUEST                ((WifiInformationElementId)94)
129 #define IE_TIM_BROADCAST_RESPONSE               ((WifiInformationElementId)95)
130 #define IE_COLLOCATED_INTERFERENCE_REPORT       ((WifiInformationElementId)96)
131 #define IE_CHANNEL_USAGE                        ((WifiInformationElementId)97)
132 #define IE_TIME_ZONE                            ((WifiInformationElementId)98)
133 #define IE_DMS_REQUEST                          ((WifiInformationElementId)99)
134 #define IE_DMS_RESPONSE                         ((WifiInformationElementId)100)
135 #define IE_LINK_IDENTIFIER                      ((WifiInformationElementId)101)
136 #define IE_WAKEUP_SCHEDULE                      ((WifiInformationElementId)102)
137 // 103 is reserved
138 #define IE_CHANNEL_SWITCH_TIMING                ((WifiInformationElementId)104)
139 #define IE_PTI_CONTROL                          ((WifiInformationElementId)105)
140 #define IE_TPU_BUFFER_STATUS                    ((WifiInformationElementId)106)
141 #define IE_INTERWORKING                         ((WifiInformationElementId)107)
142 #define IE_ADVERTISEMENT_PROTOCOL               ((WifiInformationElementId)108)
143 #define IE_EXPEDITED_BANDWIDTH_REQUEST          ((WifiInformationElementId)109)
144 #define IE_QOS_MAP_SET                          ((WifiInformationElementId)110)
145 #define IE_ROAMING_CONSORTIUM                   ((WifiInformationElementId)111)
146 #define IE_EMERGENCY_ALART_IDENTIFIER           ((WifiInformationElementId)112)
147 #define IE_MESH_CONFIGURATION                   ((WifiInformationElementId)113)
148 #define IE_MESH_ID                              ((WifiInformationElementId)114)
149 #define IE_MESH_LINK_METRIC_REPORT              ((WifiInformationElementId)115)
150 #define IE_CONGESTION_NOTIFICATION              ((WifiInformationElementId)116)
151 #define IE_MESH_PEERING_MANAGEMENT              ((WifiInformationElementId)117)
152 #define IE_MESH_CHANNEL_SWITCH_PARAMETERS       ((WifiInformationElementId)118)
153 #define IE_MESH_AWAKE_WINDOW                    ((WifiInformationElementId)119)
154 #define IE_BEACON_TIMING                        ((WifiInformationElementId)120)
155 #define IE_MCCAOP_SETUP_REQUEST                 ((WifiInformationElementId)121)
156 #define IE_MCCAOP_SETUP_REPLY                   ((WifiInformationElementId)122)
157 #define IE_MCCAOP_ADVERTISEMENT                 ((WifiInformationElementId)123)
158 #define IE_MCCAOP_TEARDOWN                      ((WifiInformationElementId)124)
159 #define IE_GANN                                 ((WifiInformationElementId)125)
160 #define IE_RANN                                 ((WifiInformationElementId)126)
161 // 67 to 126 are reserved
162 #define IE_EXTENDED_CAPABILITIES                ((WifiInformationElementId)127)
163 // 128 to 129 are reserved
164 #define IE_PREQ                                 ((WifiInformationElementId)130)
165 #define IE_PREP                                 ((WifiInformationElementId)131)
166 #define IE_PERR                                 ((WifiInformationElementId)132)
167 // 133 to 136 are reserved
168 #define IE_PROXY_UPDATE                         ((WifiInformationElementId)137)
169 #define IE_PROXY_UPDATE_CONFIRMATION            ((WifiInformationElementId)138)
170 #define IE_AUTHENTICATED_MESH_PEERING_EXCHANGE  ((WifiInformationElementId)139)
171 #define IE_MIC                                  ((WifiInformationElementId)140)
172 #define IE_DESTINATION_URI                      ((WifiInformationElementId)141)
173 #define IE_UAPSD_COEXISTENCE                    ((WifiInformationElementId)142)
174 // 143 to 173 are reserved
175 #define IE_MCCAOP_ADVERTISEMENT_OVERVIEW        ((WifiInformationElementId)174)
176 // 175 to 190 are reserved
177 #define IE_VHT_CAPABILITIES                     ((WifiInformationElementId)191)
178 #define IE_VHT_OPERATION                        ((WifiInformationElementId)192)
179 #define IE_EXTENDED_BSS_LOAD                    ((WifiInformationElementId)193)
180 #define IE_WIDE_BANDWIDTH_CHANNEL_SWITCH        ((WifiInformationElementId)194)
181 #define IE_VHT_TRANSMIT_POWER_ENVELOPE          ((WifiInformationElementId)195)
182 #define IE_CHANNEL_SWITCH_WRAPPER               ((WifiInformationElementId)196)
183 #define IE_AID                                  ((WifiInformationElementId)197)
184 #define IE_QUIET_CHANNEL                        ((WifiInformationElementId)198)
185 #define IE_OPERATING_MODE_NOTIFICATION          ((WifiInformationElementId)199)
186 // 200 to 220 are reserved
187 #define IE_VENDOR_SPECIFIC                      ((WifiInformationElementId)221)
188 // 222 to 254 are reserved
189 #define IE_EXTENSION                            ((WifiInformationElementId)255)
190 
191 #define IE_EXT_HE_CAPABILITIES                  ((WifiInformationElementId)35)
192 #define IE_EXT_HE_OPERATION                     ((WifiInformationElementId)36)
193 #define IE_EXT_UORA_PARAMETER_SET               ((WifiInformationElementId)37)
194 #define IE_EXT_MU_EDCA_PARAMETER_SET            ((WifiInformationElementId)38)
195 
196 /**
197  * \brief Information element, as defined in 802.11-2007 standard
198  * \ingroup wifi
199  *
200  * The IEEE 802.11 standard includes the notion of Information
201  * Elements, which are encodings of management information to be
202  * communicated between STAs in the payload of various frames of type
203  * Management. Information Elements (IEs) have a common format, each
204  * starting with a single octet - the Element ID, which indicates the
205  * specific type of IE (a type to represent the options here is
206  * defined as WifiInformationElementId). The next octet is a length field and
207  * encodes the number of octets in the third and final field, which is
208  * the IE Information field.
209  *
210  * The class ns3::WifiInformationElement provides a base for classes
211  * which represent specific Information Elements. This class defines
212  * pure virtual methods for serialisation
213  * (ns3::WifiInformationElement::SerializeInformationField) and
214  * deserialisation
215  * (ns3::WifiInformationElement::DeserializeInformationField) of IEs, from
216  * or to data members or other objects that simulation objects use to
217  * maintain the relevant state.
218  *
219  * This class also provides an implementation of the equality
220  * operator, which operates by comparing the serialised versions of
221  * the two WifiInformationElement objects concerned.
222  *
223  * Elements are defined to have a common general format consisting of
224  * a 1 octet Element ID field, a 1 octet length field, and a
225  * variable-length element-specific information field. Each element is
226  * assigned a unique Element ID as defined in this standard. The
227  * Length field specifies the number of octets in the Information
228  * field.
229  *
230  * This class is pure virtual and acts as base for classes which know
231  * how to serialize specific IEs.
232  */
233 class WifiInformationElement : public SimpleRefCount<WifiInformationElement>
234 {
235 public:
236   virtual ~WifiInformationElement ();
237   /**
238    * Serialize entire IE including Element ID and length fields
239    *
240    * \param i an iterator which points to where the IE should be written.
241    *
242    * \return an iterator
243    */
244   virtual Buffer::Iterator Serialize (Buffer::Iterator i) const;
245   /**
246    * Deserialize entire IE, which must be present. The iterator
247    * passed in must be pointing at the Element ID (i.e., the very
248    * first octet) of the correct type of information element,
249    * otherwise this method will generate a fatal error.
250    *
251    * \param i an iterator which points to where the IE should be read.
252    *
253    * \return an iterator
254    */
255   Buffer::Iterator Deserialize (Buffer::Iterator i);
256   /**
257    * Deserialize entire IE if it is present. The iterator passed in
258    * must be pointing at the Element ID of an information element. If
259    * the Element ID is not the one that the given class is interested
260    * in then it will return the same iterator.
261    *
262    * \param i an iterator which points to where the IE should be read.
263    *
264    * \return an iterator
265    */
266   Buffer::Iterator DeserializeIfPresent (Buffer::Iterator i);
267   /**
268    * Get the size of the serialized IE including Element ID and
269    * length fields.
270    *
271    * \return the size of the serialized IE in bytes
272    */
273   virtual uint16_t GetSerializedSize () const;
274 
275   // Each subclass must implement these pure virtual functions:
276   /**
277    * \returns Own unique Element ID
278    */
279   virtual WifiInformationElementId ElementId () const = 0;
280   /**
281    * Length of serialized information (i.e., the length of the body
282    * of the IE, not including the Element ID and length octets. This
283    * is the value that will appear in the second octet of the entire
284    * IE - the length field)
285    *
286    * \return the length of serialized information
287    */
288   virtual uint8_t GetInformationFieldSize () const = 0;
289   /**
290    * Serialize information (i.e., the body of the IE, not including
291    * the Element ID and length octets)
292    *
293    * \param start an iterator which points to where the information should
294    *        be written.
295    */
296   virtual void SerializeInformationField (Buffer::Iterator start) const = 0;
297   /**
298    * Deserialize information (i.e., the body of the IE, not including
299    * the Element ID and length octets)
300    *
301    * \param start an iterator which points to where the information should be written.
302    * \param length
303    *
304    * \return the number of bytes read
305    */
306   virtual uint8_t DeserializeInformationField (Buffer::Iterator start,
307                                                uint8_t length) = 0;
308 
309   /**
310    * \returns Own unique Element ID Extension
311    */
312   virtual WifiInformationElementId ElementIdExt () const;
313 
314   // In addition, a subclass may optionally override the following...
315   /**
316    * Generate human-readable form of IE
317    *
318    * \param os output stream
319    */
320   virtual void Print (std::ostream &os) const;
321   /**
322    * Compare two IEs for equality by ID & Length, and then through
323    * memcmp of serialised version
324    *
325    * \param a another information element to compare with
326    *
327    * \return true if the two IEs are equal,
328    *         false otherwise
329    */
330   virtual bool operator== (WifiInformationElement const & a) const;
331 
332 };
333 
334 } //namespace ns3
335 
336 #endif /* WIFI_INFORMATION_ELEMENT_H */
337