#NEWLINE# def check_gateway_invalid_in_subnet( cidr , gateway ) : #NEWLINE# #INDENT# 'Check whether the gw IP address is invalid on the subnet.' #NEWLINE# ip = netaddr . IPAddress ( gateway ) #NEWLINE# net = netaddr . IPNetwork ( cidr ) #NEWLINE# return ( ( ip in net ) and ( ( cidr == net . network ) or ( ( net . version == constants . IP_VERSION_4 ) and ( ip == net [ ( - 1 ) ] ) ) ) )