ip_icmp.h revision 1541
155714Skris/* 255714Skris * Copyright (c) 1982, 1986, 1993 355714Skris * The Regents of the University of California. All rights reserved. 455714Skris * 555714Skris * Redistribution and use in source and binary forms, with or without 655714Skris * modification, are permitted provided that the following conditions 755714Skris * are met: 855714Skris * 1. Redistributions of source code must retain the above copyright 955714Skris * notice, this list of conditions and the following disclaimer. 1055714Skris * 2. Redistributions in binary form must reproduce the above copyright 1155714Skris * notice, this list of conditions and the following disclaimer in the 1255714Skris * documentation and/or other materials provided with the distribution. 1355714Skris * 3. All advertising materials mentioning features or use of this software 1455714Skris * must display the following acknowledgement: 1555714Skris * This product includes software developed by the University of 1655714Skris * California, Berkeley and its contributors. 1755714Skris * 4. Neither the name of the University nor the names of its contributors 1855714Skris * may be used to endorse or promote products derived from this software 1955714Skris * without specific prior written permission. 2055714Skris * 2155714Skris * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2255714Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2355714Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2455714Skris * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2555714Skris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2655714Skris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2755714Skris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2855714Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2955714Skris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3055714Skris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3155714Skris * SUCH DAMAGE. 3255714Skris * 3355714Skris * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 3455714Skris */ 3555714Skris 3655714Skris/* 3755714Skris * Interface Control Message Protocol Definitions. 3855714Skris * Per RFC 792, September 1981. 3955714Skris */ 4055714Skris 4155714Skris/* 4255714Skris * Structure of an icmp header. 4355714Skris */ 4455714Skrisstruct icmp { 4555714Skris u_char icmp_type; /* type of message, see below */ 4655714Skris u_char icmp_code; /* type sub code */ 4755714Skris u_short icmp_cksum; /* ones complement cksum of struct */ 4855714Skris union { 4955714Skris u_char ih_pptr; /* ICMP_PARAMPROB */ 5055714Skris struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ 5155714Skris struct ih_idseq { 5255714Skris n_short icd_id; 5355714Skris n_short icd_seq; 5455714Skris } ih_idseq; 5555714Skris int ih_void; 5655714Skris 5755714Skris /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ 58160814Ssimon struct ih_pmtu { 59238405Sjkim n_short ipm_void; 60238405Sjkim n_short ipm_nextmtu; 61238405Sjkim } ih_pmtu; 62238405Sjkim } icmp_hun; 63238405Sjkim#define icmp_pptr icmp_hun.ih_pptr 64238405Sjkim#define icmp_gwaddr icmp_hun.ih_gwaddr 65238405Sjkim#define icmp_id icmp_hun.ih_idseq.icd_id 66238405Sjkim#define icmp_seq icmp_hun.ih_idseq.icd_seq 67238405Sjkim#define icmp_void icmp_hun.ih_void 68238405Sjkim#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void 69238405Sjkim#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu 70238405Sjkim union { 71238405Sjkim struct id_ts { 72238405Sjkim n_time its_otime; 73238405Sjkim n_time its_rtime; 74238405Sjkim n_time its_ttime; 75238405Sjkim } id_ts; 76238405Sjkim struct id_ip { 77238405Sjkim struct ip idi_ip; 78238405Sjkim /* options and then 64 bits of data */ 79238405Sjkim } id_ip; 80238405Sjkim u_long id_mask; 81238405Sjkim char id_data[1]; 82238405Sjkim } icmp_dun; 83238405Sjkim#define icmp_otime icmp_dun.id_ts.its_otime 84238405Sjkim#define icmp_rtime icmp_dun.id_ts.its_rtime 85238405Sjkim#define icmp_ttime icmp_dun.id_ts.its_ttime 86238405Sjkim#define icmp_ip icmp_dun.id_ip.idi_ip 87238405Sjkim#define icmp_mask icmp_dun.id_mask 88238405Sjkim#define icmp_data icmp_dun.id_data 89238405Sjkim}; 90238405Sjkim 91238405Sjkim/* 92238405Sjkim * Lower bounds on packet lengths for various types. 93238405Sjkim * For the error advice packets must first insure that the 94238405Sjkim * packet is large enought to contain the returned ip header. 95238405Sjkim * Only then can we do the check to see if 64 bits of packet 96238405Sjkim * data have been returned, since we need to check the returned 97238405Sjkim * ip header length. 98238405Sjkim */ 99238405Sjkim#define ICMP_MINLEN 8 /* abs minimum */ 100238405Sjkim#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ 101238405Sjkim#define ICMP_MASKLEN 12 /* address mask */ 102238405Sjkim#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ 103238405Sjkim#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) 104238405Sjkim /* N.B.: must separately check that ip_hl >= 5 */ 105238405Sjkim 106238405Sjkim/* 107238405Sjkim * Definition of type and code field values. 108238405Sjkim */ 109238405Sjkim#define ICMP_ECHOREPLY 0 /* echo reply */ 110238405Sjkim#define ICMP_UNREACH 3 /* dest unreachable, codes: */ 111238405Sjkim#define ICMP_UNREACH_NET 0 /* bad net */ 112160814Ssimon#define ICMP_UNREACH_HOST 1 /* bad host */ 113160814Ssimon#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ 114160814Ssimon#define ICMP_UNREACH_PORT 3 /* bad port */ 115160814Ssimon#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ 116160814Ssimon#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ 117160814Ssimon#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ 118160814Ssimon#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ 119160814Ssimon#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ 120160814Ssimon#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */ 121160814Ssimon#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */ 122160814Ssimon#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ 123160814Ssimon#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ 12455714Skris#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ 12555714Skris#define ICMP_REDIRECT 5 /* shorter route, codes: */ 12655714Skris#define ICMP_REDIRECT_NET 0 /* for network */ 12755714Skris#define ICMP_REDIRECT_HOST 1 /* for host */ 128109998Smarkm#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ 129109998Smarkm#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ 13055714Skris#define ICMP_ECHO 8 /* echo service */ 13155714Skris#define ICMP_ROUTERADVERT 9 /* router advertisement */ 132160814Ssimon#define ICMP_ROUTERSOLICIT 10 /* router solicitation */ 133238405Sjkim#define ICMP_TIMXCEED 11 /* time exceeded, code: */ 13455714Skris#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ 13555714Skris#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ 13655714Skris#define ICMP_PARAMPROB 12 /* ip header bad */ 13755714Skris#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */ 13855714Skris#define ICMP_TSTAMP 13 /* timestamp request */ 139160814Ssimon#define ICMP_TSTAMPREPLY 14 /* timestamp reply */ 140160814Ssimon#define ICMP_IREQ 15 /* information request */ 141160814Ssimon#define ICMP_IREQREPLY 16 /* information reply */ 142160814Ssimon#define ICMP_MASKREQ 17 /* address mask request */ 143160814Ssimon#define ICMP_MASKREPLY 18 /* address mask reply */ 144160814Ssimon 145160814Ssimon#define ICMP_MAXTYPE 18 146160814Ssimon 147160814Ssimon#define ICMP_INFOTYPE(type) \ 148160814Ssimon ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ 149160814Ssimon (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ 15055714Skris (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ 151238405Sjkim (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ 15255714Skris (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) 15355714Skris 15455714Skris#ifdef KERNEL 155238405Sjkimvoid icmp_error __P((struct mbuf *, int, int, n_long, struct ifnet *)); 15655714Skrisvoid icmp_input __P((struct mbuf *, int)); 15755714Skrisvoid icmp_reflect __P((struct mbuf *)); 15855714Skrisvoid icmp_send __P((struct mbuf *, struct mbuf *)); 15955714Skrisint icmp_sysctl __P((int *, u_int, void *, size_t *, void *, size_t)); 16055714Skris#endif 16155714Skris