123183Smckusick /* 223183Smckusick * Copyright (c) 1982 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*24812Skarels * @(#)ip_icmp.h 6.3 (Berkeley) 09/16/85 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; 45*24812Skarels u_long id_mask; 464807Swnj } icmp_dun; 474807Swnj #define icmp_otime icmp_dun.id_ts.its_otime 484807Swnj #define icmp_rtime icmp_dun.id_ts.its_rtime 494807Swnj #define icmp_ttime icmp_dun.id_ts.its_ttime 504807Swnj #define icmp_ip icmp_dun.id_ip.idi_ip 51*24812Skarels #define icmp_mask icmp_dun.id_mask 524807Swnj }; 534807Swnj 544807Swnj /* 554807Swnj * Lower bounds on packet lengths for various types. 564807Swnj * For the error advice packets must first insure that the 574807Swnj * packet is large enought to contain the returned ip header. 584807Swnj * Only then can we do the check to see if 64 bits of packet 594807Swnj * data have been returned, since we need to check the returned 604807Swnj * ip header length. 614807Swnj */ 624807Swnj #define ICMP_MINLEN 8 /* abs minimum */ 634807Swnj #define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ 64*24812Skarels #define ICMP_MASKLEN 12 /* address mask */ 654807Swnj #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ 666590Ssam #define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) 674807Swnj /* N.B.: must separately check that ip_hl >= 5 */ 684807Swnj 694807Swnj /* 704807Swnj * Definition of type and code field values. 714807Swnj */ 724807Swnj #define ICMP_ECHOREPLY 0 /* echo reply */ 734807Swnj #define ICMP_UNREACH 3 /* dest unreachable, codes: */ 744807Swnj #define ICMP_UNREACH_NET 0 /* bad net */ 754807Swnj #define ICMP_UNREACH_HOST 1 /* bad host */ 764807Swnj #define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ 774807Swnj #define ICMP_UNREACH_PORT 3 /* bad port */ 784807Swnj #define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ 794807Swnj #define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ 804807Swnj #define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ 814807Swnj #define ICMP_REDIRECT 5 /* shorter route, codes: */ 824807Swnj #define ICMP_REDIRECT_NET 0 /* for network */ 834807Swnj #define ICMP_REDIRECT_HOST 1 /* for host */ 844807Swnj #define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ 854807Swnj #define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ 864807Swnj #define ICMP_ECHO 8 /* echo service */ 874807Swnj #define ICMP_TIMXCEED 11 /* time exceeded, code: */ 884807Swnj #define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ 894807Swnj #define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ 905172Swnj #define ICMP_PARAMPROB 12 /* ip header bad */ 914807Swnj #define ICMP_TSTAMP 13 /* timestamp request */ 924807Swnj #define ICMP_TSTAMPREPLY 14 /* timestamp reply */ 934807Swnj #define ICMP_IREQ 15 /* information request */ 944807Swnj #define ICMP_IREQREPLY 16 /* information reply */ 95*24812Skarels #define ICMP_MASKREQ 17 /* address mask request */ 96*24812Skarels #define ICMP_MASKREPLY 18 /* address mask reply */ 97*24812Skarels 98*24812Skarels #define ICMP_MAXTYPE 18 99