struct udphdr {

_be16 source;

_be16 dest;

_be16 len;

_be16 check;

_udp4_lib_lookup from net/ipv4/udp.c is used to find a kernel-internal socket to which the packet is sent. They employ a hashing method to find and return an instance of the sock structure in the udphash global array when a listening process is interested in the packet. If they cannot find a socket, they send a destination unreachable message to the original system, and the contents of the packet are discarded.

Although I have not yet discussed the sock structure, it inevitably brings the term socket to mind, exactly as is intended. As we are on the borderline of the application layer, the data must be passed to userspace at some time or other using sockets as described in the sample programs at the beginning of the chapter.

25The IP address need not be specified because it is already in the IP header.

Note, however, that two data structures are used to represent sockets in the kernel. sock is the interface to the network access layer, and socket is the link to userspace. These rather lengthy structures are discussed in detail in the next section, which examines the part of the application layer anchored in the kernel. At the moment, we are interested only in the methods of the sock structure needed to forward data to the next higher layer. These must allow data received to be placed on a socket-specific wait queue and must also inform the receiving process that new data have arrived. Currently, the sock structure can be reduced to the following abbreviated version:

Continue reading here: Includenetsockh

Was this article helpful?

0 0