From 079c662ce5ab285304b3ee877890065ae864ea0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= Date: Tue, 16 Jul 2019 19:29:14 +0000 Subject: inet6: __mul: bugfix, need more tests for edge cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Asbjørn Sloth Tønnesen --- lua/inet/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lua/inet') diff --git a/lua/inet/init.lua b/lua/inet/init.lua index ef8c5f2..b89515e 100644 --- a/lua/inet/init.lua +++ b/lua/inet/init.lua @@ -647,6 +647,7 @@ end function inet6:__mul(n) local new = self:clone() local mask = new.mask + if mask == 0 then return nil, 'unable to perform operation' end local pcs = new.pcs local netbitoverflow = mask % 16 local netbitremainder = (128-mask) % 16 @@ -662,7 +663,7 @@ function inet6:__mul(n) local shiftet = lshift(n, netbitremainder) local high_shift = rshift(shiftet, 16) local low_shift = band(shiftet, 0xffff) - --print(p, netbitoverflow, hex(shiftet), hex(high_shift), hex(low_shift)) + --print(p, netbitoverflow, tohex(shiftet), tohex(high_shift), tohex(low_shift)) if was_negative then high_shift = -high_shift low_shift = -low_shift -- cgit v1.2.1