aboutsummaryrefslogtreecommitdiffstats
path: root/README.rst
diff options
context:
space:
mode:
authorAsbjørn Sloth Tønnesen <ast@2e8.dk>2019-07-20 18:19:38 +0000
committerAsbjørn Sloth Tønnesen <ast@2e8.dk>2019-07-20 18:19:38 +0000
commit9edfd0002bea4d591cb363be536c652ef3f16079 (patch)
treeac6574c09294672d5cbe79eae186588934df5d8f /README.rst
parentd42329c948cafec31250c8cdba028d116a76a709 (diff)
downloadlua-inet-9edfd0002bea4d591cb363be536c652ef3f16079.tar.gz
lua-inet-9edfd0002bea4d591cb363be536c652ef3f16079.tar.xz
lua-inet-9edfd0002bea4d591cb363be536c652ef3f16079.zip
add inet:subnets()
Signed-off-by: Asbjørn Sloth Tønnesen <ast@2e8.dk>
Diffstat (limited to 'README.rst')
-rw-r--r--README.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/README.rst b/README.rst
index 3bbb9c4..799f602 100644
--- a/README.rst
+++ b/README.rst
@@ -83,6 +83,7 @@ Operator Description
``:hostmask()`` generate hostmask as an address
``:flip()`` flip the least significant network bit
``:bits()`` return the address bits in a table
+``:subnets()`` return the amount of /n subnets
================= ======================================
@@ -397,6 +398,24 @@ Valid values for ``n`` are ``1``, ``2``, ``4``, ``8``, ``16`` or ``32``.
{ 2, 0, 0, 1, 0, 13, 11, 8, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 2 }
+
+``foo:subnets(n)``
+~~~~~~~~~~~~~~~~~~
+
+::
+
+ inet('192.0.2.0/24'):subnets(26) -- returns 4
+ inet('192.0.2.0/25'):subnets(26) -- returns 2
+ inet('192.0.2.0/26'):subnets(26) -- returns 1
+ inet('192.0.2.0/27'):subnets(26) -- returns 0.5
+ inet('192.0.2.0/28'):subnets(26) -- returns 0.25
+
+ inet('2001:db8::/48'):subnets(56) -- returns 256
+ inet('2001:db8::/56'):subnets(64) -- returns 256
+ inet('2001:db8::/48'):subnets(64) -- returns 65536
+ inet('2001:db8::/64'):subnets(56) -- returns 0.00390625
+
+
Sets
----