2. 网络接口 结构
<sys/net/if_var.h>
struct ifnet {};
这个结构包含所有接口的通用信息。
它是一个链表
FreeBSD 提供以下几个方法来管理 ifnet 结构
#include <net/if.h> #include <net/if_types.h> #include <net/if_var.h>
struct ifnet * if_alloc(u_char type); /* type 类型可以在 <net/if_types.h 中查找>*/ void if_initname(struct ifnet *ifp, const char *name, int [unit); /* 初始化 */ void if_attach(struct ifnet *ifp); /* 定义好结构后,必须调用if_attach附到系统中 */ void if_detach(struct ifnet *ifp); /* 从系统中卸载 */ void if_free(struct ifnet *ifp); /* 释放内存 */
网络接口链路结构
<sys/net/if_media.h>
struct ifmedia {};

浙公网安备 33010602011771号