Changeset 27573 in vbox for trunk/src/VBox/Devices/Network/slirp
- Timestamp:
- Mar 22, 2010 9:17:14 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 59098
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/socket.c
r27568 r27573 31 31 { 32 32 } 33 34 33 35 34 struct socket * … … 134 133 135 134 DEBUG_CALL("soread"); 136 DEBUG_ARG("so = %lx", (long 135 DEBUG_ARG("so = %lx", (long)so); 137 136 138 137 /* … … 204 203 if (nn <= 0) 205 204 { 206 #if defined(RT_OS_WINDOWS)205 #ifdef RT_OS_WINDOWS 207 206 /* 208 207 * Special case for WSAEnumNetworkEvents: If we receive 0 bytes that … … 1056 1055 1057 1056 ip = (struct ip *)buff; 1057 /* Fix ip->ip_len to contain the total packet length including the header 1058 * in _host_ byte order for all OSes. On Darwin, that value already is in 1059 * host byte order. Solaris and Darwin report only the payload. */ 1058 1060 #ifndef RT_OS_DARWIN 1059 /* Darwin: send IP.IP_LEN in host format (payload only) */1060 1061 ip->ip_len = RT_N2H_U16(ip->ip_len); 1061 1062 #endif 1062 /* Note: ip->ip_len in host byte order (all OS) */1063 hlen = (ip->ip_hl << 2); 1063 1064 #if defined(RT_OS_SOLARIS) || defined(RT_OS_DARWIN) 1064 ip->ip_len += (ip->ip_hl << 2); /* Solaris: reports only payload length */ 1065 #endif 1066 hlen = (ip->ip_hl << 2); 1065 ip->ip_len += hlen; 1066 #endif 1067 1067 if (ip->ip_len < hlen + ICMP_MINLEN) 1068 1068 { … … 1108 1108 1109 1109 icm = icmp_find_original_mbuf(pData, ip); 1110 1111 1110 if (icm == NULL) 1112 1111 { … … 1134 1133 * in ip_output0 routine only. 1135 1134 */ 1136 if ( (ip->ip_len - hlen 1135 if ( (ip->ip_len - hlen) 1137 1136 != (ip0->ip_len - (ip0->ip_hl << 2))) 1138 1137 { 1139 1138 Log(("NAT: ECHO(%d) lenght doesn't match ECHOREPLY(%d)\n", 1140 (ip->ip_len - hlen 1139 (ip->ip_len - hlen), (ip0->ip_len - (ip0->ip_hl << 2)))); 1141 1140 return; 1142 1141 } … … 1267 1266 break; 1268 1267 case IP_SUCCESS: /* echo replied */ 1269 # ifndef VBOX_WITH_SLIRP_BSD_MBUF1268 # ifndef VBOX_WITH_SLIRP_BSD_MBUF 1270 1269 m = m_get(pData); 1271 # else1270 # else 1272 1271 m = m_gethdr(pData, M_NOWAIT, MT_HEADER); 1273 # endif1272 # endif 1274 1273 m->m_data += if_maxlinkhdr; 1275 1274 ip = mtod(m, struct ip *); … … 1289 1288 data_len += ICMP_MINLEN; 1290 1289 1291 # ifndef VBOX_WITH_SLIRP_BSD_MBUF1290 # ifndef VBOX_WITH_SLIRP_BSD_MBUF 1292 1291 nbytes = (data_len + icr[i].DataSize > m->m_size? m->m_size - data_len: icr[i].DataSize); 1293 1292 memcpy(icp->icmp_data, icr[i].Data, nbytes); 1294 # else1293 # else 1295 1294 AssertMsgFailed(("ICMP")); 1296 # endif1295 # endif 1297 1296 1298 1297 data_len += icr[i].DataSize; … … 1337 1336 } 1338 1337 } 1339 #else /* RT_OS_WINDOWS */1338 #else /* !RT_OS_WINDOWS */ 1340 1339 static void sorecvfrom_icmp_unix(PNATState pData, struct socket *so) 1341 1340 { … … 1380 1379 /* basic check of IP header */ 1381 1380 if ( ip.ip_v != IPVERSION 1382 # ifndef RT_OS_DARWIN1381 # ifndef RT_OS_DARWIN 1383 1382 || ip.ip_p != IPPROTO_ICMP 1384 # endif1385 )1383 # endif 1384 ) 1386 1385 { 1387 1386 Log(("sorecvfrom_icmp_unix: 1 - step IP isn't IPv4 \n")); 1388 1387 return; 1389 1388 } 1390 # ifndef RT_OS_DARWIN1391 /* Darwin reports IP header in host format*/1389 # ifndef RT_OS_DARWIN 1390 /* Darwin reports the IP length already in host byte order. */ 1392 1391 ip.ip_len = RT_N2H_U16(ip.ip_len); 1393 #endif 1394 #if defined(RT_OS_SOLARIS) || defined(RT_OS_DARWIN) 1395 ip.ip_len += (ip.ip_hl << 2); /* Solaris: reports only payload length */ 1396 #endif 1392 # endif 1393 # if defined(RT_OS_SOLARIS) || defined(RT_OS_DARWIN) 1394 /* Solaris and Darwin report the payload only */ 1395 ip.ip_len += (ip.ip_hl << 2); 1396 # endif 1397 1397 /* Note: ip->ip_len in host byte order (all OS) */ 1398 1398 len = ip.ip_len;
Note:
See TracChangeset
for help on using the changeset viewer.