Skip to content

Commit

Permalink
v0.1.3 Added five new functions, libnl fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wraith-wireless committed Jun 16, 2016
1 parent a397641 commit cee9f7f
Show file tree
Hide file tree
Showing 11 changed files with 371 additions and 203 deletions.
92 changes: 92 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
PyRIC CHANGES

v 0.0.2 to 0.1.0
o added ifconfig/iwconfig functions to pyw
o reworked exception handling
- all exceptions from libnl, libio & pyw are pyric.error
- pyw will allow pyric to pass through
- reworked errorcodes to derive from errno
o added _iostub_, _nlstub_ and reworked traditiona commands to utilize these
o finished porting nl80211_h and nl80211_c (for attribute policies)
o pyw no longer provides familyid as a public function, rather it now uses a
private global value for the nl80211 family id and will instantiate it one
time only. In this way, callers do not not have to worry about retrieving and
passing it
o regdom get & set implemented
o info implemented
o removed radio/Radio class (shouldn't be the responsibility of this)
o added channels.py (provides channel/freq functions)
o added RFI page for notes/observations/questions
o changed utils.py to device.py
o updated libnl
o added channel set & get
- channel get only works when device is associated
- channel set only works when card is in monitor mode and all other interfaces
have been deleted
o added device add & delete
o rewrote pyw function to handle one-time & persistent functions using a
single function interface for each command
o added Card class and wrote functions to handle it in pyw
o implemented basic help functionality (for nl80211)
o added monitor flag(s) support in devadd
o began work on a user guide
o added nested attribute handling
o added partial phyinfo handles all but supported channels/bands
o fixed bugs in devinfo and phyinfo
o added setup.py and required files
o at least one card (ath9k_htc) has an unknown supported command, added a
wrapper around the list IFTYPES to handle commands not listed
o libnl: attribute related i.e. nla_* moved out of GENLMsg class and made as
standalone functions
o in pyw
- added modeset/modeget in pyw
- readded freqset in pyw
- added devcmds in pyw
- annotated (in comments) if fcts needed root privileges
- added functions to get/set ip address, netmask and broadcast
- fixed PEP8 errors
- added function pulling supported freqs out NL80211_ATTR_WIPHY_BANDS
* ATT using _getfreqs_ which attempts to find the packed version of every
freq
* nl80211_c.nl80211_parse_freqs works but is slower than _getfreqs_ and
uses several hacks which may make it invalid for certain cards
- added 4.9GHz frequencies to channels.py
- fixed _validmac_ to validate both uppercase & lowercase hex characters
- added devfreqs, devchs
o unittest completed 61 tests ran in 5.360s
o added rfkill (still working on it)
o production release

v 0.1.1 - 0.1.2
desc: wireless nic library: wireless radio identification, manipulation, enumeration
includes: /nlhelp /lib /net /utils pyw 0.1.2
changes:
o restructured hierarchy
- renamed device to hardware
o added mac address related functions to hardware
o split rfkill into functions file and definition file
o added block/unblock to pyw
o updated pyw to handle the newest version of libnl.py's processing of nested
attributes

v 0.1.3
o added this File, a revision history
o fixed issues
- # 13: Failed to process commands.help
- # 14: nlmsg_fromstream can incorrectly return error based on stream size
- # 11: MemoryError on nla_parse_nested()
o added nla_put_flag to libnl
o identified (unopened issue) and fixed error with ouifetch having invalid path
of default oui file
o moved parseoui from hardware to ouifetch renaming to parse
o removed ouifetch execution ability - parse and fetch must be called w/in
python console. Will eventually add this capability as as top-level program
o added ieee80211_h.py to net/wireless
o added supported ciphers to pyw.phyinfo dict
o added functions
- pwrsaveset and pwrsaveget
- covclassset
- retryshortset
- retrylongset
- rtsthreshset
- fragthreshset
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# setup paramaters
include LICENSE README.md TODO
include LICENSE CHANGES README.md TODO

# Include subdirectories
# note to self: even including recursive-include here, have to follow up by
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,13 @@ w0
```

#### iv. Additional Functions
PyRIC also provides functions to change Radio Parameters: coverage class, rts and
frag thresholds, and retry limits short and long

Read the user guide, or type dir(pyw) in your console to get a full listing
of pyw functions.

c. Miscelleaneous Utilities
**** v. Miscelleaneous Utilities
Several additional tools are located in the utils directory. Two of these are:
* channels.py: defines ISM and UNII band channels/frequencies and provides
functions to convert between channel and frequency and vice-versa
Expand Down
2 changes: 2 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
11) tried NL80211_CMD_GET_WIPHY, setting _WIPHY_TX_POWER_LEVEL but did
not return the current power level - currently cannot find anything in nl80211.h
that could be used to get tx power
12) add set retry short and long, set rts and set frag
13) replace hardcoded values like cc limits in setcovclass to constants

------- Request For Information RFI ----------

Expand Down
Binary file modified docs/PyRIC.pdf
Binary file not shown.
21 changes: 16 additions & 5 deletions docs/PyRIC.tex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
%
% __name__ = 'User Guide'
%__license__ = 'GPLv3'
%__version__ = '0.0.3'
%__version__ = '0.0.4'
%__date__ = 'June 2016'
%__author__ = 'Dale Patterson'
%__maintainer__ = 'Dale Patterson'
Expand Down Expand Up @@ -73,7 +73,7 @@
basicstyle=\footnotesize
}

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

\begin{document}
Expand Down Expand Up @@ -687,6 +687,7 @@ \section{API: pyw.py}\label{sec:pywapi}
\subsection{Constants}
\begin{itemize}
\item \textbf{\_FAM80211ID\_}: Global netlink family id of nl80211. Do not touch
\item \textbf{\_MAXTHRESH\_}: defines limit for thresholds or 'off'. Do not touch
\item \textbf{IFTYPES}: redefined (from nl80211\_h.py) interface modes
\item \textbf{MNTRFLAGS}: redefined (from nl80211\_h.py) monitor mode flags
\item \textbf{IPADDR}: Regular Expression for ip4 address validation
Expand Down Expand Up @@ -745,10 +746,20 @@ \subsection{Functions}
\item block(card): (rfkill block <rfkill\_idx>) type: N/A, soft blocks card
\item unblock(card): (rfkill unblock <rfkill\_idx>) type: N/A, removes the soft
block on card
\item getpwrsave(card,[nlsock]) (iw dev card.<dev> get power\_save) type: netlink
\item pwrsaveget(card,[nlsock]) (iw dev card.<dev> get power\_save) type: netlink
get card's power save state True = on, False = off
\item setpwrsave(card,on,[nlsock]) (iw dev card.<dev> set power\_save <on>) type:
\item pwrsaveset(card,on,[nlsock]) (iw dev card.<dev> set power\_save <on>) type:
netlink set card's power save state True = on, False = off
\item covclassset(card,cc,[nlsock]) (iw phy card.<phy> set coverage <cc>) type:
netlink set card's coverage class
\item retryshortset(card,lim,[nlsock]) (iw phy card.<phy> set retry short <lim>)
type:netlink set card's retry short limit
\item retrylongset(card,lim,[nlsock]) (iw phy card.<phy> set retry long <lim>)
type:netlink set card's retry long limit
\item rtsthreshset(card,thresh,[nlsock]) (iw phy card.<phy> set rts <thresh>) type:
netlink set card's RTS threshold
\item fragthreshset(card,thresh,[nlsock]) (iw phy card.<phy> set frag <thresh>) type:
netlink set card's fragmentation threshold
\item inetget(card,[iosock]): (ifconfig card.<dev>), type: ioctl, get ip4 address,
netmask and broadcast address of card
\item inetset(card,ipaddr,netmask,broadcast,[iosock]): (ifconfig card/<dev> <ipaddr>
Expand Down Expand Up @@ -1069,7 +1080,7 @@ \subsection{Functions}
\end{enumerate}

\section{Copyright and License}\label{sec:copy}
PYRIC: Python Radio Interface Controller v0.1.0\\
PYRIC: Python Radio Interface Controller v0.1.3\\

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

Expand Down
122 changes: 4 additions & 118 deletions pyric/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,132 +25,18 @@
Requires:
linux (preferred 3.x kernel)
Python 2.7
pyric 0.0.2
desc: wireless nic (radio) manipulation, enumeration, and attribute enumeration
includes: /net /lib pyw 0.0.3 radio 0.0.4 utils 0.0.2
changes:
o added ifconfig/iwconfig functions to pyw
o reworked exception handling
- all exceptions from libnl, libio & pyw are pyric.error
- pyw will allow pyric to pass through
- reworked errorcodes to derive from errno
o added _iostub_, _nlstub_ and reworked traditiona commands to utilize these
o finished porting nl80211_h and nl80211_c (for attribute policies)
o pyw no longer provides familyid as a public function, rather it now uses a
private global value for the nl80211 family id and will instantiate it one
time only. In this way, callers do not not have to worry about retrieving and
passing it
o regdom get & set implemented
o info implemented
pyric 0.0.3
desc: wireless nic (radio) manipulation, enumeration, and attribute enumeration
includes: /net /lib pyw 0.0.3 device 0.0.3 channels 0.0.1
changes:
o removed radio/Radio class (shouldn't be the responsibility of this)
o added channels.py (provides channel/freq functions)
o added RFI page for notes/observations/questions
o changed utils.py to device.py
o updated libnl
o added channel set & get
- channel get only works when device is associated
- channel set only works when card is in monitor mode and all other interfaces
have been deleted
o added device add & delete
pyric 0.0.4
desc: wireless nic (radio) manipulation, enumeration, and attribute enumeration
includes: /net /lib pyw 0.1.0 device 0.0.3 channels 0.0.1 setup 0.0.2
changes:
o rewrote pyw function to handle one-time & persistent functions using a
single function interface for each command
pyric 0.0.5
desc: wireless nic (radio) manipulation, enumeration, and attribute enumeration
includes: /net /lib /docs pyw 0.1.2 device 0.0.3 channels 0.0.1
changes:
o added Card class and wrote functions to handle it in pyw
o implemented basic help functionality (for nl80211)
o added monitor flag(s) support in devadd
o began work on a user guide
o added nested attribute handling
o added partial phyinfo handles all but supported channels/bands
o fixed bugs in devinfo and phyinfo
o added setup.py and required files
pyric 0.0.6
desc: Pythonic iw - wireless nic (radio) manipulation, enumeration, and attribute
enumeration
includes: /docs /examples /lib /net pyw 0.1.2 device 0.0.3 channels 0.0.1
changes:
o move pyric under pyric to facilitate setuptools and packaging
- moved LICENSE, MANIFEST.in README.md setup.cfg setup.py examples/ PyRIC.pdf
to outer pyric
o at least one card (ath9k_htc) has an unknown supported command, added a
wrapper around the list IFTYPES to handle commands not listed
pyric 0.0.7
desc: Pythonic iw - wireless nic (radio) manipulation, enumeration, and attribute
enumeration
includes: /docs /examples /lib /net pyw 0.1.2 device 0.0.3 channels 0.0.1
changes:
o libnl: attribute related i.e. nla_* moved out of GENLMsg class and made as
standalone functions
o in pyw
- added modeset/modeget in pyw
- readded freqset in pyw
- added devcmds in pyw
- annotated (in comments) if fcts needed root privileges
- added functions to get/set ip address, netmask and broadcast
- fixed PEP8 errors
- added function pulling supported freqs out NL80211_ATTR_WIPHY_BANDS
* ATT using _getfreqs_ which attempts to find the packed version of every
freq
* nl80211_c.nl80211_parse_freqs works but is slower than _getfreqs_ and
uses several hacks which may make it invalid for certain cards
- added 4.9GHz frequencies to channels.py
- fixed _validmac_ to validate both uppercase & lowercase hex characters
- added devfreqs, devchs
o unittest completed 61 tests ran in 5.360s
o added rfkill (still working on it)
pyric 0.1.0
desc: Pythonic iw - wireless nic (radio) manipulation, enumeration, and attribute
enumeration
includes: /docs /examples /lib /net pyw 0.1.2 device 0.0.3 channels 0.0.1
changes:
o production release
pyric 0.1.1 t0 0.1.1-*
desc: wireless nic library: wireless radio identification, manipulation, enumeration
includes: /nlhelp /lib /net /utils pyw 0.1.2
changes:
o restructured hierarchy
- renamed device to hardware
o added mac address related functions to hardware
o split rfkill into functions file and definition file
o added block/unblock to pyw
o updated pyw to handle the newest version of libnl.py's processing of nested
attributes
pyric 0.1.2
pyric 0.1.3
desc: wireless nic library: wireless radio identification, manipulation, enumeration
includes: /nlhelp /lib /net /utils pyw 0.1.4
changes:
o fixed install issues via pip where data files were not being loaded onto
the user's system
o identified and fixed error with ouifetch with invalid path of default oui file
o moved parseoui from hardware to ouifetch renaming to parse
o removed ouifetch execution ability - parse and fetch must be called w/in
python console. Will eventually add this capability as as top-level program
o added supported ciphers to pyw.phyinfo dict
o added functions getpwrsave and setpwrsave pyw
See CHANGES in top-level directory
"""

__name__ = 'pyric'
__license__ = 'GPLv3'
__version__ = '0.1.2.1'
__version__ = '0.1.3'
__date__ = 'June 2016'
__author__ = 'Dale Patterson'
__maintainer__ = 'Dale Patterson'
Expand Down
1 change: 1 addition & 0 deletions pyric/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
and not full blow objects
- added some error checking to nla_parse_nested, raising and handling error
in situations where attribute len is 0
- fixed nlmsg_fromstream to handle non-ack message parsing with a length of 36
"""

__name__ = 'lib'
Expand Down
9 changes: 5 additions & 4 deletions pyric/lib/libnl.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,16 +424,17 @@ def nlmsg_new(nltype=None,cmd=None,seq=None,pid=None,flags=None,attrs=None):
'cmd':cmd or genlh.CTRL_CMD_UNSPEC,
'attrs':attrs or []})

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

# nla_put_* append data of specified datatype
def nla_put_flag(msg,a): nla_put(msg,None,a,nlh.NLA_FLAG)
def nla_put_flag(msg,a): nla_put(msg,)
def nla_put_unspec(msg,v,a): nla_put(msg,v,a,nlh.NLA_UNSPEC)
def nla_put_u8(msg,v,a): nla_put(msg,v,a,nlh.NLA_U8)
def nla_put_u16(msg,v,a): nla_put(msg,v,a,nlh.NLA_U16)
Expand Down Expand Up @@ -667,4 +668,4 @@ def _maxbufsz_():
# return a hardcoded value
return 2097152
finally:
if fin: fin.close()
if fin: fin.close()
Loading

0 comments on commit cee9f7f

Please sign in to comment.