Nmap Development mailing list archives

Consistent IP fields naming in packet.lua


From: Henri Doreau <henri.doreau () greenbone net>
Date: Fri, 13 Jan 2012 19:57:20 +0100

Hello,

I've noticed a problem with low level code intended to deal with both
IPv4 and IPv6.

e.g.: nselib/data/packetdecoders.lua:273
"""
if ( not(self.dups[("%s:%s"):format(p.ip_src,st)]) ) then
"""

This doesn't work with IPv6 packets as p.ip_src is nil, scripts should
do: "p.ip_src or packet.toipv6(p.ip6_src)" instead. This is
complicated and other fields like ip6 or ip_v already allow to quickly
know the IP version of a packet.

I would suggest a change in packet.lua to make the library use the
same names for identical fields between IPv4 and IPv6.

Currently for IPv4, we have:
  - ip_bin_src (binary src address)
  - ip_bin_dst (binary dst address)
  - ip_src (decimal-dotted string src address)
  - ip_dst (decimal-dotted string dst address)
And for IPv6:
  - ip6_src (binary src address)
  - ip6_dst (binary dst address)


The patch attached removes ip6_src and ip6_dst and replace them by
ip_bin_src and ip_bin_dst. It also adds ip_src and ip_dst (human
readable strings) to IPv6 packet objects for convenience.

The second patch updates the scripts accordingly.

Regards.

-- 
Henri

Attachment: pkt_fields_rename.diff
Description:

Attachment: scripts_fixes.diff
Description:

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/

Current thread: