ospf.h,v

来自「TCP-IP红宝书源代码」· H,V 代码 · 共 373 行

H,V
373
字号
head	1.5;
access;
symbols;
locks
	dls:1.5; strict;
comment	@ * @;


1.5
date	97.09.21.19.26.19;	author dls;	state Dist;
branches;
next	1.4;

1.4
date	94.05.10.20.48.46;	author dls;	state Old;
branches;
next	1.3;

1.3
date	94.02.20.19.01.49;	author dls;	state Works;
branches;
next	1.2;

1.2
date	94.02.13.19.40.01;	author dls;	state Works;
branches;
next	1.1;

1.1
date	94.02.06.18.49.00;	author dls;	state OLD;
branches;
next	;


desc
@@


1.5
log
@pre-3e code
@
text
@/* ospf.h  */

/* OSPF process info */
extern	PROCESS		ospf();
#define	OSPFSTK		4096		/* stack size for OSPF input	*/
#define	OSPFPRI		  90		/* OSPF priority		*/
#define	OSPFNAM		"ospfinp"	/* name of OSPF input process	*/
#define	OSPFARGC	   0		/* count of args to ospfinp 	*/

extern	PROCESS		ospfhello();
#define	OSPFHSTK	4096		/* stack size for OSPF hello	*/
#define	OSPFHPRI	  90		/* OSPF priority		*/
#define	OSPFHNAM	"ospfhello"	/* name of OSPF hello process	*/
#define	OSPFHARGC	   0		/* count of args to ospfhello 	*/

#define	OSPFQLEN	20		/* OSPF input port queue length	*/
#define	MAXNBR		32		/* Max # active neighbors	*/

/* Manifest OSPF Configuration Parameters */

#define	OSPF_VERSION	2		/* protocol version number	*/
#ifdef notdef
#define	HELLOINTV	10		/* Hello Interval (seconds)	*/
#endif
#define	HELLOINTV	30		/* Hello Interval (seconds)	*/
#define	DEADINTV	4*HELLOINTV	/* Router Dead Interval (secs)	*/
#ifdef notdef
#define	RXMTINTV	5		/* Retransmit Interval (secs)	*/
#endif
#define	RXMTINTV	15		/* Retransmit Interval (secs)	*/

#define	AUTHLEN		8		/* 64-bit Password		*/

typedef	int	timer_t;		/* OSPF count-down timers (secs)*/

/* Area Information */

struct ospf_ar {
	unsigned long	  ar_id;	/* Area Identifier		*/
	unsigned char	  ar_authtype;	/* Authentication Type		*/
	unsigned char	  ar_auth[AUTHLEN]; /* Password, if ARA_PASSWD	*/
	int		  ar_dbmutex;	/* Mutex for Top. Database	*/
	int		  ar_hmod;	/* Hash Table Modulus		*/
	struct ospf_db	**ar_htable;	/* LSA Hash Table		*/
	struct ospf_db	 *ar_dblhead;	/* Head of Top. Database	*/
	struct ospf_if	 *ar_if;	/* List of Interfaces This Area	*/
};

#define	ARA_NONE	0		/* No Authentication for Area	*/
#define	ARA_PASSWD	1		/* Simple-password Auth.	*/

/* Neighbor Information */

struct	ospf_nb {
	unsigned char	nb_state;	/* neighbor conversation state	*/
	unsigned long	nb_seq;		/* DD packet sequence number	*/
	unsigned long	nb_rid;		/* neighbor's router ID		*/
	unsigned char	nb_prio;	/* neighbor's router priority	*/
	IPaddr		nb_ipa;		/* neighbor's IP address	*/
	unsigned char	nb_opts;	/* options			*/
	unsigned long	nb_drid;	/* neighbor's designated router	*/
	unsigned long	nb_brid;	/* backup designated router	*/
	Bool		nb_master;	/* nonzero if we are master	*/
	timer_t		nb_lastheard;	/* seconds since last HELLO	*/
	timer_t		nb_trexmt;	/* Retransmit Timer (secs)	*/
	timer_t		nb_tlastdd;	/* Slave Last DD pkt. Timer	*/
	timer_t		nb_tlsr;	/* LSR Retransmit Timer		*/
	int		nb_lsal;	/* Link Status Adv. List	*/
	int		nb_dsl;		/* Database Summary List	*/
	int		nb_lsrl;	/* Link Status Req. List	*/
};

/* Neighbor States */

#define	NBS_DOWN	0
#define	NBS_ATTEMPT	1
#define	NBS_INIT	2
#define NBS_2WAY	3
#define	NBS_EXSTART	4
#define	NBS_EXCHNG	5
#define	NBS_LOADING	6
#define	NBS_FULL	7

/* Neighbor Options */

#define	NBO_T		0x01		/* Router Does Supports IP TOS	*/
#define	NBO_E		0x02		/* Can Use External Routes	*/

#define	NBMAXLIST	10		/* Max Retrans. Queue Lengths	*/

#include "ospf_ls.h"
#include "ospf_pkt.h"
#include "ospf_if.h"
#include "ospf_db.h"

extern struct ospf_ar	ospf_ar[];
extern struct ospf_if	ospf_if[];
extern int		ospf_iport;
extern int		ospf_lspool;
extern IPaddr		AllSPFRouters, AllDRouters;
@


1.4
log
@*** empty log message ***
@
text
@d22 1
d24 2
d27 1
d29 2
@


1.3
log
@*** empty log message ***
@
text
@d4 1
a4 1
extern	int		ospf();
d10 1
a10 1
extern	int		ospfhello();
d22 1
a22 4
/*#define	HELLOINTV	10		/* Hello Interval (seconds)	*/
/*#define	DEADINTV	4*HELLOINTV	/* Router Dead Interval (secs)	*/
/*#define	RXMTINTV	5		/* Retransmit Interval (secs)	*/
#define	HELLOINTV	30		/* Hello Interval (seconds)	*/
d24 1
a24 1
#define	RXMTINTV	15		/* Retransmit Interval (secs)	*/
d33 8
a40 6
	unsigned long	 ar_id;		/* Area Identifier		*/
	unsigned char	 ar_authtype;	/* Authentication Type		*/
	unsigned char	 ar_auth[AUTHLEN]; /* Password, if ARA_PASSWD	*/
	int		 ar_dbmutex;	/* Mutex for Top. Database	*/
	struct ospf_db	*ar_dbhead;	/* Head of Top. Database	*/
	struct ospf_if	*ar_if;		/* List of Interfaces This Area	*/
d61 1
d74 1
a74 1
#define	NBS_XCHNG	5
d93 1
@


1.2
log
@*** empty log message ***
@
text
@d36 5
a40 3
	unsigned long	ar_id;		/* Area Identifier		*/
	unsigned char	ar_authtype;	/* Authentication Type		*/
	unsigned char	ar_auth[AUTHLEN]; /* Password, if ARA_PASSWD	*/
d61 1
@


1.1
log
@Initial revision
@
text
@d22 4
a25 1
#define	HELLOINTV	15		/* Hello Interval (seconds)	*/
d27 2
a30 94
/* OSPF packet format */

struct ospf {
	unsigned char	ospf_version;	/* Version Number		*/
	unsigned char	ospf_type;	/* Packet Type			*/
	unsigned short	ospf_len;	/* Packet Length		*/
	unsigned long	ospf_rid;	/* Router Identifier		*/
	unsigned long	ospf_aid;	/* Area Identifier		*/
	unsigned short	ospf_cksum;	/* Check Sum			*/
	unsigned short	ospf_authtype;	/* Authentication Type		*/
	unsigned char	ospf_auth[AUTHLEN]; /* Authentication Field	*/
	unsigned char	ospf_data[1];
};

#define	MINHDRLEN	24		/* OSPF base header length	*/

/* OSPF Packet Types */

#define	T_HELLO		1		/* Hello packet			*/
#define	T_DATADESC	2		/* Database Description		*/
#define	T_LSREQ		3		/* Link State Request		*/
#define	T_LSUPDATE	4		/* Link State Update		*/
#define	T_LSACK		5		/* Link State Acknowledgement	*/

/* OSPF Authentication Types */

#define	AU_NONE		0		/* No Authentication		*/
#define	AU_PASSWD	1		/* Simple Password		*/

/* OSPF Hello Packet */

struct	ospf_hello {
	unsigned long	oh_netmask;	/* Network Mask			*/
	unsigned short	oh_hintv;	/* Hello Interval (seconds)	*/
	unsigned char	oh_opts;	/* Options			*/
	unsigned char	oh_prio;	/* Sender's Router Priority	*/
	unsigned long	oh_rdintv;	/* Seconds Before Declare Dead	*/
	unsigned long	oh_drid;	/* Designated Router ID		*/
	unsigned long	oh_brid;	/* Backup Designated Router ID	*/
	unsigned long	oh_neighbor[1];	/* Living Neighbors		*/
};

#define	MINHELLOLEN	(MINHDRLEN + 20)

/* OSPF Database Description Packet */

struct	ospf_lsa {
	unsigned short	lsa_age;	/* Time (secs) Since Originated	*/
	unsigned char	lsa_opts;	/* Options Supported		*/
	unsigned char	lsa_type;	/* LST_* below			*/
	unsigned long	lsa_lsid;	/* Link State Identifier	*/
	unsigned long	lsa_arid;	/* Advertising Router Identifier*/
	unsigned long	lsa_seq;	/* Link State Adv. Sequence #	*/
	unsigned short	lsa_cksum;	/* Fletcher Checksum of LSA	*/
	unsigned short	lsa_len;	/* Length of Advertisement	*/
	unsigned char	lsa_data[1];	/* Link Type Specific Fields	*/
};

#define	LSAHDRLEN	20

/* Link State Advertisement Types */

#define	LST_RLINK	1		/* Router Link			*/
#define	LST_NLINK	2		/* Network Link			*/
#define	LST_SLINK	3		/* IP Network Summary Link	*/
#define	LST_BRSLINK	4		/* AS Border Router Summary	*/
#define	LST_EXTERN	5		/* AS External Link		*/

struct	ospf_dd {
	unsigned short	dd_mbz;		/* Must Be Zero			*/
	unsigned char	dd_opts;	/* Options			*/
	unsigned char	dd_control;	/* Control Bits	(DDC_* below)	*/
	unsigned long	dd_seq;		/* Sequence Number		*/
	struct ospf_lsa	dd_lsa[1];	/* Link State Advertisements	*/
};

#define	MINDDLEN	(MINHDRLEN + 8)

#define	DDC_INIT	0x04		/* Initial Sequence		*/
#define	DDC_MORE	0x02		/* More to follow		*/
#define	DDC_MSTR	0x01		/* This Router is Master	*/

/* OSPF Link State Request Packet */

struct	lsr1 {
	unsigned long	lsr_type;	/* Link State Type		*/
	unsigned long	lsr_id;		/* Link State Identifier	*/
	unsigned long	lsr_rid;	/* Advertising Router		*/
};

struct ospf_lsr	{
	struct lsr1	lsr_req[1];	/* One or More Link State Reqs.	*/
};

d56 1
a56 1
	Bool		nb_master;	/* nonzero if remote is master	*/
d59 1
a59 1
	int		nb_lsar;	/* Link Status Adv. List	*/
d61 1
a61 1
	int		nb_lsrr;	/* Link Status Req. List	*/
d82 4
a85 48
/* OSPF Interface Information */

struct ospf_if {
	unsigned int	 if_type;	/* one of IFT_* below		*/
	unsigned char	 if_state;	/* one of IFS_* below		*/
	unsigned char	 if_event;	/* one of IFE_* below		*/
	unsigned int	 if_hintv;	/* Hello Packet Interval	*/
	unsigned int	 if_rdintv;	/* Router Dead Interval		*/
	unsigned int	 if_rintv;	/* Retransmit Interval		*/
	timer_t		 if_twait;	/* Wait Timer for WAITING state	*/
	unsigned int	 if_xdelay;	/* Estimated Transmission Delay	*/
	IPaddr		 if_dipa;	/* IP Address of desig. router	*/
	IPaddr		 if_bipa;	/* IP address of backup router	*/
	unsigned int	 if_metric;	/* Cost to use this Interface	*/
	unsigned char	 if_auth[AUTHLEN]; /* Authentication Key	*/
	int		 if_nbmutex;	/* Mut. Excl. Semaphor for nbtab*/
	struct ospf_ar	*if_area;	/* Area Structure Back-pointer	*/
	struct ospf_if	*if_next;	/* Next Interface for Area	*/
	struct ospf_nb	 if_nbtab[MAXNBR+1]; /* Neighbor list this net	*/
};

#define	if_rid		if_nbtab[0].nb_rid
#define	if_prio		if_nbtab[0].nb_prio
#define	if_drid		if_nbtab[0].nb_drid
#define	if_brid		if_nbtab[0].nb_brid
#define	if_opts		if_nbtab[0].nb_opts

/* Interface Types */

#define	IFT_BROADCAST	0		/* Interface Supports Broadcast	*/
#define	IFT_MULTI	1		/* Interface Supports Multicast	*/
#define	IFT_PT2PT	2		/* Interface is Point-to-point	*/
#define	IFT_VIRTUAL	3		/* Interface is a Virtual Link	*/

/* Interface States */

#define	IFS_DOWN	0		/* Interface non-functional	*/
#define	IFS_LOOPBACK	1		/* Interface in loopback mode	*/
#define	IFS_WAITING	2		/* Electing Backup Desig. Rtr.	*/
#define	IFS_PT2PT	3		/* Interface is Point-to-Point	*/
#define	IFS_DROTHER	4		/* not Designated Router	*/
#define	IFS_BACKUP	5		/* Is Backup Designated Router	*/
#define	IFS_DR		6		/* Is Designated Router		*/

/* Scheduled Interface Events */

#define	IFE_BSEEN	0x01		/* Have Seen Backup DR Claim	*/
#define	IFE_NCHNG	0x02		/* A Neighbor State Changed	*/
@

⌨️ 快捷键说明

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