Rev 4707 | Rev 4721 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4707 | Rev 4710 | ||
---|---|---|---|
Line 37... | Line 37... | ||
37 | #ifndef __NET_IP_CLIENT_H__ |
37 | #ifndef __NET_IP_CLIENT_H__ |
38 | #define __NET_IP_CLIENT_H__ |
38 | #define __NET_IP_CLIENT_H__ |
39 | 39 | ||
40 | #include <sys/types.h> |
40 | #include <sys/types.h> |
41 | 41 | ||
42 | typedef uint8_t ip_ttl_t; |
- | |
43 | typedef uint8_t ip_tos_t; |
- | |
44 | typedef uint8_t ip_protocol_t; |
- | |
45 | - | ||
46 | #include "../structures/packet/packet.h" |
42 | #include "../structures/packet/packet.h" |
47 | 43 | ||
48 | #define IPVERSION 4 |
- | |
49 | #define MAXTTL 255 |
- | |
50 | #define IPDEFTTL 64 |
44 | #include "ip_codes.h" |
51 | - | ||
52 | #define IPTOS_TOS_MASK 0x1E |
- | |
53 | #define IPTOS_PRECEDENCE_SHIFT 5 |
- | |
54 | #define IPTOS_DELAY_SHIFT 4 |
- | |
55 | #define IPTOS_THROUGHPUT_SHIFT 3 |
- | |
56 | #define IPTOS_RELIABILITY_SHIFT 2 |
- | |
57 | #define IPTOS_COST_SHIFT 1 |
- | |
58 | - | ||
59 | #define IPTOS_NORMALDELAY ( 0x0 << IPTOS_DELAY_SHIFT ) |
- | |
60 | #define IPTOS_LOWDELAY ( 0x1 << IPTOS_DELAY_SHIFT ) |
- | |
61 | - | ||
62 | #define IPTOS_NORMALTHROUGHPUT ( 0x0 << IPTOS_THROUGHPUT_SHIFT ) |
- | |
63 | #define IPTOS_THROUGHPUT ( 0x1 << IPTOS_THROUGHPUT_SHIFT ) |
- | |
64 | - | ||
65 | #define IPTOS_NORMALRELIABILITY ( 0x0 << IPTOS_RELIABILITY_SHIFT ) |
- | |
66 | #define IPTOS_RELIABILITY ( 0x1 << IPTOS_RELIABILITY_SHIFT ) |
- | |
67 | - | ||
68 | #define IPTOS_NORMALCOST ( 0x0 << IPTOS_COST_SHIFT ) |
- | |
69 | #define IPTOS_MICNCOST ( 0x1 << IPTOS_COST_SHIFT ) |
- | |
70 | - | ||
71 | #define IPTOS_PREC_MASK 0xE0 |
- | |
72 | #define IPTOS_PREC_ROUTINE ( 0x0 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
73 | #define IPTOS_PREC_PRIORITY ( 0x1 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
74 | #define IPTOS_PREC_IMMEDIATE ( 0x2 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
75 | #define IPTOS_PREC_FLASH ( 0x3 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
76 | #define IPTOS_PREC_FLASHOVERRIDE ( 0x4 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
77 | #define IPTOS_PREC_CRITIC_ECP ( 0x5 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
78 | #define IPTOS_PREC_INTERNETCONTROL ( 0x6 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
79 | #define IPTOS_PREC_NETCONTROL ( 0x7 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
80 | - | ||
81 | #define IPOPT_COPY_SHIFT 7 |
- | |
82 | #define IPOPT_CLASS_SHIFT 5 |
- | |
83 | #define IPOPT_NUMBER_SHIFT 0 |
- | |
84 | #define IPOPT_CLASS_MASK 0x60 |
- | |
85 | #define IPOPT_NUMBER_MASK 0x1F |
- | |
86 | - | ||
87 | #define IPOPT_COPY ( 1 << IPOPT_COPY_SHIFT ) |
- | |
88 | - | ||
89 | #define IPOPT_TYPE( copy, class, number ) ((( copy ) & IPOPT_COPY ) | (( class ) & IPOPT_CLASS_MASK ) | (( number << IPOPT_NUMBER_SHIFT ) & IPOPT_NUMBER_MASK )) |
- | |
90 | - | ||
91 | #define IPOPT_COPIED( o ) (( o ) & IPOPT_COPY ) |
- | |
92 | #define IPOPT_CLASS( o ) (( o ) & IPOPT_CLASS_MASK ) |
- | |
93 | #define IPOPT_NUMBER( o ) (( o ) & IPOPT_NUMBER_MASK ) |
- | |
94 | - | ||
95 | #define IPOPT_CONTROL ( 0 << IPOPT_CLASS_SHIFT ) |
- | |
96 | #define IPOPT_RESERVED1 ( 1 << IPOPT_CLASS_SHIFT ) |
- | |
97 | #define IPOPT_MEASUREMENT ( 2 << IPOPT_CLASS_SHIFT ) |
- | |
98 | #define IPOPT_RESERVED2 ( 3 << IPOPT_CLASS_SHIFT ) |
- | |
99 | - | ||
100 | //#define IPOPT_END_OF_LIST 0x0 |
- | |
101 | #define IPOPT_END IPOPT_TYPE( 0, IPOPT_CONTROL, 0 ) |
- | |
102 | //#define IPOPT_NO_OPERATION 0x1 |
- | |
103 | #define IPOPT_NOOP IPOPT_TYPE( 0, IPOPT_CONTROL, 1 ) |
- | |
104 | //#define IPOPT_SECURITY 0x82 |
- | |
105 | #define IPOPT_SEC IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 2 ) |
- | |
106 | #define IPOPT_SEC_LENGTH 11 |
- | |
107 | #define IPOPT_SEC_UNCLASIFIED 0x0 |
- | |
108 | #define IPOPT_SEC_CONFIDENTIAL 0xF035 |
- | |
109 | #define IPOPT_SEC_EFTO 0x789A |
- | |
110 | #define IPOPT_SEC_MMMM 0xBC4D |
- | |
111 | #define IPOPT_SEC_PROG 0x5E26 |
- | |
112 | #define IPOPT_SEC_RESTRICTED 0xAF13 |
- | |
113 | #define IPOPT_SEC_SECRET 0xD788 |
- | |
114 | #define IPOPT_SEC_TOP_SECRET 0x6BC5 |
- | |
115 | //#define IPOPT_LOOSE_SOURCE 0x83 |
- | |
116 | #define IPOPT_LSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 3 ) |
- | |
117 | //#define IPOPT_STRICT_SOURCE 0x89 |
- | |
118 | #define IPOPT_SSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 9 ) |
- | |
119 | //#define IPOPT_RECORD_ROUTE 0x07 |
- | |
120 | #define IPOPT_RR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 7 ) |
- | |
121 | //#define IPOPT_STREAM_IDENTIFIER 0x88 |
- | |
122 | #define IPOPT_SID IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 8 ) |
- | |
123 | #define IPOPT_SID_LENGTH 4 |
- | |
124 | //#define IPOPT_INTERNET_TIMESTAMP 0x44 |
- | |
125 | #define IPOPT_TIMESTAMP IPOPT_TYPE( IPOPT_COPY, IPOPT_MEASUREMENT, 4 ) |
- | |
126 | #define IPOPT_CIPSO IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 5 ) |
- | |
127 | - | ||
128 | #define IPOPT_NOP IPOPT_NOOP |
- | |
129 | #define IPOPT_EOL IPOPT_END |
- | |
130 | #define IPOPT_TS IPOPT_TIMESTAMP |
- | |
131 | - | ||
132 | #define IPOPT_TS_TSONLY 0 /* timestamps only */ |
- | |
133 | #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ |
- | |
134 | #define IPOPT_TS_PRESPEC 3 /* specified modules only */ |
- | |
135 | 45 | ||
136 | int ip_client_prepare_packet( packet_t packet, ip_protocol_t protocol, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, size_t ipopt_length ); |
46 | int ip_client_prepare_packet( packet_t packet, ip_protocol_t protocol, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, size_t ipopt_length ); |
137 | 47 | ||
138 | int ip_client_process_packet( packet_t packet, ip_protocol_t * protocol, ip_ttl_t * ttl, ip_tos_t * tos, int * dont_fragment, size_t * ipopt_length ); |
48 | int ip_client_process_packet( packet_t packet, ip_protocol_t * protocol, ip_ttl_t * ttl, ip_tos_t * tos, int * dont_fragment, size_t * ipopt_length ); |
139 | 49 |