mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-20 19:12:33 +01:00
auto-t: support IP match with no IP set
This allows an interface with no IP set to be checked for by passing None in as the address. This will generate an exception by ioctl which we catch.
This commit is contained in:
parent
d2cc033d09
commit
d40cac403f
@ -146,9 +146,15 @@ def test_iface_operstate(intf=None):
|
|||||||
sock.close()
|
sock.close()
|
||||||
|
|
||||||
def test_ip_address_match(intf, ip):
|
def test_ip_address_match(intf, ip):
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
try:
|
||||||
addr = fcntl.ioctl(s.fileno(), SIOCGIFADDR, struct.pack('256s', intf.encode('utf-8')))
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
addr = socket.inet_ntoa(addr[20:24])
|
addr = fcntl.ioctl(s.fileno(), SIOCGIFADDR, struct.pack('256s', intf.encode('utf-8')))
|
||||||
|
addr = socket.inet_ntoa(addr[20:24])
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno != 99 or ip != None:
|
||||||
|
raise Exception('SIOCGIFADDR failed with %d' % e.errno)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
if ip != addr:
|
if ip != addr:
|
||||||
raise Exception('IP for %s did not match %s (was %s)' % (intf, ip, addr))
|
raise Exception('IP for %s did not match %s (was %s)' % (intf, ip, addr))
|
||||||
|
Loading…
Reference in New Issue
Block a user