Skip to content

Commit 569a9f7

Browse files
WraithWirelessWraithWireless
authored andcommitted
v0.1.5 phylist w.r.t Issue #17
1 parent e3d93ca commit 569a9f7

File tree

6 files changed

+20
-2
lines changed

6 files changed

+20
-2
lines changed

CHANGES

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ v 0.1.5 Begin STA associated functionality
123123
- link
124124
- stainfo
125125
- devset
126+
- phylist
126127
o updated nested netlink attribute handling - my understanding of it was incomplete
127128
- There are still occasional errors
128129
- nested attributes are parsed as 'far' as possible
@@ -142,4 +143,5 @@ v 0.1.5 Begin STA associated functionality
142143
testing confirms that the new nla_parse_nested is bug-free)
143144
o fixed error on devadd during restoration in examples/pentest.py
144145
o fixed output error, incorrect labeling
145-
o fixed output error ASW max tx power
146+
o fixed output error ASW max tx power
147+
o added phylist w.r.t issue #17

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ False
205205
False
206206
>>> pyw.iswinterface('wlan0')
207207
True
208+
>>> pyw.phylist() # list all current phys (Note device ASW phy1)
209+
[(1,'phy1), (0, 'phy0')]
208210
>>> pyw.regget() # get the regulatory domain
209211
'US'
210212
>>> pyw.regset('BO') # set the regulatory domain

docs/PyRIC.pdf

390 Bytes
Binary file not shown.

docs/PyRIC.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,8 @@ \subsection{Functions}
728728
\item winterfaces([iosock]): (iwconfig), type: ioctl, list wireless interfaces
729729
\item iswireless(dev,[iosock]): (iwconfig <dev>), type: ioctl, check dev is a
730730
wireless interface
731+
\item phylist(): (iw phy | grep wiphy) type: N/A, list phy indexes and phy names
732+
present on system
731733
\item regget([nlsock]: (iw reg get), type: netlink, get regulatory domain
732734
\item regset(rd,[nlsock]): (iw reg set <rd>), type: netlink, set regulatory domain
733735
to rd

pyric/pyw.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,18 @@ def iswireless(dev, *argv):
170170
if e.errno == pyric.ENODEV or e.errno == pyric.EOPNOTSUPP: return False
171171
else: raise pyric.error(e.errno, e.strerror)
172172

173+
def phylist():
174+
""" :returns: a list of tuples t = (physical indexe, physical name) """
175+
# we could walk the directory /sys/class/ieee80211 as well but we'll
176+
# let rfkill do it (just in case the above path differs across distros or
177+
# in future upgrades
178+
phys = []
179+
rfdevs = rfkill.rfkill_list()
180+
for rfk in rfdevs:
181+
if rfdevs[rfk]['type'] == 'wlan':
182+
phys.append((int(rfk.split('phy')[1]),rfk))
183+
return phys
184+
173185
def regget(*argv):
174186
"""
175187
gets the current regulatory domain (iw reg get)

pyric/utils/hardware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
contributors may be used to endorse or promote products derived from this
2121
software without specific prior written permission.
2222
23-
Defines device hardware related functions: mac address, driver, chipset
23+
Defines device hardware related functions: mac address, driver, chipset etc
2424
2525
"""
2626

0 commit comments

Comments
 (0)