src/iputils/cidr

  Source   Edit

Types

Cidr4 = object
  ip*: Ipv4
  prefix*: range[0'u8 .. 32'u8]
  Source   Edit
Cidr6 = object
  ip*: Ipv6
  prefix*: range[0'u8 .. 128'u8]
  Source   Edit

Procs

proc `$`(cidr: Cidr4 | Cidr6): string
  Source   Edit
proc cidrToIpv4Range(cidr: Cidr4): tuple[startIp, endIp: Ipv4] {....raises: [],
    tags: [].}
Returns a tuple with the startIp and endIp range of a CIDR block.   Source   Edit
proc cidrToIpv6Range(cidr: Cidr6): tuple[startIp, endIp: Ipv6] {....raises: [],
    tags: [].}
Returns a tuple with the startIp and endIp range of a CIDR block.   Source   Edit
proc cidrToString(cidr: Cidr4 | Cidr6): string
Returns an CIDR textual representation of cidr.   Source   Edit
proc contains(cidr: Cidr4; ip: Ipv4): bool {....raises: [], tags: [].}
Returns true if ip is in cidr or false if not.   Source   Edit
proc contains(cidr: Cidr6; ip: Ipv6): bool {....raises: [], tags: [].}
Returns true if ip is in cidr or false if not.   Source   Edit
proc ipv4RangeToCidr(startIp, endIp: Ipv4): seq[Cidr4] {....raises: [], tags: [].}
Returns a seq[Cidr4] with the CIDR blocks resulting from the IPv4 interval between startIp and endIp.   Source   Edit
proc ipv6RangeToCidr(startIp, endIp: Ipv6): seq[Cidr6] {....raises: [], tags: [].}
Returns a seq[Cidr6] with the CIDR blocks resulting from the IPv6 interval between startIp and endIp.   Source   Edit
proc listAllCidrContainIpv4(ip: Ipv4): seq[Cidr4] {....raises: [], tags: [].}
Returns a seq[Cidr4] with all 33 CIDR blocks containing the ip.   Source   Edit
proc listAllCidrContainIpv6(ip: Ipv6): seq[Cidr6] {....raises: [], tags: [].}
Returns a seq[Cidr6] with all 129 CIDR blocks containing the ip.   Source   Edit

Iterators

iterator cidrContainIpv4(ip: Ipv4): Cidr4 {....raises: [], tags: [].}
Iterate over all 33 CIDR blocks containing the ip.   Source   Edit
iterator cidrContainIpv6(ip: Ipv6): Cidr6 {....raises: [], tags: [].}
Iterate over all 129 CIDR blocks containing the ip.   Source   Edit