Changeset 27466 in vbox
- Timestamp:
- Mar 18, 2010 7:09:37 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/src/VBox/Devices/Network/slirp/socket.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/socket.c
r27457 r27466 1057 1057 ip = (struct ip *)buff; 1058 1058 hlen = (ip->ip_hl << 2); 1059 if (RT_N2H_U16(ip->ip_len) < hlen + ICMP_MINLEN) 1059 /* Note: ip->ip_len in host byte order */ 1060 ip->ip_len = RT_N2H_U16(ip->ip_len); 1061 #ifdef RT_OS_SOLARIS 1062 /* Solaris doesn't pass raw IP datagram, ip_len is size of payload only */ 1063 ip->ip_len += hlen; 1064 #endif 1065 if (ip->ip_len < hlen + ICMP_MINLEN) 1060 1066 { 1061 1067 Log(("send_icmp_to_guest: ICMP header is too small to understand which type/subtype of the datagram\n")); … … 1077 1083 * icmp_{type(8), code(8), cksum(16),identifier(16),seqnum(16)} 1078 1084 */ 1079 if ( RT_N2H_U16(ip->ip_len)< hlen + 8)1085 if (ip->ip_len < hlen + 8) 1080 1086 { 1081 1087 Log(("send_icmp_to_guest: NAT accept ICMP_{ECHOREPLY, TIMXCEED, UNREACH} the minimum size is 64 (see rfc792)\n")); … … 1091 1097 * icmp_{type(8), code(8), cksum(16),unused(32)} + IP header + 64 bit of original datagram 1092 1098 */ 1093 if ( RT_N2H_U16(ip->ip_len)< hlen + 2*8 + sizeof(struct ip))1099 if (ip->ip_len < hlen + 2*8 + sizeof(struct ip)) 1094 1100 { 1095 1101 Log(("send_icmp_to_guest: NAT accept ICMP_{TIMXCEED, UNREACH} the minimum size of ipheader + 64 bit of data (see rfc792)\n")); … … 1111 1117 1112 1118 src = addr->sin_addr.s_addr; 1113 #if 01114 /* @todo: check why it's too strict. */1115 1119 if (type == ICMP_ECHOREPLY) 1116 1120 { … … 1122 1126 return; 1123 1127 } 1124 if ( (RT_N2H_U16(ip->ip_len) - hlen ) 1125 != (ip0->ip_len - (ip0->ip_hl << 2))) /* the IP header in the list is in host format */ 1126 { 1127 Log(("NAT: ECHO lenght doesn't match ECHOREPLY\n")); 1128 #if 0 1129 /* 1130 * @todo ip0 seems have different byte order on different OSes, e.g. on Solaris it's required 1131 * to N2H, but on Linux no convertaion required. 1132 */ 1133 if ( (ip->ip_len - hlen ) 1134 != (ip0->ip_len - (ip0->ip_hl << 2))) 1135 { 1136 Log(("NAT: ECHO(%d) lenght doesn't match ECHOREPLY(%d)\n", 1137 (ip->ip_len - hlen ), (ip0->ip_len - (ip0->ip_hl << 2)))); 1128 1138 return; 1129 1139 } 1130 } 1131 #endif 1132 1140 #endif 1141 } 1142 1143 /* ip points on origianal ip header */ 1133 1144 ip = mtod(m, struct ip *); 1134 1145 proto = ip->ip_p; … … 1373 1384 1374 1385 len = RT_N2H_U16(ip.ip_len); 1386 #ifdef RT_OS_SOLARIS 1387 len += (ip.ip_hl << 2); /* Solaris: reports only payload length */ 1388 #endif 1375 1389 buff = RTMemAlloc(len); 1376 1390 if (buff == NULL) … … 1396 1410 } 1397 1411 if ( len < 0 1412 #ifndef RT_OS_SOLARIS 1398 1413 || len < (RT_N2H_U16(ip.ip_len)) 1414 #else 1415 || len < ((RT_N2H_U16(ip.ip_len)) + (ip.ip_hl << 2)) 1416 #endif 1399 1417 || len == 0) 1400 1418 {
Note:
See TracChangeset
for help on using the changeset viewer.

