epoc32/include/libc/netinet/ip.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000 (2010-03-16)
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 /* IP.H
     2  * 
     3  * Portions copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
     4  */
     5 
     6 /** @file
     7 @publishedAll
     8 @released
     9 */
    10 
    11 /*
    12  * Copyright (c) 1982, 1986 Regents of the University of California.
    13  * All rights reserved.
    14  *
    15  * Redistribution and use in source and binary forms are permitted
    16  * provided that this notice is preserved and that due credit is given
    17  * to the University of California at Berkeley. The name of the University
    18  * may not be used to endorse or promote products derived from this
    19  * software without specific prior written permission. This software
    20  * is provided ``as is'' without express or implied warranty.
    21  */
    22 
    23 /*
    24  * Definitions for internet protocol version 4.
    25  * Per RFC 791, September 1981.
    26  */
    27 
    28 #ifndef	_NETINET_IP_H
    29 #define	_NETINET_IP_H
    30 
    31 #include <libc\netinet\net_types.h>
    32 #include <libc\netinet\in.h>
    33 
    34 #ifdef	__cplusplus
    35 extern "C" {
    36 #endif
    37 
    38 #define	IPVERSION	4
    39 
    40 /**
    41 Structure of an internet header, naked of options.
    42 
    43 We declare ip_len and ip_off to be short, rather than u_short
    44 pragmatically since otherwise unsigned comparisons can result
    45 against negative integers quite easily, and fail in subtle ways.
    46 */
    47 struct ip {
    48 #ifdef _BIT_FIELDS_LTOH
    49 	u_char	ip_hl:4,		/* header length */
    50 		ip_v:4;			/* version */
    51 #else
    52 	u_char	ip_v:4,			/* version */
    53 		ip_hl:4;		/* header length */
    54 #endif
    55 	u_char	ip_tos;			/* type of service */
    56 	short	ip_len;			/* total length */
    57 	u_short	ip_id;			/* identification */
    58 	short	ip_off;			/* fragment offset field */
    59 #define	IP_DF 0x4000			/* dont fragment flag */
    60 #define	IP_MF 0x2000			/* more fragments flag */
    61 	u_char	ip_ttl;			/* time to live */
    62 	u_char	ip_p;			/* protocol */
    63 	u_short	ip_sum;			/* checksum */
    64 	struct	in_addr ip_src, ip_dst;	/* source and dest address */
    65 };
    66 
    67 #define	IP_MAXPACKET	65535		/* maximum packet size */
    68 
    69 /**
    70 Definitions for IP type of service (ip_tos)
    71 */
    72 #define	IPTOS_LOWDELAY		0x10
    73 #define	IPTOS_THROUGHPUT	0x08
    74 #define	IPTOS_RELIABILITY	0x04
    75 
    76 /**
    77 Definitions for IP precedence (also in ip_tos) (hopefully unused)
    78 */
    79 #define	IPTOS_PREC_NETCONTROL		0xe0
    80 #define	IPTOS_PREC_INTERNETCONTROL	0xc0
    81 #define	IPTOS_PREC_CRITIC_ECP		0xa0
    82 #define	IPTOS_PREC_FLASHOVERRIDE	0x80
    83 #define	IPTOS_PREC_FLASH		0x60
    84 #define	IPTOS_PREC_IMMEDIATE		0x40
    85 #define	IPTOS_PREC_PRIORITY		0x20
    86 #define	IPTOS_PREC_ROUTINE		0x00
    87 
    88 /**
    89 Definitions for options.
    90 */
    91 #define	IPOPT_COPIED(o)		((o)&0x80)
    92 #define	IPOPT_CLASS(o)		((o)&0x60)
    93 #define	IPOPT_NUMBER(o)		((o)&0x1f)
    94 
    95 #define	IPOPT_CONTROL		0x00
    96 #define	IPOPT_RESERVED1		0x20
    97 #define	IPOPT_DEBMEAS		0x40
    98 #define	IPOPT_RESERVED2		0x60
    99 
   100 #define	IPOPT_EOL		0		/* end of option list */
   101 #define	IPOPT_NOP		1		/* no operation */
   102 
   103 #define	IPOPT_RR		7		/* record packet route */
   104 #define	IPOPT_TS		68		/* timestamp */
   105 #define	IPOPT_SECURITY		130		/* provide s,c,h,tcc */
   106 #define	IPOPT_LSRR		131		/* loose source route */
   107 #define	IPOPT_SATID		136		/* satnet id */
   108 #define	IPOPT_SSRR		137		/* strict source route */
   109 
   110 /**
   111 Offsets to fields in options other than EOL and NOP.
   112 */
   113 #define	IPOPT_OPTVAL		0		/* option ID */
   114 #define	IPOPT_OLEN		1		/* option length */
   115 #define	IPOPT_OFFSET		2		/* offset within option */
   116 #define	IPOPT_MINOFF		4		/* min value of above */
   117 
   118 /**
   119 Time stamp option structure.
   120 */
   121 struct	ip_timestamp {
   122 	u_char	ipt_code;		/* IPOPT_TS */
   123 	u_char	ipt_len;		/* size of structure (variable) */
   124 	u_char	ipt_ptr;		/* index of current entry */
   125 #ifdef _BIT_FIELDS_LTOH
   126 	u_char	ipt_flg:4,		/* flags, see below */
   127 		ipt_oflw:4;		/* overflow counter */
   128 #else
   129 	u_char	ipt_oflw:4,		/* overflow counter */
   130 		ipt_flg:4;		/* flags, see below */
   131 #endif
   132 	union ipt_timestamp {
   133 		n_long	ipt_time[1];
   134 		struct	ipt_ta {
   135 			struct in_addr ipt_addr;
   136 			n_long ipt_time;
   137 		} ipt_ta[1];
   138 	} ipt_timestamp;
   139 };
   140 
   141 /**
   142 flag bits for ipt_flg 
   143 */
   144 #define	IPOPT_TS_TSONLY		0		/* timestamps only */
   145 #define	IPOPT_TS_TSANDADDR	1		/* timestamps and addresses */
   146 #define	IPOPT_TS_PRESPEC	2		/* specified modules only */
   147 
   148 /** 
   149 bits for security (not byte swapped) 
   150 */
   151 #define	IPOPT_SECUR_UNCLASS	0x0000
   152 #define	IPOPT_SECUR_CONFID	0xf135
   153 #define	IPOPT_SECUR_EFTO	0x789a
   154 #define	IPOPT_SECUR_MMMM	0xbc4d
   155 #define	IPOPT_SECUR_RESTR	0xaf13
   156 #define	IPOPT_SECUR_SECRET	0xd788
   157 #define	IPOPT_SECUR_TOPSECRET	0x6bc5
   158 
   159 /**
   160 Internet implementation parameters.
   161 */
   162 #define	MAXTTL		255		/* maximum time to live (seconds) */
   163 #define	IPFRAGTTL	60		/* time to live for frags, slowhz */
   164 #define	IPTTLDEC	1		/* subtracted when forwarding */
   165 
   166 #define	IP_MSS		576		/* default maximum segment size */
   167 
   168 #ifdef	__cplusplus
   169 }
   170 #endif
   171 
   172 #endif	/* _NETINET_IP_H */