ip.h
001: 
002: 
003: 
004: 
005: 
006: 
007: 
008: 
009: 
010: 
011: 
012: 
013: 
014: 
015: 
016: 
017: 
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:     
066:   };
067: 
068: #ifdef __USE_BSD
069: 
070: 
071: 
072: 
073: 
074: 
075: 
076: 
077: 
078: 
079: 
080: 
081: 
082: 
083: 
084: 
085: 
086: 
087: 
088: 
089: 
090: 
091: 
092: 
093: 
094: 
095: 
096: 
097: 
098: 
099: 
100: 
101: 
102: 
103: 
104: 
105: 
106: 
107: 
108: struct ip
109:   {
110: #if __BYTE_ORDER == __LITTLE_ENDIAN
111:     unsigned int ip_hl:4;               
112:     unsigned int ip_v:4;                
113: #endif
114: #if __BYTE_ORDER == __BIG_ENDIAN
115:     unsigned int ip_v:4;                
116:     unsigned int ip_hl:4;               
117: #endif
118:     u_int8_t ip_tos;                    
119:     u_short ip_len;                     
120:     u_short ip_id;                      
121:     u_short ip_off;                     
122: #define IP_RF 0x8000                    
123: #define IP_DF 0x4000                    
124: #define IP_MF 0x2000                    
125: #define IP_OFFMASK 0x1fff               
126:     u_int8_t ip_ttl;                    
127:     u_int8_t ip_p;                      
128:     u_short ip_sum;                     
129:     struct in_addr ip_src, ip_dst;      
130:   };
131: 
132: 
133: 
134: 
135: struct ip_timestamp
136:   {
137:     u_int8_t ipt_code;                  
138:     u_int8_t ipt_len;                   
139:     u_int8_t ipt_ptr;                   
140: #if __BYTE_ORDER == __LITTLE_ENDIAN
141:     unsigned int ipt_flg:4;             
142:     unsigned int ipt_oflw:4;            
143: #endif
144: #if __BYTE_ORDER == __BIG_ENDIAN
145:     unsigned int ipt_oflw:4;            
146:     unsigned int ipt_flg:4;             
147: #endif
148:     u_int32_t data[9];
149:   };
150: #endif 
151: 
152: #define IPVERSION       4               
153: #define IP_MAXPACKET    65535           
154: 
155: 
156: 
157: 
158: 
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: 
170: 
171: 
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: 
192: 
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: 
210: 
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: 
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: 
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               
252: #define IPOPT_END               IPOPT_EOL
253: #define IPOPT_NOP               1               
254: #define IPOPT_NOOP              IPOPT_NOP
255: 
256: #define IPOPT_RR                7               
257: #define IPOPT_TS                68              
258: #define IPOPT_TIMESTAMP         IPOPT_TS
259: #define IPOPT_SECURITY          130             
260: #define IPOPT_SEC               IPOPT_SECURITY
261: #define IPOPT_LSRR              131             
262: #define IPOPT_SATID             136             
263: #define IPOPT_SID               IPOPT_SATID
264: #define IPOPT_SSRR              137             
265: #define IPOPT_RA                148             
266: 
267: 
268: 
269: 
270: #define IPOPT_OPTVAL            0               
271: #define IPOPT_OLEN              1               
272: #define IPOPT_OFFSET            2               
273: #define IPOPT_MINOFF            4               
274: 
275: #define MAX_IPOPTLEN            40
276: 
277: 
278: #define IPOPT_TS_TSONLY         0               
279: #define IPOPT_TS_TSANDADDR      1               
280: #define IPOPT_TS_PRESPEC        3               
281: 
282: 
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: 
293: 
294: #define MAXTTL          255             
295: #define IPDEFTTL        64              
296: #define IPFRAGTTL       60              
297: #define IPTTLDEC        1               
298: 
299: #define IP_MSS          576             
300: 
301: __END_DECLS
302: 
303: #endif 
304: 
      
      
      
      
   
      
      
         
            
            © Andrew Scott 2006 -
            2025, 
            All Rights Reserved