xref: /csrg-svn/sys/netiso/clnp.h (revision 66815)
149267Sbostic /*-
2*66815Sbostic  * Copyright (c) 1991, 1993, 1994
363222Sbostic  *	The Regents of the University of California.  All rights reserved.
449267Sbostic  *
549267Sbostic  * %sccs.include.redist.c%
649267Sbostic  *
7*66815Sbostic  *	@(#)clnp.h	8.2 (Berkeley) 04/16/94
849267Sbostic  */
939194Ssklower 
1036366Ssklower /***********************************************************
1136366Ssklower 		Copyright IBM Corporation 1987
1236366Ssklower 
1336366Ssklower                       All Rights Reserved
1436366Ssklower 
1536366Ssklower Permission to use, copy, modify, and distribute this software and its
1636366Ssklower documentation for any purpose and without fee is hereby granted,
1736366Ssklower provided that the above copyright notice appear in all copies and that
1836366Ssklower both that copyright notice and this permission notice appear in
1936366Ssklower supporting documentation, and that the name of IBM not be
2036366Ssklower used in advertising or publicity pertaining to distribution of the
2136366Ssklower software without specific, written prior permission.
2236366Ssklower 
2336366Ssklower IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
2436366Ssklower ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
2536366Ssklower IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
2636366Ssklower ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
2736366Ssklower WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
2836366Ssklower ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
2936366Ssklower SOFTWARE.
3036366Ssklower 
3136366Ssklower ******************************************************************/
3236366Ssklower 
3336366Ssklower /*
3436366Ssklower  * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
3536366Ssklower  */
3652487Ssklower /* $Header: /big/BSD4.4/isis-usr/src/sys/netiso/RCS/clnp.h,v 1.1 1992/02/07 18:14:59 hagens Exp hagens $ */
3752487Ssklower /* $Source: /big/BSD4.4/isis-usr/src/sys/netiso/RCS/clnp.h,v $ */
3836366Ssklower 
3936762Ssklower /* should be config option but cpp breaks with too many #defines */
4036762Ssklower #define	DECBIT
4136762Ssklower 
4236366Ssklower /*
4336366Ssklower  *	Return true if the mbuf is a cluster mbuf
4436366Ssklower  */
4536761Ssklower #define	IS_CLUSTER(m)	((m)->m_flags & M_EXT)
4636366Ssklower 
4736366Ssklower /*
4836366Ssklower  *	Move the halfword into the two characters
4936366Ssklower  */
5036366Ssklower #define	HTOC(msb, lsb, hword)\
5136366Ssklower 	(msb) = (u_char)((hword) >> 8);\
5236366Ssklower 	(lsb) = (u_char)((hword) & 0xff)
5336366Ssklower /*
5436366Ssklower  *	Move the two charcters into the halfword
5536366Ssklower  */
5636366Ssklower #define	CTOH(msb, lsb, hword)\
5736366Ssklower 	(hword) = ((msb) << 8) | (lsb)
5836366Ssklower 
5936366Ssklower /*
6036366Ssklower  *	Return true if the checksum has been set - ie. the checksum is
6136366Ssklower  *	not zero
6236366Ssklower  */
6336366Ssklower #define	CKSUM_REQUIRED(clnp)\
6436366Ssklower 	(((clnp)->cnf_cksum_msb != 0) || ((clnp)->cnf_cksum_lsb != 0))
6536366Ssklower 
6636366Ssklower /*
6736366Ssklower  *	Fixed part of clnp header
6836366Ssklower  */
6936366Ssklower struct clnp_fixed {
7036366Ssklower 	u_char	cnf_proto_id;		/* network layer protocol identifier */
7136366Ssklower 	u_char	cnf_hdr_len;		/* length indicator (octets) */
7236366Ssklower 	u_char	cnf_vers;			/* version/protocol identifier extension */
7336366Ssklower 	u_char	cnf_ttl;			/* lifetime (500 milliseconds) */
7437469Ssklower 	u_char	cnf_type;			/* type code */
7537469Ssklower 								/* Includes err_ok, more_segs, and seg_ok */
7636366Ssklower 	u_char	cnf_seglen_msb;		/* pdu segment length (octets) high byte */
7736366Ssklower 	u_char	cnf_seglen_lsb;		/* pdu segment length (octets) low byte */
7836366Ssklower 	u_char	cnf_cksum_msb;		/* checksum high byte */
7936366Ssklower 	u_char	cnf_cksum_lsb;		/* checksum low byte */
8036366Ssklower };
8137469Ssklower #define CNF_TYPE	0x1f
8237469Ssklower #define CNF_ERR_OK	0x20
8337469Ssklower #define CNF_MORE_SEGS	0x40
8437469Ssklower #define CNF_SEG_OK	0x80
8537469Ssklower 
8636366Ssklower #define CLNP_CKSUM_OFF	0x07	/* offset of checksum */
8736366Ssklower 
8836366Ssklower #define	clnl_fixed	clnp_fixed
8936366Ssklower 
9036366Ssklower /*
9136366Ssklower  *	Segmentation part of clnp header
9236366Ssklower  */
9336366Ssklower struct clnp_segment {
9436366Ssklower 	u_short	cng_id;				/* data unit identifier */
9536366Ssklower 	u_short	cng_off;			/* segment offset */
9636366Ssklower 	u_short	cng_tot_len;		/* total length */
9736366Ssklower };
9836366Ssklower 
9936366Ssklower /*
10036366Ssklower  *	Clnp fragment reassembly structures:
10136366Ssklower  *
10236366Ssklower  *	All packets undergoing reassembly are linked together in
10336366Ssklower  *	clnp_fragl structures. Each clnp_fragl structure contains a
10436366Ssklower  *	pointer to the original clnp packet header, as well as a
10536366Ssklower  *	list of packet fragments. Each packet fragment
10636366Ssklower  *	is headed by a clnp_frag structure. This structure contains the
10736366Ssklower  *	offset of the first and last byte of the fragment, as well as
10836366Ssklower  *	a pointer to the data (an mbuf chain) of the fragment.
10936366Ssklower  */
11036366Ssklower 
11136366Ssklower /*
11236366Ssklower  *	NOTE:
11336366Ssklower  *		The clnp_frag structure is stored in an mbuf immedately preceeding
11436366Ssklower  *	the fragment data. Since there are words in this struct,
11536366Ssklower  *	it must be word aligned.
11636366Ssklower  *
11736366Ssklower  *	NOTE:
11836366Ssklower  *		All the fragment code assumes that the entire clnp header is
11936366Ssklower  *	contained in the first mbuf.
12036366Ssklower  */
12136366Ssklower struct clnp_frag {
12236366Ssklower 	u_int				cfr_first;		/* offset of first byte of this frag */
12336366Ssklower 	u_int				cfr_last;		/* offset of last byte of this frag */
12436366Ssklower 	u_int				cfr_bytes;		/* bytes to shave to get to data */
12536366Ssklower 	struct mbuf			*cfr_data;		/* ptr to data for this frag */
12636366Ssklower 	struct clnp_frag	*cfr_next;		/* next fragment in list */
12736366Ssklower };
12836366Ssklower 
12936366Ssklower struct clnp_fragl {
13036366Ssklower 	struct iso_addr		cfl_src;		/* source of the pkt */
13136366Ssklower 	struct iso_addr		cfl_dst;		/* destination of the pkt */
13236366Ssklower 	u_short				cfl_id;			/* id of the pkt */
13336366Ssklower 	u_char				cfl_ttl;		/* current ttl of pkt */
13436366Ssklower 	u_short				cfl_last;		/* offset of last byte of packet */
13536366Ssklower 	struct mbuf 		*cfl_orighdr;	/* ptr to original header */
13636366Ssklower 	struct clnp_frag	*cfl_frags;		/* linked list of fragments for pkt */
13736366Ssklower 	struct clnp_fragl	*cfl_next;		/* next pkt being reassembled */
13836366Ssklower };
13936366Ssklower 
14036366Ssklower /*
14136366Ssklower  *	The following structure is used to index into an options section
14236366Ssklower  *	of a clnp datagram. These values can be used without worry that
14336366Ssklower  *	offset or length fields are invalid or too big, etc. That is,
14436366Ssklower  *	the consistancy of the options will be guaranteed before this
14536366Ssklower  *	structure is filled in. Any pointer (field ending in p) is
14636366Ssklower  *	actually the offset from the beginning of the mbuf the option
14736366Ssklower  *	is contained in.  A value of NULL for any pointer
14836366Ssklower  *	means that the option is not present. The length any option
14936366Ssklower  *	does not include the option code or option length fields.
15036366Ssklower  */
15136366Ssklower struct clnp_optidx {
15236366Ssklower 	u_short	cni_securep;		/* ptr to beginning of security option */
15336366Ssklower 	char	cni_secure_len;		/* length of entire security option */
15436366Ssklower 
15536366Ssklower 	u_short	cni_srcrt_s;		/* offset of start of src rt option */
15636366Ssklower 	u_short	cni_srcrt_len;		/* length of entire src rt option */
15736366Ssklower 
15836366Ssklower 	u_short	cni_recrtp;			/* ptr to beginning of recrt option */
15936366Ssklower 	char	cni_recrt_len;		/* length of entire recrt option */
16036366Ssklower 
16136366Ssklower 	char	cni_priorp;			/* ptr to priority option */
16236366Ssklower 
16336366Ssklower 	u_short	cni_qos_formatp;	/* ptr to format of qos option */
16436366Ssklower 	char	cni_qos_len;		/* length of entire qos option */
16536366Ssklower 
16636366Ssklower 	u_char	cni_er_reason;		/* reason from ER pdu option */
16737469Ssklower 
16837469Ssklower 								/* ESIS options */
16937469Ssklower 
17037469Ssklower 	u_short	cni_esct;			/* value from ISH ESCT option */
17137469Ssklower 
17237469Ssklower 	u_short	cni_netmaskp;		/* ptr to beginning of netmask option */
17337469Ssklower 	char	cni_netmask_len;		/* length of entire netmask option */
17437469Ssklower 
17537469Ssklower 	u_short	cni_snpamaskp;		/* ptr to beginning of snpamask option */
17637469Ssklower 	char	cni_snpamask_len;		/* length of entire snpamask option */
17737469Ssklower 
17836366Ssklower };
17936366Ssklower 
18036366Ssklower #define	ER_INVALREAS	0xff	/* code for invalid ER pdu discard reason */
18136366Ssklower 
18236762Ssklower /* given an mbuf and addr of option, return offset from data of mbuf */
18336762Ssklower #define CLNP_OPTTOOFF(m, opt)\
18437469Ssklower 	((u_short) (opt - mtod(m, caddr_t)))
18536762Ssklower 
18636762Ssklower /* given an mbuf and offset of option, return address of option */
18736762Ssklower #define CLNP_OFFTOOPT(m, off)\
18836762Ssklower 	((caddr_t) (mtod(m, caddr_t) + off))
18936762Ssklower 
19036366Ssklower /*	return true iff src route is valid */
19136366Ssklower #define	CLNPSRCRT_VALID(oidx)\
19236366Ssklower 	((oidx) && (oidx->cni_srcrt_s))
19336366Ssklower 
19436366Ssklower /*	return the offset field of the src rt */
19536366Ssklower #define CLNPSRCRT_OFF(oidx, options)\
19636762Ssklower 	(*((u_char *)(CLNP_OFFTOOPT(options, oidx->cni_srcrt_s) + 1)))
19736366Ssklower 
19836366Ssklower /*	return the type field of the src rt */
19936366Ssklower #define CLNPSRCRT_TYPE(oidx, options)\
20036762Ssklower 	((u_char)(*(CLNP_OFFTOOPT(options, oidx->cni_srcrt_s))))
20136366Ssklower 
20236366Ssklower /* return the length of the current address */
20336366Ssklower #define CLNPSRCRT_CLEN(oidx, options)\
20436762Ssklower 	((u_char)(*(CLNP_OFFTOOPT(options, oidx->cni_srcrt_s) + CLNPSRCRT_OFF(oidx, options) - 1)))
20536366Ssklower 
20636366Ssklower /* return the address of the current address */
20736366Ssklower #define CLNPSRCRT_CADDR(oidx, options)\
20836762Ssklower 	((caddr_t)(CLNP_OFFTOOPT(options, oidx->cni_srcrt_s) + CLNPSRCRT_OFF(oidx, options)))
20936366Ssklower 
21036366Ssklower /*
21136366Ssklower  *	return true if the src route has run out of routes
21236366Ssklower  *	this is true if the offset of next route is greater than the end of the rt
21336366Ssklower  */
21436366Ssklower #define	CLNPSRCRT_TERM(oidx, options)\
21536366Ssklower 	(CLNPSRCRT_OFF(oidx, options) > oidx->cni_srcrt_len)
21636366Ssklower 
21736366Ssklower /*
21836366Ssklower  *	Options a user can set/get
21936366Ssklower  */
22036366Ssklower #define	CLNPOPT_FLAGS	0x01	/* flags: seg permitted, no er xmit, etc  */
22136366Ssklower #define	CLNPOPT_OPTS	0x02	/* datagram options */
22236366Ssklower 
22336366Ssklower /*
22436366Ssklower  *	Values for particular datagram options
22536366Ssklower  */
22636366Ssklower #define	CLNPOVAL_PAD		0xcc	/* padding */
22736366Ssklower #define	CLNPOVAL_SECURE		0xc5	/* security */
22836366Ssklower #define	CLNPOVAL_SRCRT		0xc8	/* source routing */
22936366Ssklower #define	CLNPOVAL_RECRT		0xcb	/* record route */
23036366Ssklower #define	CLNPOVAL_QOS		0xc3	/* quality of service */
23136366Ssklower #define	CLNPOVAL_PRIOR		0xcd	/* priority */
23236366Ssklower #define CLNPOVAL_ERREAS		0xc1	/* ER PDU ONLY: reason for discard */
23336366Ssklower 
23436366Ssklower #define	CLNPOVAL_SRCSPEC	0x40	/* source address specific */
23536366Ssklower #define	CLNPOVAL_DSTSPEC	0x80	/* destination address specific */
23636366Ssklower #define	CLNPOVAL_GLOBAL		0xc0	/* globally unique */
23736366Ssklower 
23836762Ssklower /* Globally Unique QOS */
23936762Ssklower #define	CLNPOVAL_SEQUENCING	0x10	/* sequencing preferred */
24036762Ssklower #define CLNPOVAL_CONGESTED	0x08	/* congestion experienced */
24136762Ssklower #define CLNPOVAL_LOWDELAY	0x04	/* low transit delay */
24236762Ssklower 
24336366Ssklower #define	CLNPOVAL_PARTRT		0x00	/* partial source routing */
24436366Ssklower #define CLNPOVAL_COMPRT		0x01	/* complete source routing */
24536366Ssklower 
24636366Ssklower /*
24736366Ssklower  *	Clnp flags used in a control block flags field.
24836366Ssklower  *	NOTE: these must be out of the range of bits defined in ../net/raw_cb.h
24936366Ssklower  */
25036366Ssklower #define	CLNP_NO_SEG		0x010	/* segmentation not permitted */
25136366Ssklower #define	CLNP_NO_ER		0x020	/* do not generate ERs */
25236366Ssklower #define CLNP_SEND_RAW	0x080	/* send pkt as RAW DT rather than TP DT */
25336366Ssklower #define	CLNP_NO_CKSUM	0x100	/* don't use clnp checksum */
25452487Ssklower #define CLNP_ECHO		0x200	/* send echo request */
25536366Ssklower #define	CLNP_NOCACHE	0x400	/* don't store cache information */
25652487Ssklower #define CLNP_ECHOR		0x800	/* send echo reply */
25736366Ssklower 
25836366Ssklower /* valid clnp flags */
25936366Ssklower #define CLNP_VFLAGS		(CLNP_SEND_RAW|CLNP_NO_SEG|CLNP_NO_ER|CLNP_NO_CKSUM\
26052487Ssklower 	|CLNP_ECHO|CLNP_NOCACHE|CLNP_ECHOR)
26136366Ssklower 
26236366Ssklower /*
26336366Ssklower  *	Constants used by clnp
26436366Ssklower  */
26536366Ssklower #define	CLNP_HDR_MIN	(sizeof (struct clnp_fixed))
26636366Ssklower #define	CLNP_HDR_MAX	(254)
26736366Ssklower #define	CLNP_TTL_UNITS	2					/* 500 milliseconds */
26836366Ssklower #define CLNP_TTL		15*CLNP_TTL_UNITS	/* time to live (seconds) */
26936366Ssklower #define	ISO8473_V1		0x01
27036366Ssklower 
27136366Ssklower /*
27236366Ssklower  *	Clnp packet types
27336366Ssklower  *	In order to test raw clnp and tp/clnp simultaneously, a third type of
27436366Ssklower  *	packet has been defined: CLNP_RAW. This is done so that the input
27536366Ssklower  *	routine can switch to the correct input routine (rclnp_input or
27636366Ssklower  *	tpclnp_input) based on the type field. If clnp had a higher level protocol
27736366Ssklower  *	field, this would not be necessary.
27836366Ssklower  */
27936366Ssklower #define	CLNP_DT			0x1C	/* normal data */
28036366Ssklower #define	CLNP_ER			0x01	/* error report */
28136366Ssklower #define	CLNP_RAW		0x1D	/* debug only */
28236366Ssklower #define CLNP_EC			0x1E	/* echo packet */
28336366Ssklower #define CLNP_ECR		0x1F	/* echo reply */
28436366Ssklower 
28536366Ssklower /*
28636366Ssklower  *	ER pdu error codes
28736366Ssklower  */
28836366Ssklower #define GEN_NOREAS			0x00	/* reason not specified */
28936366Ssklower #define GEN_PROTOERR		0x01	/* protocol procedure error */
29036366Ssklower #define GEN_BADCSUM			0x02	/* incorrect checksum */
29136366Ssklower #define GEN_CONGEST			0x03	/* pdu discarded due to congestion */
29236366Ssklower #define GEN_HDRSYNTAX		0x04	/* header syntax error */
29336366Ssklower #define GEN_SEGNEEDED		0x05	/* segmentation needed, but not permitted */
29436366Ssklower #define GEN_INCOMPLETE		0x06	/* incomplete pdu received */
29536366Ssklower #define GEN_DUPOPT			0x07	/* duplicate option */
29636366Ssklower 
29736366Ssklower /* address errors */
29836366Ssklower #define ADDR_DESTUNREACH	0x80	/* destination address unreachable */
29936366Ssklower #define ADDR_DESTUNKNOWN	0x81	/* destination address unknown */
30036366Ssklower 
30136366Ssklower /* source routing */
30236366Ssklower #define SRCRT_UNSPECERR		0x90	/* unspecified src rt error */
30336366Ssklower #define SRCRT_SYNTAX		0x91	/* syntax error in src rt field */
30436366Ssklower #define SRCRT_UNKNOWNADDR	0x92	/* unknown addr in src rt field */
30536366Ssklower #define SRCRT_BADPATH		0x93	/* path not acceptable */
30636366Ssklower 
30736366Ssklower /* lifetime */
30836366Ssklower #define TTL_EXPTRANSIT		0xa0	/* lifetime expired during transit */
30936366Ssklower #define TTL_EXPREASS		0xa1	/* lifetime expired during reassembly */
31036366Ssklower 
31136366Ssklower /* pdu discarded */
31236366Ssklower #define DISC_UNSUPPOPT		0xb0	/* unsupported option not specified? */
31336366Ssklower #define DISC_UNSUPPVERS		0xb1	/* unsupported protocol version */
31436366Ssklower #define DISC_UNSUPPSECURE	0xb2	/* unsupported security option */
31536366Ssklower #define DISC_UNSUPPSRCRT	0xb3	/* unsupported src rt option */
31636366Ssklower #define DISC_UNSUPPRECRT	0xb4	/* unsupported rec rt option */
31736366Ssklower 
31836366Ssklower /* reassembly */
31936366Ssklower #define REASS_INTERFERE		0xc0	/* reassembly interference */
32039194Ssklower #define CLNP_ERRORS		22
32136366Ssklower 
32239194Ssklower 
32339194Ssklower #ifdef KERNEL
32439194Ssklower int clnp_er_index();
32539194Ssklower #endif
32639194Ssklower 
32739194Ssklower #ifdef CLNP_ER_CODES
32839194Ssklower u_char clnp_er_codes[CLNP_ERRORS] =  {
32939194Ssklower GEN_NOREAS, GEN_PROTOERR, GEN_BADCSUM, GEN_CONGEST,
33039194Ssklower GEN_HDRSYNTAX, GEN_SEGNEEDED, GEN_INCOMPLETE, GEN_DUPOPT,
33139194Ssklower ADDR_DESTUNREACH, ADDR_DESTUNKNOWN,
33239194Ssklower SRCRT_UNSPECERR, SRCRT_SYNTAX, SRCRT_UNKNOWNADDR, SRCRT_BADPATH,
33339194Ssklower TTL_EXPTRANSIT, TTL_EXPREASS,
33439194Ssklower DISC_UNSUPPOPT, DISC_UNSUPPVERS, DISC_UNSUPPSECURE,
33539194Ssklower DISC_UNSUPPSRCRT, DISC_UNSUPPRECRT, REASS_INTERFERE };
33639194Ssklower #endif
33739194Ssklower 
33836366Ssklower #ifdef	TROLL
33936366Ssklower 
34036366Ssklower #define	TR_DUPEND		0x01	/* duplicate end of fragment */
34136366Ssklower #define TR_DUPPKT		0x02	/* duplicate entire packet */
34236366Ssklower #define	TR_DROPPKT		0x04	/* drop packet on output */
34336366Ssklower #define TR_TRIM			0x08	/* trim bytes from packet */
34436366Ssklower #define TR_CHANGE		0x10	/* change bytes in packet */
34536366Ssklower #define TR_MTU			0x20	/* delta to change device mtu */
34636366Ssklower #define	TR_CHUCK		0x40	/* drop packet in rclnp_input */
34736366Ssklower #define	TR_BLAST		0x80	/* force rclnp_output to blast many packet */
34836366Ssklower #define	TR_RAWLOOP		0x100	/* make if_loop call clnpintr directly */
34936366Ssklower struct troll {
35036366Ssklower 	int		tr_ops;				/* operations to perform */
35136366Ssklower 	float	tr_dup_size;		/* % to duplicate */
35236366Ssklower 	float	tr_dup_freq;		/* frequency to duplicate packets */
35336366Ssklower 	float	tr_drop_freq;		/* frequence to drop packets */
35436366Ssklower 	int		tr_mtu_adj;			/* delta to adjust if mtu */
35536366Ssklower 	int		tr_blast_cnt;		/* # of pkts to blast out */
35636366Ssklower };
35736366Ssklower 
35836366Ssklower #define	SN_OUTPUT(clcp, m)\
35948741Ssklower 	troll_output(clcp->clc_ifp, m, clcp->clc_firsthop, clcp->clc_rt)
36036366Ssklower 
36148741Ssklower #define	SN_MTU(ifp, rt) (((rt && rt->rt_rmx.rmx_mtu) ?\
36248741Ssklower 	rt->rt_rmx.rmx_mtu : clnp_badmtu(ifp, rt, __LINE__, __FILE__))\
36348741Ssklower 		- trollctl.tr_mtu_adj)
36436366Ssklower 
36537469Ssklower #ifdef KERNEL
36637469Ssklower extern float troll_random;
36737469Ssklower #endif
36837469Ssklower 
36936366Ssklower #else	/* NO TROLL */
37036366Ssklower 
37136366Ssklower #define	SN_OUTPUT(clcp, m)\
37248741Ssklower 	(*clcp->clc_ifp->if_output)(clcp->clc_ifp, m, clcp->clc_firsthop, clcp->clc_rt)
37336366Ssklower 
37448741Ssklower #define	SN_MTU(ifp, rt) (((rt && rt->rt_rmx.rmx_mtu) ?\
37548741Ssklower 	rt->rt_rmx.rmx_mtu : clnp_badmtu(ifp, rt, __LINE__, __FILE__)))
37636366Ssklower 
37760359Sbostic #endif	/* TROLL */
37836366Ssklower 
37936366Ssklower /*
38036366Ssklower  *	Macro to remove an address from a clnp header
38136366Ssklower  */
38236366Ssklower #define CLNP_EXTRACT_ADDR(isoa, hoff, hend)\
38336366Ssklower 	{\
38436366Ssklower 		isoa.isoa_len = (u_char)*hoff;\
38536366Ssklower 		if ((((++hoff) + isoa.isoa_len) > hend) ||\
38636366Ssklower 			(isoa.isoa_len > 20) || (isoa.isoa_len == 0)) {\
38736366Ssklower 			hoff = (caddr_t)0;\
38836366Ssklower 		} else {\
38937469Ssklower 			(void) bcopy(hoff, (caddr_t)isoa.isoa_genaddr, isoa.isoa_len);\
39036366Ssklower 			hoff += isoa.isoa_len;\
39136366Ssklower 		}\
39236366Ssklower 	}
39336366Ssklower 
39436366Ssklower /*
39536366Ssklower  *	Macro to insert an address into a clnp header
39636366Ssklower  */
39737469Ssklower #define CLNP_INSERT_ADDR(hoff, isoa)\
39837469Ssklower 	*hoff++ = (isoa).isoa_len;\
39937469Ssklower 	(void) bcopy((caddr_t)((isoa).isoa_genaddr), hoff, (isoa).isoa_len);\
40037469Ssklower 	hoff += (isoa).isoa_len;
40136366Ssklower 
40236366Ssklower /*
40336366Ssklower  *	Clnp hdr cache.	Whenever a clnp packet is sent, a copy of the
40436366Ssklower  *	header is made and kept in this cache. In addition to a copy of
40536366Ssklower  *	the cached clnp hdr, the cache contains
40636366Ssklower  *	information necessary to determine whether the new packet
40736366Ssklower  *	to send requires a new header to be built.
40836366Ssklower  */
40936366Ssklower struct clnp_cache {
41036366Ssklower 	/* these fields are used to check the validity of the cache */
41136366Ssklower 	struct iso_addr		clc_dst;		/* destination of packet */
41236366Ssklower 	struct mbuf 		*clc_options;	/* ptr to options mbuf */
41336366Ssklower 	int					clc_flags;		/* flags passed to clnp_output */
41436366Ssklower 
41536366Ssklower 	/* these fields are state that clnp_output requires to finish the pkt */
41636366Ssklower 	int					clc_segoff;		/* offset of seg part of header */
41740776Ssklower 	struct rtentry		*clc_rt;		/* ptr to rtentry (points into
41840776Ssklower 											the route structure) */
41948741Ssklower 	struct sockaddr		*clc_firsthop;	/* first hop of packet */
42048741Ssklower 	struct ifnet		*clc_ifp;		/* ptr to interface structure */
42148741Ssklower 	struct iso_ifaddr	*clc_ifa;		/* ptr to interface address */
42236366Ssklower 	struct mbuf 		*clc_hdr;		/* cached pkt hdr (finally)! */
42336366Ssklower };
42436366Ssklower 
42536366Ssklower #ifndef	satosiso
42636366Ssklower #define	satosiso(sa)\
42736366Ssklower 	((struct sockaddr_iso *)(sa))
42836366Ssklower #endif
42936366Ssklower 
43036366Ssklower #ifdef	KERNEL
43136366Ssklower caddr_t			clnp_insert_addr();
43236366Ssklower struct iso_addr	*clnp_srcaddr();
43336366Ssklower struct mbuf		*clnp_reass();
43436366Ssklower #ifdef	TROLL
43536366Ssklower struct troll	trollctl;
43660359Sbostic #endif	/* TROLL */
43760359Sbostic #endif	/* KERNEL */
438