Changeset 15054 in vbox for trunk/src/VBox/Devices/Network/slirp/ip.h
- Timestamp:
- Dec 5, 2008 8:07:25 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/ip.h
r14638 r15054 70 70 #endif 71 71 72 typedef u_int32_t n_long; /* long as received from the net */73 74 72 /* 75 73 * Definitions for internet protocol version 4. … … 81 79 * Structure of an internet header, naked of options. 82 80 */ 83 struct ip { 84 /* 85 * bitfield types must be u_int8_t for MSVC, otherwise it will use a full dword (for u_int) 86 */ 81 struct ip 82 { 87 83 #ifdef WORDS_BIGENDIAN 88 u_int ip_v:4, /* version */ 89 ip_hl:4; /* header length */ 90 #else 91 #ifdef _MSC_VER 92 u_int8_t ip_hl:4, /* header length */ 93 #else 94 u_int ip_hl:4, /* header length */ 95 #endif 96 ip_v:4; /* version */ 97 #endif 98 u_int8_t ip_tos; /* type of service */ 99 u_int16_t ip_len; /* total length */ 100 u_int16_t ip_id; /* identification */ 101 u_int16_t ip_off; /* fragment offset field */ 102 #define IP_DF 0x4000 /* don't fragment flag */ 103 #define IP_MF 0x2000 /* more fragments flag */ 104 #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ 105 u_int8_t ip_ttl; /* time to live */ 106 u_int8_t ip_p; /* protocol */ 107 u_int16_t ip_sum; /* checksum */ 108 struct in_addr ip_src,ip_dst; /* source and dest address */ 109 }; 110 111 #define IP_MAXPACKET 65535 /* maximum packet size */ 84 # ifdef _MSC_VER 85 uint8_t ip_v:4; /* version */ 86 uint8_t ip_hl:4; /* header length */ 87 # else 88 unsigned ip_v:4; /* version */ 89 unsigned ip_hl:4; /* header length */ 90 # endif 91 #else 92 # ifdef _MSC_VER 93 uint8_t ip_hl:4; /* header length */ 94 uint8_t ip_v:4; /* version */ 95 # else 96 unsigned ip_hl:4; /* header length */ 97 unsigned ip_v:4; /* version */ 98 # endif 99 #endif 100 uint8_t ip_tos; /* type of service */ 101 uint16_t ip_len; /* total length */ 102 uint16_t ip_id; /* identification */ 103 uint16_t ip_off; /* fragment offset field */ 104 #define IP_DF 0x4000 /* don't fragment flag */ 105 #define IP_MF 0x2000 /* more fragments flag */ 106 #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ 107 uint8_t ip_ttl; /* time to live */ 108 uint8_t ip_p; /* protocol */ 109 uint16_t ip_sum; /* checksum */ 110 struct in_addr ip_src; /* source address */ 111 struct in_addr ip_dst; /* destination address */ 112 }; 113 AssertCompileSize(struct ip, 20); 114 115 #define IP_MAXPACKET 65535 /* maximum packet size */ 112 116 113 117 /* … … 130 134 #define IPOPT_RESERVED2 0x60 131 135 132 #define IPOPT_EOL 0 133 #define IPOPT_NOP 1 134 135 #define IPOPT_RR 7 136 #define IPOPT_TS 68 137 #define IPOPT_SECURITY 130 138 #define IPOPT_LSRR 131 139 #define IPOPT_SATID 136 140 #define IPOPT_SSRR 137 136 #define IPOPT_EOL 0 /* end of option list */ 137 #define IPOPT_NOP 1 /* no operation */ 138 139 #define IPOPT_RR 7 /* record packet route */ 140 #define IPOPT_TS 68 /* timestamp */ 141 #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ 142 #define IPOPT_LSRR 131 /* loose source route */ 143 #define IPOPT_SATID 136 /* satnet id */ 144 #define IPOPT_SSRR 137 /* strict source route */ 141 145 142 146 /* 143 147 * Offsets to fields in options other than EOL and NOP. 144 148 */ 145 #define IPOPT_OPTVAL 0 146 #define IPOPT_OLEN 1 147 #define IPOPT_OFFSET 2 148 #define IPOPT_MINOFF 4 149 #define IPOPT_OPTVAL 0 /* option ID */ 150 #define IPOPT_OLEN 1 /* option length */ 151 #define IPOPT_OFFSET 2 /* offset within option */ 152 #define IPOPT_MINOFF 4 /* min value of above */ 149 153 150 154 /* 151 155 * Time stamp option structure. 152 156 */ 153 struct ip_timestamp { 154 u_int8_t ipt_code; /* IPOPT_TS */ 155 u_int8_t ipt_len; /* size of structure (variable) */ 156 u_int8_t ipt_ptr; /* index of current entry */ 157 /* 158 * bitfield types must be u_int8_t for MSVC, otherwise it will use a full dword (for u_int) 159 */ 157 struct ip_timestamp 158 { 159 uint8_t ipt_code; /* IPOPT_TS */ 160 uint8_t ipt_len; /* size of structure (variable) */ 161 uint8_t ipt_ptr; /* index of current entry */ 160 162 #ifdef WORDS_BIGENDIAN 161 u_int ipt_oflw:4, /* overflow counter */ 162 ipt_flg:4; /* flags, see below */ 163 #else 164 #ifdef _MSC_VER 165 u_int8_t ipt_flg:4, /* flags, see below */ 166 #else 167 u_int ipt_flg:4, /* flags, see below */ 168 #endif 169 ipt_oflw:4; /* overflow counter */ 170 #endif 171 union ipt_timestamp { 172 n_long ipt_time[1]; 173 struct ipt_ta { 174 struct in_addr ipt_addr; 175 n_long ipt_time; 176 } ipt_ta[1]; 177 } ipt_timestamp; 178 }; 163 # ifdef _MSC_VER 164 uint8_t ipt_oflw:4; /* overflow counter */ 165 uint8_t ipt_flg:4; /* flags, see below */ 166 # else 167 unsigned ipt_oflw:4; /* overflow counter */ 168 unsigned ipt_flg:4; /* flags, see below */ 169 # endif 170 #else 171 # ifdef _MSC_VER 172 uint8_t ipt_flg:4; /* flags, see below */ 173 uint8_t ipt_oflw:4; /* overflow counter */ 174 # else 175 unsigned ipt_flg:4; /* flags, see below */ 176 unsigned ipt_oflw:4; /* overflow counter */ 177 # endif 178 #endif 179 union ipt_timestamp 180 { 181 uint32_t ipt_time[1]; 182 struct ipt_ta 183 { 184 struct in_addr ipt_addr; 185 uint32_t ipt_time; 186 } ipt_ta[1]; 187 } ipt_timestamp; 188 }; 189 AssertCompileSize(struct ip_timestamp, 12); 179 190 180 191 /* flag bits for ipt_flg */ 181 #define IPOPT_TS_TSONLY 0 182 #define IPOPT_TS_TSANDADDR 1 183 #define IPOPT_TS_PRESPEC 3 192 #define IPOPT_TS_TSONLY 0 /* timestamps only */ 193 #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ 194 #define IPOPT_TS_PRESPEC 3 /* specified modules only */ 184 195 185 196 /* bits for security (not byte swapped) */ … … 195 206 * Internet implementation parameters. 196 207 */ 197 #define MAXTTL 255 198 #define IPDEFTTL 64 199 #define IPFRAGTTL 60 200 #define IPTTLDEC 1 201 202 #define IP_MSS 576 208 #define MAXTTL 255 /* maximum time to live (seconds) */ 209 #define IPDEFTTL 64 /* default ttl, from RFC 1340 */ 210 #define IPFRAGTTL 60 /* time to live for frags, slowhz */ 211 #define IPTTLDEC 1 /* subtracted when forwarding */ 212 213 #define IP_MSS 576 /* default maximum segment size */ 203 214 204 215 #ifdef HAVE_SYS_TYPES32_H /* Overcome some Solaris 2.x junk */ … … 227 238 * Overlay for ip header used by other protocols (tcp, udp). 228 239 */ 229 struct ipovly { 240 struct ipovly 241 { 230 242 #if !defined(VBOX_WITH_BSD_REASS) 231 caddr32_t ih_next, ih_prev; /* for protocol sequence q's */ 232 u_int8_t ih_x1; /* (unused) */ 243 caddr32_t ih_next; 244 caddr32_t ih_prev; /* for protocol sequence q's */ 245 u_int8_t ih_x1; /* (unused) */ 233 246 #else /* VBOX_WITH_BSD_REASS */ 234 u_int8_t ih_x1[9];/* (unused) */247 u_int8_t ih_x1[9]; /* (unused) */ 235 248 #endif /* VBOX_WITH_BSD_REASS */ 236 u_int8_t ih_pr;/* protocol */237 u_int16_t ih_len;/* protocol length */238 struct in_addr ih_src;/* source internet address */239 struct in_addr ih_dst;/* destination internet address */240 }; 241 242 /* 243 * Ip reassembly queue structure. Each fragment 244 * being reassembled is attached to one of these structures.245 * They are timed out after ipq_ttl drops to 0, and may also246 * be reclaimed if memory becomes tight.249 u_int8_t ih_pr; /* protocol */ 250 u_int16_t ih_len; /* protocol length */ 251 struct in_addr ih_src; /* source internet address */ 252 struct in_addr ih_dst; /* destination internet address */ 253 }; 254 AssertCompileSize(struct ipovly, 20); 255 256 /* 257 * Ip reassembly queue structure. Each fragment being reassembled is 258 * attached to one of these structures. They are timed out after ipq_ttl 259 * drops to 0, and may also be reclaimed if memory becomes tight. 247 260 * size 28 bytes 248 261 */ 249 struct ipq_t { 262 struct ipq_t 263 { 250 264 #ifndef VBOX_WITH_BSD_REASS 251 ipqp_32 next,prev; /* to other reass headers */ 265 ipqp_32 next; 266 ipqp_32 prev; /* to other reass headers */ 252 267 #else /* VBOX_WITH_BSD_REASS */ 253 268 TAILQ_ENTRY(ipq_t) ipq_list; 254 269 #endif /* VBOX_WITH_BSD_REASS */ 255 u_int8_t ipq_ttl;/* time for reass q to live */256 u_int8_t ipq_p;/* protocol of this fragment */257 u_int16_t ipq_id;/* sequence id for reassembly */270 u_int8_t ipq_ttl; /* time for reass q to live */ 271 u_int8_t ipq_p; /* protocol of this fragment */ 272 u_int16_t ipq_id; /* sequence id for reassembly */ 258 273 #ifndef VBOX_WITH_BSD_REASS 259 ipasfragp_32 ipq_next,ipq_prev; /* to ip headers of fragments */ 274 ipasfragp_32 ipq_next; 275 ipasfragp_32 ipq_prev; /* to ip headers of fragments */ 260 276 #else /* VBOX_WITH_BSD_REASS */ 261 u_int8_t ipq_nfrags; /* # of fragments in this packet*/262 struct mbuf *ipq_frags; /* to ip headers of fragments*/277 struct mbuf *ipq_frags; /* to ip headers of fragments */ 278 uint8_t ipq_nfrags; /* # of fragments in this packet */ 263 279 #endif /* VBOX_WITH_BSD_REASS */ 264 265 struct in_addr ipq_src,ipq_dst;280 struct in_addr ipq_src; 281 struct in_addr ipq_dst; 266 282 }; 267 283 … … 283 299 * Note: ipf_next must be at same offset as ipq_next above 284 300 */ 285 struct ipasfrag { 301 struct ipasfrag 302 { 286 303 #ifdef WORDS_BIGENDIAN 287 u_int ip_v:4, 288 ip_hl:4; 289 #else 290 #ifdef _MSC_VER 291 u_int8_t ip_hl:4, 292 #else 293 u_int ip_hl:4, 294 #endif 295 ip_v:4; 296 #endif 297 /* BUG : u_int changed to u_int8_t. 298 * sizeof(u_int)==4 on linux 2.0 299 */ 300 u_int8_t ipf_mff; /* XXX overlays ip_tos: use low bit 301 * to avoid destroying tos (PPPDTRuu); 302 * copied from (ip_off&IP_MF) */ 303 u_int16_t ip_len; 304 u_int16_t ip_id; 305 u_int16_t ip_off; 306 u_int8_t ip_ttl; 307 u_int8_t ip_p; 308 u_int16_t ip_sum; 309 ipasfragp_32 ipf_next; /* next fragment */ 310 ipasfragp_32 ipf_prev; /* previous fragment */ 311 }; 304 # ifdef _MSC_VER 305 uint8_t ip_v:4; 306 uint8_t ip_hl:4; 307 # else 308 unsigned ip_v:4; 309 unsigned ip_hl:4; 310 # endif 311 #else 312 # ifdef _MSC_VER 313 uint8_t ip_hl:4; 314 uint8_t ip_v:4; 315 # else 316 unsigned ip_hl:4; 317 unsigned ip_v:4; 318 # endif 319 #endif 320 u_int8_t ipf_mff; /* XXX overlays ip_tos: use low bit 321 * to avoid destroying tos (PPPDTRuu); 322 * copied from (ip_off & IP_MF) */ 323 u_int16_t ip_len; 324 u_int16_t ip_id; 325 u_int16_t ip_off; 326 u_int8_t ip_ttl; 327 u_int8_t ip_p; 328 u_int16_t ip_sum; 329 ipasfragp_32 ipf_next; /* next fragment */ 330 ipasfragp_32 ipf_prev; /* previous fragment */ 331 }; 332 AssertCompileSize(struct ipasfrag, 20); 312 333 313 334 /* … … 319 340 #define MAX_IPOPTLEN 40 320 341 321 struct ipoption { 322 struct in_addr ipopt_dst; /* first-hop dst if source routed */ 323 int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */ 342 struct ipoption 343 { 344 struct in_addr ipopt_dst; /* first-hop dst if source routed */ 345 int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */ 324 346 }; 325 347 … … 329 351 */ 330 352 331 struct ipstat_t {332 u_long ips_total; /* total packets received */ 333 u_long ips_badsum; /* checksum bad */334 u_long ips_tooshort; /* packet too short*/335 u_long ips_toosmall; /* not enough data*/336 u_long ips_badhlen; /* ip header length < data size*/337 u_long ips_badlen; /* ip length < ip header length*/338 u_long ips_fragments; /* fragments received*/339 u_long ips_fragdropped; /* frags dropped (dups, out of space)*/340 u_long ips_fragtimeout; /* fragments timed out*/341 u_long ips_forward; /* packets forwarded*/342 u_long ips_cantforward; /* packets rcvd for unreachable dest*/343 u_long ips_redirectsent; /* packets forwarded on same net */344 u_long ips_noproto; /* unknown or unsupported protocol*/345 u_long ips_delivered; /* datagrams delivered to upper level*/346 u_long ips_localout; /* total ip packets generated here*/347 u_long ips_odropped; /* lost packets due to nobufs, etc.*/348 u_long ips_reassembled; /* total packets reassembled ok*/349 u_long ips_fragmented; /* datagrams successfully fragmented*/350 u_long ips_ofragments; /* output fragments created */351 u_long ips_cantfrag; /* don't fragment flag was set, etc.*/352 u_long ips_badoptions; /* error in option processing*/353 u_long ips_noroute; /* packets discarded due to no route*/354 u_long ips_badvers; /* ip version != 4*/355 u_long ips_rawout; /* total raw ip packets generated*/356 u_long ips_unaligned; /* times the ip packet was not aligned */357 }; 358 359 360 #endif 353 struct ipstat_t 354 { 355 u_long ips_total; /* total packets received */ 356 u_long ips_badsum; /* checksum bad */ 357 u_long ips_tooshort; /* packet too short */ 358 u_long ips_toosmall; /* not enough data */ 359 u_long ips_badhlen; /* ip header length < data size */ 360 u_long ips_badlen; /* ip length < ip header length */ 361 u_long ips_fragments; /* fragments received */ 362 u_long ips_fragdropped; /* frags dropped (dups, out of space) */ 363 u_long ips_fragtimeout; /* fragments timed out */ 364 u_long ips_forward; /* packets forwarded */ 365 u_long ips_cantforward; /* packets rcvd for unreachable dest */ 366 u_long ips_redirectsent; /* packets forwarded on same net */ 367 u_long ips_noproto; /* unknown or unsupported protocol */ 368 u_long ips_delivered; /* datagrams delivered to upper level*/ 369 u_long ips_localout; /* total ip packets generated here */ 370 u_long ips_odropped; /* lost packets due to nobufs, etc. */ 371 u_long ips_reassembled; /* total packets reassembled ok */ 372 u_long ips_fragmented; /* datagrams successfully fragmented */ 373 u_long ips_ofragments; /* output fragments created */ 374 u_long ips_cantfrag; /* don't fragment flag was set, etc. */ 375 u_long ips_badoptions; /* error in option processing */ 376 u_long ips_noroute; /* packets discarded due to no route */ 377 u_long ips_badvers; /* ip version != 4 */ 378 u_long ips_rawout; /* total raw ip packets generated */ 379 u_long ips_unaligned; /* times the ip packet was not aligned */ 380 }; 381 382 #endif
Note:
See TracChangeset
for help on using the changeset viewer.