Skip to content

Commit

Permalink
v0.1.6 added freqget
Browse files Browse the repository at this point in the history
  • Loading branch information
WraithWireless authored and WraithWireless committed Aug 7, 2016
1 parent 4383106 commit a2e811d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
9 changes: 5 additions & 4 deletions CHANGES
Expand Up @@ -169,10 +169,11 @@ v 0.1.6 Continue with STA functionality
- issue 2: caller/user must configure dhcp request or inet themselves
- issue 3: only works on open networks
o Issue #24 (TODO #50) resolved. getcard which is the entry point for any
nl80211 functionality uses devinfo to retrieve the Card tuple. devinfo will now
report No Such device as two seperate errors one identifying when there is
no device currently present on the machine and one identifying when the
nl80211 functionality uses devinfo to retrieve the Card tuple. devinfo will
now report No Such device as two seperate errors one identifying when there
is no device currently present on the machine and one identifying when the
specified dev's driver does not support nl80211
o fixed TypeError resulting from raising pyric.error incorrectly
o made phyadd which accepts only the physical index and returns a card with
correct dev (w.r.t https://wraithwireless.wordpress.com/2016/07/24/linux-kernel-bug/)
correct dev (w.r.t https://wraithwireless.wordpress.com/2016/07/24/linux-kernel-bug/)
o added freqget
Binary file modified docs/PyRIC.pdf
Binary file not shown.
6 changes: 4 additions & 2 deletions docs/PyRIC.tex
Expand Up @@ -801,10 +801,12 @@ \subsection{Functions}
netlink,sets the tx power to pwr (in dBm) with level setting lvl
\item txget(card,[iosock]): (iwconfig card.<dev> | grep Tx-Power card), type:
ioctl, get card's transmission power
\item chget(card,[nlsock]): (iw dev <card.dev> info | grep channelS), type:
netlink, get card's current channel (only works for cards in mode managed)
\item chget(card,[nlsock]): (iw dev <card.dev> info | grep channel), type:
netlink, get card's current channel
\item chset(card,ch,chw,[nlsock]): iw phy <card.phy> set channel <ch> <chw>),
type: netlink, set card's current channel to ch with width chw
\item freqget(card,[nlsock]): (iw dev <card.dev> info | grep channel), type:
netlink, get card's current frequency
\item freqset(card,rf,chw,[nlsock]): iw phy <card.phy> set freq <rf> <chw>),
type: netlink, set card's current frequency to rf with width chw
\item devmodes(card,[iosock]): (iw phy card.<phy>), type: netlink, get modes
Expand Down
20 changes: 18 additions & 2 deletions pyric/pyw.py
Expand Up @@ -254,6 +254,7 @@ def getcard(dev, *argv):
"""
get the Card object from device name
:param dev: device name
:param argv: netlink socket at argv[0] or empty
:returns: a Card with device name dev
"""
try:
Expand Down Expand Up @@ -1365,6 +1366,21 @@ def chset(card, ch, chw=None, *argv):

return freqset(card, channels.ch2rf(ch), chw, nlsock)

def freqget(card, *argv):
"""
gets the current frequency for device (iw dev <card.dev> info | grep channel)
:param card: Card object
:param argv: netlink socket at argv[0] (or empty)
NOTE: will only work if dev is associated w/ AP or device is in monitor mode
and has had [ch|freq]set previously
"""
try:
nlsock = argv[0]
except IndexError:
return _nlstub_(chget, card)

return devinfo(card, nlsock)['RF']

def freqset(card, rf, chw=None, *argv):
"""
REQUIRES ROOT PRIVILEGES
Expand Down Expand Up @@ -1495,7 +1511,7 @@ def devset(card, ndev, *argv):
set a new dev.
o this is not a true set name: it adds a new card with ndev as the dev then
deletes the current card, returning the new card
- in effect, it will appear as if the card as a new name but, it will also
- in effect, it will appear as if the card has a new name but, it will also
have a new ifindex
"""
try:
Expand Down Expand Up @@ -2418,4 +2434,4 @@ def _fut_chset(card, ch, chw, *argv):
nl.nla_put_u32(msg, channels.ch2rf(ch), nl80211h.NL80211_ATTR_WIPHY_FREQ)
nl.nla_put_u32(msg, channels.CHTYPES.index(chw), nl80211h.NL80211_ATTR_WIPHY_CHANNEL_TYPE)
nl.nl_sendmsg(nlsock, msg)
_ = nl.nl_recvmsg(nlsock)
_ = nl.nl_recvmsg(nlsock)

0 comments on commit a2e811d

Please sign in to comment.