Changeset 10964 in vbox for trunk/include
- Timestamp:
- Jul 30, 2008 1:48:29 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/net.h
r10963 r10964 150 150 unsigned int ip_len : 16; 151 151 #else 152 /** Header length given as a 32-bit word count. */152 /** 00:0 - Header length given as a 32-bit word count. */ 153 153 unsigned int ip_hl : 4; 154 /** Header version. */154 /** 00:4 - Header version. */ 155 155 unsigned int ip_v : 4; 156 /** Type of service. */156 /** 01 - Type of service. */ 157 157 unsigned int ip_tos : 8; 158 /** Total length (header + data). */158 /** 02 - Total length (header + data). */ 159 159 unsigned int ip_len : 16; 160 160 #endif 161 /** Packet idenficiation. */161 /** 04 - Packet idenficiation. */ 162 162 uint16_t ip_id; 163 /** Offset if fragmented. */163 /** 06 - Offset if fragmented. */ 164 164 uint16_t ip_off; 165 /** Time to live. */165 /** 08 - Time to live. */ 166 166 uint8_t ip_ttl; 167 /** Protocol. */167 /** 09 - Protocol. */ 168 168 uint8_t ip_p; 169 /** Header check sum. */169 /** 0a - Header check sum. */ 170 170 uint16_t ip_sum; 171 /** Source address. */172 uint32_tip_src;173 /** Destination address. */174 uint32_tip_dst;175 /** Options (optional). */171 /** 0c - Source address. */ 172 RTNETADDRIPV4 ip_src; 173 /** 10 - Destination address. */ 174 RTNETADDRIPV4 ip_dst; 175 /** 14 - Options (optional). */ 176 176 uint32_t ip_options[1]; 177 177 } RTNETIPV4; … … 198 198 /** @} */ 199 199 200 /** 201 * Calculates the checksum of the IPv4 header. 202 * 203 * @returns Checksum. 204 * @param pIpHdr Pointer to the IPv4 header to checksum. Assumes 205 * the caller already checked the minimum size requirement. 206 */ 207 RTDECL(uint16_t) RTNetIPv4Checksum(PCRTNETIPV4 pIpHdr); 208 209 /** 210 * Verifies the header version, header size, packet size, and header checksum 211 * of the specified IPv4 header. 212 * 213 * @returns true if valid, false if invalid. 214 * @param pIpHdr Pointer to the IPv4 header to validate. 215 * @param cbHdrMax The max header size, or the max size of what pIpHdr points 216 * to if you like. Note that an IPv4 header can be up to 60 bytes. 217 * @param cbPktMax The max IP packet size, IP header and payload. This doesn't have 218 * to be mapped following pIpHdr. 219 */ 220 RTDECL(bool) RTNetIPv4IsValid(PCRTNETIPV4 pIpHdr, size_t cbHdrMax, size_t cbPktMax); 221 200 222 201 223 /** … … 216 238 #pragma pack(0) 217 239 AssertCompileSize(RTNETUDP, 8); 240 /** Pointer to an UDP header. */ 218 241 typedef RTNETUDP *PRTNETUDP; 242 /** Pointer to a const UDP header. */ 219 243 typedef RTNETUDP const *PCRTNETUDP; 220 244 221 /** The minimum IPv4packet length (in bytes). (RTNETUDP::uh_ulen) */245 /** The minimum UDP packet length (in bytes). (RTNETUDP::uh_ulen) */ 222 246 #define RTNETUDP_MIN_LEN (8) 223 247 … … 258 282 } RTNETDHCP; 259 283 #pragma pack(0) 260 / // @todo AssertCompileSize(RTNETDHCP, );284 /** @todo AssertCompileSize(RTNETDHCP, ); */ 261 285 /** Pointer to a DHCP packet. */ 262 286 typedef RTNETDHCP *PRTNETDHCP; 263 287 /** Pointer to a const DHCP packet. */ 264 288 typedef RTNETDHCP const *PCRTNETDHCP; 289 290 291 /** 292 * TCP packet. 293 */ 294 #pragma pack(1) 295 typedef struct RTNETTCP 296 { 297 /** 00 - The source port. */ 298 uint16_t th_sport; 299 /** 02 - The destination port. */ 300 uint16_t th_dport; 301 /** 04 - The sequence number. */ 302 uint32_t th_seq; 303 /** 08 - The acknowledgement number. */ 304 uint32_t th_ack; 305 #ifdef RT_BIG_ENDIAN 306 unsigned int th_win : 16; 307 unsigned int th_flags : 8; 308 unsigned int th_off : 4; 309 unsigned int th_x2 : 4; 310 #else 311 /** 0c:0 - Reserved. */ 312 unsigned int th_x2 : 4; 313 /** 0c:4 - The data offset given as a dword count from the start of this header. */ 314 unsigned int th_off : 4; 315 /** 0d - flags. */ 316 unsigned int th_flags : 8; 317 /** 0e - The window. */ 318 unsigned int th_win : 16; 319 #endif 320 /** 10 - The checksum of the pseudo header, the TCP header and the data. */ 321 uint16_t th_sum; 322 /** 12 - The urgent pointer. */ 323 uint16_t th_urp; 324 /* (options follows here and then the data (aka text).) */ 325 } RTNETTCP; 326 #pragma pack(0) 327 AssertCompileSize(RTNETTCP, 20); 328 /** Pointer to a TCP packet. */ 329 typedef RTNETTCP *PRTNETTCP; 330 /** Pointer to a const TCP packet. */ 331 typedef RTNETTCP const *PCRTNETTCP; 332 333 /** The minimum TCP header length (in bytes). (RTNETTCP::th_off * 4) */ 334 #define RTNETTCP_MIN_LEN (20) 265 335 266 336
Note:
See TracChangeset
for help on using the changeset viewer.