DataScript: avi.utils.ip.netaddr

Function avi.utils.ip.netaddr(ip_addr, netmask)
Description Accepts an IPv4 or IPv6 IP address and netmask and returns the network address.
Events HTTP_REQ
HTTP_RESP
Parameter ip_addr is a string containing the IP address.

netmask is an integer containing the network mask.
Returns If
  • ip_addr or mask is nil,
  • ip_addr contains "NIL", or
  • ip_addr contains an invalid IPv6 or IPv4 address,
then the function returns NIL

else the function returns the IPv6 or IPv4 address of the network.
Example avi.utils.ip.netaddr ("43.225.52.40", 24) returns 43.225.52.0

avi.utils.ip.netaddr ("2001:0db8:85a3:0000:0000:8a2e:0370:7334", 53) returns 1:2001:db8:85a3::