Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin adding support for OpenWrt. #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions eap_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def make_logger(use_syslog=False, debug=False):
### EdgeOS


class EdgeOS(object):
class EdgeOS():
def __init__(self, log):
self.log = log

Expand Down Expand Up @@ -478,6 +478,35 @@ def getmac(ifname):
return getifhwaddr(ifname)


### Generic Linux

class LinuxOS(EdgeOS):
def setmac(self, ifname, mac):
"""Set interface `ifname` mac to `mac`, which may be either a packed
string or in "aa:bb:cc:dd:ee:ff" format."""
if len(mac) == 6:
mac = strmac(mac)
self.run("ip link set dev %s down" % ifname)
self.run("ip link set dev %s address %s" % (ifname, mac))
self.run("ip link set dev %s up" % ifname)



### OpenWrt

class OpenWrt(EdgeOS):
def restart_dhclient(self, name):
self.run("systemctl", "restart", "dnsmasq@%s" % name)

def setmac(self, ifname, mac):
"""Set interface `ifname` mac to `mac`, which may be either a packed
string or in "aa:bb:cc:dd:ee:ff" format."""
if len(mac) == 6:
mac = strmac(mac)
self.run("/sbin/uci", "set" "network.wan_dev.macaddr=%s" % mac)
self.run("/sbin/uci", "commit")


### EAP frame/packet decoding
# c.f. https://github.com/the-tcpdump-group/tcpdump/blob/master/print-eap.c

Expand Down Expand Up @@ -577,7 +606,7 @@ def __str__(self):
### EAP Proxy


class EAPProxy(object):
class EAPProxy():
_poll_events = {
select.POLLERR: "POLLERR",
select.POLLHUP: "POLLHUP",
Expand Down