-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnl_utilities.h
73 lines (54 loc) · 1.55 KB
/
nl_utilities.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef NL_UTILITIES_H
#define NL_UTILITIES_H
#include <linux/nl80211.h>
/*
* 2.4 (assumes 20MHz width) & 5 (assues 80MHz width) GHz channel frequencies.
* Yes, these channels may be used without restriction in NA.
*/
enum wifi_chan_freqs {
CHANNEL_1 = 2412,
CHANNEL_6 = 2437,
CHANNEL_11 = 2462,
CHANNEL_36 = 5180,
CHANNEL_40 = 5200,
CHANNEL_44 = 5220,
CHANNEL_48 = 5240,
CHANNEL_149 = 5745,
CHANNEL_153 = 5765,
CHANNEL_157 = 5785,
CHANNEL_161 = 5805,
CHANNEL_165 = 5825
};
typedef struct {
int nl80211_id;
struct nl_sock *sk;
} nl_handle;
struct phy_info {
unsigned phy_id;
char *phy_name;
unsigned hard_mon;
unsigned soft_mon;
unsigned new_if;
unsigned set_if;
struct phy_info *next;
};
struct if_info {
char *if_name;
unsigned if_index;
unsigned wdev;
unsigned wiphy;
unsigned if_type;
unsigned if_freq;
};
void nl_init(nl_handle *nl);
void nl_cleanup(nl_handle *nl);
int get_if_index(char *if_name);
enum nl80211_iftype iftype_str_to_num(const char *base_iftype);
int create_new_interface(nl_handle *nl, char *if_name, enum nl80211_iftype if_type, unsigned wiphy);
int delete_interface(nl_handle *nl, unsigned if_index);
int get_interface_config(nl_handle *nl, struct if_info *info, unsigned if_index);
int set_if_up(const char *if_name);
int set_if_down(const char *if_name);
int set_interface_channel(nl_handle *nl, unsigned if_index, enum wifi_chan_freqs freq);
int set_interface_type(nl_handle *nl, enum nl80211_iftype type, unsigned if_index);
#endif