VirtualBox

Changeset 27568 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Mar 22, 2010 3:37:08 AM (15 years ago)
Author:
vboxsync
Message:

NAT: ICMP Darwin specifics. Darwin reports IP in host format and IP.IP_LEN shows amount of bytes of datagram payload.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/socket.c

    r27468 r27568  
    10561056
    10571057    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
    10581066    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_SOLARIS
    1062     /* Solaris doesn't pass raw IP datagram, ip_len is size of payload only */
    1063     ip->ip_len += hlen;
    1064 #endif
    10651067    if (ip->ip_len < hlen + ICMP_MINLEN)
    10661068    {
     
    11611163    original_hlen = ip->ip_hl << 2;
    11621164    /* 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
    11631169    /* m_room space in the saved m buffer */
    11641170    m_room = M_ROOM(m);
     
    11741180    }
    11751181    memcpy(m->m_data + original_hlen, buff + hlen, len - hlen);
    1176 #ifndef VBOX_WITH_SLIRP_BSD_MBUF
    11771182    m->m_len = len - hlen + original_hlen;
    11781183    ip->ip_len = m->m_len;
    1179 #else
    1180     ip->ip_len = m_length(m, NULL);
    11811184#endif
    11821185    ip->ip_p = IPPROTO_ICMP; /* the original package could be whatever, but we're response via ICMP*/
     
    13771380    /* basic check of IP header */
    13781381    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    )
    13801386    {
    13811387        Log(("sorecvfrom_icmp_unix: 1 - step IP isn't IPv4 \n"));
    13821388        return;
    13831389    }
    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;
    13891399    buff = RTMemAlloc(len);
    13901400    if (buff == NULL)
     
    14051415    {
    14061416        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));
    14081418        RTMemFree(buff);
    14091419        return;
    14101420    }
    14111421    if (   len < 0
    1412 #ifndef RT_OS_SOLARIS
    1413         || len < (RT_N2H_U16(ip.ip_len))
    1414 #else
    1415         || len < ((RT_N2H_U16(ip.ip_len)) + (ip.ip_hl << 2))
    1416 #endif
    14171422        || len == 0)
    14181423    {
    14191424        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))));
    14211426        RTMemFree(buff);
    14221427        return;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette