MAC Address Resolution
An interesting issue with Ethernet communication is how to associate the MAC addresses (the interface’s unique hardware ID) with the IP number. Most protocols have a similar problem, but we concentrate on the Ethernet-like case here. We’ll try to offer a complete description of the issue, so we will show three situations: ARP, Ethernet headers without ARP (like plip), and non-Ethernet headers.
Using ARP with Ethernet
The usual way to deal with address resolution is by using ARP, the
Address Resolution Protocol. Fortunately, ARP is managed by the
kernel, and an Ethernet interface doesn’t need to do anything special
to support ARP. As long as dev->addr and
dev->addr_len are correctly assigned at open
time, the driver doesn’t need to worry about resolving IP numbers to
physical addresses; ether_setup assigns the
correct device methods to dev->hard_header and
dev->rebuild_header.
Although the kernel normally handles the details of address resolution (and caching of the results), it calls upon the interface driver to help in the building of the packet. After all, the driver knows about the details of the physical layer header, while the authors of the networking code have tried to insulate the rest of the kernel from that knowledge. To this end, the kernel calls the driver’s hard_header method to lay out the packet with the results of the ARP query. Normally, Ethernet driver writers need not know about this process—the common Ethernet code takes care ...