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