genericopenlibs/cstdlib/LINCINET/IP.H
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /* IP.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  * Definitions for internet protocol version 4.
       
    26  * Per RFC 791, September 1981.
       
    27  */
       
    28 
       
    29 #ifndef	_NETINET_IP_H
       
    30 #define	_NETINET_IP_H
       
    31 
       
    32 #ifdef	__cplusplus
       
    33 extern "C" {
       
    34 #endif
       
    35 
       
    36 #define	IPVERSION	4
       
    37 
       
    38 /**
       
    39 Structure of an internet header, naked of options.
       
    40 
       
    41 We declare ip_len and ip_off to be short, rather than u_short
       
    42 pragmatically since otherwise unsigned comparisons can result
       
    43 against negative integers quite easily, and fail in subtle ways.
       
    44 */
       
    45 struct ip {
       
    46 #ifdef _BIT_FIELDS_LTOH
       
    47 	u_char	ip_hl:4,		/* header length */
       
    48 		ip_v:4;			/* version */
       
    49 #else
       
    50 	u_char	ip_v:4,			/* version */
       
    51 		ip_hl:4;		/* header length */
       
    52 #endif
       
    53 	u_char	ip_tos;			/* type of service */
       
    54 	short	ip_len;			/* total length */
       
    55 	u_short	ip_id;			/* identification */
       
    56 	short	ip_off;			/* fragment offset field */
       
    57 #define	IP_DF 0x4000			/* dont fragment flag */
       
    58 #define	IP_MF 0x2000			/* more fragments flag */
       
    59 	u_char	ip_ttl;			/* time to live */
       
    60 	u_char	ip_p;			/* protocol */
       
    61 	u_short	ip_sum;			/* checksum */
       
    62 	struct	in_addr ip_src, ip_dst;	/* source and dest address */
       
    63 };
       
    64 
       
    65 #define	IP_MAXPACKET	65535		/* maximum packet size */
       
    66 
       
    67 /**
       
    68 Definitions for IP type of service (ip_tos)
       
    69 */
       
    70 #define	IPTOS_LOWDELAY		0x10
       
    71 #define	IPTOS_THROUGHPUT	0x08
       
    72 #define	IPTOS_RELIABILITY	0x04
       
    73 
       
    74 /**
       
    75 Definitions for IP precedence (also in ip_tos) (hopefully unused)
       
    76 */
       
    77 #define	IPTOS_PREC_NETCONTROL		0xe0
       
    78 #define	IPTOS_PREC_INTERNETCONTROL	0xc0
       
    79 #define	IPTOS_PREC_CRITIC_ECP		0xa0
       
    80 #define	IPTOS_PREC_FLASHOVERRIDE	0x80
       
    81 #define	IPTOS_PREC_FLASH		0x60
       
    82 #define	IPTOS_PREC_IMMEDIATE		0x40
       
    83 #define	IPTOS_PREC_PRIORITY		0x20
       
    84 #define	IPTOS_PREC_ROUTINE		0x00
       
    85 
       
    86 /**
       
    87 Definitions for options.
       
    88 */
       
    89 #define	IPOPT_COPIED(o)		((o)&0x80)
       
    90 #define	IPOPT_CLASS(o)		((o)&0x60)
       
    91 #define	IPOPT_NUMBER(o)		((o)&0x1f)
       
    92 
       
    93 #define	IPOPT_CONTROL		0x00
       
    94 #define	IPOPT_RESERVED1		0x20
       
    95 #define	IPOPT_DEBMEAS		0x40
       
    96 #define	IPOPT_RESERVED2		0x60
       
    97 
       
    98 #define	IPOPT_EOL		0		/* end of option list */
       
    99 #define	IPOPT_NOP		1		/* no operation */
       
   100 
       
   101 #define	IPOPT_RR		7		/* record packet route */
       
   102 #define	IPOPT_TS		68		/* timestamp */
       
   103 #define	IPOPT_SECURITY		130		/* provide s,c,h,tcc */
       
   104 #define	IPOPT_LSRR		131		/* loose source route */
       
   105 #define	IPOPT_SATID		136		/* satnet id */
       
   106 #define	IPOPT_SSRR		137		/* strict source route */
       
   107 
       
   108 /**
       
   109 Offsets to fields in options other than EOL and NOP.
       
   110 */
       
   111 #define	IPOPT_OPTVAL		0		/* option ID */
       
   112 #define	IPOPT_OLEN		1		/* option length */
       
   113 #define	IPOPT_OFFSET		2		/* offset within option */
       
   114 #define	IPOPT_MINOFF		4		/* min value of above */
       
   115 
       
   116 /**
       
   117 Time stamp option structure.
       
   118 */
       
   119 struct	ip_timestamp {
       
   120 	u_char	ipt_code;		/* IPOPT_TS */
       
   121 	u_char	ipt_len;		/* size of structure (variable) */
       
   122 	u_char	ipt_ptr;		/* index of current entry */
       
   123 #ifdef _BIT_FIELDS_LTOH
       
   124 	u_char	ipt_flg:4,		/* flags, see below */
       
   125 		ipt_oflw:4;		/* overflow counter */
       
   126 #else
       
   127 	u_char	ipt_oflw:4,		/* overflow counter */
       
   128 		ipt_flg:4;		/* flags, see below */
       
   129 #endif
       
   130 	union ipt_timestamp {
       
   131 		n_long	ipt_time[1];
       
   132 		struct	ipt_ta {
       
   133 			struct in_addr ipt_addr;
       
   134 			n_long ipt_time;
       
   135 		} ipt_ta[1];
       
   136 	} ipt_timestamp;
       
   137 };
       
   138 
       
   139 /**
       
   140 flag bits for ipt_flg 
       
   141 */
       
   142 #define	IPOPT_TS_TSONLY		0		/* timestamps only */
       
   143 #define	IPOPT_TS_TSANDADDR	1		/* timestamps and addresses */
       
   144 #define	IPOPT_TS_PRESPEC	2		/* specified modules only */
       
   145 
       
   146 /** 
       
   147 bits for security (not byte swapped) 
       
   148 */
       
   149 #define	IPOPT_SECUR_UNCLASS	0x0000
       
   150 #define	IPOPT_SECUR_CONFID	0xf135
       
   151 #define	IPOPT_SECUR_EFTO	0x789a
       
   152 #define	IPOPT_SECUR_MMMM	0xbc4d
       
   153 #define	IPOPT_SECUR_RESTR	0xaf13
       
   154 #define	IPOPT_SECUR_SECRET	0xd788
       
   155 #define	IPOPT_SECUR_TOPSECRET	0x6bc5
       
   156 
       
   157 /**
       
   158 Internet implementation parameters.
       
   159 */
       
   160 #define	MAXTTL		255		/* maximum time to live (seconds) */
       
   161 #define	IPFRAGTTL	60		/* time to live for frags, slowhz */
       
   162 #define	IPTTLDEC	1		/* subtracted when forwarding */
       
   163 
       
   164 #define	IP_MSS		576		/* default maximum segment size */
       
   165 
       
   166 #ifdef	__cplusplus
       
   167 }
       
   168 #endif
       
   169 
       
   170 #endif	/* _NETINET_IP_H */