VirtualBox

Changeset 15232 in vbox for trunk/src/VBox/Devices/Network


Ignore:
Timestamp:
Dec 10, 2008 8:17:39 AM (16 years ago)
Author:
vboxsync
Message:

slirp:icmp ignoring all incomming ICMP messages except TIMEXEED and ECHOREPLY

File:
1 edited

Legend:

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

    r15207 r15232  
    1313#include <sys/filio.h>
    1414#endif
    15 #if defined(VBOX_WITH_SLIRP_ICMP) && defined (RT_OS_WINDOWS) 
     15#if defined(VBOX_WITH_SLIRP_ICMP) && defined (RT_OS_WINDOWS)
    1616#include <iphlpapi.h>
    1717#include <icmpapi.h>
     
    439439    {
    440440        /* This is a "ping" reply */
    441 #if !defined(VBOX_WITH_SLIRP_ICMP) || (defined(VBOX_WITH_SLIRP_ICMP) && !defined(RT_OS_WINDOWS)) 
     441#if !defined(VBOX_WITH_SLIRP_ICMP) || (defined(VBOX_WITH_SLIRP_ICMP) && !defined(RT_OS_WINDOWS))
    442442        sorecvfrom_icmp_unix(pData, so);
    443443#endif
     
    780780
    781781#ifdef VBOX_WITH_SLIRP_ICMP
    782 static void 
     782static void
    783783send_icmp_to_guest(PNATState pData, char *buff, size_t len, struct socket *so, const struct sockaddr_in *addr)
    784784{
     
    794794    icp = (struct icmp *)((char *)ip + (ip->ip_hl << 2));
    795795
    796     Assert(icp->icmp_type == ICMP_ECHOREPLY || icp->icmp_type == ICMP_TIMXCEED);
     796    if (icp->icmp_type != ICMP_ECHOREPLY && icp->icmp_type != ICMP_TIMXCEED)
     797    {
     798        LogRel(("received ICMP(t:%d, c:%d)\n", icp->icmp_type, icp->icmp_code));
     799        return;
     800    }
    797801
    798802    if (icp->icmp_type == ICMP_TIMXCEED)
     
    849853
    850854# ifdef RT_OS_WINDOWS
    851 static void 
     855static void
    852856sorecvfrom_icmp_win(PNATState pData, struct socket *so)
    853857{
     
    872876    for (i = 0; i < len; ++i)
    873877    {
    874         switch(icr[i].Status) 
     878        switch(icr[i].Status)
    875879        {
    876880            case IP_DEST_HOST_UNREACHABLE:
     
    892896                ip->ip_dst.s_addr = so->so_laddr.s_addr; /*XXX: still the hack*/
    893897                ip->ip_hl = sizeof(struct ip) >> 2; /* requiered for icmp_reflect, no IP options */
    894                 ip->ip_ttl = icr[i].Options.Ttl; 
     898                ip->ip_ttl = icr[i].Options.Ttl;
    895899
    896900                icp = (struct icmp *)&ip[1]; /* no options */
     
    901905                memcpy(icp->icmp_data, icr[i].Data, icr[i].DataSize);
    902906
    903                 ip->ip_len = sizeof(struct ip) + ICMP_MINLEN + icr[i].DataSize; 
     907                ip->ip_len = sizeof(struct ip) + ICMP_MINLEN + icr[i].DataSize;
    904908                m->m_len = ip->ip_len;
    905909
     
    908912
    909913                ip_broken = icr[i].Data;
    910                 icm = icmp_find_original_mbuf(pData, ip_broken);     
     914                icm = icmp_find_original_mbuf(pData, ip_broken);
    911915                if (icm == NULL) {
    912916                    LogRel(("ICMP: can't find original package (first double word %x)\n", *(uint32_t *)ip_broken));
     
    918922                src = ip->ip_src.s_addr;
    919923                ip->ip_dst.s_addr = src;
    920                 ip->ip_dst.s_addr = icr[i].Address; 
     924                ip->ip_dst.s_addr = icr[i].Address;
    921925                icp = (struct icmp *)((char *)ip + (ip->ip_hl << 2));
    922926                ip_broken->ip_src.s_addr = src; /*it packet sent from host not from guest*/
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