mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 06:29:23 +01:00
auto-t: hostapd: add set_address/group_neighbors
This adds a few utilities for setting up an FT environment. All the roaming tests basically copy/paste the same code for setting up the hostapd instances and this can cause problems if not done correctly. set_address() sets the MAC address on the device, and restarts hostapd group_neighbors() takes a list of HostapdCLI objects and makes each a neighbor to the others. The neighbor report element requires the operating class which isn't advertised by hostapd. For this we assume operating class 81 but this can be set explicitly if it differs. Currently no roaming tests use 5/6GHz frequencies, and just in case an exception will be thrown if the channel is greater than 14 and the op_class didn't change.
This commit is contained in:
parent
90dc2e5547
commit
3439d09817
@ -281,3 +281,34 @@ class HostapdCLI(object):
|
||||
@property
|
||||
def enabled(self):
|
||||
return self._get_status()['state'] == 'ENABLED'
|
||||
|
||||
def set_address(self, mac):
|
||||
os.system('ip link set dev %s down' % self.ifname)
|
||||
os.system('ip link set dev %s addr %s up' % (self.ifname, mac))
|
||||
|
||||
self.reload()
|
||||
self.wait_for_event("AP-ENABLED")
|
||||
|
||||
def _add_neighbors(self, *args, op_class=81):
|
||||
for hapd in args:
|
||||
status = hapd._get_status()
|
||||
|
||||
ssid = status['ssid[0]']
|
||||
bssid = status['bssid[0]']
|
||||
channel = int(status['channel'])
|
||||
|
||||
if (channel > 14 and op_class == 81):
|
||||
raise Exception("default add_neighbors assumes opclass 0x51!")
|
||||
|
||||
channel = '{:02x}'.format(channel)
|
||||
oper_class = '{:02x}'.format(op_class)
|
||||
|
||||
self.set_neighbor(bssid, ssid, '%s8f000000%s%s060603000000' %
|
||||
(bssid.replace(':', ''), oper_class, channel))
|
||||
|
||||
@classmethod
|
||||
def group_neighbors(cls, *args):
|
||||
for hapd in args:
|
||||
others = [h for h in args if h != hapd]
|
||||
|
||||
hapd._add_neighbors(*others)
|
||||
|
Loading…
Reference in New Issue
Block a user