libwifi 0.0.3
An 802.11 Frame Parsing and Generation library in C
tag.h
Go to the documentation of this file.
1/* Copyright 2021 The libwifi Authors
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef LIBWIFI_CORE_TAG_H
17#define LIBWIFI_CORE_TAG_H
18
19#include <stdint.h>
20#include <sys/types.h>
21
22/* 802.11 Tagged Parameter values */
26 // Reserved 2
32 // Reserved 8-9
40 // Reserved 17-31
51 TAG_ERP = 42,
56 // Reserved 47
57 TAG_RSN = 48,
58 // Reserved 49
86 // Undefined 77
112 // Undefined 103
134 TAG_GANN = 125,
135 TAG_RANN = 126,
137 // Reserved 128-129
138 TAG_PREQ = 130,
139 TAG_PREP = 131,
140 TAG_PERR = 132,
141 // Reserved 133-136
142 TAG_PXU = 137,
143 TAG_PXUC = 138,
145 TAG_MIC = 140,
153 // Reserved 149-150
158 // Reserved 155-156
175 // Reserved 173
178 // Reserved 176
180 // Reserved 178-180
197 TAG_AID = 197,
202 // Reserved 203
206 // Reserved 207-220
208 // Reserved 222-254,
210};
211
216 uint8_t tag_num;
217 uint8_t tag_len;
218} __attribute__((packed));
219
220/*
221 * A tagged parameter will include a header as well as some body,
222 * depending on the tag number. The length of the body buffer is
223 * determined with the header.tag_len variable.
224 */
227 unsigned char *body;
228} __attribute__((packed));
229
230/*
231 * A collection of total tagged parameters
232 */
234 size_t length;
235 unsigned char *parameters;
236} __attribute__((packed));
237
238/*
239 * Vendor specific tagged parameters have an OUI and Sub-Type
240 * to determine their use
241 */
243 unsigned char oui[3];
244 int8_t type;
245} __attribute__((packed));
246
253int libwifi_add_tag(struct libwifi_tagged_parameters *tagged_parameters,
254 struct libwifi_tagged_parameter *tagged_parameter);
255
262int libwifi_remove_tag(struct libwifi_tagged_parameters *tagged_parameters, int tag_number);
263
275size_t libwifi_create_tag(struct libwifi_tagged_parameter *tagged_parameter, int tag_number,
276 const unsigned char *tag_data, size_t tag_length);
277
283void libwifi_free_tag(struct libwifi_tagged_parameter *tagged_parameter);
284
293size_t libwifi_dump_tag(struct libwifi_tagged_parameter *tag, unsigned char *buf, size_t buf_len);
294
304int libwifi_quick_add_tag(struct libwifi_tagged_parameters *tagged_parameters, int tag_number,
305 const unsigned char *tag_data, size_t tag_length);
306
314int libwifi_check_tag(struct libwifi_tagged_parameters *tags, int tag_number);
315
322char* libwifi_get_tag_name(int tag_number);
323
324#endif /* LIBWIFI_CORE_TAG_H */
struct libwifi_tagged_parameters tags
Definition: assoc_request.h:2
A tagged parameter always consists of a tag number and length.
Definition: tag.h:215
uint8_t tag_num
Definition: tag.h:216
uint8_t tag_len
Definition: tag.h:217
unsigned char oui[3]
Definition: tag.h:243
unsigned char * body
Definition: tag.h:227
struct libwifi_tag_header header
Definition: tag.h:226
unsigned char * parameters
Definition: tag.h:235
char * libwifi_get_tag_name(int tag_number)
Get the name of a tagged parameter via a supplied tag number.
Definition: tag.c:149
int libwifi_quick_add_tag(struct libwifi_tagged_parameters *tagged_parameters, int tag_number, const unsigned char *tag_data, size_t tag_length)
Add a tagged parameter via tag number and data to a management frame.
Definition: tag.c:118
int libwifi_add_tag(struct libwifi_tagged_parameters *tagged_parameters, struct libwifi_tagged_parameter *tagged_parameter)
Add a tagged parameter to a list of frame tagged parameters.
Definition: tag.c:25
struct libwifi_tag_header __attribute__((packed))
void libwifi_free_tag(struct libwifi_tagged_parameter *tagged_parameter)
Free a tagged parameters body.
Definition: tag.c:99
int libwifi_remove_tag(struct libwifi_tagged_parameters *tagged_parameters, int tag_number)
Remove a tagged parameter from a list of frame tagged parameters.
Definition: tag.c:55
int libwifi_check_tag(struct libwifi_tagged_parameters *tags, int tag_number)
Check if a tagged parameter is present via tag number.
Definition: tag.c:133
size_t libwifi_create_tag(struct libwifi_tagged_parameter *tagged_parameter, int tag_number, const unsigned char *tag_data, size_t tag_length)
Create a tagged parameter from a tag number, length and data.
Definition: tag.c:81
libwifi_tag_numbers
Definition: tag.h:23
@ TAG_ADDBA_EXTENSION
Definition: tag.h:161
@ TAG_EXTENDED_BSS_LOAD
Definition: tag.h:193
@ TAG_CHANNEL_SWITCH_TIMING
Definition: tag.h:113
@ TAG_MCCAOP_TEARDOWN
Definition: tag.h:133
@ TAG_RANN
Definition: tag.h:135
@ TAG_ADVERTISEMENT_PROTOCOL
Definition: tag.h:117
@ TAG_IBSS_DFS
Definition: tag.h:50
@ TAG_TSPEC
Definition: tag.h:36
@ TAG_DESTINATION_URI
Definition: tag.h:146
@ TAG_EXPEDITED_BANDWIDTH_REQUEST
Definition: tag.h:118
@ TAG_FMS_REQUEST
Definition: tag.h:96
@ TAG_DMG_OPERATION
Definition: tag.h:154
@ TAG_DIAGNOSTIC_REPORT
Definition: tag.h:90
@ TAG_CONGESTION_NOTIFICATION
Definition: tag.h:125
@ TAG_BSS_PARAMETERS
Definition: tag.h:30
@ TAG_MULTIPLE_BSSID
Definition: tag.h:80
@ TAG_HT_CAPABILITIES
Definition: tag.h:54
@ TAG_U_APSD_COEXISTENCE
Definition: tag.h:147
@ TAG_TVHT_OPERATION
Definition: tag.h:201
@ TAG_ERP
Definition: tag.h:51
@ TAG_AWAKE_WINDOW
Definition: tag.h:159
@ TAG_MULTIPLE_MAC_SUBLAYERS
Definition: tag.h:172
@ TAG_RIC_DESCRIPTOR
Definition: tag.h:84
@ TAG_EXTENDED_CAPABILITIES
Definition: tag.h:136
@ TAG_SSID_LIST
Definition: tag.h:93
@ TAG_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT
Definition: tag.h:69
@ TAG_TIME_ZONE
Definition: tag.h:107
@ TAG_CHALLENGE_TEXT
Definition: tag.h:39
@ TAG_SWITCHING_STREAM
Definition: tag.h:165
@ TAG_HCCA_TXOP_UPDATE_COUNT
Definition: tag.h:187
@ TAG_WAKEUP_SCHEDULE
Definition: tag.h:111
@ TAG_MESH_PEERING_MANAGEMENT
Definition: tag.h:126
@ TAG_DYNAMIC_TONE_PAIRING_REPORT
Definition: tag.h:167
@ TAG_MEASUREMENT_PILOT_TRANSMISSION
Definition: tag.h:75
@ TAG_RELAY_TRANSFER_PARAMETER_SET
Definition: tag.h:170
@ TAG_RM_ENABLED_CAPABILITIES
Definition: tag.h:79
@ TAG_AUTHENTICATED_MESH_PEERING_EXCHANGE
Definition: tag.h:144
@ TAG_EVENT_REPORT
Definition: tag.h:88
@ TAG_SUPPORTED_OPERATING_CLASSES
Definition: tag.h:68
@ TAG_RSN
Definition: tag.h:57
@ TAG_DMG_BSS_PARAMETER_CHANGE
Definition: tag.h:155
@ TAG_QOS_CAPABILITY
Definition: tag.h:55
@ TAG_WNM_SLEEP_MODE
Definition: tag.h:102
@ TAG_DMG_TSPEC
Definition: tag.h:151
@ TAG_DEVICE_LOCATION
Definition: tag.h:203
@ TAG_TPU_BUFFER_STATUS
Definition: tag.h:115
@ TAG_MANAGEMENT_MIC
Definition: tag.h:85
@ TAG_CHANNEL_SWITCH_WRAPPER
Definition: tag.h:196
@ TAG_BSS_AC_ACCESS_DELAY
Definition: tag.h:77
@ TAG_EVENT_REQUEST
Definition: tag.h:87
@ TAG_OVERLAPPING_BSS_PARAMETERS
Definition: tag.h:83
@ TAG_MCCAOP_ADVERTISEMENT_OVERVIEW
Definition: tag.h:176
@ TAG_STA_AVAILABILITY
Definition: tag.h:150
@ TAG_PTI_CONTROL
Definition: tag.h:114
@ TAG_DSE_REGISTERED_LOCATION
Definition: tag.h:67
@ TAG_QOS_MAP
Definition: tag.h:119
@ TAG_NONTRANSMITTED_BSSID_CAPABILITY
Definition: tag.h:92
@ TAG_QLOAD_REPORT
Definition: tag.h:186
@ TAG_BSS_AVAILABLE_ADMISSION_CAPACITY
Definition: tag.h:76
@ TAG_SCHEDULE
Definition: tag.h:38
@ TAG_BSS_AVERAGE_ACCESS_DELAY
Definition: tag.h:72
@ TAG_SCS_DESCRIPTOR
Definition: tag.h:185
@ TAG_TIMEOUT_INTERVAL
Definition: tag.h:65
@ TAG_QUIET_PERIOD_RESPONSE
Definition: tag.h:179
@ TAG_TCLAS_PROCESSING
Definition: tag.h:53
@ TAG_DMG_LINK_MARGIN
Definition: tag.h:164
@ TAG_DMG_LINK_ADAPTATION_ACKNOWLEDGEMENT
Definition: tag.h:174
@ TAG_FMS_RESPONSE
Definition: tag.h:97
@ TAG_QUIET_CHANNEL
Definition: tag.h:198
@ TAG_MULTIPLE_BSSID_INDEX
Definition: tag.h:94
@ TAG_UPSIM
Definition: tag.h:199
@ TAG_CHANNEL_USAGE
Definition: tag.h:106
@ TAG_BEAMLINK_MAINTENANCE
Definition: tag.h:171
@ TAG_POWER_CAPABILITY
Definition: tag.h:42
@ TAG_FMS_DESCRIPTOR
Definition: tag.h:95
@ TAG_PERR
Definition: tag.h:140
@ TAG_LOCATION_PARAMTERS
Definition: tag.h:91
@ TAG_MIC
Definition: tag.h:145
@ TAG_SSID
Definition: tag.h:24
@ TAG_INTRA_ACCESS_CATEGORY_PRIORITY
Definition: tag.h:184
@ TAG_VENDOR_SPECIFIC
Definition: tag.h:207
@ TAG_PREQ
Definition: tag.h:138
@ TAG_BSS_LOAD
Definition: tag.h:34
@ TAG_ANTENNA
Definition: tag.h:73
@ TAG_TIME_ADVERTISEMENT
Definition: tag.h:78
@ TAG_VHT_CAPABILITIES
Definition: tag.h:191
@ TAG_SUPPORTED_CHANNELS
Definition: tag.h:45
@ TAG_INTERWORKING
Definition: tag.h:116
@ TAG_PXU
Definition: tag.h:142
@ TAG_MEASUREMENT_REPORT
Definition: tag.h:48
@ TAG_MOBILITY_DOMAIN
Definition: tag.h:63
@ TAG_SUPP_RATES
Definition: tag.h:25
@ TAG_MCCAOP_SETUP_REPLY
Definition: tag.h:131
@ TAG_CLUSTER_TIME_OFFSET
Definition: tag.h:183
@ TAG_EDCA_PARAMETERS
Definition: tag.h:35
@ TAG_BEACON_TIMING
Definition: tag.h:129
@ TAG_CF_PARAMETER
Definition: tag.h:28
@ TAG_TFS_RESPONSE
Definition: tag.h:101
@ TAG_NEIGHBOR_REPORT
Definition: tag.h:61
@ TAG_U_PID
Definition: tag.h:173
@ TAG_MESH_LINK_METRIC_REPORT
Definition: tag.h:124
@ TAG_DMS_REQUEST
Definition: tag.h:108
@ TAG_WIDE_BANDWIDTH_CHANNEL_SWITCH
Definition: tag.h:194
@ TAG_TIM
Definition: tag.h:29
@ TAG_EMERGENCY_ALERT_IDENTIFIER
Definition: tag.h:121
@ TAG_TPC_REQUEST
Definition: tag.h:43
@ TAG_QUIET_PERIOD_REQUEST
Definition: tag.h:177
@ TAG_TS_DELAY
Definition: tag.h:52
@ TAG_MESH_AWAKE_WINDOW
Definition: tag.h:128
@ TAG_ANTENNA_SECTOR_ID_PATTERN
Definition: tag.h:190
@ TAG_TCLAS
Definition: tag.h:37
@ TAG_EXTENDED_SUPPORTED_RATES
Definition: tag.h:59
@ TAG_HT_OPERATION
Definition: tag.h:70
@ TAG_COUNTRY
Definition: tag.h:31
@ TAG_NEXT_DMG_ATI
Definition: tag.h:152
@ TAG_VHT_OPERATION
Definition: tag.h:192
@ TAG_QOS_TRAFFIC_CAPABILITY
Definition: tag.h:98
@ TAG_AID
Definition: tag.h:197
@ TAG_TPC_REPORT
Definition: tag.h:44
@ TAG_MESH_CHANNEL_SWITCH_PARAMETERS
Definition: tag.h:127
@ TAG_SECONDARY_CHANNEL_OFFSET
Definition: tag.h:71
@ TAG_DMS_RESPONSE
Definition: tag.h:109
@ TAG_TFS_REQUEST
Definition: tag.h:100
@ TAG_BSS_COEXISTENCE
Definition: tag.h:81
@ TAG_HIGHER_LAYER_STREAM_ID
Definition: tag.h:188
@ TAG_ROAMING_CONSORTIUM
Definition: tag.h:120
@ TAG_MESH_CONFIGURATION
Definition: tag.h:122
@ TAG_QUIET
Definition: tag.h:49
@ TAG_TRANSMIT_POWER_ENVELOPE
Definition: tag.h:195
@ TAG_ECAPC_POLICY
Definition: tag.h:182
@ TAG_CHANNEL_SWITCH_ANNOUNCEMENT
Definition: tag.h:46
@ TAG_COLLOCATED_INTERFERENCE_REPORT
Definition: tag.h:105
@ TAG_MULTI_BAND
Definition: tag.h:160
@ TAG_PXUC
Definition: tag.h:143
@ TAG_EXTENDED_SCHEDULE
Definition: tag.h:149
@ TAG_CHANNEL_MEASUREMENT_FEEDBACK
Definition: tag.h:157
@ TAG_NEXTPCP_LIST
Definition: tag.h:162
@ TAG_MESH_ID
Definition: tag.h:123
@ TAG_PCP_HANDOVER
Definition: tag.h:163
@ TAG_MCCAOP_SETUP_REQUEST
Definition: tag.h:130
@ TAG_WHITE_SPACE_MAP
Definition: tag.h:204
@ TAG_RIC_DATA
Definition: tag.h:66
@ TAG_AP_CHANNEL_REPORT
Definition: tag.h:60
@ TAG_TIM_BROADCAST_RESPONSE
Definition: tag.h:104
@ TAG_ELEMENT_EXTENSION
Definition: tag.h:209
@ TAG_DMG_WAKEUP_SCHEDULE
Definition: tag.h:148
@ TAG_SESSION_TRANSITION
Definition: tag.h:166
@ TAG_RCPI
Definition: tag.h:62
@ TAG_BSS_MAX_IDLE_PERIOD
Definition: tag.h:99
@ TAG_LINK_IDENTIFIER
Definition: tag.h:110
@ TAG_REDUCED_NEIGHBOR_REPORT
Definition: tag.h:200
@ TAG_DIAGNOSTIC_REQUEST
Definition: tag.h:89
@ TAG_FINE_TIMING_MEASUREMENT_PARAMETERS
Definition: tag.h:205
@ TAG_DMG_BEAM_REFINEMENT
Definition: tag.h:156
@ TAG_QMF_POLICY
Definition: tag.h:181
@ TAG_FAST_BSS_TRANSITION
Definition: tag.h:64
@ TAG_CLUSTER_REPORT
Definition: tag.h:168
@ TAG_MCCAOP_ADVERTISEMENT
Definition: tag.h:132
@ TAG_REQUEST
Definition: tag.h:33
@ TAG_PREP
Definition: tag.h:139
@ TAG_POWER_CONSTRAINT
Definition: tag.h:41
@ TAG_TIM_BROADCAST_REQUEST
Definition: tag.h:103
@ TAG_RELAY_CAPABILITIES
Definition: tag.h:169
@ TAG_RSNI
Definition: tag.h:74
@ TAG_GCR_GROUP_ADDRESS
Definition: tag.h:189
@ TAG_DS_PARAMETER
Definition: tag.h:27
@ TAG_GANN
Definition: tag.h:134
@ TAG_MEASUREMENT_REQUEST
Definition: tag.h:47
@ TAG_BSS_INTOLERANT_CHANNEL_REPORT
Definition: tag.h:82
size_t libwifi_dump_tag(struct libwifi_tagged_parameter *tag, unsigned char *buf, size_t buf_len)
Dump a tagged parameter into a raw buffer, for use with other buffers or injection.
Definition: tag.c:103