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