in_network's consistency now verify that IP is not network or broadcast's IP + ip_netmask's consistency now verify that IP is not broadcast's IP
This commit is contained in:
@ -215,6 +215,8 @@ class IPOption(Option):
|
||||
'netmask {4} ({5})')
|
||||
raise ValueError(msg.format(ip, opts[0].impl_getname(), network,
|
||||
opts[1].impl_getname(), netmask, opts[2].impl_getname()))
|
||||
# test if ip is not network/broadcast IP
|
||||
opts[2]._cons_ip_netmask((opts[2], opts[0]), (netmask, ip), warnings_only)
|
||||
|
||||
|
||||
class PortOption(Option):
|
||||
@ -344,16 +346,14 @@ class NetmaskOption(Option):
|
||||
ip = IP('{0}/{1}'.format(val_ipnetwork, val_netmask),
|
||||
make_net=make_net)
|
||||
#if cidr == 32, ip same has network
|
||||
if ip.prefixlen() != 32:
|
||||
try:
|
||||
IP('{0}/{1}'.format(val_ipnetwork, val_netmask),
|
||||
make_net=not make_net)
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
if make_net: # pragma: optional cover
|
||||
msg = _("invalid IP {0} ({1}) with netmask {2},"
|
||||
" this IP is a network")
|
||||
if make_net and ip.prefixlen() != 32:
|
||||
val_ip = IP(val_ipnetwork)
|
||||
if ip.net() == val_ip:
|
||||
msg = _("invalid IP {0} ({1}) with netmask {2},"
|
||||
" this IP is a network")
|
||||
if ip.broadcast() == val_ip:
|
||||
msg = _("invalid IP {0} ({1}) with netmask {2},"
|
||||
" this IP is a broadcast")
|
||||
|
||||
except ValueError: # pragma: optional cover
|
||||
if not make_net:
|
||||
|
Reference in New Issue
Block a user