Skip to content

Commit

Permalink
v0.1.4 updated to support linux kernel v 4
Browse files Browse the repository at this point in the history
  • Loading branch information
WraithWireless authored and WraithWireless committed Jun 26, 2016
1 parent a937e2a commit 669818a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 27 deletions.
33 changes: 12 additions & 21 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
3) parse NL80211_ATTR_WIPHY_BANDS (have workaround currently in place)
- after figuring out _CIPHER_SUITES, may be able to get a solution for the bands
4) RFI (1)
5) Should we move to netlink for setting ip address?
- ioctl allows us to set erroneous values for netmask, broadcast whereas netlink
forces validity
6) find a better way to get supported standards of a card
7) code up txget, txset via netlink even though cards don't seem to support it
8) Two commands that would add information of minor value
o ethtool. uses ioctl but does not follow same pattern as ifconfig seems
to use
Expand Down Expand Up @@ -109,18 +105,17 @@ error strings and test for NLE_SUCCESS in netlink error message
6) Setting the channel/Frequency
nl80211.h states that using NL80211_CMD_SET_WIPHY to set the channel is deprecated
in place of NL80211_CMD_SET_CHANNEL. Below is the attempted code:
phy = devinfoex(nlsock,nic)['phy']
msg = nl.nlmsg_new(nl_type=_FAM80211ID_,
cmd=nl80211h.NL80211_CMD_SET_CHANNEL,
flags=nlh.NLM_F_REQUEST | nlh.NLM_F_ACK)
msg.nla_put_u32(phy,nl80211h.NL80211_ATTR_WIPHY)
msg.nla_put_u32(channels.ch2rf(ch),nl80211h.NL80211_ATTR_WIPHY_FREQ)
msg.nla_put_u32(CHWIDTHS.index(chw),nl80211h.NL80211_ATTR_WIPHY_CHANNEL_TYPE)

# Here as found during updating nl80211.h, _CHANNEL_TYPE is not CHANNEL_WIDTH

and results in a 'invalid argument' error. So, am I sending the wrong crap? The
description for this command in nl80211_h
msg = nl.nlmsg_new(nltype=_familyid_(nlsock),
cmd=nl80211h.NL80211_CMD_SET_CHANNEL,
flags=nlh.NLM_F_REQUEST | nlh.NLM_F_ACK)
nl.nla_put_u32(msg, card.idx, nl80211h.NL80211_ATTR_IFINDEX)
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)

and results in a 'Operation not supported' error.
The description for this command in nl80211_h

* @NL80211_CMD_SET_CHANNEL: Set the channel (using %NL80211_ATTR_WIPHY_FREQ
* and the attributes determining channel width) the given interface
Expand All @@ -132,11 +127,7 @@ description for this command in nl80211_h
* of any other interfaces, and other interfaces will again take
* precedence when they are used.

mentions ifindex. Adding the ifindex with:

msg.nla_put_u32(nl80211h.NL80211_ATTR_IFINDEX,8)

still gives an 'invalid argument' error. Took out channel width and still no go
This works if the card is in monitor mode

* workaround in place, using the deprecated NL80211_CMD_SET_WIPHY

Expand Down
2 changes: 1 addition & 1 deletion pyric/net/wireless/nl80211_h.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@
* mesh config parameters may be given.
* @NL80211_CMD_LEAVE_MESH: Leave the mesh network -- no special arguments, the
* network is determined by the network interface.
* @NL80211_CMD_UNPROT_DEAUTHENTICATE: Unprotected deauthentication frame
* @NL80211_CMD_UNPR_OT_DEAUTHENTICATE: Unprotected deauthentication frame
* notification. This event is used to indicate that an unprotected
* deauthentication frame was dropped when MFP is in use.
* @NL80211_CMD_UNPROT_DISASSOCIATE: Unprotected disassociation frame
Expand Down
10 changes: 5 additions & 5 deletions pyric/pyw.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,6 @@ def chset(card, ch, chw=None, *argv):
device's channels to be changed
"""
if ch not in channels.channels(): raise pyric.error(errno.EINVAL, "Invalid channel")
if chw not in channels.CHTYPES: raise pyric.error(errno.EINVAL, "Invalid width")

try:
nlsock = argv[0]
Expand All @@ -1310,7 +1309,8 @@ def freqset(card, rf, chw=None, *argv):
:param argv: netlink socket at argv[0] (or empty)
"""
if rf not in channels.freqs(): raise pyric.error(errno.EINVAL, "Invalid frequency")
if chw not in channels.CHTYPES: raise pyric.error(errno.EINVAL, "Invalid width")
if chw in channels.CHTYPES: chw = channels.CHTYPES.index(chw)
else: raise pyric.error(errno.EINVAL, "Invalid width")

try:
nlsock = argv[0]
Expand All @@ -1323,8 +1323,7 @@ def freqset(card, rf, chw=None, *argv):
flags=nlh.NLM_F_REQUEST | nlh.NLM_F_ACK)
nl.nla_put_u32(msg, card.phy, nl80211h.NL80211_ATTR_WIPHY)
nl.nla_put_u32(msg, rf, nl80211h.NL80211_ATTR_WIPHY_FREQ)
nl.nla_put_u32(msg, channels.CHTYPES.index(chw),
nl80211h.NL80211_ATTR_WIPHY_CHANNEL_TYPE)
nl.nla_put_u32(msg, chw, nl80211h.NL80211_ATTR_WIPHY_CHANNEL_TYPE)
nl.nl_sendmsg(nlsock, msg)
nl.nl_recvmsg(nlsock)
except AttributeError:
Expand Down Expand Up @@ -1777,6 +1776,7 @@ def _fut_chset(card, ch, chw, *argv):
:param argv: netlink socket at argv[0] (or empty)
uses the newer NL80211_CMD_SET_CHANNEL vice iw's depecrated version which
uses *_SET_WIPHY however, ATT does not work raise Errno 22 Invalid Argument
NOTE: This only works for cards in monitor mode
"""
if ch not in channels.channels(): raise pyric.error(errno.EINVAL, "Invalid channel")
if chw not in channels.CHTYPES: raise pyric.error(errno.EINVAL, "Invalid channel width")
Expand All @@ -1788,7 +1788,7 @@ def _fut_chset(card, ch, chw, *argv):
msg = nl.nlmsg_new(nltype=_familyid_(nlsock),
cmd=nl80211h.NL80211_CMD_SET_CHANNEL,
flags=nlh.NLM_F_REQUEST | nlh.NLM_F_ACK)
nl.nla_put_u32(msg, card.phy, nl80211h.NL80211_ATTR_WIPHY)
nl.nla_put_u32(msg, card.idx, nl80211h.NL80211_ATTR_IFINDEX)
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)
Expand Down

0 comments on commit 669818a

Please sign in to comment.