VirtualBox

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


Ignore:
Timestamp:
Dec 8, 2008 3:23:40 PM (16 years ago)
Author:
vboxsync
Message:

Dynamic detection of IcmpParceReplies function according MSDN recommendation was introduced

Location:
trunk/src/VBox/Devices/Network/slirp
Files:
3 edited

Legend:

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

    r15106 r15112  
    8181    insque(pData, &pData->icmp_socket, &udb);
    8282#else
     83    pData->hmIcmpLibrary = LoadLibrary("Iphlpapi.dll");
     84    if (pData->hmIcmpLibrary != NULL) {
     85            pData->pfIcmpParseReplies = (long (WINAPI *)(void *, long))GetProcAddress(pData->hmIcmpLibrary, "IcmpParseReplies");
     86    }
     87    if (pData->pfIcmpParseReplies == NULL) {
     88            FreeLibrary(pData->hmIcmpLibrary);
     89            pData->hmIcmpLibrary = LoadLibrary("Icmp.dll");
     90            if (pData->hmIcmpLibrary == NULL) {
     91                    LogRel(("Icmp.dll couldn't be loaded"));
     92                    return (1);
     93            }
     94            pData->pfIcmpParseReplies = (long (WINAPI *)(void *, long))GetProcAddress(pData->hmIcmpLibrary, "IcmpParseReplies");
     95    }
     96    if (pData->pfIcmpParseReplies == NULL) {
     97            LogRel(("Can't find IcmpParseReplies symbol"));
     98            FreeLibrary(pData->hmIcmpLibrary);
     99            return (1);
     100    }
    83101    pData->icmp_socket.s = IcmpCreateFile();
    84102    pData->phEvents[VBOX_ICMP_EVENT_INDEX] = CreateEvent(NULL, FALSE, FALSE, NULL);
     
    130148    }
    131149    if (found == 1)
    132         return cm;
     150        return icm;
    133151
    134152    return NULL;
     
    301319                ipopt.Ttl = ip->ip_ttl;
    302320                status = IcmpSendEcho2(pData->icmp_socket.s, pData->phEvents[VBOX_ICMP_EVENT_INDEX],
    303                                        NULL, NULL, addr.sin_addr.s_addr, icp, icmplen, &ipopt,
     321                                       NULL, NULL, addr.sin_addr.s_addr, icp->icmp_data, icmplen - offsetof(struct icmp, icmp_data) , &ipopt,
    304322                                       pData->pvIcmpBuffer, pData->szIcmpBuffer, 10);
    305323                if (status == 0 && (error = GetLastError()) != ERROR_IO_PENDING)
  • trunk/src/VBox/Devices/Network/slirp/slirp_state.h

    r15086 r15112  
    140140    void *pvIcmpBuffer;
    141141    size_t szIcmpBuffer;
     142    /* Accordin MSDN specification IcmpParseReplies
     143     * function should be detected in runtime
     144     */
     145    long (WINAPI * pfIcmpParseReplies)(void *, long);
     146    HMODULE hmIcmpLibrary;
    142147#endif
    143148#endif
  • trunk/src/VBox/Devices/Network/slirp/socket.c

    r15105 r15112  
    1414#endif
    1515#if defined(VBOX_WITH_SLIRP_ICMP) && defined (RT_OS_WINDOWS)
     16#include <iphlpapi.h>
    1617#include <icmpapi.h>
    1718#endif
     
    843844        ICMP_ECHO_REPLY *icr;
    844845        u_char code = ~0;
    845         len = IcmpParseReplies(pData->pvIcmpBuffer, pData->szIcmpBuffer);
     846        len = pData->pfIcmpParseReplies(pData->pvIcmpBuffer, pData->szIcmpBuffer);
    846847        if (len <= 0) {
    847848              LogRel(("Error (%d) occured on ICMP receiving \n", GetLastError())); 
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