netwerk/sctp/src/user_ip_icmp.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/sctp/src/user_ip_icmp.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,223 @@
     1.4 +/*-
     1.5 + * Copyright (c) 1982, 1986, 1993
     1.6 + *	The Regents of the University of California.  All rights reserved.
     1.7 + *
     1.8 + * Redistribution and use in source and binary forms, with or without
     1.9 + * modification, are permitted provided that the following conditions
    1.10 + * are met:
    1.11 + * 1. Redistributions of source code must retain the above copyright
    1.12 + *    notice, this list of conditions and the following disclaimer.
    1.13 + * 2. Redistributions in binary form must reproduce the above copyright
    1.14 + *    notice, this list of conditions and the following disclaimer in the
    1.15 + *    documentation and/or other materials provided with the distribution.
    1.16 + * 4. Neither the name of the University nor the names of its contributors
    1.17 + *    may be used to endorse or promote products derived from this software
    1.18 + *    without specific prior written permission.
    1.19 + *
    1.20 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    1.21 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.22 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.23 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    1.24 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    1.25 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    1.26 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    1.27 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    1.28 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    1.29 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.30 + * SUCH DAMAGE.
    1.31 + *
    1.32 + */
    1.33 +
    1.34 +#ifndef _USER_IP_ICMP_H_
    1.35 +#define _USER_IP_ICMP_H_
    1.36 +
    1.37 +/*
    1.38 + * Interface Control Message Protocol Definitions.
    1.39 + * Per RFC 792, September 1981.
    1.40 + */
    1.41 +
    1.42 +/*
    1.43 + * Internal of an ICMP Router Advertisement
    1.44 + */
    1.45 +struct icmp_ra_addr {
    1.46 +	u_int32_t ira_addr;
    1.47 +	u_int32_t ira_preference;
    1.48 +};
    1.49 +
    1.50 +/*
    1.51 + * Structure of an icmp header.
    1.52 + */
    1.53 +struct icmphdr {
    1.54 +	u_char	icmp_type;		/* type of message, see below */
    1.55 +	u_char	icmp_code;		/* type sub code */
    1.56 +	u_short	icmp_cksum;		/* ones complement cksum of struct */
    1.57 +};
    1.58 +
    1.59 +#if defined(__Userspace_os_Windows)
    1.60 +struct icmp6_hdr {
    1.61 +	u_int8_t icmp6_type;
    1.62 +	u_int8_t icmp6_code;
    1.63 +	u_int16_t icmp6_cksum;
    1.64 +	union {
    1.65 +		u_int32_t icmp6_un_data32[1];
    1.66 +		u_int16_t icmp6_un_data16[2];
    1.67 +		u_int8_t icmp6_un_data8[4];
    1.68 +	} icmp6_dataun;
    1.69 +} __packed;
    1.70 +
    1.71 +#define icmp6_data32 icmp6_dataun.icmp6_un_data32
    1.72 +#define icmp6_mtu icmp6_data32[0]
    1.73 +#endif
    1.74 +
    1.75 +/*
    1.76 + * Structure of an icmp packet.
    1.77 + *
    1.78 + * XXX: should start with a struct icmphdr.
    1.79 + */
    1.80 +struct icmp {
    1.81 +	u_char	icmp_type;		/* type of message, see below */
    1.82 +	u_char	icmp_code;		/* type sub code */
    1.83 +	u_short	icmp_cksum;		/* ones complement cksum of struct */
    1.84 +	union {
    1.85 +		u_char ih_pptr;			/* ICMP_PARAMPROB */
    1.86 +		struct in_addr ih_gwaddr;	/* ICMP_REDIRECT */
    1.87 +		struct ih_idseq {
    1.88 +			uint16_t	icd_id;	/* network format */
    1.89 +			uint16_t	icd_seq; /* network format */
    1.90 +		} ih_idseq;
    1.91 +		int ih_void;
    1.92 +
    1.93 +		/* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
    1.94 +		struct ih_pmtu {
    1.95 +			uint16_t ipm_void;	/* network format */
    1.96 +			uint16_t ipm_nextmtu;	/* network format */
    1.97 +		} ih_pmtu;
    1.98 +
    1.99 +		struct ih_rtradv {
   1.100 +			u_char irt_num_addrs;
   1.101 +			u_char irt_wpa;
   1.102 +			u_int16_t irt_lifetime;
   1.103 +		} ih_rtradv;
   1.104 +	} icmp_hun;
   1.105 +#define	icmp_pptr	icmp_hun.ih_pptr
   1.106 +#define	icmp_gwaddr	icmp_hun.ih_gwaddr
   1.107 +#define	icmp_id		icmp_hun.ih_idseq.icd_id
   1.108 +#define	icmp_seq	icmp_hun.ih_idseq.icd_seq
   1.109 +#define	icmp_void	icmp_hun.ih_void
   1.110 +#define	icmp_pmvoid	icmp_hun.ih_pmtu.ipm_void
   1.111 +#define	icmp_nextmtu	icmp_hun.ih_pmtu.ipm_nextmtu
   1.112 +#define	icmp_num_addrs	icmp_hun.ih_rtradv.irt_num_addrs
   1.113 +#define	icmp_wpa	icmp_hun.ih_rtradv.irt_wpa
   1.114 +#define	icmp_lifetime	icmp_hun.ih_rtradv.irt_lifetime
   1.115 +	union {
   1.116 +		struct id_ts {			/* ICMP Timestamp */
   1.117 +			/*
   1.118 +			 * The next 3 fields are in network format,
   1.119 +			 * milliseconds since 00:00 GMT
   1.120 +			 */
   1.121 +			uint32_t its_otime;	/* Originate */
   1.122 +			uint32_t its_rtime;	/* Receive */
   1.123 +			uint32_t its_ttime;	/* Transmit */
   1.124 +		} id_ts;
   1.125 +		struct id_ip  {
   1.126 +			struct ip idi_ip;
   1.127 +			/* options and then 64 bits of data */
   1.128 +		} id_ip;
   1.129 +		struct icmp_ra_addr id_radv;
   1.130 +		u_int32_t id_mask;
   1.131 +		char	id_data[1];
   1.132 +	} icmp_dun;
   1.133 +#define	icmp_otime	icmp_dun.id_ts.its_otime
   1.134 +#define	icmp_rtime	icmp_dun.id_ts.its_rtime
   1.135 +#define	icmp_ttime	icmp_dun.id_ts.its_ttime
   1.136 +#define	icmp_ip		icmp_dun.id_ip.idi_ip
   1.137 +#define	icmp_radv	icmp_dun.id_radv
   1.138 +#define	icmp_mask	icmp_dun.id_mask
   1.139 +#define	icmp_data	icmp_dun.id_data
   1.140 +};
   1.141 +
   1.142 +/*
   1.143 + * Lower bounds on packet lengths for various types.
   1.144 + * For the error advice packets must first insure that the
   1.145 + * packet is large enough to contain the returned ip header.
   1.146 + * Only then can we do the check to see if 64 bits of packet
   1.147 + * data have been returned, since we need to check the returned
   1.148 + * ip header length.
   1.149 + */
   1.150 +#define	ICMP_MINLEN	8				/* abs minimum */
   1.151 +#define	ICMP_TSLEN	(8 + 3 * sizeof (uint32_t))	/* timestamp */
   1.152 +#define	ICMP_MASKLEN	12				/* address mask */
   1.153 +#define	ICMP_ADVLENMIN	(8 + sizeof (struct ip) + 8)	/* min */
   1.154 +#define	ICMP_ADVLEN(p)	(8 + ((p)->icmp_ip.ip_hl << 2) + 8)
   1.155 +	/* N.B.: must separately check that ip_hl >= 5 */
   1.156 +
   1.157 +/*
   1.158 + * Definition of type and code field values.
   1.159 + */
   1.160 +#define	ICMP_ECHOREPLY		0		/* echo reply */
   1.161 +#define	ICMP_UNREACH		3		/* dest unreachable, codes: */
   1.162 +#define		ICMP_UNREACH_NET	0		/* bad net */
   1.163 +#define		ICMP_UNREACH_HOST	1		/* bad host */
   1.164 +#define		ICMP_UNREACH_PROTOCOL	2		/* bad protocol */
   1.165 +#define		ICMP_UNREACH_PORT	3		/* bad port */
   1.166 +#define		ICMP_UNREACH_NEEDFRAG	4		/* IP_DF caused drop */
   1.167 +#define		ICMP_UNREACH_SRCFAIL	5		/* src route failed */
   1.168 +#define		ICMP_UNREACH_NET_UNKNOWN 6		/* unknown net */
   1.169 +#define		ICMP_UNREACH_HOST_UNKNOWN 7		/* unknown host */
   1.170 +#define		ICMP_UNREACH_ISOLATED	8		/* src host isolated */
   1.171 +#define		ICMP_UNREACH_NET_PROHIB	9		/* prohibited access */
   1.172 +#define		ICMP_UNREACH_HOST_PROHIB 10		/* ditto */
   1.173 +#define		ICMP_UNREACH_TOSNET	11		/* bad tos for net */
   1.174 +#define		ICMP_UNREACH_TOSHOST	12		/* bad tos for host */
   1.175 +#define		ICMP_UNREACH_FILTER_PROHIB 13		/* admin prohib */
   1.176 +#define		ICMP_UNREACH_HOST_PRECEDENCE 14		/* host prec vio. */
   1.177 +#define		ICMP_UNREACH_PRECEDENCE_CUTOFF 15	/* prec cutoff */
   1.178 +#define	ICMP_SOURCEQUENCH	4		/* packet lost, slow down */
   1.179 +#define	ICMP_REDIRECT		5		/* shorter route, codes: */
   1.180 +#define		ICMP_REDIRECT_NET	0		/* for network */
   1.181 +#define		ICMP_REDIRECT_HOST	1		/* for host */
   1.182 +#define		ICMP_REDIRECT_TOSNET	2		/* for tos and net */
   1.183 +#define		ICMP_REDIRECT_TOSHOST	3		/* for tos and host */
   1.184 +#define	ICMP_ALTHOSTADDR	6		/* alternate host address */
   1.185 +#define	ICMP_ECHO		8		/* echo service */
   1.186 +#define	ICMP_ROUTERADVERT	9		/* router advertisement */
   1.187 +#define		ICMP_ROUTERADVERT_NORMAL		0	/* normal advertisement */
   1.188 +#define		ICMP_ROUTERADVERT_NOROUTE_COMMON	16	/* selective routing */
   1.189 +#define	ICMP_ROUTERSOLICIT	10		/* router solicitation */
   1.190 +#define	ICMP_TIMXCEED		11		/* time exceeded, code: */
   1.191 +#define		ICMP_TIMXCEED_INTRANS	0		/* ttl==0 in transit */
   1.192 +#define		ICMP_TIMXCEED_REASS	1		/* ttl==0 in reass */
   1.193 +#define	ICMP_PARAMPROB		12		/* ip header bad */
   1.194 +#define		ICMP_PARAMPROB_ERRATPTR 0		/* error at param ptr */
   1.195 +#define		ICMP_PARAMPROB_OPTABSENT 1		/* req. opt. absent */
   1.196 +#define		ICMP_PARAMPROB_LENGTH 2			/* bad length */
   1.197 +#define	ICMP_TSTAMP		13		/* timestamp request */
   1.198 +#define	ICMP_TSTAMPREPLY	14		/* timestamp reply */
   1.199 +#define	ICMP_IREQ		15		/* information request */
   1.200 +#define	ICMP_IREQREPLY		16		/* information reply */
   1.201 +#define	ICMP_MASKREQ		17		/* address mask request */
   1.202 +#define	ICMP_MASKREPLY		18		/* address mask reply */
   1.203 +#define	ICMP_TRACEROUTE		30		/* traceroute */
   1.204 +#define	ICMP_DATACONVERR	31		/* data conversion error */
   1.205 +#define	ICMP_MOBILE_REDIRECT	32		/* mobile host redirect */
   1.206 +#define	ICMP_IPV6_WHEREAREYOU	33		/* IPv6 where-are-you */
   1.207 +#define	ICMP_IPV6_IAMHERE	34		/* IPv6 i-am-here */
   1.208 +#define	ICMP_MOBILE_REGREQUEST	35		/* mobile registration req */
   1.209 +#define	ICMP_MOBILE_REGREPLY	36		/* mobile registration reply */
   1.210 +#define	ICMP_SKIP		39		/* SKIP */
   1.211 +#define	ICMP_PHOTURIS		40		/* Photuris */
   1.212 +#define		ICMP_PHOTURIS_UNKNOWN_INDEX	1	/* unknown sec index */
   1.213 +#define		ICMP_PHOTURIS_AUTH_FAILED	2	/* auth failed */
   1.214 +#define		ICMP_PHOTURIS_DECRYPT_FAILED	3	/* decrypt failed */
   1.215 +
   1.216 +#define	ICMP_MAXTYPE		40
   1.217 +
   1.218 +#define	ICMP_INFOTYPE(type) \
   1.219 +	((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
   1.220 +	(type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
   1.221 +	(type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
   1.222 +	(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
   1.223 +	(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
   1.224 +
   1.225 +
   1.226 +#endif

mercurial