- # Add mapping of hostname to ip to our data structure
- host_ip_mappings[hostname].add(ip)
- # Add mapping of ip to hostname to our data structure
- ip_host_mappings[ip].add(hostname)
- return (host_ip_mappings, ip_host_mappings)
+ # Create the tuple that indicates WHEN the ip to hostname mapping occurred
+ timestamp_hostname_tuple = (timestamp,hostname)
+ if device_mac in result:
+ # If we already have DNS data for the device with this MAC:
+ # Add the mapping to the DeviceDNSMap that is already present in the dict.
+ result[device_mac].add_mapping(ip, timestamp_hostname_tuple)
+ else:
+ # No DNS data for this device yet:
+ # Create a new DeviceDNSMap, add the mapping, and at it to the dict.
+ ddm = DeviceDNSMap(device_mac)
+ ddm.add_mapping(ip, timestamp_hostname_tuple)
+ result[device_mac] = ddm
+ return result