aboutsummaryrefslogtreecommitdiffstats
path: root/README.rst
diff options
context:
space:
mode:
authorAsbjørn Sloth Tønnesen <ast@2e8.dk>2019-07-18 18:45:50 +0000
committerAsbjørn Sloth Tønnesen <ast@2e8.dk>2019-07-18 18:45:50 +0000
commit7140c113b09266747c9add120e27b3e0eb017214 (patch)
tree9ff5917149cc98672dfecfcf5c0b51182181c3ad /README.rst
parentecf033ea15c312f6153ca761ee329058de5de918 (diff)
downloadlua-inet-7140c113b09266747c9add120e27b3e0eb017214.tar.gz
lua-inet-7140c113b09266747c9add120e27b3e0eb017214.tar.xz
lua-inet-7140c113b09266747c9add120e27b3e0eb017214.zip
add more power to add/sub operators
Signed-off-by: Asbjørn Sloth Tønnesen <ast@2e8.dk>
Diffstat (limited to 'README.rst')
-rw-r--r--README.rst17
1 files changed, 15 insertions, 2 deletions
diff --git a/README.rst b/README.rst
index fae2397..208ddbd 100644
--- a/README.rst
+++ b/README.rst
@@ -157,9 +157,12 @@ Addition
::
+ inet('192.0.2.0') + 24 -- returns inet('192.0.2.24')
inet('2001:db8::/64') + 5 -- returns inet('2001:db8::5/64')
- --inet('::ffff:0.0.0.0/96') + inet('192.0.2.24') -- returns inet('192.0.2.24')
+ -- mixed networks special:
+ inet('::ffff:0.0.0.0/96') + inet('192.0.2.24') -- returns inet('::ffff:192.0.2.24')
+ inet('192.0.2.24') + inet('::ffff:0.0.0.0/96') -- returns inet('::ffff:192.0.2.24')
``foo - bar``
~~~~~~~~~~~~~
@@ -170,7 +173,17 @@ Subtract
inet('2001:db8::5/64') - 5 -- returns inet('2001:db8::/64')
- --inet('2001:db8::5/64') - inet('2001:db8::') -- returns 5
+ inet('192.0.2.24') - inet('192.0.2.0') -- returns 24
+
+ inet('2001:db8::5/64') - inet('2001:db8::') -- returns 5
+
+ -- by calling the operator method directly additional debuging info are available:
+ inet('2001:db8::5/64') - inet('ffff::') -- returns nil
+ inet('2001:db8::5/64'):__sub(inet('ffff::'))
+ -- returns nil, 'result is out of range', { 8194, 3512, 0, 0, 0, 0, 0, 5 }
+
+ -- mixed networks special:
+ inet('::ffff:192.0.2.24') - inet('::ffff:0.0.0.0/96') -- returns inet('192.0.2.24')
``foo / bar``
~~~~~~~~~~~~~