diff options
Diffstat (limited to 'src/libwifi/core/frame/management/common.h')
-rw-r--r-- | src/libwifi/core/frame/management/common.h | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/src/libwifi/core/frame/management/common.h b/src/libwifi/core/frame/management/common.h new file mode 100644 index 0000000..1f5d042 --- /dev/null +++ b/src/libwifi/core/frame/management/common.h | |||
@@ -0,0 +1,101 @@ | |||
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_COMMON_H | ||
17 | #define LIBWIFI_CORE_COMMON_H | ||
18 | |||
19 | #include "../../misc/security.h" | ||
20 | #include "../tag.h" | ||
21 | #include <stdint.h> | ||
22 | #include <stdlib.h> | ||
23 | |||
24 | #define LIBWIFI_BSS 0 | ||
25 | #define LIBWIFI_STA 1 | ||
26 | |||
27 | /* | ||
28 | * A libwifi_bss struct is used as a common model for BSS / APs, and can be derived | ||
29 | * from parsed frames or used to generate new frames. Fields may be optional. | ||
30 | * | ||
31 | * transmitter - The transmitter MAC address | ||
32 | * receiver - The receiver MAC address | ||
33 | * bssid - BSSID MAC address | ||
34 | * ssid - AP SSID | ||
35 | * hidden - Hidden state boolean | ||
36 | * channel - BSS Channel | ||
37 | * wps - WPS state boolean | ||
38 | * encryption_info - Bitfield of encryption state, such as WPA version and ciphers | ||
39 | * signal - RSSI in dBm | ||
40 | * wpa_info - WPA1 information, present if encryption_info has the WPA1 bit set | ||
41 | * rsn_info - WPA2 and/or WPA3 information, present if encryption_info has WPA2 or WPA3 bit set | ||
42 | * tags - List of tagged parameters | ||
43 | */ | ||
44 | struct libwifi_bss { | ||
45 | unsigned char transmitter[6]; | ||
46 | unsigned char receiver[6]; | ||
47 | unsigned char bssid[6]; | ||
48 | char ssid[33]; | ||
49 | int8_t hidden; | ||
50 | uint8_t channel; | ||
51 | uint8_t wps; | ||
52 | uint64_t encryption_info; | ||
53 | int signal; | ||
54 | struct libwifi_wpa_info wpa_info; | ||
55 | struct libwifi_rsn_info rsn_info; | ||
56 | struct libwifi_tagged_parameters tags; | ||
57 | }; | ||
58 | |||
59 | /* | ||
60 | * A libwifi_bss can be populated with dynamically allocated tags, which must be free'd by | ||
61 | * the user application to avoid memory leaks. This function provides an easy wrapper for any | ||
62 | * libwifi allocations made. | ||
63 | */ | ||
64 | static inline void libwifi_free_bss(struct libwifi_bss *bss) { | ||
65 | free(bss->tags.parameters); | ||
66 | } | ||
67 | |||
68 | /* | ||
69 | * A libwifi_sta struct is used as a common model for stations, roaming or associated, | ||
70 | * and can be derived from parsed frames or used to generate new frames. Fields may be optional. | ||
71 | * | ||
72 | * channel - BSS Channel | ||
73 | * randomized - Client has a likely randomized MAC | ||
74 | * transmitter - The transmitter MAC address | ||
75 | * receiver - The receiver MAC address | ||
76 | * bssid - BSSID MAC address | ||
77 | * ssid - AP SSID | ||
78 | * broadcast_ssid - STA is broadcasting for SSID | ||
79 | * tags - List of tagged parameters | ||
80 | */ | ||
81 | struct libwifi_sta { | ||
82 | uint8_t channel; | ||
83 | uint8_t randomized; | ||
84 | unsigned char transmitter[6]; | ||
85 | unsigned char receiver[6]; | ||
86 | unsigned char bssid[6]; | ||
87 | char ssid[33]; | ||
88 | uint8_t broadcast_ssid; | ||
89 | struct libwifi_tagged_parameters tags; | ||
90 | }; | ||
91 | |||
92 | /* | ||
93 | * A libwifi_sta can be populated with dynamically allocated tags, which must be free'd by | ||
94 | * the user application to avoid memory leaks. This function provides an easy wrapper for any | ||
95 | * libwifi allocations made. | ||
96 | */ | ||
97 | static inline void libwifi_free_sta(struct libwifi_sta *sta) { | ||
98 | free(sta->tags.parameters); | ||
99 | } | ||
100 | |||
101 | #endif /* LIBWIFI_CORE_COMMON_H */ | ||