summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2017-11-20 17:52:35 +0900
committerLorenzo Colitti <lorenzo@google.com>2017-11-20 17:59:32 +0900
commitee7c0f16f136d328eef686bdb11a26b16c94cdcf (patch)
treec6c04ae2efc36c9b3ca87d40cc59975eb3d9de99
parent2f5df35a91a09fb0fbe80f2bce913316bd269e3a (diff)
downloadtests-ee7c0f16f136d328eef686bdb11a26b16c94cdcf.tar.gz
Use a UDP socket instead of a ping socket for ioctls.
The type of socket used for ioctls does not affect the success of the calls themselves, so UDP is just as good as ping. However, UDP makes this code more reusable, because on many systems, ping sockets are restricted by default. Test: all_tests.sh passes on android-4.9 Change-Id: I44a25af880659b364edbec72850d968b2ef17f11
-rwxr-xr-xnet/test/net_test.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/test/net_test.py b/net/test/net_test.py
index c36dca9..d6d6809 100755
--- a/net/test/net_test.py
+++ b/net/test/net_test.py
@@ -200,14 +200,14 @@ def CreateSocketPair(family, socktype, addr):
def GetInterfaceIndex(ifname):
- s = IPv4PingSocket()
+ s = UDPSocket(AF_INET)
ifr = struct.pack("%dsi" % IFNAMSIZ, ifname, 0)
ifr = fcntl.ioctl(s, scapy.SIOCGIFINDEX, ifr)
return struct.unpack("%dsi" % IFNAMSIZ, ifr)[1]
def SetInterfaceHWAddr(ifname, hwaddr):
- s = IPv4PingSocket()
+ s = UDPSocket(AF_INET)
hwaddr = hwaddr.replace(":", "")
hwaddr = hwaddr.decode("hex")
if len(hwaddr) != 6:
@@ -217,7 +217,7 @@ def SetInterfaceHWAddr(ifname, hwaddr):
def SetInterfaceState(ifname, up):
- s = IPv4PingSocket()
+ s = UDPSocket(AF_INET)
ifr = struct.pack("%dsH" % IFNAMSIZ, ifname, 0)
ifr = fcntl.ioctl(s, scapy.SIOCGIFFLAGS, ifr)
_, flags = struct.unpack("%dsH" % IFNAMSIZ, ifr)