Skip to content

Commit a86b1ba

Browse files
committed
Update python3wifi for Python 3.9 compatibility
1 parent a0b24c5 commit a86b1ba

File tree

3 files changed

+639
-601
lines changed

3 files changed

+639
-601
lines changed

octoprint_wifistatus/python3wifi/flags.py

Lines changed: 101 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -17,95 +17,97 @@
1717
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
1818
# USA
1919

20-
modes = ['Auto',
21-
'Ad-Hoc',
22-
'Managed',
23-
'Master',
24-
'Repeat',
25-
'Second',
26-
'Monitor',
27-
'Unknown/bug']
20+
modes = [
21+
"Auto",
22+
"Ad-Hoc",
23+
"Managed",
24+
"Master",
25+
"Repeat",
26+
"Second",
27+
"Monitor",
28+
"Unknown/bug",
29+
]
2830

2931
IFNAMSIZE = 16
3032
IW_ESSID_MAX_SIZE = 32
3133
IW_MAX_FREQUENCIES = 32
3234
IW_MAX_BITRATES = 32
3335
IW_MAX_TXPOWER = 8
3436

35-
SIOCGIFCONF = 0x8912 # ifconf struct
37+
SIOCGIFCONF = 0x8912 # ifconf struct
3638

3739
# ioctl calls for the Linux/i386 kernel
38-
SIOCSIWCOMMIT = 0x8B00 # Commit pending changes to driver
39-
SIOCGIWNAME = 0x8B01 # get name == wireless protocol
40-
SIOCSIWNWID = 0x8B02 # set network id (pre-802.11)
41-
SIOCGIWNWID = 0x8B03 # get network id (the cell)
42-
SIOCSIWFREQ = 0x8B04 # set channel/frequency
43-
SIOCGIWFREQ = 0x8B05 # get channel/frequency
44-
SIOCSIWMODE = 0x8B06 # set the operation mode
45-
SIOCGIWMODE = 0x8B07 # get operation mode
46-
SIOCSIWSENS = 0x8B08 # set sensitivity (dBm)
47-
SIOCGIWSENS = 0x8B09 # get sensitivity
48-
SIOCSIWRANGE = 0x8B0A # Unused
49-
SIOCGIWRANGE = 0x8B0B # Get range of parameters
50-
SIOCSIWPRIV = 0x8B0C # Unused
51-
SIOCGIWPRIV = 0x8B0D # get private ioctl interface info
52-
SIOCSIWSTATS = 0x8B0E # Unused
53-
SIOCGIWSTATS = 0x8B0F # Get /proc/net/wireless stats
54-
SIOCSIWSPY = 0x8B10 # set spy addresses
55-
SIOCGIWSPY = 0x8B11 # get spy info (quality of link)
56-
SIOCSIWTHRSPY = 0x8B12 # set spy threshold (spy event)
57-
SIOCGIWTHRSPY = 0x8B13 # get spy threshold
58-
SIOCSIWAP = 0x8B14 # set AP MAC address
59-
SIOCGIWAP = 0x8B15 # get AP MAC addresss
60-
SIOCGIWAPLIST = 0x8B17 # Deprecated in favor of scanning
61-
SIOCSIWSCAN = 0x8B18 # set scanning off
62-
SIOCGIWSCAN = 0x8B19 # get scanning results
63-
SIOCSIWESSID = 0x8B1A # set essid
64-
SIOCGIWESSID = 0x8B1B # get essid
65-
SIOCSIWNICKN = 0x8B1C # set node name/nickname
66-
SIOCGIWNICKN = 0x8B1D # get node name/nickname
67-
SIOCSIWRATE = 0x8B20 # set default bit rate (bps)
68-
SIOCGIWRATE = 0x8B21 # get default bit rate (bps)
69-
SIOCSIWRTS = 0x8B22 # set RTS/CTS threshold (bytes)
70-
SIOCGIWRTS = 0x8B23 # get RTS/CTS threshold (bytes)
71-
SIOCSIWFRAG = 0x8B24 # set fragmentation thr (bytes)
72-
SIOCGIWFRAG = 0x8B25 # get fragmentation thr (bytes)
73-
SIOCSIWTXPOW = 0x8B26 # set transmit power (dBm)
74-
SIOCGIWTXPOW = 0x8B27 # get transmit power (dBm)
75-
SIOCSIWRETRY = 0x8B28 # set retry limits and lifetime
76-
SIOCGIWRETRY = 0x8B29 # get retry limits and lifetime
77-
SIOCSIWENCODE = 0x8B2A # set encryption information
78-
SIOCGIWENCODE = 0x8B2B # get encryption information
79-
SIOCSIWPOWER = 0x8B2C # set Power Management settings
80-
SIOCGIWPOWER = 0x8B2D # get power managment settings
81-
SIOCSIWMODUL = 0x8B2E # set Modulations settings
82-
SIOCGIWMODUL = 0x8B2F # get Modulations settings
83-
SIOCSIWGENIE = 0x8B30 # set generic IE
84-
SIOCGIWGENIE = 0x8B31 # get generic IE
40+
SIOCSIWCOMMIT = 0x8B00 # Commit pending changes to driver
41+
SIOCGIWNAME = 0x8B01 # get name == wireless protocol
42+
SIOCSIWNWID = 0x8B02 # set network id (pre-802.11)
43+
SIOCGIWNWID = 0x8B03 # get network id (the cell)
44+
SIOCSIWFREQ = 0x8B04 # set channel/frequency
45+
SIOCGIWFREQ = 0x8B05 # get channel/frequency
46+
SIOCSIWMODE = 0x8B06 # set the operation mode
47+
SIOCGIWMODE = 0x8B07 # get operation mode
48+
SIOCSIWSENS = 0x8B08 # set sensitivity (dBm)
49+
SIOCGIWSENS = 0x8B09 # get sensitivity
50+
SIOCSIWRANGE = 0x8B0A # Unused
51+
SIOCGIWRANGE = 0x8B0B # Get range of parameters
52+
SIOCSIWPRIV = 0x8B0C # Unused
53+
SIOCGIWPRIV = 0x8B0D # get private ioctl interface info
54+
SIOCSIWSTATS = 0x8B0E # Unused
55+
SIOCGIWSTATS = 0x8B0F # Get /proc/net/wireless stats
56+
SIOCSIWSPY = 0x8B10 # set spy addresses
57+
SIOCGIWSPY = 0x8B11 # get spy info (quality of link)
58+
SIOCSIWTHRSPY = 0x8B12 # set spy threshold (spy event)
59+
SIOCGIWTHRSPY = 0x8B13 # get spy threshold
60+
SIOCSIWAP = 0x8B14 # set AP MAC address
61+
SIOCGIWAP = 0x8B15 # get AP MAC addresss
62+
SIOCGIWAPLIST = 0x8B17 # Deprecated in favor of scanning
63+
SIOCSIWSCAN = 0x8B18 # set scanning off
64+
SIOCGIWSCAN = 0x8B19 # get scanning results
65+
SIOCSIWESSID = 0x8B1A # set essid
66+
SIOCGIWESSID = 0x8B1B # get essid
67+
SIOCSIWNICKN = 0x8B1C # set node name/nickname
68+
SIOCGIWNICKN = 0x8B1D # get node name/nickname
69+
SIOCSIWRATE = 0x8B20 # set default bit rate (bps)
70+
SIOCGIWRATE = 0x8B21 # get default bit rate (bps)
71+
SIOCSIWRTS = 0x8B22 # set RTS/CTS threshold (bytes)
72+
SIOCGIWRTS = 0x8B23 # get RTS/CTS threshold (bytes)
73+
SIOCSIWFRAG = 0x8B24 # set fragmentation thr (bytes)
74+
SIOCGIWFRAG = 0x8B25 # get fragmentation thr (bytes)
75+
SIOCSIWTXPOW = 0x8B26 # set transmit power (dBm)
76+
SIOCGIWTXPOW = 0x8B27 # get transmit power (dBm)
77+
SIOCSIWRETRY = 0x8B28 # set retry limits and lifetime
78+
SIOCGIWRETRY = 0x8B29 # get retry limits and lifetime
79+
SIOCSIWENCODE = 0x8B2A # set encryption information
80+
SIOCGIWENCODE = 0x8B2B # get encryption information
81+
SIOCSIWPOWER = 0x8B2C # set Power Management settings
82+
SIOCGIWPOWER = 0x8B2D # get power managment settings
83+
SIOCSIWMODUL = 0x8B2E # set Modulations settings
84+
SIOCGIWMODUL = 0x8B2F # get Modulations settings
85+
SIOCSIWGENIE = 0x8B30 # set generic IE
86+
SIOCGIWGENIE = 0x8B31 # get generic IE
8587
# WPA
86-
SIOCSIWMLME = 0x8B16 # request MLME operation; uses struct iw_mlme
87-
SIOCSIWAUTH = 0x8B32 # set authentication mode params
88-
SIOCGIWAUTH = 0x8B33 # get authentication mode params
89-
SIOCSIWENCODEEXT = 0x8B34 # set encoding token & mode
90-
SIOCGIWENCODEEXT = 0x8B35 # get encoding token & mode
91-
SIOCSIWPMKSA = 0x8B36 # PMKSA cache operation
88+
SIOCSIWMLME = 0x8B16 # request MLME operation; uses struct iw_mlme
89+
SIOCSIWAUTH = 0x8B32 # set authentication mode params
90+
SIOCGIWAUTH = 0x8B33 # get authentication mode params
91+
SIOCSIWENCODEEXT = 0x8B34 # set encoding token & mode
92+
SIOCGIWENCODEEXT = 0x8B35 # get encoding token & mode
93+
SIOCSIWPMKSA = 0x8B36 # PMKSA cache operation
9294

93-
SIOCIWFIRST = 0x8B00 # FIRST ioctl identifier
94-
SIOCIWLAST = 0x8BFF # LAST ioctl identifier
95+
SIOCIWFIRST = 0x8B00 # FIRST ioctl identifier
96+
SIOCIWLAST = 0x8BFF # LAST ioctl identifier
9597

9698
# Wireless events
97-
IWEVFIRST = 0x8C00 # FIRST event identifier
98-
IWEVTXDROP = 0x8C00 # Packet dropped to excessive retry
99-
IWEVQUAL = 0x8C01 # Quality statistics from scan
100-
IWEVCUSTOM = 0x8C02 # Custom Ascii string from Driver
101-
IWEVREGISTERED = 0x8C03 # Discovered a new node (AP mode)
102-
IWEVEXPIRED = 0x8C04 # Expired a node (AP mode)
103-
IWEVGENIE = 0x8C05 # Generic IE (WPA, RSN, WMM, ..)
104-
IWEVMICHAELMICFAILURE = 0x8C06 # Michael MIC failure
105-
IWEVASSOCREQIE = 0x8C07 # IEs used in (Re)Association Request.
106-
IWEVASSOCRESPIE = 0x8C08 # IEs used in (Re)Association Response.
107-
IWEVPMKIDCAND = 0x8C09 # PMKID candidate for RSN pre-authentication
108-
IWEVLAST = 0x8C0A # LAST event identifier
99+
IWEVFIRST = 0x8C00 # FIRST event identifier
100+
IWEVTXDROP = 0x8C00 # Packet dropped to excessive retry
101+
IWEVQUAL = 0x8C01 # Quality statistics from scan
102+
IWEVCUSTOM = 0x8C02 # Custom Ascii string from Driver
103+
IWEVREGISTERED = 0x8C03 # Discovered a new node (AP mode)
104+
IWEVEXPIRED = 0x8C04 # Expired a node (AP mode)
105+
IWEVGENIE = 0x8C05 # Generic IE (WPA, RSN, WMM, ..)
106+
IWEVMICHAELMICFAILURE = 0x8C06 # Michael MIC failure
107+
IWEVASSOCREQIE = 0x8C07 # IEs used in (Re)Association Request.
108+
IWEVASSOCRESPIE = 0x8C08 # IEs used in (Re)Association Response.
109+
IWEVPMKIDCAND = 0x8C09 # PMKID candidate for RSN pre-authentication
110+
IWEVLAST = 0x8C0A # LAST event identifier
109111

110112
# Power management flags
111113
IW_POWER_ON = 0x0000 # No details ...
@@ -137,46 +139,46 @@
137139
IW_RETRY_LONG = 0x0020 # Value is for long packets
138140

139141
# Modes of operation
140-
IW_MODE_AUTO = 0 # Let the driver decides
141-
IW_MODE_ADHOC = 1 # Single cell network
142-
IW_MODE_INFRA = 2 # Multi cell network, roaming, ...
143-
IW_MODE_MASTER = 3 # Synchronisation master or Access Point
144-
IW_MODE_REPEAT = 4 # Wireless Repeater (forwarder)
145-
IW_MODE_SECOND = 5 # Secondary master/repeater (backup)
146-
IW_MODE_MONITOR = 6 # Passive monitor (listen only)
142+
IW_MODE_AUTO = 0 # Let the driver decides
143+
IW_MODE_ADHOC = 1 # Single cell network
144+
IW_MODE_INFRA = 2 # Multi cell network, roaming, ...
145+
IW_MODE_MASTER = 3 # Synchronisation master or Access Point
146+
IW_MODE_REPEAT = 4 # Wireless Repeater (forwarder)
147+
IW_MODE_SECOND = 5 # Secondary master/repeater (backup)
148+
IW_MODE_MONITOR = 6 # Passive monitor (listen only)
147149

148150
# Statistics flags (bitmask in updated)
149-
IW_QUAL_QUAL_UPDATED = 0x01 # Value was updated since last read
151+
IW_QUAL_QUAL_UPDATED = 0x01 # Value was updated since last read
150152
IW_QUAL_LEVEL_UPDATED = 0x02
151153
IW_QUAL_NOISE_UPDATED = 0x04
152154
IW_QUAL_ALL_UPDATED = 0x07
153-
IW_QUAL_DBM = 0x08 # Level + Noise are dBm
154-
IW_QUAL_QUAL_INVALID = 0x10 # Driver doesn't provide value
155+
IW_QUAL_DBM = 0x08 # Level + Noise are dBm
156+
IW_QUAL_QUAL_INVALID = 0x10 # Driver doesn't provide value
155157
IW_QUAL_LEVEL_INVALID = 0x20
156158
IW_QUAL_NOISE_INVALID = 0x40
157-
IW_QUAL_RCPI = 0x80 # Level + Noise are 802.11k RCPI
159+
IW_QUAL_RCPI = 0x80 # Level + Noise are 802.11k RCPI
158160
IW_QUAL_ALL_INVALID = 0x70
159161

160162
# Frequency flags
161-
IW_FREQ_AUTO = 0x00 # Let the driver decide
162-
IW_FREQ_FIXED = 0x01 # Force a specific value
163+
IW_FREQ_AUTO = 0x00 # Let the driver decide
164+
IW_FREQ_FIXED = 0x01 # Force a specific value
163165

164166
# Maximum number of size of encoding token available
165167
IW_MAX_ENCODING_SIZES = 8
166168

167169
# Maximum size of the encoding token in bytes
168-
IW_ENCODING_TOKEN_MAX = 64 # 512 bits (for now)
170+
IW_ENCODING_TOKEN_MAX = 64 # 512 bits (for now)
169171

170172
# Flags for encoding (along with the token)
171-
IW_ENCODE_INDEX = 0x00FF # Token index (if needed)
172-
IW_ENCODE_FLAGS = 0xFF00 # Flags defined below
173-
IW_ENCODE_MODE = 0xF000 # Modes defined below
174-
IW_ENCODE_DISABLED = 0x8000 # Encoding disabled
175-
IW_ENCODE_ENABLED = 0x0000 # Encoding enabled
176-
IW_ENCODE_RESTRICTED = 0x4000 # Refuse non-encoded packets
177-
IW_ENCODE_OPEN = 0x2000 # Accept non-encoded packets
178-
IW_ENCODE_NOKEY = 0x0800 # Key is write only, so not present
179-
IW_ENCODE_TEMP = 0x0400 # Temporary key
173+
IW_ENCODE_INDEX = 0x00FF # Token index (if needed)
174+
IW_ENCODE_FLAGS = 0xFF00 # Flags defined below
175+
IW_ENCODE_MODE = 0xF000 # Modes defined below
176+
IW_ENCODE_DISABLED = 0x8000 # Encoding disabled
177+
IW_ENCODE_ENABLED = 0x0000 # Encoding enabled
178+
IW_ENCODE_RESTRICTED = 0x4000 # Refuse non-encoded packets
179+
IW_ENCODE_OPEN = 0x2000 # Accept non-encoded packets
180+
IW_ENCODE_NOKEY = 0x0800 # Key is write only, so not present
181+
IW_ENCODE_TEMP = 0x0400 # Temporary key
180182

181183
# MAC address length
182184
ETH_ALEN = 6

0 commit comments

Comments
 (0)