xref: /csrg-svn/sys/netinet/ip_icmp.h (revision 29142)
123183Smckusick /*
2*29142Smckusick  * Copyright (c) 1982, 1986 Regents of the University of California.
323183Smckusick  * All rights reserved.  The Berkeley software License Agreement
423183Smckusick  * specifies the terms and conditions for redistribution.
523183Smckusick  *
6*29142Smckusick  *	@(#)ip_icmp.h	7.1 (Berkeley) 06/05/86
723183Smckusick  */
84807Swnj 
94807Swnj /*
104807Swnj  * Interface Control Message Protocol Definitions.
114807Swnj  * Per RFC 792, September 1981.
124807Swnj  */
134807Swnj 
144807Swnj /*
154807Swnj  * Structure of an icmp header.
164807Swnj  */
174807Swnj struct icmp {
184807Swnj 	u_char	icmp_type;		/* type of message, see below */
194807Swnj 	u_char	icmp_code;		/* type sub code */
204807Swnj 	u_short	icmp_cksum;		/* ones complement cksum of struct */
214807Swnj 	union {
224807Swnj 		u_char ih_pptr;			/* ICMP_PARAMPROB */
234923Swnj 		struct in_addr ih_gwaddr;	/* ICMP_REDIRECT */
244807Swnj 		struct ih_idseq {
254807Swnj 			n_short	icd_id;
264807Swnj 			n_short	icd_seq;
274807Swnj 		} ih_idseq;
286583Ssam 		int ih_void;
294807Swnj 	} icmp_hun;
304807Swnj #define	icmp_pptr	icmp_hun.ih_pptr
314807Swnj #define	icmp_gwaddr	icmp_hun.ih_gwaddr
324807Swnj #define	icmp_id		icmp_hun.ih_idseq.icd_id
334807Swnj #define	icmp_seq	icmp_hun.ih_idseq.icd_seq
346583Ssam #define	icmp_void	icmp_hun.ih_void
354807Swnj 	union {
364807Swnj 		struct id_ts {
374807Swnj 			n_time its_otime;
384807Swnj 			n_time its_rtime;
394807Swnj 			n_time its_ttime;
404807Swnj 		} id_ts;
414807Swnj 		struct id_ip  {
424807Swnj 			struct ip idi_ip;
434807Swnj 			/* options and then 64 bits of data */
444807Swnj 		} id_ip;
4524812Skarels 		u_long	id_mask;
4627060Skarels 		char	id_data[1];
474807Swnj 	} icmp_dun;
484807Swnj #define	icmp_otime	icmp_dun.id_ts.its_otime
494807Swnj #define	icmp_rtime	icmp_dun.id_ts.its_rtime
504807Swnj #define	icmp_ttime	icmp_dun.id_ts.its_ttime
514807Swnj #define	icmp_ip		icmp_dun.id_ip.idi_ip
5224812Skarels #define	icmp_mask	icmp_dun.id_mask
5327060Skarels #define	icmp_data	icmp_dun.id_data
544807Swnj };
554807Swnj 
564807Swnj /*
574807Swnj  * Lower bounds on packet lengths for various types.
584807Swnj  * For the error advice packets must first insure that the
594807Swnj  * packet is large enought to contain the returned ip header.
604807Swnj  * Only then can we do the check to see if 64 bits of packet
614807Swnj  * data have been returned, since we need to check the returned
624807Swnj  * ip header length.
634807Swnj  */
644807Swnj #define	ICMP_MINLEN	8				/* abs minimum */
654807Swnj #define	ICMP_TSLEN	(8 + 3 * sizeof (n_time))	/* timestamp */
6624812Skarels #define	ICMP_MASKLEN	12				/* address mask */
674807Swnj #define	ICMP_ADVLENMIN	(8 + sizeof (struct ip) + 8)	/* min */
686590Ssam #define	ICMP_ADVLEN(p)	(8 + ((p)->icmp_ip.ip_hl << 2) + 8)
694807Swnj 	/* N.B.: must separately check that ip_hl >= 5 */
704807Swnj 
714807Swnj /*
724807Swnj  * Definition of type and code field values.
734807Swnj  */
744807Swnj #define	ICMP_ECHOREPLY		0		/* echo reply */
754807Swnj #define	ICMP_UNREACH		3		/* dest unreachable, codes: */
764807Swnj #define		ICMP_UNREACH_NET	0		/* bad net */
774807Swnj #define		ICMP_UNREACH_HOST	1		/* bad host */
784807Swnj #define		ICMP_UNREACH_PROTOCOL	2		/* bad protocol */
794807Swnj #define		ICMP_UNREACH_PORT	3		/* bad port */
804807Swnj #define		ICMP_UNREACH_NEEDFRAG	4		/* IP_DF caused drop */
814807Swnj #define		ICMP_UNREACH_SRCFAIL	5		/* src route failed */
824807Swnj #define	ICMP_SOURCEQUENCH	4		/* packet lost, slow down */
834807Swnj #define	ICMP_REDIRECT		5		/* shorter route, codes: */
844807Swnj #define		ICMP_REDIRECT_NET	0		/* for network */
854807Swnj #define		ICMP_REDIRECT_HOST	1		/* for host */
864807Swnj #define		ICMP_REDIRECT_TOSNET	2		/* for tos and net */
874807Swnj #define		ICMP_REDIRECT_TOSHOST	3		/* for tos and host */
884807Swnj #define	ICMP_ECHO		8		/* echo service */
894807Swnj #define	ICMP_TIMXCEED		11		/* time exceeded, code: */
904807Swnj #define		ICMP_TIMXCEED_INTRANS	0		/* ttl==0 in transit */
914807Swnj #define		ICMP_TIMXCEED_REASS	1		/* ttl==0 in reass */
925172Swnj #define	ICMP_PARAMPROB		12		/* ip header bad */
934807Swnj #define	ICMP_TSTAMP		13		/* timestamp request */
944807Swnj #define	ICMP_TSTAMPREPLY	14		/* timestamp reply */
954807Swnj #define	ICMP_IREQ		15		/* information request */
964807Swnj #define	ICMP_IREQREPLY		16		/* information reply */
9724812Skarels #define	ICMP_MASKREQ		17		/* address mask request */
9824812Skarels #define	ICMP_MASKREPLY		18		/* address mask reply */
9924812Skarels 
10024812Skarels #define	ICMP_MAXTYPE		18
101