original_docstring: Add an IP address-MAC address relationship
docstring: Add an IP address-MAC address relationship
docstring_tokens: Add an IP address - MAC address relationship
code: def add_ip_addr(self, ip_version, ip_addr, hw_addr, description, silent=False):
          """Add an IP address-MAC address relationship"""
          if self.is_ignored(hw_addr):
              return
          if ip_addr in self.known_ip_addresses:
              return
          # Canonicalize the ip address
          if ip_version == 4:
              new_ip_addr = canonical_ipv4_address(ip_addr)
          elif ip_version == 6:
              new_ip_version, new_ip_addr = canonical_ipv6_address_with_version(ip_addr)
              if new_ip_version == 4:
                  # The version changed, because it was an V4MAPPED address
                  ip_version = new_ip_version
                  ip_addr = new_ip_addr
          else:
              raise RuntimeError("Invalid IP version {}".format(ip_version))
          if new_ip_addr != ip_addr:
              logger.warning("Tried adding a non-canonical IPv%d address %r -> %r (from %s)",
                             ip_version, ip_addr, new_ip_addr, description)
              self.known_ip_addresses.add(ip_addr)
              ip_addr = new_ip_addr
              if ip_addr in self.known_ip_addresses:
                  return
          if not silent:
              logger.info("Found IPv%d address %s for %s (%s) from %s",
                          ip_version, ip_addr, hw_addr,
                          get_mac_manuf_desc(hw_addr), description)
          if hw_addr not in self.ip_for_hw:
              self.ip_for_hw[hw_addr] = set()
          self.ip_for_hw[hw_addr].add(ip_addr)
          self.known_ip_addresses.add(ip_addr)
code_tokens: def add_ip_addr ( self , ip_version , ip_addr , hw_addr , description , silent = False ) : if self . is_ignored ( hw_addr ) : return if ip_addr in self . known_ip_addresses : return if ip_version == 4 : new_ip_addr = canonical_ipv4_address ( ip_addr ) elif ip_version == 6 : new_ip_version , new_ip_addr = canonical_ipv6_address_with_version ( ip_addr ) if new_ip_version == 4 : ip_version = new_ip_version ip_addr = new_ip_addr else : raise RuntimeError ( "Invalid IP version {}" . format ( ip_version ) ) if new_ip_addr != ip_addr : logger . warning ( "Tried adding a non-canonical IPv%d address %r -> %r (from %s)" , ip_version , ip_addr , new_ip_addr , description ) self . known_ip_addresses . add ( ip_addr ) ip_addr = new_ip_addr if ip_addr in self . known_ip_addresses : return if not silent : logger . info ( "Found IPv%d address %s for %s (%s) from %s" , ip_version , ip_addr , hw_addr , get_mac_manuf_desc ( hw_addr ) , description ) if hw_addr not in self . ip_for_hw : self . ip_for_hw [ hw_addr ] = set ( ) self . ip_for_hw [ hw_addr ] . add ( ip_addr ) self . known_ip_addresses . add ( ip_addr )
short_docstring: Add an IP address-MAC address relationship
short_docstring_tokens: Add an IP address - MAC address relationship
comment: """Add an IP address-MAC address relationship"""$SEP$# Canonicalize the ip address$SEP$# The version changed, because it was an V4MAPPED address