Added 2 address resolvers to JRegistry. IpAddressResolver and IEEEOuiResolver. Ip resolver when enabled resolves and caches IP addresses to hostnames. OUI resolver downloads and caches OUI manufacturer prefix database. JFormatter has been modified to allow IP addresses and MAC addresses to use resolvers. It has new methods for enabling and disabling address resolutions. Default is disabled although it can be changed globally or on a per formatter basis with
static JFormatter.setDefaultResolveAddress(boolean) and instance JFormatter.setResolveAddress(boolean). The first is the global default while the second is per instance.
JRegistry provides setter and getter methods for accessing the address resolvers. Resolvers implement the interface JRegistry.Resolver. Therefore custom algorithms and resolver types can be added replacing default ones.
Here is what output from Ethernet and Ip4 headers looks like now:
Eth: ******* Ethernet - "Ethernet" - offset=0 (0x0) length=14 Eth: Eth: destination = SMC_22:5a:03 (00:04:e2:22:5a:03) Eth: .... ..0. .... .... = [0] LG bit Eth: .... ...0 .... .... = [0] IG bit Eth: source = KYE_20:6c:df (00:c0:df:20:6c:df) Eth: .... ..0. .... .... = [0] LG bit Eth: .... ...0 .... .... = [0] IG bit Eth: type = 0x800 (2048) [ip version 4] Eth: Ip: ******* Ip4 - "ip version 4" - offset=14 (0xE) length=20 Ip: Ip: version = 4 Ip: hlen = 5 [5 * 4 = 20 bytes, No Ip Options] Ip: diffserv = 0x0 (0) Ip: 0000 00.. = [0] code point: not set Ip: .... ..0. = [0] ECN bit: not set Ip: .... ...0 = [0] ECE bit: not set Ip: length = 475 Ip: id = 0xC139 (49465) Ip: flags = 0x2 (2) Ip: 0.. = [0] reserved Ip: .1. = [1] do not fragment: set Ip: ..0 = [0] more fragments: not set Ip: offset = 0 Ip: ttl = 64 [time to live] Ip: type = 6 [next: tcp] Ip: checksum = 0x617C (24956) Ip: source = 10.1.1.1 (resolve failed) Ip: destination = 10.1.1.101 (resolve failed) Ip:
The OUI resolver is interesting, since its default behaviour is this. Look for compressed OUI cache locally and load it. If not found, look for uncompressed raw IEEE OUI.txt file, parse it and produce a compressed file and cache it. Otherwise download from a URL connection, parse it and cache it. The OUI file is too big to supply with jNetPcap library by default (2Mb in size). The compressed one is 180Kb, which is something that will be supplied by default. The URL getter functionality will be disabled in the release version, but the capability to do that will be available through specific API, probably in JRegistry.