3 * Portions Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
13 * Copyright (c) 1982, 1986 Regents of the University of California.
14 * All rights reserved.
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.
25 * Definitions for internet protocol version 4.
26 * Per RFC 791, September 1981.
39 Structure of an internet header, naked of options.
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.
46 #ifdef _BIT_FIELDS_LTOH
47 u_char ip_hl:4, /* header length */
50 u_char ip_v:4, /* version */
51 ip_hl:4; /* header length */
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 */
65 #define IP_MAXPACKET 65535 /* maximum packet size */
68 Definitions for IP type of service (ip_tos)
70 #define IPTOS_LOWDELAY 0x10
71 #define IPTOS_THROUGHPUT 0x08
72 #define IPTOS_RELIABILITY 0x04
75 Definitions for IP precedence (also in ip_tos) (hopefully unused)
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
87 Definitions for options.
89 #define IPOPT_COPIED(o) ((o)&0x80)
90 #define IPOPT_CLASS(o) ((o)&0x60)
91 #define IPOPT_NUMBER(o) ((o)&0x1f)
93 #define IPOPT_CONTROL 0x00
94 #define IPOPT_RESERVED1 0x20
95 #define IPOPT_DEBMEAS 0x40
96 #define IPOPT_RESERVED2 0x60
98 #define IPOPT_EOL 0 /* end of option list */
99 #define IPOPT_NOP 1 /* no operation */
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 */
109 Offsets to fields in options other than EOL and NOP.
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 */
117 Time stamp option structure.
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 */
127 u_char ipt_oflw:4, /* overflow counter */
128 ipt_flg:4; /* flags, see below */
130 union ipt_timestamp {
133 struct in_addr ipt_addr;
140 flag bits for ipt_flg
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 */
147 bits for security (not byte swapped)
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
158 Internet implementation parameters.
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 */
164 #define IP_MSS 576 /* default maximum segment size */
170 #endif /* _NETINET_IP_H */