Changeset 27568 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Mar 22, 2010 3:37:08 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/socket.c
r27468 r27568 1056 1056 1057 1057 ip = (struct ip *)buff; 1058 #ifndef RT_OS_DARWIN 1059 /* Darwin: send IP.IP_LEN in host format (payload only) */ 1060 ip->ip_len = RT_N2H_U16(ip->ip_len); 1061 #endif 1062 /* Note: ip->ip_len in host byte order (all OS) */ 1063 #if defined(RT_OS_SOLARIS) || defined(RT_OS_DARWIN) 1064 ip->ip_len += (ip->ip_hl << 2); /* Solaris: reports only payload length */ 1065 #endif 1058 1066 hlen = (ip->ip_hl << 2); 1059 /* Note: ip->ip_len in host byte order */1060 ip->ip_len = RT_N2H_U16(ip->ip_len);1061 #ifdef RT_OS_SOLARIS1062 /* Solaris doesn't pass raw IP datagram, ip_len is size of payload only */1063 ip->ip_len += hlen;1064 #endif1065 1067 if (ip->ip_len < hlen + ICMP_MINLEN) 1066 1068 { … … 1161 1163 original_hlen = ip->ip_hl << 2; 1162 1164 /* saves original ip header and options */ 1165 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 1166 m_copyback(pData, m, original_hlen, len - hlen, buff + hlen); 1167 ip->ip_len = m_length(m, NULL); 1168 #else 1163 1169 /* m_room space in the saved m buffer */ 1164 1170 m_room = M_ROOM(m); … … 1174 1180 } 1175 1181 memcpy(m->m_data + original_hlen, buff + hlen, len - hlen); 1176 #ifndef VBOX_WITH_SLIRP_BSD_MBUF1177 1182 m->m_len = len - hlen + original_hlen; 1178 1183 ip->ip_len = m->m_len; 1179 #else1180 ip->ip_len = m_length(m, NULL);1181 1184 #endif 1182 1185 ip->ip_p = IPPROTO_ICMP; /* the original package could be whatever, but we're response via ICMP*/ … … 1377 1380 /* basic check of IP header */ 1378 1381 if ( ip.ip_v != IPVERSION 1379 || ip.ip_p != IPPROTO_ICMP) 1382 #ifndef RT_OS_DARWIN 1383 || ip.ip_p != IPPROTO_ICMP 1384 #endif 1385 ) 1380 1386 { 1381 1387 Log(("sorecvfrom_icmp_unix: 1 - step IP isn't IPv4 \n")); 1382 1388 return; 1383 1389 } 1384 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 1390 #ifndef RT_OS_DARWIN 1391 /* Darwin reports IP header in host format */ 1392 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 1397 /* Note: ip->ip_len in host byte order (all OS) */ 1398 len = ip.ip_len; 1389 1399 buff = RTMemAlloc(len); 1390 1400 if (buff == NULL) … … 1405 1415 { 1406 1416 Log(("sorecvfrom_icmp_unix: 2 - step can't read IP body (would block expected:%d)\n", 1407 RT_N2H_U16(ip.ip_len)));1417 ip.ip_len)); 1408 1418 RTMemFree(buff); 1409 1419 return; 1410 1420 } 1411 1421 if ( len < 0 1412 #ifndef RT_OS_SOLARIS1413 || len < (RT_N2H_U16(ip.ip_len))1414 #else1415 || len < ((RT_N2H_U16(ip.ip_len)) + (ip.ip_hl << 2))1416 #endif1417 1422 || len == 0) 1418 1423 { 1419 1424 Log(("sorecvfrom_icmp_unix: 2 - step read of the rest of datagramm is fallen (errno:%d, len:%d expected: %d)\n", 1420 errno, len, ( RT_N2H_U16(ip.ip_len)- sizeof(struct ip))));1425 errno, len, (ip.ip_len - sizeof(struct ip)))); 1421 1426 RTMemFree(buff); 1422 1427 return;
Note:
See TracChangeset
for help on using the changeset viewer.