mirror of
https://github.com/nmap/nmap.git
synced 2025-12-15 20:29:03 +00:00
Compress strings of zeros in packet.toipv6.
I do this just by passing the uncompressed names through nmap.resolve. Before: fe80:0000:0000:0000:0000:0000:0000:0001, 2001:0470:1f05:155e:0000:0000:0000:0003 After: fe80::1, 2001:470:1f05:155e::3
This commit is contained in:
@@ -492,11 +492,16 @@ end
|
||||
-- @param raw_ipv6_addr 16-byte string.
|
||||
-- @return IPv6 address string.
|
||||
function toipv6(raw_ipv6_addr)
|
||||
local long_addr_str
|
||||
local status, addrs
|
||||
|
||||
if not raw_ipv6_addr then
|
||||
return nil, "IPv6 address was not specified."
|
||||
end
|
||||
return string.format("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
|
||||
string.byte(raw_ipv6_addr,1,16))
|
||||
long_addr_str = stdnse.tohex(raw_ipv6_addr, {separator=":", group=4})
|
||||
status, addrs = nmap.resolve(long_addr_str, "inet6")
|
||||
|
||||
return (status and addrs[1]) or long_addr_str
|
||||
end
|
||||
--- Generate the link-local IPv6 address from the MAC address.
|
||||
-- @param mac MAC address string.
|
||||
|
||||
Reference in New Issue
Block a user