123183Smckusick /* 229142Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 3*32787Sbostic * All rights reserved. 423183Smckusick * 5*32787Sbostic * Redistribution and use in source and binary forms are permitted 6*32787Sbostic * provided that this notice is preserved and that due credit is given 7*32787Sbostic * to the University of California at Berkeley. The name of the University 8*32787Sbostic * may not be used to endorse or promote products derived from this 9*32787Sbostic * software without specific prior written permission. This software 10*32787Sbostic * is provided ``as is'' without express or implied warranty. 11*32787Sbostic * 12*32787Sbostic * @(#)ip_icmp.h 7.3 (Berkeley) 12/07/87 1323183Smckusick */ 144807Swnj 154807Swnj /* 164807Swnj * Interface Control Message Protocol Definitions. 174807Swnj * Per RFC 792, September 1981. 184807Swnj */ 194807Swnj 204807Swnj /* 214807Swnj * Structure of an icmp header. 224807Swnj */ 234807Swnj struct icmp { 244807Swnj u_char icmp_type; /* type of message, see below */ 254807Swnj u_char icmp_code; /* type sub code */ 264807Swnj u_short icmp_cksum; /* ones complement cksum of struct */ 274807Swnj union { 284807Swnj u_char ih_pptr; /* ICMP_PARAMPROB */ 294923Swnj struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ 304807Swnj struct ih_idseq { 314807Swnj n_short icd_id; 324807Swnj n_short icd_seq; 334807Swnj } ih_idseq; 346583Ssam int ih_void; 354807Swnj } icmp_hun; 364807Swnj #define icmp_pptr icmp_hun.ih_pptr 374807Swnj #define icmp_gwaddr icmp_hun.ih_gwaddr 384807Swnj #define icmp_id icmp_hun.ih_idseq.icd_id 394807Swnj #define icmp_seq icmp_hun.ih_idseq.icd_seq 406583Ssam #define icmp_void icmp_hun.ih_void 414807Swnj union { 424807Swnj struct id_ts { 434807Swnj n_time its_otime; 444807Swnj n_time its_rtime; 454807Swnj n_time its_ttime; 464807Swnj } id_ts; 474807Swnj struct id_ip { 484807Swnj struct ip idi_ip; 494807Swnj /* options and then 64 bits of data */ 504807Swnj } id_ip; 5124812Skarels u_long id_mask; 5227060Skarels char id_data[1]; 534807Swnj } icmp_dun; 544807Swnj #define icmp_otime icmp_dun.id_ts.its_otime 554807Swnj #define icmp_rtime icmp_dun.id_ts.its_rtime 564807Swnj #define icmp_ttime icmp_dun.id_ts.its_ttime 574807Swnj #define icmp_ip icmp_dun.id_ip.idi_ip 5824812Skarels #define icmp_mask icmp_dun.id_mask 5927060Skarels #define icmp_data icmp_dun.id_data 604807Swnj }; 614807Swnj 624807Swnj /* 634807Swnj * Lower bounds on packet lengths for various types. 644807Swnj * For the error advice packets must first insure that the 654807Swnj * packet is large enought to contain the returned ip header. 664807Swnj * Only then can we do the check to see if 64 bits of packet 674807Swnj * data have been returned, since we need to check the returned 684807Swnj * ip header length. 694807Swnj */ 704807Swnj #define ICMP_MINLEN 8 /* abs minimum */ 714807Swnj #define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ 7224812Skarels #define ICMP_MASKLEN 12 /* address mask */ 734807Swnj #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ 746590Ssam #define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) 754807Swnj /* N.B.: must separately check that ip_hl >= 5 */ 764807Swnj 774807Swnj /* 784807Swnj * Definition of type and code field values. 794807Swnj */ 804807Swnj #define ICMP_ECHOREPLY 0 /* echo reply */ 814807Swnj #define ICMP_UNREACH 3 /* dest unreachable, codes: */ 824807Swnj #define ICMP_UNREACH_NET 0 /* bad net */ 834807Swnj #define ICMP_UNREACH_HOST 1 /* bad host */ 844807Swnj #define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ 854807Swnj #define ICMP_UNREACH_PORT 3 /* bad port */ 864807Swnj #define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ 874807Swnj #define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ 884807Swnj #define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ 894807Swnj #define ICMP_REDIRECT 5 /* shorter route, codes: */ 904807Swnj #define ICMP_REDIRECT_NET 0 /* for network */ 914807Swnj #define ICMP_REDIRECT_HOST 1 /* for host */ 924807Swnj #define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ 934807Swnj #define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ 944807Swnj #define ICMP_ECHO 8 /* echo service */ 954807Swnj #define ICMP_TIMXCEED 11 /* time exceeded, code: */ 964807Swnj #define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ 974807Swnj #define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ 985172Swnj #define ICMP_PARAMPROB 12 /* ip header bad */ 994807Swnj #define ICMP_TSTAMP 13 /* timestamp request */ 1004807Swnj #define ICMP_TSTAMPREPLY 14 /* timestamp reply */ 1014807Swnj #define ICMP_IREQ 15 /* information request */ 1024807Swnj #define ICMP_IREQREPLY 16 /* information reply */ 10324812Skarels #define ICMP_MASKREQ 17 /* address mask request */ 10424812Skarels #define ICMP_MASKREPLY 18 /* address mask reply */ 10524812Skarels 10624812Skarels #define ICMP_MAXTYPE 18 10731394Skarels 10831394Skarels #define ICMP_INFOTYPE(type) \ 10931394Skarels ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ 11031394Skarels (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ 11131394Skarels (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ 11231394Skarels (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) 113