VirtualBox

Ignore:
Timestamp:
Nov 12, 2014 4:16:52 AM (10 years ago)
Author:
vboxsync
Message:

NAT: We don't support Windows 2000, so use Windows ICMP API directly.
We have been using runtime lookup for some functions and direct calls
for some others which is inconsistent and proves "by construction"
that the indirection is not necessary.

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

Legend:

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

    r53298 r53310  
    2222#include <icmpapi.h>
    2323
    24 /*
    25  * XXX: we don't support w2k anymore, so we may just as well link to
    26  * iphlpapi.dll and use direct references now.  Besides, we already
    27  * refer to some of Icmp* functions directly anyway.
    28  */
    29 #include <iprt/ldr.h>
    3024
    3125int
    3226icmpwin_init(PNATState pData)
    3327{
    34     RTLDRMOD hLdrMod;
    35     int rc;
    36 
    37     rc = RTLdrLoadSystem("Iphlpapi.dll", true /*fNoUnload*/, &hLdrMod);
    38     if (RT_SUCCESS(rc))
    39     {
    40         pData->pfIcmpParseReplies = (long (WINAPI *)(void *, long))RTLdrGetFunction(hLdrMod, "IcmpParseReplies");
    41         pData->pfIcmpCloseHandle = (BOOL (WINAPI *)(HANDLE))RTLdrGetFunction(hLdrMod, "IcmpCloseHandle");
    42         RTLdrClose(hLdrMod);
    43     }
    44 
    45     if (pData->pfIcmpParseReplies == NULL)
    46     {
    47         int rc = RTLdrLoadSystem("Icmp.dll", true /*fNoUnload*/, &hLdrMod);
    48         if (RT_FAILURE(rc))
    49         {
    50             LogRel(("NAT: Icmp.dll could not be loaded: %Rrc\n", rc));
    51             return 1;
    52         }
    53         pData->pfIcmpParseReplies = (long (WINAPI *)(void *, long))RTLdrGetFunction(hLdrMod, "IcmpParseReplies");
    54         pData->pfIcmpCloseHandle = (BOOL (WINAPI *)(HANDLE))RTLdrGetFunction(hLdrMod, "IcmpCloseHandle");
    55         RTLdrClose(hLdrMod);
    56     }
    57 
    58     if (pData->pfIcmpParseReplies == NULL)
    59     {
    60         LogRel(("NAT: Can't find IcmpParseReplies symbol\n"));
    61         return 1;
    62     }
    63     if (pData->pfIcmpCloseHandle == NULL)
    64     {
    65         LogRel(("NAT: Can't find IcmpCloseHandle symbol\n"));
    66         return 1;
    67     }
    68 
    6928    pData->icmp_socket.sh = IcmpCreateFile();
    7029    pData->phEvents[VBOX_ICMP_EVENT_INDEX] = CreateEvent(NULL, FALSE, FALSE, NULL);
     
    7938icmpwin_finit(PNATState pData)
    8039{
    81     pData->pfIcmpCloseHandle(pData->icmp_socket.sh);
     40    IcmpCloseHandle(pData->icmp_socket.sh);
    8241    RTMemFree(pData->pvIcmpBuffer);
    8342}
  • trunk/src/VBox/Devices/Network/slirp/slirp_state.h

    r52754 r53310  
    203203    void *pvIcmpBuffer;
    204204    uint32_t cbIcmpBuffer;
    205     /* According MSDN specification IcmpParseReplies
    206      * function should be detected at runtime.
    207      */
    208     long (WINAPI * pfIcmpParseReplies)(void *, long);
    209     BOOL (WINAPI * pfIcmpCloseHandle)(HANDLE);
    210205# endif
    211206#if defined(RT_OS_WINDOWS)
  • trunk/src/VBox/Devices/Network/slirp/socket.c

    r53056 r53310  
    14611461    int size;
    14621462
    1463     len = pData->pfIcmpParseReplies(pData->pvIcmpBuffer, pData->cbIcmpBuffer);
     1463    len = IcmpParseReplies(pData->pvIcmpBuffer, pData->cbIcmpBuffer);
    14641464    if (len < 0)
    14651465    {
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