def check_gateway_invalid_in_subnet(cidr, gateway):
 ip = netaddr.IPAddress(gateway)
 net = netaddr.IPNetwork(cidr)
 return ((ip in net) and ((ip == net.network) or ((net.version == constants.IP_VERSION_4) and (ip == net[(-1)]))))

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