1*23183Smckusick /* 2*23183Smckusick * Copyright (c) 1982 Regents of the University of California. 3*23183Smckusick * All rights reserved. The Berkeley software License Agreement 4*23183Smckusick * specifies the terms and conditions for redistribution. 5*23183Smckusick * 6*23183Smckusick * @(#)ip_icmp.h 6.2 (Berkeley) 06/08/85 7*23183Smckusick */ 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; 454807Swnj } icmp_dun; 464807Swnj #define icmp_otime icmp_dun.id_ts.its_otime 474807Swnj #define icmp_rtime icmp_dun.id_ts.its_rtime 484807Swnj #define icmp_ttime icmp_dun.id_ts.its_ttime 494807Swnj #define icmp_ip icmp_dun.id_ip.idi_ip 504807Swnj }; 514807Swnj 524807Swnj /* 534807Swnj * Lower bounds on packet lengths for various types. 544807Swnj * For the error advice packets must first insure that the 554807Swnj * packet is large enought to contain the returned ip header. 564807Swnj * Only then can we do the check to see if 64 bits of packet 574807Swnj * data have been returned, since we need to check the returned 584807Swnj * ip header length. 594807Swnj */ 604807Swnj #define ICMP_MINLEN 8 /* abs minimum */ 614807Swnj #define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ 624807Swnj #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ 636590Ssam #define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) 644807Swnj /* N.B.: must separately check that ip_hl >= 5 */ 654807Swnj 664807Swnj /* 674807Swnj * Definition of type and code field values. 684807Swnj */ 694807Swnj #define ICMP_ECHOREPLY 0 /* echo reply */ 704807Swnj #define ICMP_UNREACH 3 /* dest unreachable, codes: */ 714807Swnj #define ICMP_UNREACH_NET 0 /* bad net */ 724807Swnj #define ICMP_UNREACH_HOST 1 /* bad host */ 734807Swnj #define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ 744807Swnj #define ICMP_UNREACH_PORT 3 /* bad port */ 754807Swnj #define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ 764807Swnj #define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ 774807Swnj #define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ 784807Swnj #define ICMP_REDIRECT 5 /* shorter route, codes: */ 794807Swnj #define ICMP_REDIRECT_NET 0 /* for network */ 804807Swnj #define ICMP_REDIRECT_HOST 1 /* for host */ 814807Swnj #define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ 824807Swnj #define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ 834807Swnj #define ICMP_ECHO 8 /* echo service */ 844807Swnj #define ICMP_TIMXCEED 11 /* time exceeded, code: */ 854807Swnj #define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ 864807Swnj #define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ 875172Swnj #define ICMP_PARAMPROB 12 /* ip header bad */ 884807Swnj #define ICMP_TSTAMP 13 /* timestamp request */ 894807Swnj #define ICMP_TSTAMPREPLY 14 /* timestamp reply */ 904807Swnj #define ICMP_IREQ 15 /* information request */ 914807Swnj #define ICMP_IREQREPLY 16 /* information reply */ 92