os/ossrv/genericopenlibs/cstdlib/LINCINET/IP_ICMP.H
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/* IP_ICMP.H
sl@0
     2
 * 
sl@0
     3
 * Portions Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     4
 * All rights reserved.
sl@0
     5
 */
sl@0
     6
 
sl@0
     7
/** @file
sl@0
     8
@publishedAll
sl@0
     9
@released
sl@0
    10
*/
sl@0
    11
sl@0
    12
/*
sl@0
    13
 * Copyright (c) 1982, 1986 Regents of the University of California.
sl@0
    14
 * All rights reserved.
sl@0
    15
 *
sl@0
    16
 * Redistribution and use in source and binary forms are permitted
sl@0
    17
 * provided that this notice is preserved and that due credit is given
sl@0
    18
 * to the University of California at Berkeley. The name of the University
sl@0
    19
 * may not be used to endorse or promote products derived from this
sl@0
    20
 * software without specific prior written permission. This software
sl@0
    21
 * is provided ``as is'' without express or implied warranty.
sl@0
    22
 */
sl@0
    23
sl@0
    24
/*
sl@0
    25
 * Interface Control Message Protocol Definitions.
sl@0
    26
 * Per RFC 792, September 1981.
sl@0
    27
 */
sl@0
    28
sl@0
    29
#ifndef	_NETINET_IP_ICMP_H
sl@0
    30
#define	_NETINET_IP_ICMP_H
sl@0
    31
sl@0
    32
#ifdef	__cplusplus
sl@0
    33
extern "C" {
sl@0
    34
#endif
sl@0
    35
sl@0
    36
/**
sl@0
    37
Structure of an icmp header.
sl@0
    38
*/
sl@0
    39
struct icmp {
sl@0
    40
	u_char	icmp_type;		/* type of message, see below */
sl@0
    41
	u_char	icmp_code;		/* type sub code */
sl@0
    42
	u_short	icmp_cksum;		/* ones complement cksum of struct */
sl@0
    43
	union {
sl@0
    44
		u_char ih_pptr;			/* ICMP_PARAMPROB */
sl@0
    45
		struct in_addr ih_gwaddr;	/* ICMP_REDIRECT */
sl@0
    46
		struct ih_idseq {
sl@0
    47
			n_short	icd_id;
sl@0
    48
			n_short	icd_seq;
sl@0
    49
		} ih_idseq;
sl@0
    50
		int ih_void;
sl@0
    51
	} icmp_hun;
sl@0
    52
#define	icmp_pptr	icmp_hun.ih_pptr
sl@0
    53
#define	icmp_gwaddr	icmp_hun.ih_gwaddr
sl@0
    54
#define	icmp_id		icmp_hun.ih_idseq.icd_id
sl@0
    55
#define	icmp_seq	icmp_hun.ih_idseq.icd_seq
sl@0
    56
#define	icmp_void	icmp_hun.ih_void
sl@0
    57
	union {
sl@0
    58
		struct id_ts {
sl@0
    59
			n_time its_otime;
sl@0
    60
			n_time its_rtime;
sl@0
    61
			n_time its_ttime;
sl@0
    62
		} id_ts;
sl@0
    63
		struct id_ip  {
sl@0
    64
			struct ip idi_ip;
sl@0
    65
			/* options and then 64 bits of data */
sl@0
    66
		} id_ip;
sl@0
    67
		u_long	id_mask;
sl@0
    68
		char	id_data[1];
sl@0
    69
	} icmp_dun;
sl@0
    70
#define	icmp_otime	icmp_dun.id_ts.its_otime
sl@0
    71
#define	icmp_rtime	icmp_dun.id_ts.its_rtime
sl@0
    72
#define	icmp_ttime	icmp_dun.id_ts.its_ttime
sl@0
    73
#define	icmp_ip		icmp_dun.id_ip.idi_ip
sl@0
    74
#define	icmp_mask	icmp_dun.id_mask
sl@0
    75
#define	icmp_data	icmp_dun.id_data
sl@0
    76
};
sl@0
    77
sl@0
    78
/**
sl@0
    79
Lower bounds on packet lengths for various types.
sl@0
    80
For the error advice packets must first insure that the
sl@0
    81
packet is large enought to contain the returned ip header.
sl@0
    82
Only then can we do the check to see if 64 bits of packet
sl@0
    83
data have been returned, since we need to check the returned
sl@0
    84
ip header length.
sl@0
    85
*/
sl@0
    86
#define	ICMP_MINLEN	8				/* abs minimum */
sl@0
    87
#define	ICMP_TSLEN	(8 + 3 * sizeof (n_time))	/* timestamp */
sl@0
    88
#define	ICMP_MASKLEN	12				/* address mask */
sl@0
    89
#define	ICMP_ADVLENMIN	(8 + sizeof (struct ip) + 8)	/* min */
sl@0
    90
#define	ICMP_ADVLEN(p)	(8 + ((p)->icmp_ip.ip_hl << 2) + 8)
sl@0
    91
	/* N.B.: must separately check that ip_hl >= 5 */
sl@0
    92
sl@0
    93
/**
sl@0
    94
Definition of type and code field values.
sl@0
    95
*/
sl@0
    96
#define	ICMP_ECHOREPLY		0		/* echo reply */
sl@0
    97
#define	ICMP_UNREACH		3		/* dest unreachable, codes: */
sl@0
    98
#define		ICMP_UNREACH_NET	0		/* bad net */
sl@0
    99
#define		ICMP_UNREACH_HOST	1		/* bad host */
sl@0
   100
#define		ICMP_UNREACH_PROTOCOL	2		/* bad protocol */
sl@0
   101
#define		ICMP_UNREACH_PORT	3		/* bad port */
sl@0
   102
#define		ICMP_UNREACH_NEEDFRAG	4		/* IP_DF caused drop */
sl@0
   103
#define		ICMP_UNREACH_SRCFAIL	5		/* src route failed */
sl@0
   104
#define	ICMP_SOURCEQUENCH	4		/* packet lost, slow down */
sl@0
   105
#define	ICMP_REDIRECT		5		/* shorter route, codes: */
sl@0
   106
#define		ICMP_REDIRECT_NET	0		/* for network */
sl@0
   107
#define		ICMP_REDIRECT_HOST	1		/* for host */
sl@0
   108
#define		ICMP_REDIRECT_TOSNET	2		/* for tos and net */
sl@0
   109
#define		ICMP_REDIRECT_TOSHOST	3		/* for tos and host */
sl@0
   110
#define	ICMP_ECHO		8		/* echo service */
sl@0
   111
#define	ICMP_TIMXCEED		11		/* time exceeded, code: */
sl@0
   112
#define		ICMP_TIMXCEED_INTRANS	0		/* ttl==0 in transit */
sl@0
   113
#define		ICMP_TIMXCEED_REASS	1		/* ttl==0 in reass */
sl@0
   114
#define	ICMP_PARAMPROB		12		/* ip header bad */
sl@0
   115
#define	ICMP_TSTAMP		13		/* timestamp request */
sl@0
   116
#define	ICMP_TSTAMPREPLY	14		/* timestamp reply */
sl@0
   117
#define	ICMP_IREQ		15		/* information request */
sl@0
   118
#define	ICMP_IREQREPLY		16		/* information reply */
sl@0
   119
#define	ICMP_MASKREQ		17		/* address mask request */
sl@0
   120
#define	ICMP_MASKREPLY		18		/* address mask reply */
sl@0
   121
#define	ICMP_MAXTYPE		18
sl@0
   122
sl@0
   123
#define	ICMP_INFOTYPE(type) \
sl@0
   124
	((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
sl@0
   125
	(type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
sl@0
   126
	(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
sl@0
   127
	(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
sl@0
   128
sl@0
   129
#ifdef	__cplusplus
sl@0
   130
}
sl@0
   131
#endif
sl@0
   132
sl@0
   133
#endif	/* _NETINET_IP_ICMP_H */