VirtualBox

Ignore:
Timestamp:
Mar 22, 2010 9:17:14 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
59098
Message:

NAT: cosmetics; refined comments

File:
1 edited

Legend:

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

    r27568 r27573  
    3131{
    3232}
    33 
    3433
    3534struct socket *
     
    134133
    135134    DEBUG_CALL("soread");
    136     DEBUG_ARG("so = %lx", (long )so);
     135    DEBUG_ARG("so = %lx", (long)so);
    137136
    138137    /*
     
    204203    if (nn <= 0)
    205204    {
    206 #if defined(RT_OS_WINDOWS)
     205#ifdef RT_OS_WINDOWS
    207206        /*
    208207         * Special case for WSAEnumNetworkEvents: If we receive 0 bytes that
     
    10561055
    10571056    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. */
    10581060#ifndef RT_OS_DARWIN
    1059     /* Darwin: send IP.IP_LEN in host format (payload only) */
    10601061    ip->ip_len = RT_N2H_U16(ip->ip_len);
    10611062#endif
    1062     /* Note: ip->ip_len in host byte order (all OS) */
     1063    hlen = (ip->ip_hl << 2);
    10631064#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
    10671067    if (ip->ip_len < hlen + ICMP_MINLEN)
    10681068    {
     
    11081108
    11091109    icm = icmp_find_original_mbuf(pData, ip);
    1110 
    11111110    if (icm == NULL)
    11121111    {
     
    11341133         * in ip_output0 routine only.   
    11351134         */
    1136         if (   (ip->ip_len - hlen )
     1135        if (   (ip->ip_len - hlen)
    11371136            != (ip0->ip_len - (ip0->ip_hl << 2)))
    11381137        {
    11391138            Log(("NAT: ECHO(%d) lenght doesn't match ECHOREPLY(%d)\n",
    1140                 (ip->ip_len - hlen ), (ip0->ip_len - (ip0->ip_hl << 2))));
     1139                (ip->ip_len - hlen), (ip0->ip_len - (ip0->ip_hl << 2))));
    11411140            return;
    11421141        }
     
    12671266                break;
    12681267            case IP_SUCCESS: /* echo replied */
    1269 #ifndef VBOX_WITH_SLIRP_BSD_MBUF
     1268# ifndef VBOX_WITH_SLIRP_BSD_MBUF
    12701269                m = m_get(pData);
    1271 #else
     1270# else
    12721271                m = m_gethdr(pData, M_NOWAIT, MT_HEADER);
    1273 #endif
     1272# endif
    12741273                m->m_data += if_maxlinkhdr;
    12751274                ip = mtod(m, struct ip *);
     
    12891288                data_len += ICMP_MINLEN;
    12901289
    1291 #ifndef VBOX_WITH_SLIRP_BSD_MBUF
     1290# ifndef VBOX_WITH_SLIRP_BSD_MBUF
    12921291                nbytes = (data_len + icr[i].DataSize > m->m_size? m->m_size - data_len: icr[i].DataSize);
    12931292                memcpy(icp->icmp_data, icr[i].Data, nbytes);
    1294 #else
     1293# else
    12951294                AssertMsgFailed(("ICMP"));
    1296 #endif
     1295# endif
    12971296
    12981297                data_len += icr[i].DataSize;
     
    13371336    }
    13381337}
    1339 #else /* RT_OS_WINDOWS */
     1338#else /* !RT_OS_WINDOWS */
    13401339static void sorecvfrom_icmp_unix(PNATState pData, struct socket *so)
    13411340{
     
    13801379    /* basic check of IP header */
    13811380    if (   ip.ip_v != IPVERSION
    1382 #ifndef RT_OS_DARWIN
     1381# ifndef RT_OS_DARWIN
    13831382        || ip.ip_p != IPPROTO_ICMP
    1384 #endif
    1385     )
     1383# endif
     1384        )
    13861385    {
    13871386        Log(("sorecvfrom_icmp_unix: 1 - step IP isn't IPv4 \n"));
    13881387        return;
    13891388    }
    1390 #ifndef RT_OS_DARWIN
    1391     /* Darwin reports IP header in host format */
     1389# ifndef RT_OS_DARWIN
     1390    /* Darwin reports the IP length already in host byte order. */
    13921391    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
    13971397    /* Note: ip->ip_len in host byte order (all OS) */
    13981398    len = ip.ip_len;
Note: See TracChangeset for help on using the changeset viewer.

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