/* Copyright 1984 by the Massachusetts Institute of Technology */

/* Old style CHAOS packet format */

#define	chaddr	union	chadru

chaddr	{	swrd	oc_word;

		struct	{	unsb	oc_hst;
				unsb	oc_snt;
			}	oc_addr;
	};

#define	mkcha(x)	((chaddr *) (x))
#define	mkscha(x)	(mkcha(x)->oc_addr.oc_snt), mkunsb(mkcha(x)->oc_addr.oc_hst)


#define	ochpkt struct	ocpstr

ochpkt	{	byte	oc_pad;	
		unsb	oc_opc;
		unss	oc_len : 12;
		unss	oc_fc : 4;
		chaddr	oc_dst;
		unss	oc_dind;
		chaddr	oc_src;
		unss	oc_sind;
		unss	oc_pkt;
		unss	oc_ack;
/*		byte	oc_data[];	compiler doesn't like zero length
					structure elements */
		};

#define	mkoch(x)	((ochpkt *) (x))


/* New style (InterNet based) format */

#define	nchpkt	struct	ncpstr

nchpkt	{	unss	nc_sind;
		unss	nc_dind;
		unss	nc_pkt;
		unss	nc_ack;
		unsb	nc_opc;
		byte	nc_pad;
		swrd	nc_cksum;
	};

#define	mknch(x)	((nchpkt *) (x))


#define	CHMAX	488		/* Max data size in bytes */
#define	CHMXCST	512		/* Infinite cost for CHAOS */
/* #define	INCH	020		/* Protocol number in Internet */

#define CHRFC	01		/* Opcodes */
#define CHOPN	02
#define CHCLS	03
#define CHFWD	04
#define CHANS	05
#define CHSNS	06
#define CHSTS	07
#define CHRUT	010
#define CHLOS	011
#define CHLSN	012
#define CHMNT	013
#define CHEOF	014
#define CHUNC	015
#define CHBRD	016
#define CHBDAT	0200
#define	CHWDAT	0300



/* Structure definition for CHAOS address initialization tables.
 */

#define	chia	struct	chintaddr

chia	{	byte		chia_addr[2];
		chia		*chia_link;
		unss		chia_cost;
		};

#define	mkchia(x)	((chia *) (x))



/* Structure definition for CHAOS fixed routing entry table initialization.
 */

#define	chfre	struct	chfrestr

chfre	{	unsb		chfre_snt;
		unss		chfre_cost;
		byte		chfre_addr[2];
		};
