Dr Andrew Scott G7VAV

My photo
 
May 2024
Mo Tu We Th Fr Sa Su
29 30 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31 1 2
3 4 5 6 7 8 9


ip.h
001: /* Copyright (C) 1991-1993,1995-2000,2009,2010 Free Software Foundation, Inc.
002:    This file is part of the GNU C Library.
003: 
004:    The GNU C Library is free software; you can redistribute it and/or
005:    modify it under the terms of the GNU Lesser General Public
006:    License as published by the Free Software Foundation; either
007:    version 2.1 of the License, or (at your option) any later version.
008: 
009:    The GNU C Library is distributed in the hope that it will be useful,
010:    but WITHOUT ANY WARRANTY; without even the implied warranty of
011:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:    Lesser General Public License for more details.
013: 
014:    You should have received a copy of the GNU Lesser General Public
015:    License along with the GNU C Library; if not, write to the Free
016:    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
017:    02111-1307 USA.  */
018: 
019: #ifndef __NETINET_IP_H
020: #define __NETINET_IP_H 1
021: 
022: #include <features.h>
023: #include <sys/types.h>
024: 
025: #include <netinet/in.h>
026: 
027: __BEGIN_DECLS
028: 
029: struct timestamp
030:   {
031:     u_int8_t len;
032:     u_int8_t ptr;
033: #if __BYTE_ORDER == __LITTLE_ENDIAN
034:     unsigned int flags:4;
035:     unsigned int overflow:4;
036: #elif __BYTE_ORDER == __BIG_ENDIAN
037:     unsigned int overflow:4;
038:     unsigned int flags:4;
039: #else
040: # error "Please fix <bits/endian.h>"
041: #endif
042:     u_int32_t data[9];
043:   };
044: 
045: struct iphdr
046:   {
047: #if __BYTE_ORDER == __LITTLE_ENDIAN
048:     unsigned int ihl:4;
049:     unsigned int version:4;
050: #elif __BYTE_ORDER == __BIG_ENDIAN
051:     unsigned int version:4;
052:     unsigned int ihl:4;
053: #else
054: # error "Please fix <bits/endian.h>"
055: #endif
056:     u_int8_t tos;
057:     u_int16_t tot_len;
058:     u_int16_t id;
059:     u_int16_t frag_off;
060:     u_int8_t ttl;
061:     u_int8_t protocol;
062:     u_int16_t check;
063:     u_int32_t saddr;
064:     u_int32_t daddr;
065:     /*The options start here. */
066:   };
067: 
068: #ifdef __USE_BSD
069: /*
070:  * Copyright (c) 1982, 1986, 1993
071:  *      The Regents of the University of California.  All rights reserved.
072:  *
073:  * Redistribution and use in source and binary forms, with or without
074:  * modification, are permitted provided that the following conditions
075:  * are met:
076:  * 1. Redistributions of source code must retain the above copyright
077:  *    notice, this list of conditions and the following disclaimer.
078:  * 2. Redistributions in binary form must reproduce the above copyright
079:  *    notice, this list of conditions and the following disclaimer in the
080:  *    documentation and/or other materials provided with the distribution.
081:  * 4. Neither the name of the University nor the names of its contributors
082:  *    may be used to endorse or promote products derived from this software
083:  *    without specific prior written permission.
084:  *
085:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
086:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
087:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
088:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
089:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
090:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
091:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
092:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
093:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
094:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
095:  * SUCH DAMAGE.
096:  *
097:  *      @(#)ip.h        8.1 (Berkeley) 6/10/93
098:  */
099: 
100: /*
101:  * Definitions for internet protocol version 4.
102:  * Per RFC 791, September 1981.
103:  */
104: 
105: /*
106:  * Structure of an internet header, naked of options.
107:  */
108: struct ip
109:   {
110: #if __BYTE_ORDER == __LITTLE_ENDIAN
111:     unsigned int ip_hl:4;               /* header length */
112:     unsigned int ip_v:4;                /* version */
113: #endif
114: #if __BYTE_ORDER == __BIG_ENDIAN
115:     unsigned int ip_v:4;                /* version */
116:     unsigned int ip_hl:4;               /* header length */
117: #endif
118:     u_int8_t ip_tos;                    /* type of service */
119:     u_short ip_len;                     /* total length */
120:     u_short ip_id;                      /* identification */
121:     u_short ip_off;                     /* fragment offset field */
122: #define IP_RF 0x8000                    /* reserved fragment flag */
123: #define IP_DF 0x4000                    /* dont fragment flag */
124: #define IP_MF 0x2000                    /* more fragments flag */
125: #define IP_OFFMASK 0x1fff               /* mask for fragmenting bits */
126:     u_int8_t ip_ttl;                    /* time to live */
127:     u_int8_t ip_p;                      /* protocol */
128:     u_short ip_sum;                     /* checksum */
129:     struct in_addr ip_src, ip_dst;      /* source and dest address */
130:   };
131: 
132: /*
133:  * Time stamp option structure.
134:  */
135: struct ip_timestamp
136:   {
137:     u_int8_t ipt_code;                  /* IPOPT_TS */
138:     u_int8_t ipt_len;                   /* size of structure (variable) */
139:     u_int8_t ipt_ptr;                   /* index of current entry */
140: #if __BYTE_ORDER == __LITTLE_ENDIAN
141:     unsigned int ipt_flg:4;             /* flags, see below */
142:     unsigned int ipt_oflw:4;            /* overflow counter */
143: #endif
144: #if __BYTE_ORDER == __BIG_ENDIAN
145:     unsigned int ipt_oflw:4;            /* overflow counter */
146:     unsigned int ipt_flg:4;             /* flags, see below */
147: #endif
148:     u_int32_t data[9];
149:   };
150: #endif /* __USE_BSD */
151: 
152: #define IPVERSION       4               /* IP version number */
153: #define IP_MAXPACKET    65535           /* maximum packet size */
154: 
155: /*
156:  * Definitions for Explicit Congestion Notification (ECN)
157:  *
158:  * Taken from RFC-3168, Section 5.
159:  */
160: 
161: #define IPTOS_ECN_MASK          0x03
162: #define IPTOS_ECN(x)            ((x) & IPTOS_ECN_MASK)
163: #define IPTOS_ECN_NOT_ECT       0x00
164: #define IPTOS_ECN_ECT1          0x01
165: #define IPTOS_ECN_ECT0          0x02
166: #define IPTOS_ECN_CE            0x03
167: 
168: /*
169:  * Definitions for IP differentiated services code points (DSCP)
170:  *
171:  * Taken from RFC-2597, Section 6 and RFC-2598, Section 2.3.
172:  */
173: 
174: #define IPTOS_DSCP_MASK         0xfc
175: #define IPTOS_DSCP(x)           ((x) & IPTOS_DSCP_MASK)
176: #define IPTOS_DSCP_AF11         0x28
177: #define IPTOS_DSCP_AF12         0x30
178: #define IPTOS_DSCP_AF13         0x38
179: #define IPTOS_DSCP_AF21         0x48
180: #define IPTOS_DSCP_AF22         0x50
181: #define IPTOS_DSCP_AF23         0x58
182: #define IPTOS_DSCP_AF31         0x68
183: #define IPTOS_DSCP_AF32         0x70
184: #define IPTOS_DSCP_AF33         0x78
185: #define IPTOS_DSCP_AF41         0x88
186: #define IPTOS_DSCP_AF42         0x90
187: #define IPTOS_DSCP_AF43         0x98
188: #define IPTOS_DSCP_EF           0xb8
189: 
190: /*
191:  * In RFC 2474, Section 4.2.2.1, the Class Selector Codepoints subsume
192:  * the old ToS Precedence values.
193:  */
194: 
195: #define IPTOS_CLASS_MASK                0xe0
196: #define IPTOS_CLASS(class)              ((class) & IPTOS_CLASS_MASK)
197: #define IPTOS_CLASS_CS0                 0x00
198: #define IPTOS_CLASS_CS1                 0x20
199: #define IPTOS_CLASS_CS2                 0x40
200: #define IPTOS_CLASS_CS3                 0x60
201: #define IPTOS_CLASS_CS4                 0x80
202: #define IPTOS_CLASS_CS5                 0xa0
203: #define IPTOS_CLASS_CS6                 0xc0
204: #define IPTOS_CLASS_CS7                 0xe0
205: 
206: #define IPTOS_CLASS_DEFAULT             IPTOS_CLASS_CS0
207: 
208: /*
209:  * Definitions for IP type of service (ip_tos) [deprecated; use DSCP
210:  * and CS definitions above instead.]
211:  */
212: #define IPTOS_TOS_MASK          0x1E
213: #define IPTOS_TOS(tos)          ((tos) & IPTOS_TOS_MASK)
214: #define IPTOS_LOWDELAY          0x10
215: #define IPTOS_THROUGHPUT        0x08
216: #define IPTOS_RELIABILITY       0x04
217: #define IPTOS_LOWCOST           0x02
218: #define IPTOS_MINCOST           IPTOS_LOWCOST
219: 
220: /*
221:  * Definitions for IP precedence (also in ip_tos) [also deprecated.]
222:  */
223: #define IPTOS_PREC_MASK                 IPTOS_CLASS_MASK
224: #define IPTOS_PREC(tos)                 IPTOS_CLASS(tos)
225: #define IPTOS_PREC_NETCONTROL           IPTOS_CLASS_CS7
226: #define IPTOS_PREC_INTERNETCONTROL      IPTOS_CLASS_CS6
227: #define IPTOS_PREC_CRITIC_ECP           IPTOS_CLASS_CS5
228: #define IPTOS_PREC_FLASHOVERRIDE        IPTOS_CLASS_CS4
229: #define IPTOS_PREC_FLASH                IPTOS_CLASS_CS3
230: #define IPTOS_PREC_IMMEDIATE            IPTOS_CLASS_CS2
231: #define IPTOS_PREC_PRIORITY             IPTOS_CLASS_CS1
232: #define IPTOS_PREC_ROUTINE              IPTOS_CLASS_CS0
233: 
234: /*
235:  * Definitions for options.
236:  */
237: #define IPOPT_COPY              0x80
238: #define IPOPT_CLASS_MASK        0x60
239: #define IPOPT_NUMBER_MASK       0x1f
240: 
241: #define IPOPT_COPIED(o)         ((o) & IPOPT_COPY)
242: #define IPOPT_CLASS(o)          ((o) & IPOPT_CLASS_MASK)
243: #define IPOPT_NUMBER(o)         ((o) & IPOPT_NUMBER_MASK)
244: 
245: #define IPOPT_CONTROL           0x00
246: #define IPOPT_RESERVED1         0x20
247: #define IPOPT_DEBMEAS           0x40
248: #define IPOPT_MEASUREMENT       IPOPT_DEBMEAS
249: #define IPOPT_RESERVED2         0x60
250: 
251: #define IPOPT_EOL               0               /* end of option list */
252: #define IPOPT_END               IPOPT_EOL
253: #define IPOPT_NOP               1               /* no operation */
254: #define IPOPT_NOOP              IPOPT_NOP
255: 
256: #define IPOPT_RR                7               /* record packet route */
257: #define IPOPT_TS                68              /* timestamp */
258: #define IPOPT_TIMESTAMP         IPOPT_TS
259: #define IPOPT_SECURITY          130             /* provide s,c,h,tcc */
260: #define IPOPT_SEC               IPOPT_SECURITY
261: #define IPOPT_LSRR              131             /* loose source route */
262: #define IPOPT_SATID             136             /* satnet id */
263: #define IPOPT_SID               IPOPT_SATID
264: #define IPOPT_SSRR              137             /* strict source route */
265: #define IPOPT_RA                148             /* router alert */
266: 
267: /*
268:  * Offsets to fields in options other than EOL and NOP.
269:  */
270: #define IPOPT_OPTVAL            0               /* option ID */
271: #define IPOPT_OLEN              1               /* option length */
272: #define IPOPT_OFFSET            2               /* offset within option */
273: #define IPOPT_MINOFF            4               /* min value of above */
274: 
275: #define MAX_IPOPTLEN            40
276: 
277: /* flag bits for ipt_flg */
278: #define IPOPT_TS_TSONLY         0               /* timestamps only */
279: #define IPOPT_TS_TSANDADDR      1               /* timestamps and addresses */
280: #define IPOPT_TS_PRESPEC        3               /* specified modules only */
281: 
282: /* bits for security (not byte swapped) */
283: #define IPOPT_SECUR_UNCLASS     0x0000
284: #define IPOPT_SECUR_CONFID      0xf135
285: #define IPOPT_SECUR_EFTO        0x789a
286: #define IPOPT_SECUR_MMMM        0xbc4d
287: #define IPOPT_SECUR_RESTR       0xaf13
288: #define IPOPT_SECUR_SECRET      0xd788
289: #define IPOPT_SECUR_TOPSECRET   0x6bc5
290: 
291: /*
292:  * Internet implementation parameters.
293:  */
294: #define MAXTTL          255             /* maximum time to live (seconds) */
295: #define IPDEFTTL        64              /* default ttl, from RFC 1340 */
296: #define IPFRAGTTL       60              /* time to live for frags, slowhz */
297: #define IPTTLDEC        1               /* subtracted when forwarding */
298: 
299: #define IP_MSS          576             /* default maximum segment size */
300: 
301: __END_DECLS
302: 
303: #endif /* netinet/ip.h */
304: 


for client 18.221.165.246
© Andrew Scott 2006 - 2024,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/