The link layer at each node is intialized by the simulated kernel at boot time. The kernel boot code reads the network configuration file (Section 2.1) and creates a list of networking interfaces on the node. Each element on this list is a struct ifnet defined in $PDIR/include/if.h:
struct ifnet { TAILQ_ENTRY(ifnet) if_next; int if_index; /* interface number */ struct sockaddr_in if_addr; /* address of interface */ struct sockaddr_in if_netmask; /* netmask of if_addr */ int if_mtu; /* MTU of interface */ void (*if_start)(struct ifnet *ifp, struct pbuf *p); struct hwif *if_hwif; /* hardware device */ };
The head of this list can be accessed by calling the function ifnet_listhead() provided by the simulator. The TAILQ_ENTRY() macro is a macro defined in $PDIR/include/queue.h that is useful for creating linked lists. Iterating over the interface list can be done as follows:
struct ifnet *ifp = ifnet_listhead(); for( ; ifp; ifp = TAILQ_NEXT(ifp, if_next)) { printf(``interface index: %d\n'', ifp->if_index); }