
/*	protocol.h	4.10	83/08/11	*/
/*
 * Routing Information Protocol
 *
 * Derived from Xerox NS Routing Information Protocol
 * by changing 32-bit net numbers to sockaddr's and
 * padding stuff to 32-bit boundaries.
 */
#define	RIPVERSION	1

/* Since the implementation is quite internet specific I stuck in sa_addr.
 * If C allowed casts on the left hand side of an expression this wouldn't
 * be necessary.
 */
struct sockaddr {
	unss	sa_family;		/* address family */
	unss	sa_port;		/* port */
	inaddr	sa_addr;		/* a network address */
	inaddr	sa_gw;			/* the gateway to sa_addr */
	unsl	sa_pad;			/* the rest of the 14 bytes */
};

struct netinfo {
	struct	sockaddr rip_dst;	/* destination net/host */
	unss	rip_1unused;		/* It is actually a long but its */
	unsb	rip_2unused;		/* value is limited to at most 16 */
					/* So only get useful byte. (Saves */
					/* having to byte swap long.) */
	unsb	rip_metric;		/* cost of route */
};

struct rip {
	byte	rip_cmd;		/* request/response */
	byte	rip_vers;		/* protocol version # */
	byte	rip_res1[2];		/* pad to 32-bit boundary */
	union {
		struct	netinfo ru_nets[1];	/* variable length... */
		char	ru_tracefile[1];	/* ditto ... */
	} ripun;
#define	rip_nets	ripun.ru_nets
#define	rip_tracefile	ripun.ru_tracefile
};
 
/*
 * Address families.
 */
#define	AF_INET	2			/* internet */

/*
 * Packet types.
 */
#define	RIPCMD_REQUEST		1	/* want info */
#define	RIPCMD_RESPONSE		2	/* responding to request */
#define	RIPCMD_TRACEON		3	/* turn tracing on */
#define	RIPCMD_TRACEOFF		4	/* turn it off */
#define RIPCMD_REQGW		5	/* want gateway info */
#define RIPCMD_RSPGW		6	/* data with gateway info */

#define	RIPCMD_MAX		7
#ifdef RIPCMDS
char *ripcmds[RIPCMD_MAX] =
  { "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF" ,
    "REQUEST+", "RESPONSE+"};
#endif

#define	HOPCNT_INFINITY		16	/* per Xerox NS */
#define	MAXPACKETSIZE		512	/* max broadcast size */

#define RIPBRDPRI	0130	/* Priority of RIP table broadcast task. */
#define RIP_BRD_DELAY	2	/* Delay between modifying routing tables
				 * and re-broadcasting them. (seconds) */

/*
 * Timer values used in managing the routing table.
 * Every update forces an entry's timer to be reset.  After
 * EXPIRE_TIME without updates, the entry is marked invalid,
 * but held onto until GARBAGE_TIME so that others may
 * see it "be deleted".
 */
#define	TIMER_RATE		30	/* alarm clocks every 30 seconds */

#define	SUPPLY_INTERVAL		30	/* time to supply tables */
#define	UPDATE_TIME		90	/* time to update an entry */
#define	EXPIRE_TIME		180	/* time to mark entry invalid */
#define	GARBAGE_TIME		240	/* time to garbage collect */
