This chapter is from ifnet, each network device has a own ifnet structure, this structure has ifaddr linked list, that is, each interface
All addresses, can be one, or can be multiple forms of linked lists. And then there's a ifqueue that's pointing to the Mbuf list; and then there's a lot
Handles function pointers to initialize interfaces, send packets, and so on.
struct ifnet { /* This is the record interface type, where the interface type is Ethernet/or * slip or loopback interface */ char *if_name; /* name, e.g. ' en ' or ' lo ' */ /* this is to form the ifnet structure list, because each interface has its own ifnet structure, * For example, there are two Ethernet cards, there are two of this structure, with this pointer to connect */ struct ifnet *if_next; /* all struct ifnets are chained */ /* then each interface can have multiple addresses possible, such as Ethernet, * we can set multiple IP addresses to it, forming a chain */ struct ifaddr *if_addrlist; /* linked list of addresses per if */ /* I don't know what it is yet, but the number of listeners in the mix makes me think of Libpcap library * set up promiscuous mode */ int if_pcount; /* number of promiscuous listeners * / /* Package filter use, and then look at */ caddr_t if_bpf; /* packet filter structure */ /* This is almost the same as the one below, but it doesn't matter what the interface type is, it's all numbered * so the number is the only */ u_short if_index; /* numeric abbreviation for this if */ /* has this type of interface in front of it, in case this interface has multiple, * then it is again identified as 0/1/...*/ short if_unit; /* sub-unit for lower level driver */ /* this recording time but the specifics are unclear */ short if_timer; /* time ' til if_watchdog called */ /* The State and properties of this interface, such as the work is not working, can do */ short if_flags; /* up/down, broadcast, etc. */ struct if_data {/* generic interface information */ u_ Char ifi_type; /* etHernet, tokenring, etc */ u_char ifi_addrlen; /* media address length */ u_char ifi_hdrlen; /* media header length */ u_long ifi_mtu; /* maximum transmission unit */ u_long ifi_metric; /* routing metric (external only) */ u_long ifi_baudrate; /* linespeed *//* volatile statistics */ u_long Ifi_ipackets; /* packets received on interface */ u_long ifi_ ierrors; /* input errors on interface */ u_long ifi_opackets; /* packets sent on interface */ u_long ifi_oerrors; /* output errors on interface */ u_long ifi_collisions; /* Collisions on csma interfaces */ u_long ifi_ibytes; /* total number of octets received */ u_long ifi_obytes; /* total number of octets Sent */ u_long ifi_imcasts; /* packets received via multicast */ u_long ifi_omcasts; /* packets sent via multicast */ u_long ifi_iqdrops; /* dropped on input, this interface */ u_long ifi_noproto; /* destined for unsupported protocol */ struct timeval ifi_lastchange;/* last updated */ } if_data;/* procedure handles *//* This is the initialization of the handler function */ int (*if_init) /* init routine */ __p ((int)); int (*if_output) /* output routine (enqueue) &NBSp;*/ __p ((struct ifnet *, struct mbuf *, struct sockaddr * , struct rtentry *)); int (*if_start) /* initiate output routine */ __p ((struct ifnet *)); int (* If_done) /* output complete routine */ __p ((struct ifnet * )); /* (Xxx not used; fake prototype) */ int (*if_ioctl) /* ioctl routine */ __p ((struct ifnet *, u_long, caddr_t)) ; int (*if_reset) __p ((int)); /* new autoconfig will permit removal */ int (*if_watchdog) /* timer routine */ __p ((int)); /* This is the structure that points to the Mbuf list */ struct ifqueue { struct mbuf *ifq_head; struct mbuf *ifq_tail; int ifq_len; int ifq_maxlen; int ifq_drops; } if_snd; /* output queue */};
TCP/IP Protocol detailed 2nd volume 3rd Chapter Interface Layer