os/ossrv/genericopenlibs/cstdlib/LINCINET/IP_ICMP.H
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LINCINET/IP_ICMP.H	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,133 @@
     1.4 +/* IP_ICMP.H
     1.5 + * 
     1.6 + * Portions Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
     1.7 + * All rights reserved.
     1.8 + */
     1.9 + 
    1.10 +/** @file
    1.11 +@publishedAll
    1.12 +@released
    1.13 +*/
    1.14 +
    1.15 +/*
    1.16 + * Copyright (c) 1982, 1986 Regents of the University of California.
    1.17 + * All rights reserved.
    1.18 + *
    1.19 + * Redistribution and use in source and binary forms are permitted
    1.20 + * provided that this notice is preserved and that due credit is given
    1.21 + * to the University of California at Berkeley. The name of the University
    1.22 + * may not be used to endorse or promote products derived from this
    1.23 + * software without specific prior written permission. This software
    1.24 + * is provided ``as is'' without express or implied warranty.
    1.25 + */
    1.26 +
    1.27 +/*
    1.28 + * Interface Control Message Protocol Definitions.
    1.29 + * Per RFC 792, September 1981.
    1.30 + */
    1.31 +
    1.32 +#ifndef	_NETINET_IP_ICMP_H
    1.33 +#define	_NETINET_IP_ICMP_H
    1.34 +
    1.35 +#ifdef	__cplusplus
    1.36 +extern "C" {
    1.37 +#endif
    1.38 +
    1.39 +/**
    1.40 +Structure of an icmp header.
    1.41 +*/
    1.42 +struct icmp {
    1.43 +	u_char	icmp_type;		/* type of message, see below */
    1.44 +	u_char	icmp_code;		/* type sub code */
    1.45 +	u_short	icmp_cksum;		/* ones complement cksum of struct */
    1.46 +	union {
    1.47 +		u_char ih_pptr;			/* ICMP_PARAMPROB */
    1.48 +		struct in_addr ih_gwaddr;	/* ICMP_REDIRECT */
    1.49 +		struct ih_idseq {
    1.50 +			n_short	icd_id;
    1.51 +			n_short	icd_seq;
    1.52 +		} ih_idseq;
    1.53 +		int ih_void;
    1.54 +	} icmp_hun;
    1.55 +#define	icmp_pptr	icmp_hun.ih_pptr
    1.56 +#define	icmp_gwaddr	icmp_hun.ih_gwaddr
    1.57 +#define	icmp_id		icmp_hun.ih_idseq.icd_id
    1.58 +#define	icmp_seq	icmp_hun.ih_idseq.icd_seq
    1.59 +#define	icmp_void	icmp_hun.ih_void
    1.60 +	union {
    1.61 +		struct id_ts {
    1.62 +			n_time its_otime;
    1.63 +			n_time its_rtime;
    1.64 +			n_time its_ttime;
    1.65 +		} id_ts;
    1.66 +		struct id_ip  {
    1.67 +			struct ip idi_ip;
    1.68 +			/* options and then 64 bits of data */
    1.69 +		} id_ip;
    1.70 +		u_long	id_mask;
    1.71 +		char	id_data[1];
    1.72 +	} icmp_dun;
    1.73 +#define	icmp_otime	icmp_dun.id_ts.its_otime
    1.74 +#define	icmp_rtime	icmp_dun.id_ts.its_rtime
    1.75 +#define	icmp_ttime	icmp_dun.id_ts.its_ttime
    1.76 +#define	icmp_ip		icmp_dun.id_ip.idi_ip
    1.77 +#define	icmp_mask	icmp_dun.id_mask
    1.78 +#define	icmp_data	icmp_dun.id_data
    1.79 +};
    1.80 +
    1.81 +/**
    1.82 +Lower bounds on packet lengths for various types.
    1.83 +For the error advice packets must first insure that the
    1.84 +packet is large enought to contain the returned ip header.
    1.85 +Only then can we do the check to see if 64 bits of packet
    1.86 +data have been returned, since we need to check the returned
    1.87 +ip header length.
    1.88 +*/
    1.89 +#define	ICMP_MINLEN	8				/* abs minimum */
    1.90 +#define	ICMP_TSLEN	(8 + 3 * sizeof (n_time))	/* timestamp */
    1.91 +#define	ICMP_MASKLEN	12				/* address mask */
    1.92 +#define	ICMP_ADVLENMIN	(8 + sizeof (struct ip) + 8)	/* min */
    1.93 +#define	ICMP_ADVLEN(p)	(8 + ((p)->icmp_ip.ip_hl << 2) + 8)
    1.94 +	/* N.B.: must separately check that ip_hl >= 5 */
    1.95 +
    1.96 +/**
    1.97 +Definition of type and code field values.
    1.98 +*/
    1.99 +#define	ICMP_ECHOREPLY		0		/* echo reply */
   1.100 +#define	ICMP_UNREACH		3		/* dest unreachable, codes: */
   1.101 +#define		ICMP_UNREACH_NET	0		/* bad net */
   1.102 +#define		ICMP_UNREACH_HOST	1		/* bad host */
   1.103 +#define		ICMP_UNREACH_PROTOCOL	2		/* bad protocol */
   1.104 +#define		ICMP_UNREACH_PORT	3		/* bad port */
   1.105 +#define		ICMP_UNREACH_NEEDFRAG	4		/* IP_DF caused drop */
   1.106 +#define		ICMP_UNREACH_SRCFAIL	5		/* src route failed */
   1.107 +#define	ICMP_SOURCEQUENCH	4		/* packet lost, slow down */
   1.108 +#define	ICMP_REDIRECT		5		/* shorter route, codes: */
   1.109 +#define		ICMP_REDIRECT_NET	0		/* for network */
   1.110 +#define		ICMP_REDIRECT_HOST	1		/* for host */
   1.111 +#define		ICMP_REDIRECT_TOSNET	2		/* for tos and net */
   1.112 +#define		ICMP_REDIRECT_TOSHOST	3		/* for tos and host */
   1.113 +#define	ICMP_ECHO		8		/* echo service */
   1.114 +#define	ICMP_TIMXCEED		11		/* time exceeded, code: */
   1.115 +#define		ICMP_TIMXCEED_INTRANS	0		/* ttl==0 in transit */
   1.116 +#define		ICMP_TIMXCEED_REASS	1		/* ttl==0 in reass */
   1.117 +#define	ICMP_PARAMPROB		12		/* ip header bad */
   1.118 +#define	ICMP_TSTAMP		13		/* timestamp request */
   1.119 +#define	ICMP_TSTAMPREPLY	14		/* timestamp reply */
   1.120 +#define	ICMP_IREQ		15		/* information request */
   1.121 +#define	ICMP_IREQREPLY		16		/* information reply */
   1.122 +#define	ICMP_MASKREQ		17		/* address mask request */
   1.123 +#define	ICMP_MASKREPLY		18		/* address mask reply */
   1.124 +#define	ICMP_MAXTYPE		18
   1.125 +
   1.126 +#define	ICMP_INFOTYPE(type) \
   1.127 +	((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
   1.128 +	(type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
   1.129 +	(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
   1.130 +	(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
   1.131 +
   1.132 +#ifdef	__cplusplus
   1.133 +}
   1.134 +#endif
   1.135 +
   1.136 +#endif	/* _NETINET_IP_ICMP_H */