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