123183Smckusick /* 2*63218Sbostic * Copyright (c) 1982, 1986, 1993 3*63218Sbostic * The Regents of the University of California. All rights reserved. 423183Smckusick * 544479Sbostic * %sccs.include.redist.c% 632787Sbostic * 7*63218Sbostic * @(#)ip_icmp.h 8.1 (Berkeley) 06/10/93 823183Smckusick */ 94807Swnj 104807Swnj /* 114807Swnj * Interface Control Message Protocol Definitions. 124807Swnj * Per RFC 792, September 1981. 134807Swnj */ 144807Swnj 154807Swnj /* 164807Swnj * Structure of an icmp header. 174807Swnj */ 184807Swnj struct icmp { 194807Swnj u_char icmp_type; /* type of message, see below */ 204807Swnj u_char icmp_code; /* type sub code */ 214807Swnj u_short icmp_cksum; /* ones complement cksum of struct */ 224807Swnj union { 234807Swnj u_char ih_pptr; /* ICMP_PARAMPROB */ 244923Swnj struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ 254807Swnj struct ih_idseq { 264807Swnj n_short icd_id; 274807Swnj n_short icd_seq; 284807Swnj } ih_idseq; 296583Ssam int ih_void; 3057433Sandrew 3157433Sandrew /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ 3257433Sandrew struct ih_pmtu { 3357433Sandrew n_short ipm_void; 3457433Sandrew n_short ipm_nextmtu; 3557433Sandrew } ih_pmtu; 364807Swnj } icmp_hun; 374807Swnj #define icmp_pptr icmp_hun.ih_pptr 384807Swnj #define icmp_gwaddr icmp_hun.ih_gwaddr 394807Swnj #define icmp_id icmp_hun.ih_idseq.icd_id 404807Swnj #define icmp_seq icmp_hun.ih_idseq.icd_seq 416583Ssam #define icmp_void icmp_hun.ih_void 4257433Sandrew #define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void 4357433Sandrew #define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu 444807Swnj union { 454807Swnj struct id_ts { 464807Swnj n_time its_otime; 474807Swnj n_time its_rtime; 484807Swnj n_time its_ttime; 494807Swnj } id_ts; 504807Swnj struct id_ip { 514807Swnj struct ip idi_ip; 524807Swnj /* options and then 64 bits of data */ 534807Swnj } id_ip; 5424812Skarels u_long id_mask; 5527060Skarels char id_data[1]; 564807Swnj } icmp_dun; 574807Swnj #define icmp_otime icmp_dun.id_ts.its_otime 584807Swnj #define icmp_rtime icmp_dun.id_ts.its_rtime 594807Swnj #define icmp_ttime icmp_dun.id_ts.its_ttime 604807Swnj #define icmp_ip icmp_dun.id_ip.idi_ip 6124812Skarels #define icmp_mask icmp_dun.id_mask 6227060Skarels #define icmp_data icmp_dun.id_data 634807Swnj }; 644807Swnj 654807Swnj /* 664807Swnj * Lower bounds on packet lengths for various types. 674807Swnj * For the error advice packets must first insure that the 684807Swnj * packet is large enought to contain the returned ip header. 694807Swnj * Only then can we do the check to see if 64 bits of packet 704807Swnj * data have been returned, since we need to check the returned 714807Swnj * ip header length. 724807Swnj */ 734807Swnj #define ICMP_MINLEN 8 /* abs minimum */ 744807Swnj #define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ 7524812Skarels #define ICMP_MASKLEN 12 /* address mask */ 764807Swnj #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ 776590Ssam #define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) 784807Swnj /* N.B.: must separately check that ip_hl >= 5 */ 794807Swnj 804807Swnj /* 814807Swnj * Definition of type and code field values. 824807Swnj */ 834807Swnj #define ICMP_ECHOREPLY 0 /* echo reply */ 844807Swnj #define ICMP_UNREACH 3 /* dest unreachable, codes: */ 854807Swnj #define ICMP_UNREACH_NET 0 /* bad net */ 864807Swnj #define ICMP_UNREACH_HOST 1 /* bad host */ 874807Swnj #define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ 884807Swnj #define ICMP_UNREACH_PORT 3 /* bad port */ 894807Swnj #define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ 904807Swnj #define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ 9157433Sandrew #define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ 9257433Sandrew #define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ 9357433Sandrew #define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ 9457433Sandrew #define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */ 9557433Sandrew #define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */ 9657433Sandrew #define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ 9757433Sandrew #define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ 984807Swnj #define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ 994807Swnj #define ICMP_REDIRECT 5 /* shorter route, codes: */ 1004807Swnj #define ICMP_REDIRECT_NET 0 /* for network */ 1014807Swnj #define ICMP_REDIRECT_HOST 1 /* for host */ 1024807Swnj #define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ 1034807Swnj #define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ 1044807Swnj #define ICMP_ECHO 8 /* echo service */ 10557433Sandrew #define ICMP_ROUTERADVERT 9 /* router advertisement */ 10657433Sandrew #define ICMP_ROUTERSOLICIT 10 /* router solicitation */ 1074807Swnj #define ICMP_TIMXCEED 11 /* time exceeded, code: */ 1084807Swnj #define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ 1094807Swnj #define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ 1105172Swnj #define ICMP_PARAMPROB 12 /* ip header bad */ 11157433Sandrew #define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */ 1124807Swnj #define ICMP_TSTAMP 13 /* timestamp request */ 1134807Swnj #define ICMP_TSTAMPREPLY 14 /* timestamp reply */ 1144807Swnj #define ICMP_IREQ 15 /* information request */ 1154807Swnj #define ICMP_IREQREPLY 16 /* information reply */ 11624812Skarels #define ICMP_MASKREQ 17 /* address mask request */ 11724812Skarels #define ICMP_MASKREPLY 18 /* address mask reply */ 11824812Skarels 11924812Skarels #define ICMP_MAXTYPE 18 12031394Skarels 12131394Skarels #define ICMP_INFOTYPE(type) \ 12231394Skarels ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ 12357433Sandrew (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ 12431394Skarels (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ 12531394Skarels (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ 12631394Skarels (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) 12760637Smckusick 12860637Smckusick #ifdef KERNEL 12960637Smckusick void icmp_error __P((struct mbuf *, int, int, n_long, struct ifnet *)); 13061331Sbostic void icmp_input __P((struct mbuf *, int)); 13161331Sbostic void icmp_reflect __P((struct mbuf *)); 13261331Sbostic void icmp_send __P((struct mbuf *, struct mbuf *)); 13361331Sbostic int icmp_sysctl __P((int *, u_int, void *, size_t *, void *, size_t)); 13460637Smckusick #endif 135