libwifi 0.0.3
An 802.11 Frame Parsing and Generation library in C
common.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_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 */
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;
53 int signal;
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 */
64static 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 */
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];
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 */
97static inline void libwifi_free_sta(struct libwifi_sta *sta) {
98 free(sta->tags.parameters);
99}
100
101#endif /* LIBWIFI_CORE_COMMON_H */
static void libwifi_free_bss(struct libwifi_bss *bss)
Definition: common.h:64
static void libwifi_free_sta(struct libwifi_sta *sta)
Definition: common.h:97
int8_t hidden
Definition: common.h:49
struct libwifi_tagged_parameters tags
Definition: common.h:56
unsigned char transmitter[6]
Definition: common.h:45
uint64_t encryption_info
Definition: common.h:52
uint8_t channel
Definition: common.h:50
struct libwifi_wpa_info wpa_info
Definition: common.h:54
char ssid[33]
Definition: common.h:48
int signal
Definition: common.h:53
uint8_t wps
Definition: common.h:51
unsigned char receiver[6]
Definition: common.h:46
struct libwifi_rsn_info rsn_info
Definition: common.h:55
unsigned char bssid[6]
Definition: common.h:47
libwifi Representation of a 802.11 RSN Information Element ┌───────────────────────────────────┐ │ Ve...
Definition: security.h:220
struct libwifi_tagged_parameters tags
Definition: common.h:89
unsigned char transmitter[6]
Definition: common.h:84
uint8_t channel
Definition: common.h:82
uint8_t randomized
Definition: common.h:83
char ssid[33]
Definition: common.h:87
uint8_t broadcast_ssid
Definition: common.h:88
unsigned char receiver[6]
Definition: common.h:85
unsigned char bssid[6]
Definition: common.h:86
unsigned char * parameters
Definition: tag.h:235
libwifi Representation of a Microsoft WPA Information Element ┌───────────────────────────────────┐ │...
Definition: security.h:193