Modify check ip in net for spcifing some nets.

develop
Mike Hiretsky 13 years ago
parent 11de1bea3e
commit 55dff18799

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

Loading…
Cancel
Save