⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 if.h

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * if.h *//* static     char    *sccsid = "@(#)if.h	4.8	(ULTRIX)	11/14/90"; *//************************************************************************ *									* *		      Copyright (c) 1985, 1989 by			* *		Digital Equipment Corporation, Maynard, MA		* *			All rights reserved.				* *									* *   This software is furnished under a license and may be used and	* *   copied  only  in accordance with the terms of such license and	* *   with the  inclusion  of  the  above  copyright  notice.   This	* *   software  or  any  other copies thereof may not be provided or	* *   otherwise made available to any other person.  No title to and	* *   ownership of the software is hereby transferred.			* *									* *   This software is  derived  from  software  received  from  the	* *   University    of   California,   Berkeley,   and   from   Bell	* *   Laboratories.  Use, duplication, or disclosure is  subject  to	* *   restrictions  under  license  agreements  with  University  of	* *   California and with AT&T.						* *									* *   The information in this software is subject to change  without	* *   notice  and should not be construed as a commitment by Digital	* *   Equipment Corporation.						* *									* *   Digital assumes no responsibility for the use  or  reliability	* *   of its software on equipment which is not supplied by Digital.	* *									* ************************************************************************//************************************************************************ *									* *			Modification History				* * *	Chran-Ham Chang 9-Nov-90 *		Added structure to support FDDI read status  * *	Ursula Sinkewicz 18-Sep-90					 *		X.25 changes (from NAC)					 *									* *	Chran-Ham Chang 7-Sep-90				        * *		Added structures to support FDDI MIB  			*  *								        * *	Matt Thomas 20-Aug-90						* *		Add if_sysid_type cell to ifnet structure.		* *									* *	Chran-Ham Chang 9-Aug-90				        * *		Added ifeeporm structure to support the FDDI EEPROM     *  *		update					                * *									* *	Matt Thomas 20-Nov-89						* *		Augment ifstate for DSV11 (and other device) support	* *									* *	Uttam Shikarpur 24-Oct-89					* *	Added ifversion field to ifnet structure, and est_mbloksent and * *	est_mbytesent to the estat structure for network management.	*	 *									* *	Matt Thomas 17-Jul-89						* *		Change ifnetptr references to m_ifp			* *									* *	Ursula Sinkewicz 28-Feb-89					* * 		SMP/mips merge. (Added changes from R. Bhanukitsiri	* * 		02/06/89).						* *									* * 	Larry Palmer 15-Jan-88						* *		Final 43bsd release					* *									* *  001 - Larry Cohen 3/6/85  - add LOOPBACK flag to indicate that 	* *		interface is in loopback mode.				* *									* *	Larry Cohen  -	09/16/85					* * 		Add 43bsd alpha tape changes for subnet routing		* *									* *	Ursula Sinkewic - 03/05/86					* *		Added bscintrq for BISYNC 2780/3780			* *									* *      Ed Ferris - 4/18/86						* * 		Add point to point state info for DECnet.		* ***********************************************************************/#ifndef KERNEL#include <sys/smp_lock.h>#else#include "../h/smp_lock.h"  /* 8.4.88.us */#endif/* * Structures defining a network interface, providing a packet * transport mechanism (ala level 0 of the PUP protocols). * * Each interface accepts output datagrams of a specified maximum * length, and provides higher level routines with input datagrams * received from its medium. * * Output occurs when the routine if_output is called, with three parameters: *	(*ifp->if_output)(ifp, m, dst) * Here m is the mbuf chain to be sent and dst is the destination address. * The output routine encapsulates the supplied datagram if necessary, * and then transmits it on its medium. * * On input, each interface unwraps the data received by it, and either * places it on the input queue of a internetwork datagram routine * and posts the associated software interrupt, or passes the datagram to a raw * packet input routine. * * Routines exist for locating interfaces by their addresses * or for locating a interface on a certain network, as well as more general * routing and gateway routines maintaining information used to locate * interfaces.  These routines live in the files if.c and route.c *//* * Structure defining a queue for a network interface. * * (Would like to call this struct ``if'', but C isn't PL/1.) * * EVENTUALLY PURGE if_net AND if_host FROM STRUCTURE */#define	IFVERLEN	512struct ifnet {	char	*if_name;		/* name, e.g. ``en'' or ``lo'' */	short	if_unit;		/* sub-unit for lower level driver */	short	if_mtu;			/* maximum transmission unit */#ifdef old	int	if_net;			/* network number of interface */#endif	short	if_flags;		/* up/down, broadcast, etc. */	short	if_timer;		/* time 'til if_watchdog called */	int	if_metric;		/* routing metric (external only) */	struct	ifaddr *if_addrlist;	/* linked list of addresses per if */	struct	sockaddr if_addr;	/* address of interface */	struct	ifqueue {		struct	mbuf *ifq_head;		struct	mbuf *ifq_tail;		int	ifq_len;		int	ifq_maxlen;		int	ifq_drops;		struct lock_t lk_ifqueue; /* SMP lock for ifqueue */	} if_snd;			/* output queue *//* procedure handles */	int	(*if_init)();		/* init routine */	int	(*if_output)();		/* output routine */	int	(*if_ioctl)();		/* ioctl routine */	int	(*if_reset)();		/* bus reset routine */	int	(*if_watchdog)();	/* timer routine *//* generic interface statistics */	int	if_ipackets;		/* packets received on interface */	int	if_ierrors;		/* input errors on interface */	int	if_opackets;		/* packets sent on interface */	int	if_oerrors;		/* output errors on interface */	int	if_collisions;		/* collisions on csma interfaces *//* end statistics */	int	d_affinity;		/* 8.9.88.us  Nonsymm net devices. */	char	if_version[IFVERLEN];	/* ptr to hardware version and rev */	struct	ifnet *if_next;	int	if_type;	struct	lock_t *lk_softc;	int	(*if_start)();		/* Start routine */	int	if_sysid_type;		/* MOP SYSID device code */};/* * 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 */	union {		struct	sockaddr ifu_broadaddr;		struct	sockaddr ifu_dstaddr;	} ifa_ifu;#define	ifa_broadaddr	ifa_ifu.ifu_broadaddr	/* broadcast address */#define	ifa_dstaddr	ifa_ifu.ifu_dstaddr	/* other end of p-to-p link */	struct	ifnet *ifa_ifp;		/* back-pointer to interface */	struct	ifaddr *ifa_next;	/* next address for interface */};#define	IFF_UP		0x1		/* interface is up */#define	IFF_BROADCAST	0x2		/* broadcast address valid */#define	IFF_DEBUG	0x4		/* turn on debugging */#define	IFF_LOOPBACK	0x8		/* is a loopback net */#define	IFF_POINTOPOINT	0x10		/* interface is point-to-point link */#define	IFF_NOTRAILERS	0x20		/* avoid use of trailers */#define	IFF_RUNNING	0x40		/* resources allocated */#define	IFF_NOARP	0x80		/* no address resolution protocol */#define	IFF_CANTCHANGE	(IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING)#define IFF_PROMISC	0x100		/* receive all packets */#define IFF_ALLMULTI	0x200		/* receive all multicast packets */#define IFF_DYNPROTO	0x400		/* support dynamic proto dispatching */ #define IFF_MOP		0x800		/* device in MOP mode */#define IFF_OACTIVE	0x1000		/* Device outputting */#define IFF_802HDR	0x2000		/* 802 encapsulation */#define	IFF_PFCOPYALL	0x4000		/* pfilt gets packets to this host *//* interface types for benefit of parsing media address headers */#define IFT_OTHER	0x1		/* none of the following */#define IFT_1822	0x2		/* old-style arpanet imp */#define IFT_HDH1822	0x3		/* HDH arpanet imp */#define IFT_X25DDN	0x4		/* x25 to imp */#define IFT_X25		0x5		/* PDN X25 interface */#define	IFT_ETHER	0x6		/* Ethernet I or II */#define	IFT_ISO88023	0x7		/* CMSA CD */#define	IFT_ISO88024	0x8		/* Token Bus */#define	IFT_ISO88025	0x9		/* Token Ring */#define	IFT_ISO88026	0xa		/* MAN */#define	IFT_STARLAN	0xb#define	IFT_P10		0xc		/* Proteon 10MBit ring */#define	IFT_P80		0xd		/* Proteon 10MBit ring */#define IFT_HY		0xe		/* Hyperchannel */#define IFT_FDDI	0xf#define IFT_LAPB	0x10#define IFT_SDLC	0x11#define IFT_T1		0x12#define IFT_CEPT	0x13#define IFT_ISDNBASIC	0x14#define IFT_ISDNPRIMARY	0x15#define IFT_PTPSERIAL	0x16#define	IFT_LOOP	0x18		/* loopback */#define IFT_EON		0x19		/* ISO over IP */#define	IFT_XETHER	0x1a		/* obsolete 3MB experimental ethernet */#define	IFT_NSIP	0x1b		/* XNS over IP */#define	IFT_SLIP	0x1c		/* IP over generic TTY *//* * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1) * input routines have 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_act = 0; \	if ((ifq)->ifq_tail == 0) \		(ifq)->ifq_head = m; \	else \		(ifq)->ifq_tail->m_act = m; \	(ifq)->ifq_tail = m; \	(ifq)->ifq_len++; \}#define	IF_ENQUEUEIF(ifq, m, ifp) { \	(m)->m_act = 0; \	if ((ifq)->ifq_tail == 0) \		(ifq)->ifq_head = m; \	else \		(ifq)->ifq_tail->m_act = m; \	(ifq)->ifq_tail = m; \	(ifq)->ifq_len++; \	(m)->m_ifp = ifp; \}#define	IF_PREPEND(ifq, m) { \	(m)->m_act = (ifq)->ifq_head; \	if ((ifq)->ifq_tail == 0) \		(ifq)->ifq_tail = (m); \	(ifq)->ifq_head = (m); \	(ifq)->ifq_len++; \}/* * Packets destined for level-1 protocol input routines * have a pointer to the receiving interface prepended to the data. * IF_DEQUEUEIF extracts and returns this pointer when dequeueing the packet. * IF_ADJ should be used otherwise to adjust for its presence. */#ifdef BSD43#define	IF_ADJ(m) { \	(m)->m_off += sizeof(struct ifnet *); \	(m)->m_len -= sizeof(struct ifnet *); \	if ((m)->m_len == 0) { \		struct mbuf *n; \		MFREE((m), n); \		(m) = n; \	} \}#else/* ifnet is held someplace else */#define	IF_ADJ(m) { \	if ((m)->m_len == 0) { \		struct mbuf *n; \		MFREE((m), n); \		(m) = n; \	} \}#endif#define	IF_DEQUEUEIF(ifq, m, ifp) { \	(m) = (ifq)->ifq_head; \	if (m) { \		if (((ifq)->ifq_head = (m)->m_act) == 0) \			(ifq)->ifq_tail = 0; \		(m)->m_act = 0; \		(ifq)->ifq_len--; \		(ifp) = (m)->m_ifp; \	} \}#define	IF_DEQUEUE(ifq, m) { \	(m) = (ifq)->ifq_head; \	if (m) { \		if (((ifq)->ifq_head = (m)->m_act) == 0) \			(ifq)->ifq_tail = 0; \		(m)->m_act = 0; \		(ifq)->ifq_len--; \	} \}#define	IFQ_MAXLEN	50#define	IFNET_SLOWHZ	1		/* granularity is 1 second *//* * 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;		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_data	ifr_ifru.ifru_data	/* for use by interface */};/* * structure used to query de and qe for physical addresses */struct ifdevea {        char    ifr_name[IFNAMSIZ];             /* if name, e.g. "en0" */        u_char default_pa[6];                   /* default hardware address */        u_char current_pa[6];                   /* current physical address */};/* * structure used in SIOCSTATE request to set device state and ownership */#define	IFMAXENTITY	5struct ifstate {	char    ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */	u_short	if_family;			/* current family ownership */	u_short	if_next_family;			/* next family ownership */	u_short	if_mode:3,			/* mode of device */		if_ustate:1,			/* user requested state */		if_nomuxhdr:1,			/* if set, omit mux header */		if_dstate:4,			/* current state of device */		if_xferctl:1,			/* xfer control to nxt family */		if_rdstate:1,			/* read current state */		if_wrstate:1,			/* set current state */		if_reserved:4;	u_short if_dataportstate:3,		/* data port entity states */	        if_allocate:1,			/* allocate port */	        if_deallocate:1,		/* deallocate port */	        if_start:1,			/* start port */	        if_stop:1,			/* stop port */	        if_txabort:1,			/* transmit abort */	        if_setframe:1,			/* set protocol framing & CRC */	        if_frametype:3,			/* protocol framing types */	        if_errorchecktype:3,		/* error check types */		if_setrxbuffsize:1;		/* set receive buffer size */	struct protosw *if_pr;			/* client protocol module */	int     if_rxbuffsize;			/* receive buffer size */	int     if_lec[IFMAXENTITY];		/* DNA Local Entity Class */	u_char  *if_lei;			/* DNA Local Entity Instance */	u_short if_leisiz;			/* size of Local Entity Instance */	caddr_t if_clientname;                  /* client local Entity Name */	caddr_t if_clientref;			/* client handle */};#define	IFS_USROFF	0x0	/* user request to stop device */#define	IFS_USRON	0x1	/* user request to start device */#define	IFS_DDCMPFDX	0x0	/* operate in DDCMP full duplex */#define	IFS_MOP		0x1	/* operate in MOP */#define	IFS_DDCMPHDXP	0x2	/* operate in DDCMP half duplex, primary */#define	IFS_DDCMPHDXS	0x3	/* operate in DDCMP half duplex, secondary */#define IFS_NOMUXHDR	0x1	/* do not multiplex on point to point line */#define IFS_MUXHDR	0x0	/* multiplex on point to point line */#define IFS_HALTED	0x0	/* device state = halted */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -