|
|
@ -123,11 +123,13 @@ def getIpNet(ip,mask):
|
|
|
|
return "{ip}/{net}".format(ip=intIpToStrIp(ip&mask),
|
|
|
|
return "{ip}/{net}".format(ip=intIpToStrIp(ip&mask),
|
|
|
|
net=net)
|
|
|
|
net=net)
|
|
|
|
|
|
|
|
|
|
|
|
def isIpInNet(checkip,ipnet):
|
|
|
|
def isIpInNet(checkip,*ipnets):
|
|
|
|
"""Check is ip in specified net"""
|
|
|
|
"""Check is ip in specified nets"""
|
|
|
|
ip,op,net = ipnet.partition('/')
|
|
|
|
return map(lambda x:x[0],
|
|
|
|
mask = strIpToIntIp(netToMask(int(net)))
|
|
|
|
filter(lambda x:strIpToIntIp(checkip)&x[2] == strIpToIntIp(x[1])&x[2],
|
|
|
|
return (strIpToIntIp(checkip)&mask) == (strIpToIntIp(ip)&mask)
|
|
|
|
map(lambda x:(x[0],x[1][0],strIpToIntIp(netToMask(int(x[1][1])))),
|
|
|
|
|
|
|
|
map(lambda x:(x,x.partition('/')[0::2]),
|
|
|
|
|
|
|
|
ipnets))))
|
|
|
|
|
|
|
|
|
|
|
|
def receiveMac(interface="eth0"):
|
|
|
|
def receiveMac(interface="eth0"):
|
|
|
|
"""Get MAC from interface"""
|
|
|
|
"""Get MAC from interface"""
|
|
|
|