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

📄 ip.h

📁 这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易于我们学习和理解
💻 H
📖 第 1 页 / 共 2 页
字号:
typedef struct	Conv	Conv;typedef struct	Fs	Fs;typedef union	Hwaddr	Hwaddr;typedef struct	IP	IP;typedef struct	IPaux	IPaux;typedef struct	Ipself	Ipself;typedef struct	Ipselftab	Ipselftab;typedef struct	Iplink	Iplink;typedef struct	Iplifc	Iplifc;typedef struct	Ipmulti	Ipmulti;typedef struct	Ipifc	Ipifc;typedef struct	Iphash	Iphash;typedef struct	Ipht	Ipht;typedef struct	Netlog	Netlog;typedef struct	Medium	Medium;typedef struct	Proto	Proto;typedef struct	Arpent	Arpent;typedef struct	Arp Arp;typedef struct	Route	Route;typedef struct	Routerparams	Routerparams;typedef struct 	Hostparams	Hostparams;typedef struct 	v6router	v6router;typedef struct	v6params	v6params;#pragma incomplete Arp#pragma incomplete Ipself#pragma incomplete Ipselftab#pragma incomplete IP#pragma incomplete Netlogenum{	Addrlen=	64,	Maxproto=	20,	Nhash=		64,	Maxincall=	5,	Nchans=		1024,	MAClen=		16,		/* longest mac address */	MAXTTL=		255,	DFLTTOS=	0,	IPaddrlen=	16,	IPv4addrlen=	4,	IPv4off=	12,	IPllen=		4,	/* ip versions */	V4=		4,	V6=		6,	IP_VER4= 	0x40,	IP_VER6=	0x60,	/* 2^Lroot trees in the root table */	Lroot=		10,	Maxpath =	64,};enum{	Idle=		0,	Announcing=	1,	Announced=	2,	Connecting=	3,	Connected=	4,};/* *  one per conversation directory */struct Conv{	QLock;	int	x;			/* conversation index */	Proto*	p;	int	restricted;		/* remote port is restricted */	uint	ttl;			/* max time to live */	uint	tos;			/* type of service */	int	ignoreadvice;		/* don't terminate connection on icmp errors */	uchar	ipversion;	uchar	laddr[IPaddrlen];	/* local IP address */	uchar	raddr[IPaddrlen];	/* remote IP address */	ushort	lport;			/* local port number */	ushort	rport;			/* remote port number */	char	*owner;			/* protections */	int	perm;	int	inuse;			/* opens of listen/data/ctl */	int	length;	int	state;	/* udp specific */	int	headers;		/* data src/dst headers in udp */	int	reliable;		/* true if reliable udp */	Conv*	incall;			/* calls waiting to be listened for */	Conv*	next;	Queue*	rq;			/* queued data waiting to be read */	Queue*	wq;			/* queued data waiting to be written */	Queue*	eq;			/* returned error packets */	Queue*	sq;			/* snooping queue */	Ref	snoopers;		/* number of processes with snoop open */	QLock	car;	Rendez	cr;	char	cerr[ERRMAX];	QLock	listenq;	Rendez	listenr;	Ipmulti	*multi;			/* multicast bindings for this interface */	void*	ptcl;			/* protocol specific stuff */	Route	*r;			/* last route used */	ulong	rgen;			/* routetable generation for *r */};struct Medium{	char	*name;	int	hsize;		/* medium header size */	int	mintu;		/* default min mtu */	int	maxtu;		/* default max mtu */	int	maclen;		/* mac address length  */	void	(*bind)(Ipifc*, int, char**);	void	(*unbind)(Ipifc*);	void	(*bwrite)(Ipifc *ifc, Block *b, int version, uchar *ip);	/* for arming interfaces to receive multicast */	void	(*addmulti)(Ipifc *ifc, uchar *a, uchar *ia);	void	(*remmulti)(Ipifc *ifc, uchar *a, uchar *ia);	/* process packets written to 'data' */	void	(*pktin)(Fs *f, Ipifc *ifc, Block *bp);	/* routes for router boards */	void	(*addroute)(Ipifc *ifc, int, uchar*, uchar*, uchar*, int);	void	(*remroute)(Ipifc *ifc, int, uchar*, uchar*);	void	(*flushroutes)(Ipifc *ifc);	/* for routing multicast groups */	void	(*joinmulti)(Ipifc *ifc, uchar *a, uchar *ia);	void	(*leavemulti)(Ipifc *ifc, uchar *a, uchar *ia);	/* address resolution */	void	(*ares)(Fs*, int, uchar*, uchar*, int, int);	/* resolve */	void	(*areg)(Ipifc*, uchar*);			/* register */	/* v6 address generation */	void	(*pref2addr)(uchar *pref, uchar *ea);	int	unbindonclose;	/* if non-zero, unbind on last close */};/* logical interface associated with a physical one */struct Iplifc{	uchar	local[IPaddrlen];	uchar	mask[IPaddrlen];	uchar	remote[IPaddrlen];	uchar	net[IPaddrlen];	uchar	tentative;	/* =1 => v6 dup disc on, =0 => confirmed unique */	uchar	onlink;		/* =1 => onlink, =0 offlink. */	uchar	autoflag;	/* v6 autonomous flag */	long 	validlt;	/* v6 valid lifetime */	long 	preflt;		/* v6 preferred lifetime */	long	origint;	/* time when addr was added */	Iplink	*link;		/* addresses linked to this lifc */	Iplifc	*next;};/* binding twixt Ipself and Iplifc */struct Iplink{	Ipself	*self;	Iplifc	*lifc;	Iplink	*selflink;	/* next link for this local address */	Iplink	*lifclink;	/* next link for this ifc */	ulong	expire;	Iplink	*next;		/* free list */	int	ref;};/* rfc 2461, pp.40--43. *//* default values, one per stack */struct Routerparams {	int	mflag;	int	oflag;	int 	maxraint;	int	minraint;	int	linkmtu;	int	reachtime;	int	rxmitra;	int	ttl;	int	routerlt;	};struct Hostparams {	int	rxmithost;};struct Ipifc{	RWlock;		Conv	*conv;		/* link to its conversation structure */	char	dev[64];	/* device we're attached to */	Medium	*m;		/* Media pointer */	int	maxtu;		/* Maximum transfer unit */	int	mintu;		/* Minumum tranfer unit */	int	mbps;		/* megabits per second */	void	*arg;		/* medium specific */	int	reassemble;	/* reassemble IP packets before forwarding */	/* these are used so that we can unbind on the fly */	Lock	idlock;	uchar	ifcid;		/* incremented each 'bind/unbind/add/remove' */	int	ref;		/* number of proc's using this ipifc */	Rendez	wait;		/* where unbinder waits for ref == 0 */	int	unbinding;	uchar	mac[MAClen];	/* MAC address */	Iplifc	*lifc;		/* logical interfaces on this physical one */	ulong	in, out;	/* message statistics */	ulong	inerr, outerr;	/* ... */	uchar	sendra6;	/* == 1 => send router advs on this ifc	*/	uchar	recvra6;	/* == 1 => recv router advs on this ifc */	Routerparams rp;	/* router parameters as in RFC 2461, pp.40--43. 					used only if node is router */};/* *  one per multicast-lifc pair used by a Conv */struct Ipmulti{	uchar	ma[IPaddrlen];	uchar	ia[IPaddrlen];	Ipmulti	*next;};/* *  hash table for 2 ip addresses + 2 ports */enum{	Nipht=		521,	/* convenient prime */	IPmatchexact=	0,	/* match on 4 tuple */	IPmatchany,		/* *!* */	IPmatchport,		/* *!port */	IPmatchaddr,		/* addr!* */	IPmatchpa,		/* addr!port */};struct Iphash{	Iphash	*next;	Conv	*c;	int	match;};struct Ipht{	Lock;	Iphash	*tab[Nipht];};void iphtadd(Ipht*, Conv*);void iphtrem(Ipht*, Conv*);Conv* iphtlook(Ipht *ht, uchar *sa, ushort sp, uchar *da, ushort dp);/* *  one per multiplexed protocol */struct Proto{	QLock;	char*		name;		/* protocol name */	int		x;		/* protocol index */	int		ipproto;	/* ip protocol type */	char*		(*connect)(Conv*, char**, int);	char*		(*announce)(Conv*, char**, int);	char*		(*bind)(Conv*, char**, int);	int		(*state)(Conv*, char*, int);	void		(*create)(Conv*);	void		(*close)(Conv*);	void		(*rcv)(Proto*, Ipifc*, Block*);	char*		(*ctl)(Conv*, char**, int);	void		(*advise)(Proto*, Block*, char*);	int		(*stats)(Proto*, char*, int);	int		(*local)(Conv*, char*, int);	int		(*remote)(Conv*, char*, int);	int		(*inuse)(Conv*);	int		(*gc)(Proto*);	/* returns true if any conversations are freed */	Fs		*f;		/* file system this proto is part of */	Conv		**conv;		/* array of conversations */	int		ptclsize;	/* size of per protocol ctl block */	int		nc;		/* number of conversations */	int		ac;	Qid		qid;		/* qid for protocol directory */	ushort		nextport;	ushort		nextrport;	void		*priv;};/* *  one per IP protocol stack */struct Fs{	RWlock;	int	dev;

⌨️ 快捷键说明

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