ip_icmp.h revision 53187
11541Srgrimes/* 21541Srgrimes * Copyright (c) 1982, 1986, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * Redistribution and use in source and binary forms, with or without 61541Srgrimes * modification, are permitted provided that the following conditions 71541Srgrimes * are met: 81541Srgrimes * 1. Redistributions of source code must retain the above copyright 91541Srgrimes * notice, this list of conditions and the following disclaimer. 101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111541Srgrimes * notice, this list of conditions and the following disclaimer in the 121541Srgrimes * documentation and/or other materials provided with the distribution. 131541Srgrimes * 3. All advertising materials mentioning features or use of this software 141541Srgrimes * must display the following acknowledgement: 151541Srgrimes * This product includes software developed by the University of 161541Srgrimes * California, Berkeley and its contributors. 171541Srgrimes * 4. Neither the name of the University nor the names of its contributors 181541Srgrimes * may be used to endorse or promote products derived from this software 191541Srgrimes * without specific prior written permission. 201541Srgrimes * 211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311541Srgrimes * SUCH DAMAGE. 321541Srgrimes * 331541Srgrimes * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 3450477Speter * $FreeBSD: head/sys/netinet/ip_icmp.h 53187 1999-11-15 18:27:30Z jmb $ 351541Srgrimes */ 361541Srgrimes 372169Spaul#ifndef _NETINET_IP_ICMP_H_ 382169Spaul#define _NETINET_IP_ICMP_H_ 392169Spaul 401541Srgrimes/* 411541Srgrimes * Interface Control Message Protocol Definitions. 421541Srgrimes * Per RFC 792, September 1981. 431541Srgrimes */ 441541Srgrimes 451541Srgrimes/* 4613486Sfenner * Internal of an ICMP Router Advertisement 4713486Sfenner */ 4813486Sfennerstruct icmp_ra_addr { 4913486Sfenner u_int32_t ira_addr; 5013486Sfenner u_int32_t ira_preference; 5113486Sfenner}; 5213486Sfenner 5313486Sfenner/* 541541Srgrimes * Structure of an icmp header. 551541Srgrimes */ 561541Srgrimesstruct icmp { 571541Srgrimes u_char icmp_type; /* type of message, see below */ 581541Srgrimes u_char icmp_code; /* type sub code */ 591541Srgrimes u_short icmp_cksum; /* ones complement cksum of struct */ 601541Srgrimes union { 611541Srgrimes u_char ih_pptr; /* ICMP_PARAMPROB */ 621541Srgrimes struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ 631541Srgrimes struct ih_idseq { 641541Srgrimes n_short icd_id; 651541Srgrimes n_short icd_seq; 661541Srgrimes } ih_idseq; 671541Srgrimes int ih_void; 681541Srgrimes 691541Srgrimes /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ 701541Srgrimes struct ih_pmtu { 718876Srgrimes n_short ipm_void; 721541Srgrimes n_short ipm_nextmtu; 731541Srgrimes } ih_pmtu; 7413486Sfenner 7513486Sfenner struct ih_rtradv { 7613486Sfenner u_char irt_num_addrs; 7713486Sfenner u_char irt_wpa; 7813486Sfenner u_int16_t irt_lifetime; 7913486Sfenner } ih_rtradv; 801541Srgrimes } icmp_hun; 811541Srgrimes#define icmp_pptr icmp_hun.ih_pptr 821541Srgrimes#define icmp_gwaddr icmp_hun.ih_gwaddr 831541Srgrimes#define icmp_id icmp_hun.ih_idseq.icd_id 841541Srgrimes#define icmp_seq icmp_hun.ih_idseq.icd_seq 851541Srgrimes#define icmp_void icmp_hun.ih_void 861541Srgrimes#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void 871541Srgrimes#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu 8813486Sfenner#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs 8913486Sfenner#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa 9013486Sfenner#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime 911541Srgrimes union { 921541Srgrimes struct id_ts { 931541Srgrimes n_time its_otime; 941541Srgrimes n_time its_rtime; 951541Srgrimes n_time its_ttime; 961541Srgrimes } id_ts; 971541Srgrimes struct id_ip { 981541Srgrimes struct ip idi_ip; 991541Srgrimes /* options and then 64 bits of data */ 1001541Srgrimes } id_ip; 10113486Sfenner struct icmp_ra_addr id_radv; 10237621Sbde u_int32_t id_mask; 1031541Srgrimes char id_data[1]; 1041541Srgrimes } icmp_dun; 1051541Srgrimes#define icmp_otime icmp_dun.id_ts.its_otime 1061541Srgrimes#define icmp_rtime icmp_dun.id_ts.its_rtime 1071541Srgrimes#define icmp_ttime icmp_dun.id_ts.its_ttime 1081541Srgrimes#define icmp_ip icmp_dun.id_ip.idi_ip 10913486Sfenner#define icmp_radv icmp_dun.id_radv 1101541Srgrimes#define icmp_mask icmp_dun.id_mask 1111541Srgrimes#define icmp_data icmp_dun.id_data 1121541Srgrimes}; 1131541Srgrimes 1141541Srgrimes/* 1151541Srgrimes * Lower bounds on packet lengths for various types. 1161541Srgrimes * For the error advice packets must first insure that the 11713765Smpp * packet is large enough to contain the returned ip header. 1181541Srgrimes * Only then can we do the check to see if 64 bits of packet 1191541Srgrimes * data have been returned, since we need to check the returned 1201541Srgrimes * ip header length. 1211541Srgrimes */ 1221541Srgrimes#define ICMP_MINLEN 8 /* abs minimum */ 1231541Srgrimes#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ 1241541Srgrimes#define ICMP_MASKLEN 12 /* address mask */ 1251541Srgrimes#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ 12617269Swollman#ifndef _IP_VHL 1271541Srgrimes#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) 1281541Srgrimes /* N.B.: must separately check that ip_hl >= 5 */ 12917269Swollman#else 13017269Swollman#define ICMP_ADVLEN(p) (8 + (IP_VHL_HL((p)->icmp_ip.ip_vhl) << 2) + 8) 13117269Swollman /* N.B.: must separately check that header length >= 5 */ 13217269Swollman#endif 1331541Srgrimes 1341541Srgrimes/* 1351541Srgrimes * Definition of type and code field values. 1361541Srgrimes */ 1371541Srgrimes#define ICMP_ECHOREPLY 0 /* echo reply */ 1381541Srgrimes#define ICMP_UNREACH 3 /* dest unreachable, codes: */ 1391541Srgrimes#define ICMP_UNREACH_NET 0 /* bad net */ 1401541Srgrimes#define ICMP_UNREACH_HOST 1 /* bad host */ 1411541Srgrimes#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ 1421541Srgrimes#define ICMP_UNREACH_PORT 3 /* bad port */ 1431541Srgrimes#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ 1441541Srgrimes#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ 1451541Srgrimes#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ 1461541Srgrimes#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ 1471541Srgrimes#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ 1481541Srgrimes#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */ 1491541Srgrimes#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */ 1501541Srgrimes#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ 1511541Srgrimes#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ 15217720Sfenner#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */ 15317720Sfenner#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */ 15417720Sfenner#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */ 1551541Srgrimes#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ 1561541Srgrimes#define ICMP_REDIRECT 5 /* shorter route, codes: */ 1571541Srgrimes#define ICMP_REDIRECT_NET 0 /* for network */ 1581541Srgrimes#define ICMP_REDIRECT_HOST 1 /* for host */ 1591541Srgrimes#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ 1601541Srgrimes#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ 1611541Srgrimes#define ICMP_ECHO 8 /* echo service */ 1621541Srgrimes#define ICMP_ROUTERADVERT 9 /* router advertisement */ 1631541Srgrimes#define ICMP_ROUTERSOLICIT 10 /* router solicitation */ 1641541Srgrimes#define ICMP_TIMXCEED 11 /* time exceeded, code: */ 1651541Srgrimes#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ 1661541Srgrimes#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ 1671541Srgrimes#define ICMP_PARAMPROB 12 /* ip header bad */ 16853187Sjmb#define ICMP_PARAMPROB_ERRATPTR 0 /* error at param ptr */ 1691541Srgrimes#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */ 17053187Sjmb#define ICMP_PARAMPROB_LENGTH 2 /* bad length */ 1711541Srgrimes#define ICMP_TSTAMP 13 /* timestamp request */ 1721541Srgrimes#define ICMP_TSTAMPREPLY 14 /* timestamp reply */ 1731541Srgrimes#define ICMP_IREQ 15 /* information request */ 1741541Srgrimes#define ICMP_IREQREPLY 16 /* information reply */ 1751541Srgrimes#define ICMP_MASKREQ 17 /* address mask request */ 1761541Srgrimes#define ICMP_MASKREPLY 18 /* address mask reply */ 1771541Srgrimes 1781541Srgrimes#define ICMP_MAXTYPE 18 1791541Srgrimes 1801541Srgrimes#define ICMP_INFOTYPE(type) \ 1811541Srgrimes ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ 1821541Srgrimes (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ 1831541Srgrimes (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ 1841541Srgrimes (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ 1851541Srgrimes (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) 1861541Srgrimes 1871541Srgrimes#ifdef KERNEL 1881541Srgrimesvoid icmp_error __P((struct mbuf *, int, int, n_long, struct ifnet *)); 1891541Srgrimesvoid icmp_input __P((struct mbuf *, int)); 1901541Srgrimes#endif 1912169Spaul 1922169Spaul#endif 193