Title: hash_fd() / unhash_fd() / udp


Hash tables enable quick lookups. The hash table used by the udp code enables a udp file descriptor to be found quickly using its common udp port number (0-65535).

hash_fd(udp_fd) either places the udp file descriptor udp_fd, hash_fd()'s only parameter, at the head of the up_port_any linked list of the file descriptor's udp port (if the file descriptor is not associated with a specific udp port) or the function calculates the hash of the udp file descriptor based on its udp port number and places it at the head of the linked list for that hash value (e.g., up_port_hash[10)).

unhash_fd(udp_fd) removes the udp file descriptor udp_fd, unhash_fd()'s only parameter, from the linked list where hash_fd() inserted it.

Note that the port used for the hash is not the physical udp port.