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