summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/control1
-rw-r--r--python/vyos/ifconfig/bond.py3
-rw-r--r--python/vyos/ifconfig/bridge.py3
-rw-r--r--python/vyos/ifconfig/dummy.py3
-rw-r--r--python/vyos/ifconfig/ethernet.py3
-rw-r--r--python/vyos/ifconfig/geneve.py3
-rw-r--r--python/vyos/ifconfig/l2tpv3.py3
-rw-r--r--python/vyos/ifconfig/loopback.py3
-rw-r--r--python/vyos/ifconfig/macvlan.py3
-rw-r--r--python/vyos/ifconfig/vlan.py3
-rw-r--r--python/vyos/ifconfig/vxlan.py3
-rw-r--r--python/vyos/ifconfig/wireguard.py3
-rwxr-xr-xsrc/conf_mode/interfaces-wireless.py33
13 files changed, 30 insertions, 37 deletions
diff --git a/debian/control b/debian/control
index e61e2d043..53c4130d7 100644
--- a/debian/control
+++ b/debian/control
@@ -29,6 +29,7 @@ Depends: python3,
python3-hurry.filesize,
python3-vici (>= 5.7.2),
python3-bottle,
+ python3-netaddr,
python3-zmq,
cron,
ipaddrcheck,
diff --git a/python/vyos/ifconfig/bond.py b/python/vyos/ifconfig/bond.py
index 211790459..c9dac891f 100644
--- a/python/vyos/ifconfig/bond.py
+++ b/python/vyos/ifconfig/bond.py
@@ -73,9 +73,6 @@ class BondIf(VLANIf):
'type': 'bond',
}
- def __init__(self, ifname, **kargs):
- super().__init__(ifname, **kargs)
-
def remove(self):
"""
Remove interface from operating system. Removing the interface
diff --git a/python/vyos/ifconfig/bridge.py b/python/vyos/ifconfig/bridge.py
index 392718d9f..90c44af13 100644
--- a/python/vyos/ifconfig/bridge.py
+++ b/python/vyos/ifconfig/bridge.py
@@ -76,9 +76,6 @@ class BridgeIf(Interface):
'type': 'bridge',
}
- def __init__(self, ifname, **kargs):
- super().__init__(ifname, **kargs)
-
def set_ageing_time(self, time):
"""
Set bridge interface MAC address aging time in seconds. Internal kernel
diff --git a/python/vyos/ifconfig/dummy.py b/python/vyos/ifconfig/dummy.py
index 55935a16e..58b89fe68 100644
--- a/python/vyos/ifconfig/dummy.py
+++ b/python/vyos/ifconfig/dummy.py
@@ -27,6 +27,3 @@ class DummyIf(Interface):
default = {
'type': 'dummy',
}
-
- def __init__(self, ifname, **kargs):
- super().__init__(ifname, **kargs)
diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py
index 9863ca826..8b6b6d9db 100644
--- a/python/vyos/ifconfig/ethernet.py
+++ b/python/vyos/ifconfig/ethernet.py
@@ -53,9 +53,6 @@ class EthernetIf(VLANIf):
'type': 'ethernet',
}
- def __init__(self, ifname, **kargs):
- super().__init__(ifname, **kargs)
-
def _delete(self):
# Ethernet interfaces can not be removed
pass
diff --git a/python/vyos/ifconfig/geneve.py b/python/vyos/ifconfig/geneve.py
index 46782a685..c6834fcd7 100644
--- a/python/vyos/ifconfig/geneve.py
+++ b/python/vyos/ifconfig/geneve.py
@@ -32,9 +32,6 @@ class GeneveIf(Interface):
'type': 'geneve',
}
- def __init__(self, ifname, **kargs):
- super().__init__(ifname, **kargs)
-
def _create(self):
cmd = 'ip link add name {} type geneve id {} remote {}' \
.format(self.config['ifname'], config['vni'], config['remote'])
diff --git a/python/vyos/ifconfig/l2tpv3.py b/python/vyos/ifconfig/l2tpv3.py
index 491fd24a7..a87535277 100644
--- a/python/vyos/ifconfig/l2tpv3.py
+++ b/python/vyos/ifconfig/l2tpv3.py
@@ -35,9 +35,6 @@ class L2TPv3If(Interface):
'type': 'l2tp',
}
- def __init__(self, ifname, **kargs):
- super().__init__(ifname, **kargs)
-
def _create(self):
# create tunnel interface
cmd = 'ip l2tp add tunnel tunnel_id {} '.format(config['tunnel_id'])
diff --git a/python/vyos/ifconfig/loopback.py b/python/vyos/ifconfig/loopback.py
index 410a19dcf..37b8e9e3b 100644
--- a/python/vyos/ifconfig/loopback.py
+++ b/python/vyos/ifconfig/loopback.py
@@ -27,9 +27,6 @@ class LoopbackIf(Interface):
'type': 'loopback',
}
- def __init__(self, ifname, **kargs):
- super().__init__(ifname, **kargs)
-
def remove(self):
"""
Loopback interface can not be deleted from operating system. We can
diff --git a/python/vyos/ifconfig/macvlan.py b/python/vyos/ifconfig/macvlan.py
index a86f84f3e..da3beea8b 100644
--- a/python/vyos/ifconfig/macvlan.py
+++ b/python/vyos/ifconfig/macvlan.py
@@ -27,9 +27,6 @@ class MACVLANIf(VLANIf):
'type': 'macvlan',
}
- def __init__(self, ifname, **kargs):
- super().__init__(ifname, **kargs)
-
def _create(self):
cmd = 'ip link add {ifname} link {link} type macvlan mode {mode}'.format(
**self.config)
diff --git a/python/vyos/ifconfig/vlan.py b/python/vyos/ifconfig/vlan.py
index ad5d066c4..4e0db83c7 100644
--- a/python/vyos/ifconfig/vlan.py
+++ b/python/vyos/ifconfig/vlan.py
@@ -30,9 +30,6 @@ class VLANIf(Interface):
'type': 'vlan',
}
- def __init__(self, ifname, **kargs):
- super().__init__(ifname, **kargs)
-
def remove(self):
"""
Remove interface from operating system. Removing the interface
diff --git a/python/vyos/ifconfig/vxlan.py b/python/vyos/ifconfig/vxlan.py
index 86702b2cd..f7a04d81b 100644
--- a/python/vyos/ifconfig/vxlan.py
+++ b/python/vyos/ifconfig/vxlan.py
@@ -50,9 +50,6 @@ class VXLANIf(Interface):
# the IANA's selection of a standard destination port
}
- def __init__(self, ifname, **kargs):
- super().__init__(ifname, **kargs)
-
def _create(self):
cmd = ''
if self.config['remote']:
diff --git a/python/vyos/ifconfig/wireguard.py b/python/vyos/ifconfig/wireguard.py
index 411c3e146..044041f68 100644
--- a/python/vyos/ifconfig/wireguard.py
+++ b/python/vyos/ifconfig/wireguard.py
@@ -54,9 +54,6 @@ class WireGuardIf(Interface):
'allowed-ips': [], 'pubkey': None, 'fwmark': 0, 'psk': '/dev/null'}
"""
- def __init__(self, ifname, **kargs):
- super().__init__(ifname, **kargs)
-
def update(self):
if not self.config['private-key']:
raise ValueError("private key required")
diff --git a/src/conf_mode/interfaces-wireless.py b/src/conf_mode/interfaces-wireless.py
index 19e1f01b8..40d8912cc 100755
--- a/src/conf_mode/interfaces-wireless.py
+++ b/src/conf_mode/interfaces-wireless.py
@@ -22,10 +22,12 @@ from sys import exit
from stat import S_IRWXU,S_IRGRP,S_IXGRP,S_IROTH,S_IXOTH
from pwd import getpwnam
from grp import getgrnam
+from re import findall
from subprocess import Popen, PIPE
from psutil import pid_exists
from netifaces import interfaces
+from netaddr import *
from vyos.ifconfig import EthernetIf
from vyos.ifconfig_vlan import apply_vlan_config, verify_vlan_config
@@ -1144,6 +1146,10 @@ def get_config():
if conf.exists('ip enable-arp-ignore'):
wifi['ip_enable_arp_ignore'] = 1
+ # Wireless physical device
+ if conf.exists('physical-device'):
+ wifi['phy'] = conf.return_value('physical-device')
+
# Media Access Control (MAC) address
if conf.exists('mac'):
wifi['mac'] = conf.return_value('mac')
@@ -1164,10 +1170,6 @@ def get_config():
if conf.exists('vrf'):
wifi['vrf'] = conf.return_value('vrf')
- # Wireless physical device
- if conf.exists('phy'):
- wifi['phy'] = conf.return_value('phy')
-
# Transmission power reduction in dBm
if conf.exists('reduce-transmit-power'):
wifi['reduce_transmit_power'] = conf.return_value('reduce-transmit-power')
@@ -1288,6 +1290,9 @@ def verify(wifi):
if wifi['type'] != 'monitor' and not wifi['ssid']:
raise ConfigError('SSID must be set for {}'.format(wifi['intf']))
+ if not wifi['phy']:
+ raise ConfigError('You must specify physical-device')
+
if wifi['type'] == 'access-point':
c = Config()
if not c.exists('system wifi-regulatory-domain'):
@@ -1326,6 +1331,26 @@ def verify(wifi):
return None
def generate(wifi):
+
+ if not wifi['mac']:
+ # http://wiki.stocksy.co.uk/wiki/Multiple_SSIDs_with_hostapd
+ # generate locally administered MAC address from used phy interface
+ with open('/sys/class/ieee80211/{}/addresses'.format(wifi['phy']), 'r') as f:
+ tmp = EUI(f.read().rstrip()).value
+ # mask last nibble from the MAC address
+ tmp &= 0xfffffffffff0
+ # set locally administered bit in MAC address
+ tmp |= 0x020000000000
+ # we now need to add an offset to our MAC address indicating this
+ # subinterfaces index
+ tmp += int(findall(r'\d+', wifi['intf'])[0])
+
+ # convert integer to "real" MAC address representation
+ mac = EUI(hex(tmp).split('x')[-1])
+ # change dialect to use : as delimiter instead of -
+ mac.dialect = mac_unix_expanded
+ wifi['mac'] = str(mac)
+
pid = 0
# always stop hostapd service first before reconfiguring it
pidfile = get_pid('hostapd', wifi['intf'])