📄 if.h
字号:
/* etc. *//* * Bit values in if_ipending */#define IFI_RECV 1 /* I want to receive */#define IFI_XMIT 2 /* I want to transmit *//* * Output queues (ifp->if_snd) and slow device input queues (*ifp->if_slowq) * are queues of messages stored on ifqueue structures * (defined above). Entries are added to and deleted from these structures * by these macros, which should be called with ipl raised to splimp(). */#define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)#define IF_DROP(ifq) ((ifq)->ifq_drops++)#define IF_ENQUEUE(ifq, m) { \ (m)->m_nextpkt = 0; \ if ((ifq)->ifq_tail == 0) \ (ifq)->ifq_head = m; \ else \ (ifq)->ifq_tail->m_nextpkt = m; \ (ifq)->ifq_tail = m; \ (ifq)->ifq_len++; \}#define IF_PREPEND(ifq, m) { \ (m)->m_nextpkt = (ifq)->ifq_head; \ if ((ifq)->ifq_tail == 0) \ (ifq)->ifq_tail = (m); \ (ifq)->ifq_head = (m); \ (ifq)->ifq_len++; \}#define IF_DEQUEUE(ifq, m) { \ (m) = (ifq)->ifq_head; \ if (m) { \ if (((ifq)->ifq_head = (m)->m_nextpkt) == 0) \ (ifq)->ifq_tail = 0; \ (m)->m_nextpkt = 0; \ (ifq)->ifq_len--; \ } \}#ifdef KERNEL#define IF_ENQ_DROP(ifq, m) if_enq_drop(ifq, m)#if defined(__GNUC__) && defined(MT_HEADER)static inline intif_queue_drop(struct ifqueue *ifq, struct mbuf *m){ IF_DROP(ifq); return 0;}static inline intif_enq_drop(struct ifqueue *ifq, struct mbuf *m){ if (IF_QFULL(ifq) && !if_queue_drop(ifq, m)) return 0; IF_ENQUEUE(ifq, m); return 1;}#else#ifdef MT_HEADERint if_enq_drop __P((struct ifqueue *, struct mbuf *));#endif#endif#endif /* KERNEL */#define IFQ_MAXLEN 50#define IFNET_SLOWHZ 1 /* granularity is 1 second *//* * The ifaddr structure contains information about one address * of an interface. They are maintained by the different address families, * are allocated and attached when an address is set, and are linked * together so all addresses for an interface can be located. */struct ifaddr { struct sockaddr *ifa_addr; /* address of interface */ struct sockaddr *ifa_dstaddr; /* other end of p-to-p link */#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ struct sockaddr *ifa_netmask; /* used to determine subnet */ struct ifnet *ifa_ifp; /* back-pointer to interface */ struct ifaddr *ifa_next; /* next address for interface */ void (*ifa_rtrequest) __P((int, struct rtentry *, struct sockaddr *)); /* check or clean routes (+ or -)'d */ u_short ifa_flags; /* mostly rt_flags for cloning */ short ifa_refcnt; /* references to this structure */ int ifa_metric; /* cost of going out this interface */#ifdef notdef struct rtentry *ifa_rt; /* XXXX for ROUTETOIF ????? */#endif};#define IFA_ROUTE RTF_UP /* route installed *//* * Message format for use in obtaining information about interfaces * from getkerninfo and the routing socket */struct if_msghdr { u_short ifm_msglen; /* to skip over non-understood messages */ u_char ifm_version; /* future binary compatability */ u_char ifm_type; /* message type */ int ifm_addrs; /* like rtm_addrs */ int ifm_flags; /* value of if_flags */ u_short ifm_index; /* index for associated ifp */ struct if_data ifm_data;/* statistics and other data about if */};/* * Message format for use in obtaining information about interface addresses * from getkerninfo and the routing socket */struct ifa_msghdr { u_short ifam_msglen; /* to skip over non-understood messages */ u_char ifam_version; /* future binary compatability */ u_char ifam_type; /* message type */ int ifam_addrs; /* like rtm_addrs */ int ifam_flags; /* value of ifa_flags */ u_short ifam_index; /* index for associated ifp */ int ifam_metric; /* value of ifa_metric */};/* * Interface request structure used for socket * ioctl's. All interface ioctl's must have parameter * definitions which begin with ifr_name. The * remainder may be interface specific. */struct ifreq {#define IFNAMSIZ 16 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ union { struct sockaddr ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; short ifru_flags; int ifru_metric; int ifru_mtu; int ifru_phys; caddr_t ifru_data; } ifr_ifru;#define ifr_addr ifr_ifru.ifru_addr /* address */#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */#define ifr_flags ifr_ifru.ifru_flags /* flags */#define ifr_metric ifr_ifru.ifru_metric /* metric */#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */#define ifr_phys ifr_ifru.ifru_phys /* physical wire */#define ifr_data ifr_ifru.ifru_data /* for use by interface */};struct ifaliasreq { char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ struct sockaddr ifra_addr; struct sockaddr ifra_broadaddr; struct sockaddr ifra_mask;};/* * Structure used in SIOCGIFCONF request. * Used to retrieve interface configuration * for machine (useful for programs which * must know all networks accessible). */struct ifconf { int ifc_len; /* size of associated buffer */ union { caddr_t ifcu_buf; struct ifreq *ifcu_req; } ifc_ifcu;#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */};#include <net/if_arp.h>#ifdef KERNEL#define IFAFREE(ifa) \ if ((ifa)->ifa_refcnt <= 0) \ ifafree(ifa); \ else \ (ifa)->ifa_refcnt--;extern struct ifnet *ifnet;extern int ifqmaxlen;extern struct ifnet loif[];extern int if_index;extern struct ifaddr **ifnet_addrs;void ether_ifattach __P((struct ifnet *));void ether_input __P((struct ifnet *, struct ether_header *, struct mbuf *));int ether_output __P((struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *));#ifndef EMB_SYSvoid ether_ioctl __P((struct ifnet *, int , caddr_t ));#elsevoid ether_ioctl __P((struct ifnet *, unsigned int , caddr_t ));#endif /* !EMB_SYS */void if_attach __P((struct ifnet *));void if_down __P((struct ifnet *));void if_up __P((struct ifnet *));#ifdef vaxvoid ifubareset __P((int));#endif/*void ifinit __P((void));*/ /* declared in systm.h for main() */#ifndef EMB_SYSint ifioctl __P((struct socket *, int, caddr_t, struct proc *));#elseint ifioctl __P((struct socket *, unsigned int, caddr_t, char *));#endif /* !EMB_SYS */int ifpromisc __P((struct ifnet *, int));struct ifnet *ifunit __P((char *));int if_poll_recv_slow __P((struct ifnet *ifp, int *quotap));void if_poll_xmit_slow __P((struct ifnet *ifp, int *quotap));void if_poll_throttle __P((void));void if_poll_unthrottle __P((void *));void if_poll_init __P((void));void if_poll __P((void));struct ifaddr *ifa_ifwithaddr __P((struct sockaddr *));struct ifaddr *ifa_ifwithdstaddr __P((struct sockaddr *));struct ifaddr *ifa_ifwithnet __P((struct sockaddr *));struct ifaddr *ifa_ifwithroute __P((int, struct sockaddr *, struct sockaddr *));struct ifaddr *ifaof_ifpforaddr __P((struct sockaddr *, struct ifnet *));void ifafree __P((struct ifaddr *));int looutput __P((struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *));#endif /* KERNEL */#endif /* !_NET_IF_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -