diff options
author | Marc <marc@malloc.me> | 2022-10-16 20:05:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-16 20:05:57 +0100 |
commit | f418aabe41c21b7669caff0aed5ed0f2fdfef318 (patch) | |
tree | ceae3842463aa08fc92eaff1b10c9b7b74d4bd7e /utils | |
parent | 57cff1f43620d060e4b15d5e9e92529ac3658f90 (diff) | |
parent | 97fc0835937513b808c2a0e07b1b0ac44a39e852 (diff) | |
download | libwifi-f418aabe41c21b7669caff0aed5ed0f2fdfef318.tar.gz libwifi-f418aabe41c21b7669caff0aed5ed0f2fdfef318.tar.bz2 libwifi-f418aabe41c21b7669caff0aed5ed0f2fdfef318.zip |
Merge pull request #11 from libwifi/6ghz
Add support for 6GHz and initial extension tag parsing
Diffstat (limited to 'utils')
-rw-r--r-- | utils/src/test_parsing.c | 84 |
1 files changed, 31 insertions, 53 deletions
diff --git a/utils/src/test_parsing.c b/utils/src/test_parsing.c index b9f9dbc..b5e2d53 100644 --- a/utils/src/test_parsing.c +++ b/utils/src/test_parsing.c | |||
@@ -132,26 +132,36 @@ void print_tag_info(unsigned char *data, size_t data_len) { | |||
132 | } while (libwifi_tag_iterator_next(&it) != -1); | 132 | } while (libwifi_tag_iterator_next(&it) != -1); |
133 | } | 133 | } |
134 | 134 | ||
135 | void parse_radiotap(const unsigned char *packet, size_t packet_len) { | 135 | void parse_radiotap(const struct libwifi_frame *frame) { |
136 | struct libwifi_radiotap_info rtap_info; | 136 | const struct libwifi_radiotap_info *rtap_info = frame->radiotap_info; |
137 | libwifi_parse_radiotap_info(&rtap_info, packet, packet_len); | ||
138 | 137 | ||
139 | printf("=== Radiotap Parsing ===\n"); | 138 | printf("=== Radiotap Parsing ===\n"); |
140 | printf("Radiotap Channel: %d\n", rtap_info.channel.freq); | 139 | printf("Radiotap Channel Freq: %d MHz\n", rtap_info->channel.freq); |
141 | printf("Radiotap Channel Flags: 0x%04x\n", rtap_info.channel.flags); | 140 | printf("Radiotap Freq Band: "); |
142 | printf("Radiotap Rate: %.2f Mb/s\n", rtap_info.rate); | 141 | if (rtap_info->channel.band & LIBWIFI_RADIOTAP_BAND_2GHZ) { |
143 | printf("Radiotap Rate Raw: 0x%02x\n", rtap_info.rate_raw); | 142 | printf("2.4 GHz\n"); |
144 | printf("Radiotap Signal: %d dBm\n", rtap_info.signal); | 143 | } else if (rtap_info->channel.band & LIBWIFI_RADIOTAP_BAND_5GHZ) { |
145 | for (int i = 0; i < rtap_info.antenna_count; i++) { | 144 | printf("5 GHz\n"); |
146 | printf("Radiotap Antenna %d: %d dBm\n", rtap_info.antennas[i].antenna_number, rtap_info.antennas[i].signal); | 145 | } else if (rtap_info->channel.band & LIBWIFI_RADIOTAP_BAND_6GHZ) { |
146 | printf("6 GHz\n"); | ||
147 | } else { | ||
148 | printf("Unknown Band\n"); | ||
149 | } | ||
150 | printf("Radiotap Channel: %d\n", rtap_info->channel.center); | ||
151 | printf("Radiotap Channel Flags: 0x%04x\n", rtap_info->channel.flags); | ||
152 | printf("Radiotap Rate: %.2f Mb/s\n", rtap_info->rate); | ||
153 | printf("Radiotap Rate Raw: 0x%02x\n", rtap_info->rate_raw); | ||
154 | printf("Radiotap Signal: %d dBm\n", rtap_info->signal); | ||
155 | for (int i = 0; i < rtap_info->antenna_count; i++) { | ||
156 | printf("Radiotap Antenna %d: %d dBm\n", rtap_info->antennas[i].antenna_number, rtap_info->antennas[i].signal); | ||
147 | } | 157 | } |
148 | printf("Radiotap Flags: 0x%04x\n", rtap_info.flags); | 158 | printf("Radiotap Flags: 0x%04x\n", rtap_info->flags); |
149 | printf("Radiotap Extended Flags: 0x%08x\n", rtap_info.extended_flags); | 159 | printf("Radiotap Extended Flags: 0x%08x\n", rtap_info->extended_flags); |
150 | printf("Radiotap RX Flags: 0x%04x\n", rtap_info.rx_flags); | 160 | printf("Radiotap RX Flags: 0x%04x\n", rtap_info->rx_flags); |
151 | printf("Radiotap TX Flags: 0x%04x\n", rtap_info.tx_flags); | 161 | printf("Radiotap TX Flags: 0x%04x\n", rtap_info->tx_flags); |
152 | printf("Radiotap TX Power: %d\n", rtap_info.tx_power); | 162 | printf("Radiotap TX Power: %d\n", rtap_info->tx_power); |
153 | printf("Radiotap RTS Retries: %d\n", rtap_info.rts_retries); | 163 | printf("Radiotap RTS Retries: %d\n", rtap_info->rts_retries); |
154 | printf("Radiotap Data Retries: %d\n", rtap_info.data_retries); | 164 | printf("Radiotap Data Retries: %d\n", rtap_info->data_retries); |
155 | printf("=== Radiotap End ===\n"); | 165 | printf("=== Radiotap End ===\n"); |
156 | } | 166 | } |
157 | 167 | ||
@@ -165,10 +175,6 @@ void parse_beacon(struct libwifi_frame frame, unsigned char *args, const struct | |||
165 | return; | 175 | return; |
166 | } | 176 | } |
167 | 177 | ||
168 | if (got_radiotap && parse_radiotap_header) { | ||
169 | parse_radiotap(packet, header->caplen); | ||
170 | } | ||
171 | |||
172 | print_bss_info(&bss); | 178 | print_bss_info(&bss); |
173 | } | 179 | } |
174 | } | 180 | } |
@@ -183,10 +189,6 @@ void parse_probe_request(struct libwifi_frame frame, unsigned char *args, const | |||
183 | return; | 189 | return; |
184 | } | 190 | } |
185 | 191 | ||
186 | if (got_radiotap && parse_radiotap_header) { | ||
187 | parse_radiotap(packet, header->caplen); | ||
188 | } | ||
189 | |||
190 | print_sta_info(&sta); | 192 | print_sta_info(&sta); |
191 | } | 193 | } |
192 | } | 194 | } |
@@ -200,10 +202,6 @@ void parse_probe_response(struct libwifi_frame frame, unsigned char *args, const | |||
200 | return; | 202 | return; |
201 | } | 203 | } |
202 | 204 | ||
203 | if (got_radiotap && parse_radiotap_header) { | ||
204 | parse_radiotap(packet, header->caplen); | ||
205 | } | ||
206 | |||
207 | print_bss_info(&bss); | 205 | print_bss_info(&bss); |
208 | } | 206 | } |
209 | } | 207 | } |
@@ -218,10 +216,6 @@ void parse_deauth(struct libwifi_frame frame, unsigned char *args, const struct | |||
218 | return; | 216 | return; |
219 | } | 217 | } |
220 | 218 | ||
221 | if (got_radiotap && parse_radiotap_header) { | ||
222 | parse_radiotap(packet, header->caplen); | ||
223 | } | ||
224 | |||
225 | printf("=== Deauthentication Frame ===\n"); | 219 | printf("=== Deauthentication Frame ===\n"); |
226 | if (deauth.ordered) { | 220 | if (deauth.ordered) { |
227 | printf("Address 1: " MACSTR "\n", MAC2STR(deauth.frame_header.ordered.addr1)); | 221 | printf("Address 1: " MACSTR "\n", MAC2STR(deauth.frame_header.ordered.addr1)); |
@@ -257,10 +251,6 @@ void parse_disassoc(struct libwifi_frame frame, unsigned char *args, const struc | |||
257 | return; | 251 | return; |
258 | } | 252 | } |
259 | 253 | ||
260 | if (got_radiotap && parse_radiotap_header) { | ||
261 | parse_radiotap(packet, header->caplen); | ||
262 | } | ||
263 | |||
264 | printf("=== Disassociation Frame ===\n"); | 254 | printf("=== Disassociation Frame ===\n"); |
265 | if (disassoc.ordered) { | 255 | if (disassoc.ordered) { |
266 | printf("Address 1: " MACSTR "\n", MAC2STR(disassoc.frame_header.ordered.addr1)); | 256 | printf("Address 1: " MACSTR "\n", MAC2STR(disassoc.frame_header.ordered.addr1)); |
@@ -295,10 +285,6 @@ void parse_assoc_request(struct libwifi_frame frame, unsigned char *args, const | |||
295 | return; | 285 | return; |
296 | } | 286 | } |
297 | 287 | ||
298 | if (got_radiotap && parse_radiotap_header) { | ||
299 | parse_radiotap(packet, header->caplen); | ||
300 | } | ||
301 | |||
302 | print_sta_info(&sta); | 288 | print_sta_info(&sta); |
303 | } | 289 | } |
304 | } | 290 | } |
@@ -312,10 +298,6 @@ void parse_assoc_response(struct libwifi_frame frame, unsigned char *args, const | |||
312 | return; | 298 | return; |
313 | } | 299 | } |
314 | 300 | ||
315 | if (got_radiotap && parse_radiotap_header) { | ||
316 | parse_radiotap(packet, header->caplen); | ||
317 | } | ||
318 | |||
319 | print_bss_info(&bss); | 301 | print_bss_info(&bss); |
320 | } | 302 | } |
321 | } | 303 | } |
@@ -329,10 +311,6 @@ void parse_reassoc_request(struct libwifi_frame frame, unsigned char *args, cons | |||
329 | return; | 311 | return; |
330 | } | 312 | } |
331 | 313 | ||
332 | if (got_radiotap && parse_radiotap_header) { | ||
333 | parse_radiotap(packet, header->caplen); | ||
334 | } | ||
335 | |||
336 | print_sta_info(&sta); | 314 | print_sta_info(&sta); |
337 | } | 315 | } |
338 | } | 316 | } |
@@ -346,10 +324,6 @@ void parse_reassoc_response(struct libwifi_frame frame, unsigned char *args, con | |||
346 | return; | 324 | return; |
347 | } | 325 | } |
348 | 326 | ||
349 | if (got_radiotap && parse_radiotap_header) { | ||
350 | parse_radiotap(packet, header->caplen); | ||
351 | } | ||
352 | |||
353 | print_bss_info(&bss); | 327 | print_bss_info(&bss); |
354 | } | 328 | } |
355 | } | 329 | } |
@@ -427,6 +401,10 @@ void parse_packet(unsigned char *args, const struct pcap_pkthdr *header, const u | |||
427 | return; | 401 | return; |
428 | } | 402 | } |
429 | 403 | ||
404 | if (got_radiotap && parse_radiotap_header && frame.flags & LIBWIFI_FLAGS_RADIOTAP_PRESENT) { | ||
405 | parse_radiotap(&frame); | ||
406 | } | ||
407 | |||
430 | memset(&bss, 0, sizeof(struct libwifi_bss)); | 408 | memset(&bss, 0, sizeof(struct libwifi_bss)); |
431 | memset(&sta, 0, sizeof(struct libwifi_sta)); | 409 | memset(&sta, 0, sizeof(struct libwifi_sta)); |
432 | 410 | ||