Skip to content

Commit cee9f7f

Browse files
author
wraith-wireless
committed
v0.1.3 Added five new functions, libnl fixes
1 parent a397641 commit cee9f7f

File tree

11 files changed

+371
-203
lines changed

11 files changed

+371
-203
lines changed

CHANGES

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
PyRIC CHANGES
2+
3+
v 0.0.2 to 0.1.0
4+
o added ifconfig/iwconfig functions to pyw
5+
o reworked exception handling
6+
- all exceptions from libnl, libio & pyw are pyric.error
7+
- pyw will allow pyric to pass through
8+
- reworked errorcodes to derive from errno
9+
o added _iostub_, _nlstub_ and reworked traditiona commands to utilize these
10+
o finished porting nl80211_h and nl80211_c (for attribute policies)
11+
o pyw no longer provides familyid as a public function, rather it now uses a
12+
private global value for the nl80211 family id and will instantiate it one
13+
time only. In this way, callers do not not have to worry about retrieving and
14+
passing it
15+
o regdom get & set implemented
16+
o info implemented
17+
o removed radio/Radio class (shouldn't be the responsibility of this)
18+
o added channels.py (provides channel/freq functions)
19+
o added RFI page for notes/observations/questions
20+
o changed utils.py to device.py
21+
o updated libnl
22+
o added channel set & get
23+
- channel get only works when device is associated
24+
- channel set only works when card is in monitor mode and all other interfaces
25+
have been deleted
26+
o added device add & delete
27+
o rewrote pyw function to handle one-time & persistent functions using a
28+
single function interface for each command
29+
o added Card class and wrote functions to handle it in pyw
30+
o implemented basic help functionality (for nl80211)
31+
o added monitor flag(s) support in devadd
32+
o began work on a user guide
33+
o added nested attribute handling
34+
o added partial phyinfo handles all but supported channels/bands
35+
o fixed bugs in devinfo and phyinfo
36+
o added setup.py and required files
37+
o at least one card (ath9k_htc) has an unknown supported command, added a
38+
wrapper around the list IFTYPES to handle commands not listed
39+
o libnl: attribute related i.e. nla_* moved out of GENLMsg class and made as
40+
standalone functions
41+
o in pyw
42+
- added modeset/modeget in pyw
43+
- readded freqset in pyw
44+
- added devcmds in pyw
45+
- annotated (in comments) if fcts needed root privileges
46+
- added functions to get/set ip address, netmask and broadcast
47+
- fixed PEP8 errors
48+
- added function pulling supported freqs out NL80211_ATTR_WIPHY_BANDS
49+
* ATT using _getfreqs_ which attempts to find the packed version of every
50+
freq
51+
* nl80211_c.nl80211_parse_freqs works but is slower than _getfreqs_ and
52+
uses several hacks which may make it invalid for certain cards
53+
- added 4.9GHz frequencies to channels.py
54+
- fixed _validmac_ to validate both uppercase & lowercase hex characters
55+
- added devfreqs, devchs
56+
o unittest completed 61 tests ran in 5.360s
57+
o added rfkill (still working on it)
58+
o production release
59+
60+
v 0.1.1 - 0.1.2
61+
desc: wireless nic library: wireless radio identification, manipulation, enumeration
62+
includes: /nlhelp /lib /net /utils pyw 0.1.2
63+
changes:
64+
o restructured hierarchy
65+
- renamed device to hardware
66+
o added mac address related functions to hardware
67+
o split rfkill into functions file and definition file
68+
o added block/unblock to pyw
69+
o updated pyw to handle the newest version of libnl.py's processing of nested
70+
attributes
71+
72+
v 0.1.3
73+
o added this File, a revision history
74+
o fixed issues
75+
- # 13: Failed to process commands.help
76+
- # 14: nlmsg_fromstream can incorrectly return error based on stream size
77+
- # 11: MemoryError on nla_parse_nested()
78+
o added nla_put_flag to libnl
79+
o identified (unopened issue) and fixed error with ouifetch having invalid path
80+
of default oui file
81+
o moved parseoui from hardware to ouifetch renaming to parse
82+
o removed ouifetch execution ability - parse and fetch must be called w/in
83+
python console. Will eventually add this capability as as top-level program
84+
o added ieee80211_h.py to net/wireless
85+
o added supported ciphers to pyw.phyinfo dict
86+
o added functions
87+
- pwrsaveset and pwrsaveget
88+
- covclassset
89+
- retryshortset
90+
- retrylongset
91+
- rtsthreshset
92+
- fragthreshset

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# setup paramaters
2-
include LICENSE README.md TODO
2+
include LICENSE CHANGES README.md TODO
33

44
# Include subdirectories
55
# note to self: even including recursive-include here, have to follow up by

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,13 @@ w0
357357
```
358358

359359
#### iv. Additional Functions
360+
PyRIC also provides functions to change Radio Parameters: coverage class, rts and
361+
frag thresholds, and retry limits short and long
362+
360363
Read the user guide, or type dir(pyw) in your console to get a full listing
361364
of pyw functions.
362365

363-
c. Miscelleaneous Utilities
366+
**** v. Miscelleaneous Utilities
364367
Several additional tools are located in the utils directory. Two of these are:
365368
* channels.py: defines ISM and UNII band channels/frequencies and provides
366369
functions to convert between channel and frequency and vice-versa

TODO

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
11) tried NL80211_CMD_GET_WIPHY, setting _WIPHY_TX_POWER_LEVEL but did
2626
not return the current power level - currently cannot find anything in nl80211.h
2727
that could be used to get tx power
28+
12) add set retry short and long, set rts and set frag
29+
13) replace hardcoded values like cc limits in setcovclass to constants
2830

2931
------- Request For Information RFI ----------
3032

docs/PyRIC.pdf

1.03 KB
Binary file not shown.

docs/PyRIC.tex

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
%
2020
% __name__ = 'User Guide'
2121
%__license__ = 'GPLv3'
22-
%__version__ = '0.0.3'
22+
%__version__ = '0.0.4'
2323
%__date__ = 'June 2016'
2424
%__author__ = 'Dale Patterson'
2525
%__maintainer__ = 'Dale Patterson'
@@ -73,7 +73,7 @@
7373
basicstyle=\footnotesize
7474
}
7575

76-
\title{\includegraphics[scale=1]{logo}\\ PyRIC v0.1.2: User Manual}
76+
\title{\includegraphics[scale=1]{logo}\\ PyRIC v0.1.3: User Manual}
7777
\author{Dale V. Patterson\\ [email protected]}
7878

7979
\begin{document}
@@ -687,6 +687,7 @@ \section{API: pyw.py}\label{sec:pywapi}
687687
\subsection{Constants}
688688
\begin{itemize}
689689
\item \textbf{\_FAM80211ID\_}: Global netlink family id of nl80211. Do not touch
690+
\item \textbf{\_MAXTHRESH\_}: defines limit for thresholds or 'off'. Do not touch
690691
\item \textbf{IFTYPES}: redefined (from nl80211\_h.py) interface modes
691692
\item \textbf{MNTRFLAGS}: redefined (from nl80211\_h.py) monitor mode flags
692693
\item \textbf{IPADDR}: Regular Expression for ip4 address validation
@@ -745,10 +746,20 @@ \subsection{Functions}
745746
\item block(card): (rfkill block <rfkill\_idx>) type: N/A, soft blocks card
746747
\item unblock(card): (rfkill unblock <rfkill\_idx>) type: N/A, removes the soft
747748
block on card
748-
\item getpwrsave(card,[nlsock]) (iw dev card.<dev> get power\_save) type: netlink
749+
\item pwrsaveget(card,[nlsock]) (iw dev card.<dev> get power\_save) type: netlink
749750
get card's power save state True = on, False = off
750-
\item setpwrsave(card,on,[nlsock]) (iw dev card.<dev> set power\_save <on>) type:
751+
\item pwrsaveset(card,on,[nlsock]) (iw dev card.<dev> set power\_save <on>) type:
751752
netlink set card's power save state True = on, False = off
753+
\item covclassset(card,cc,[nlsock]) (iw phy card.<phy> set coverage <cc>) type:
754+
netlink set card's coverage class
755+
\item retryshortset(card,lim,[nlsock]) (iw phy card.<phy> set retry short <lim>)
756+
type:netlink set card's retry short limit
757+
\item retrylongset(card,lim,[nlsock]) (iw phy card.<phy> set retry long <lim>)
758+
type:netlink set card's retry long limit
759+
\item rtsthreshset(card,thresh,[nlsock]) (iw phy card.<phy> set rts <thresh>) type:
760+
netlink set card's RTS threshold
761+
\item fragthreshset(card,thresh,[nlsock]) (iw phy card.<phy> set frag <thresh>) type:
762+
netlink set card's fragmentation threshold
752763
\item inetget(card,[iosock]): (ifconfig card.<dev>), type: ioctl, get ip4 address,
753764
netmask and broadcast address of card
754765
\item inetset(card,ipaddr,netmask,broadcast,[iosock]): (ifconfig card/<dev> <ipaddr>
@@ -1069,7 +1080,7 @@ \subsection{Functions}
10691080
\end{enumerate}
10701081

10711082
\section{Copyright and License}\label{sec:copy}
1072-
PYRIC: Python Radio Interface Controller v0.1.0\\
1083+
PYRIC: Python Radio Interface Controller v0.1.3\\
10731084

10741085
Copyright (C) 2016 Dale V. Patterson ([email protected])\\
10751086

pyric/__init__.py

Lines changed: 4 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -25,132 +25,18 @@
2525
Requires:
2626
linux (preferred 3.x kernel)
2727
Python 2.7
28-
29-
pyric 0.0.2
30-
desc: wireless nic (radio) manipulation, enumeration, and attribute enumeration
31-
includes: /net /lib pyw 0.0.3 radio 0.0.4 utils 0.0.2
32-
changes:
33-
o added ifconfig/iwconfig functions to pyw
34-
o reworked exception handling
35-
- all exceptions from libnl, libio & pyw are pyric.error
36-
- pyw will allow pyric to pass through
37-
- reworked errorcodes to derive from errno
38-
o added _iostub_, _nlstub_ and reworked traditiona commands to utilize these
39-
o finished porting nl80211_h and nl80211_c (for attribute policies)
40-
o pyw no longer provides familyid as a public function, rather it now uses a
41-
private global value for the nl80211 family id and will instantiate it one
42-
time only. In this way, callers do not not have to worry about retrieving and
43-
passing it
44-
o regdom get & set implemented
45-
o info implemented
4628
47-
pyric 0.0.3
48-
desc: wireless nic (radio) manipulation, enumeration, and attribute enumeration
49-
includes: /net /lib pyw 0.0.3 device 0.0.3 channels 0.0.1
50-
changes:
51-
o removed radio/Radio class (shouldn't be the responsibility of this)
52-
o added channels.py (provides channel/freq functions)
53-
o added RFI page for notes/observations/questions
54-
o changed utils.py to device.py
55-
o updated libnl
56-
o added channel set & get
57-
- channel get only works when device is associated
58-
- channel set only works when card is in monitor mode and all other interfaces
59-
have been deleted
60-
o added device add & delete
61-
62-
pyric 0.0.4
63-
desc: wireless nic (radio) manipulation, enumeration, and attribute enumeration
64-
includes: /net /lib pyw 0.1.0 device 0.0.3 channels 0.0.1 setup 0.0.2
65-
changes:
66-
o rewrote pyw function to handle one-time & persistent functions using a
67-
single function interface for each command
68-
69-
pyric 0.0.5
70-
desc: wireless nic (radio) manipulation, enumeration, and attribute enumeration
71-
includes: /net /lib /docs pyw 0.1.2 device 0.0.3 channels 0.0.1
72-
changes:
73-
o added Card class and wrote functions to handle it in pyw
74-
o implemented basic help functionality (for nl80211)
75-
o added monitor flag(s) support in devadd
76-
o began work on a user guide
77-
o added nested attribute handling
78-
o added partial phyinfo handles all but supported channels/bands
79-
o fixed bugs in devinfo and phyinfo
80-
o added setup.py and required files
81-
82-
pyric 0.0.6
83-
desc: Pythonic iw - wireless nic (radio) manipulation, enumeration, and attribute
84-
enumeration
85-
includes: /docs /examples /lib /net pyw 0.1.2 device 0.0.3 channels 0.0.1
86-
changes:
87-
o move pyric under pyric to facilitate setuptools and packaging
88-
- moved LICENSE, MANIFEST.in README.md setup.cfg setup.py examples/ PyRIC.pdf
89-
to outer pyric
90-
o at least one card (ath9k_htc) has an unknown supported command, added a
91-
wrapper around the list IFTYPES to handle commands not listed
92-
93-
pyric 0.0.7
94-
desc: Pythonic iw - wireless nic (radio) manipulation, enumeration, and attribute
95-
enumeration
96-
includes: /docs /examples /lib /net pyw 0.1.2 device 0.0.3 channels 0.0.1
97-
changes:
98-
o libnl: attribute related i.e. nla_* moved out of GENLMsg class and made as
99-
standalone functions
100-
o in pyw
101-
- added modeset/modeget in pyw
102-
- readded freqset in pyw
103-
- added devcmds in pyw
104-
- annotated (in comments) if fcts needed root privileges
105-
- added functions to get/set ip address, netmask and broadcast
106-
- fixed PEP8 errors
107-
- added function pulling supported freqs out NL80211_ATTR_WIPHY_BANDS
108-
* ATT using _getfreqs_ which attempts to find the packed version of every
109-
freq
110-
* nl80211_c.nl80211_parse_freqs works but is slower than _getfreqs_ and
111-
uses several hacks which may make it invalid for certain cards
112-
- added 4.9GHz frequencies to channels.py
113-
- fixed _validmac_ to validate both uppercase & lowercase hex characters
114-
- added devfreqs, devchs
115-
o unittest completed 61 tests ran in 5.360s
116-
o added rfkill (still working on it)
117-
118-
pyric 0.1.0
119-
desc: Pythonic iw - wireless nic (radio) manipulation, enumeration, and attribute
120-
enumeration
121-
includes: /docs /examples /lib /net pyw 0.1.2 device 0.0.3 channels 0.0.1
122-
changes:
123-
o production release
124-
125-
pyric 0.1.1 t0 0.1.1-*
126-
desc: wireless nic library: wireless radio identification, manipulation, enumeration
127-
includes: /nlhelp /lib /net /utils pyw 0.1.2
128-
changes:
129-
o restructured hierarchy
130-
- renamed device to hardware
131-
o added mac address related functions to hardware
132-
o split rfkill into functions file and definition file
133-
o added block/unblock to pyw
134-
o updated pyw to handle the newest version of libnl.py's processing of nested
135-
attributes
136-
137-
pyric 0.1.2
29+
pyric 0.1.3
13830
desc: wireless nic library: wireless radio identification, manipulation, enumeration
13931
includes: /nlhelp /lib /net /utils pyw 0.1.4
14032
changes:
141-
o fixed install issues via pip where data files were not being loaded onto
142-
the user's system
143-
o identified and fixed error with ouifetch with invalid path of default oui file
144-
o moved parseoui from hardware to ouifetch renaming to parse
145-
o removed ouifetch execution ability - parse and fetch must be called w/in
146-
python console. Will eventually add this capability as as top-level program
147-
o added supported ciphers to pyw.phyinfo dict
148-
o added functions getpwrsave and setpwrsave pyw
33+
See CHANGES in top-level directory
34+
14935
"""
15036

15137
__name__ = 'pyric'
15238
__license__ = 'GPLv3'
153-
__version__ = '0.1.2.1'
39+
__version__ = '0.1.3'
15440
__date__ = 'June 2016'
15541
__author__ = 'Dale Patterson'
15642
__maintainer__ = 'Dale Patterson'

pyric/lib/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
and not full blow objects
3838
- added some error checking to nla_parse_nested, raising and handling error
3939
in situations where attribute len is 0
40+
- fixed nlmsg_fromstream to handle non-ack message parsing with a length of 36
4041
"""
4142

4243
__name__ = 'lib'

pyric/lib/libnl.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,16 +424,17 @@ def nlmsg_new(nltype=None,cmd=None,seq=None,pid=None,flags=None,attrs=None):
424424
'cmd':cmd or genlh.CTRL_CMD_UNSPEC,
425425
'attrs':attrs or []})
426426

427-
def nlmsg_fromstream(stream):
427+
def nlmsg_fromstream(stream,override=False):
428428
"""
429429
create a GENLMsg from a stream
430430
:param stream: packed binary data
431+
:param override: override ack processings - DO NOT USE for debugging only
431432
:returns: a GENLMsg
432433
"""
433434
# parse out netlink/generic netlink headers
434435
try:
435436
l,t,fs,s,p = struct.unpack_from(nlh.nl_nlmsghdr,stream,0)
436-
if t == nlh.NLMSG_ERROR or l == nlh.NLMSGACKLEN:
437+
if t == nlh.NLMSG_ERROR or (l == nlh.NLMSGACKLEN and not override):
437438
# have an (possible) ack/nack i.e. error msg
438439
e = struct.unpack_from(nlh.nl_nlmsgerr,stream,nlh.NLMSGHDRLEN)[0]
439440
raise pyric.error(abs(e),strerror(abs(e)))
@@ -554,7 +555,7 @@ def nla_put(msg,v,a,d):
554555
msg['attrs'].append((a,v,d))
555556

556557
# nla_put_* append data of specified datatype
557-
def nla_put_flag(msg,a): nla_put(msg,None,a,nlh.NLA_FLAG)
558+
def nla_put_flag(msg,a): nla_put(msg,)
558559
def nla_put_unspec(msg,v,a): nla_put(msg,v,a,nlh.NLA_UNSPEC)
559560
def nla_put_u8(msg,v,a): nla_put(msg,v,a,nlh.NLA_U8)
560561
def nla_put_u16(msg,v,a): nla_put(msg,v,a,nlh.NLA_U16)
@@ -667,4 +668,4 @@ def _maxbufsz_():
667668
# return a hardcoded value
668669
return 2097152
669670
finally:
670-
if fin: fin.close()
671+
if fin: fin.close()

0 commit comments

Comments
 (0)