Quick Reference

This section provides a reference for the concepts introduced in this chapter. It also explains the role of each header file that a driver needs to include. The list of fields in the device and sk_buff structures, however, are not repeated here.

#include <linux/netdevice.h>

This header hosts the definition of struct device and includes a few other headers that are needed by network drivers.

void netif_rx(struct sk_buff *skb);

This function can be called at interrupt time to notify the kernel that a packet has been received and encapsulated into a socket buffer.

#include <linux/if.h>

Included by netdevice.h, this file declares the interface flags (IFF_ macros) and struct ifmap, which has a major role in the ioctl implementation for network drivers.

#include <linux/if_ether.h> , ETH_ALEN , ETH_P_IP , struct ethhdr; , struct enet_statistics;

Included by netdevice.h, if_ether.h defines all the ETH_ macros used to represent octet lengths (like the address length) and network protocols (like IP). It also defines the structures ethhdr and enet_statistics. Note that enet_statistics, despite its name and the header in which it is defined, is used by all interfaces, not just Ethernet ones.

#include <linux/skbuff.h>

The definition of struct sk_buff and related structures, as well as several inline functions to act on the buffers. This header is included by netdevice.h.

#include <linux/etherdevice.h> , void ether_setup(struct device *dev);

This function sets most device ...

Get Linux Device Drivers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.