Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>With this code, it does not validate correctly.</p> <p>For example:</p> <pre><code>scala&gt; val ip = java.net.InetAddress.getByName("::ffff:1.2.176.0") ip: java.net.InetAddress = /1.2.176.0 scala&gt; val prefix = new InetPrefix(ip, 20) prefix: InetPrefix = InetPrefix@6febf6f9 scala&gt; prefix.contains(java.net.InetAddress.getByName("::ffff:1.2.176.20")) res11: Boolean = true scala&gt; prefix.contains(java.net.InetAddress.getByName("::ffff:1.2.191.20")) res12: Boolean = false </code></pre> <p>But if you calculate that network: (1.2.176.0/20)</p> <pre><code>$ sipcalc 1.2.176.0/20 -[ipv4 : 1.2.176.0/20] - 0 [CIDR] Host address - 1.2.176.0 Host address (decimal) - 16953344 Host address (hex) - 102B000 Network address - 1.2.176.0 Network mask - 255.255.240.0 Network mask (bits) - 20 Network mask (hex) - FFFFF000 Broadcast address - 1.2.191.255 Cisco wildcard - 0.0.15.255 Addresses in network - 4096 Network range - 1.2.176.0 - 1.2.191.255 Usable range - 1.2.176.1 - 1.2.191.254 - </code></pre> <p>I rewrote both (IPv4 and IPv6) in Scala put it for everyone on GitHub. It now also validates within ranges (so /20 etc will be regarded, which the old one did not do.)</p> <p>You can find the code (i separated it into IPv4 and IPv6) at <a href="https://github.com/wasted/scala-util/blob/master/src/main/scala/io/wasted/util/InetPrefix.scala" rel="nofollow">https://github.com/wasted/scala-util/blob/master/src/main/scala/io/wasted/util/InetPrefix.scala</a></p> <p>I also created a <a href="http://uberblo.gs/2012/12/scala-utils-with-ip-subnet-matching" rel="nofollow">blogpost about this</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload