|
|
|
@ -50,6 +50,8 @@ SIOCGIFHWADDR = 0x8927
|
|
|
|
|
|
|
|
|
|
# Resources allocated
|
|
|
|
|
IFF_RUNNING = 0x40
|
|
|
|
|
IFF_MASTER = 0x400
|
|
|
|
|
IFF_SLAVE = 0x800
|
|
|
|
|
|
|
|
|
|
# ip digit from 0|1-255|254 (template)
|
|
|
|
|
IP_DIG = "[%s-9]|(?:1[0-9]|[1-9])[0-9]|2[0-4][0-9]|25[0-%s]"
|
|
|
|
@ -243,8 +245,7 @@ def getIp(iface):
|
|
|
|
|
ip = struct.unpack('16sH2x4s8x', res)[2]
|
|
|
|
|
return socket.inet_ntoa(ip)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getPlugged(iface):
|
|
|
|
|
def checkFlag(iface, flag):
|
|
|
|
|
sockfd = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
|
|
|
ifreq = struct.pack('16sH14s', iface, socket.AF_INET, '\x00' * 14)
|
|
|
|
|
try:
|
|
|
|
@ -253,8 +254,16 @@ def getPlugged(iface):
|
|
|
|
|
return False
|
|
|
|
|
finally:
|
|
|
|
|
sockfd.close()
|
|
|
|
|
return bool(struct.unpack('16sH2x4s8x', res)[1] & IFF_RUNNING)
|
|
|
|
|
return bool(struct.unpack('16sH2x4s8x', res)[1] & flag)
|
|
|
|
|
|
|
|
|
|
def getPlugged(iface):
|
|
|
|
|
return checkFlag(iface, IFF_RUNNING)
|
|
|
|
|
|
|
|
|
|
def isSlaveInterface(iface):
|
|
|
|
|
return checkFlag(iface, IFF_SLAVE)
|
|
|
|
|
|
|
|
|
|
def isMasterInterface(iface):
|
|
|
|
|
return checkFlag(iface, IFF_MASTER)
|
|
|
|
|
|
|
|
|
|
def getMask(iface):
|
|
|
|
|
"""
|
|
|
|
|