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 {};

 

posted @ 2017-12-20 12:16  elewei  阅读(386)  评论(0)    收藏  举报