VirtualBox

Changeset 43213 in vbox


Ignore:
Timestamp:
Sep 6, 2012 8:37:56 AM (12 years ago)
Author:
vboxsync
Message:

RTSocketGetAddrInfo -> RTSocketQueryAddressStr

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/mangling.h

    r43171 r43213  
    11971197# define RTSocketClose                                  RT_MANGLER(RTSocketClose)
    11981198# define RTSocketFromNative                             RT_MANGLER(RTSocketFromNative)
    1199 # define RTSocketGetAddrInfo                            RT_MANGLER(RTSocketGetAddrInfo)
     1199# define RTSocketQueryAddressStr                        RT_MANGLER(RTSocketQueryAddressStr)
    12001200# define RTSocketGetLocalAddress                        RT_MANGLER(RTSocketGetLocalAddress)
    12011201# define RTSocketGetPeerAddress                         RT_MANGLER(RTSocketGetPeerAddress)
  • trunk/include/iprt/socket.h

    r43206 r43213  
    130130 * Try resolve a host name, returning the first matching address.
    131131 *
    132  * @remarks Gets the ip addresses of a hostname via getaddrinfo(). It returns
    133  *          only the first result for the moment, but this will change with the
    134  *          upcoming IPv6 struct.
    135  *
    136132 * @returns IPRT status code.
    137133 * @param   pszHost         Name or IP address to look up.
    138  * @param   pszResult       Where to return the result.
    139  * @param   pcbResult       Input: The size of the @a pszResult buffer.
     134 * @param   pszAddress      Where to return the stringified address.
     135 * @param   pcbAddress      Input: The size of the @a pszResult buffer.
    140136 *                          Output: size of the returned string.  This is set on
    141137 *                          VERR_BUFFER_OVERFLOW and most other error statuses.
     
    148144 *                          Not modified on failure.
    149145 */
    150 RTDECL(int) RTSocketGetAddrInfo(const char *pszHost, char *pszResult, size_t *pcbResult, PRTNETADDRTYPE penmAddrType);
     146RTDECL(int) RTSocketQueryAddressStr(const char *pszHost, char *pszAddress, size_t *pcbAddress, PRTNETADDRTYPE penmAddrType);
    151147
    152148/**
  • trunk/src/VBox/ExtPacks/VNC/VBoxVNC.cpp

    r43171 r43213  
    337337    uint32_t cbOut = 0;
    338338    size_t resSize = 0;
    339     RTNETADDRTYPE iAddrType = RTNETADDRTYPE_INVALID;
     339    RTNETADDRTYPE enmAddrType;
    340340    char *pszTCPAddress = NULL;
    341341    char *pszTCPPort = NULL;
     
    346346    char *pszServerAddress4 = NULL;
    347347    char *pszServerAddress6 = NULL;
    348     char *pszGetAddrInfo4 = NULL; // used to store the result of RTSocketGetAddrInfo()
    349     char *pszGetAddrInfo6 = NULL; // used to store the result of RTSocketGetAddrInfo()
     348    char *pszGetAddrInfo4 = NULL; // used to store the result of RTSocketQueryAddressStr()
     349    char *pszGetAddrInfo6 = NULL; // used to store the result of RTSocketQueryAddressStr()
    350350
    351351    // get address
     
    383383    pVRDEFeature->u32ClientId = 0;
    384384
     385    /** @todo r=bird: I believe this code is more than a little of confused
     386     *        about how to use RTStrCopy...  The 2nd parameter is the size of the
     387     *        destination buffer, not the size of the source string!!   */
    385388    RTStrCopy(pVRDEFeature->achInfo, 19, "Property/TCP/Ports");
    386389
     
    404407    const uint32_t lVNCAddress4FeatureSize = sizeof(VRDEFEATURE) + 24;
    405408
    406     pszVNCAddress4 = (char *) RTMemTmpAlloc(24);
    407     memset(pszVNCAddress4,'\0',24);
     409    pszVNCAddress4 = (char *) RTMemTmpAllocZ(24);
    408410
    409411    pVRDEFeature->u32ClientId = 0;
     
    454456    rc = -1;
    455457
    456     pszVNCAddress6 = (char *) RTMemTmpAlloc(VNC_ADDRESS_OPTION_MAX);
    457     memset(pszVNCAddress6,'\0',VNC_ADDRESS_OPTION_MAX);
     458    pszVNCAddress6 = (char *) RTMemTmpAllocZ(VNC_ADDRESS_OPTION_MAX);
    458459
    459460    pVRDEFeature->u32ClientId = 0;
     
    476477
    477478    // VNCPort6
    478     pszVNCPort6 = (char *) RTMemTmpAlloc(6);
    479     memset(pszVNCPort6,'\0', 6);
     479    pszVNCPort6 = (char *) RTMemTmpAllocZ(6);
    480480
    481481    pVRDEFeature->u32ClientId = 0;
     
    573573    {
    574574        // here we go, we prefer IPv6 over IPv4;
    575         pszGetAddrInfo6 = (char *) RTMemTmpAlloc(42);
    576         memset(pszGetAddrInfo6, '\0', 42);
    577575        resSize = 42;
    578         iAddrType = RTNETADDRTYPE_IPV6;
    579 
    580         rc = RTSocketGetAddrInfo(pszTCPAddress, pszGetAddrInfo6, &resSize, &iAddrType);
     576        pszGetAddrInfo6 = (char *) RTMemTmpAllocZ(resSize);
     577        enmAddrType = RTNETADDRTYPE_IPV6;
     578
     579        rc = RTSocketQueryAddressStr(pszTCPAddress, pszGetAddrInfo6, &resSize, &enmAddrType);
    581580
    582581        if (RT_SUCCESS(rc))
     
    593592        if (!pszServerAddress6)
    594593        {
    595             pszGetAddrInfo4 = (char *) RTMemTmpAlloc(16);
    596             memset(pszGetAddrInfo4,'\0',16);
    597594            resSize = 16;
    598             iAddrType = RTNETADDRTYPE_IPV4;
    599 
    600             rc = RTSocketGetAddrInfo(pszTCPAddress, pszGetAddrInfo4, &resSize, &iAddrType);
     595            pszGetAddrInfo4 = (char *) RTMemTmpAllocZ(resSize);
     596            enmAddrType = RTNETADDRTYPE_IPV4;
     597
     598            rc = RTSocketQueryAddressStr(pszTCPAddress, pszGetAddrInfo4, &resSize, &enmAddrType);
    601599
    602600            if (RT_SUCCESS(rc))
     
    614612    if (!pszServerAddress4 && strlen(pszVNCAddress4) > 0)
    615613    {
    616         pszGetAddrInfo4 = (char *) RTMemTmpAlloc(16);
    617         memset(pszGetAddrInfo4,'\0',16);
    618614        resSize = 16;
    619         iAddrType = RTNETADDRTYPE_IPV4;
    620 
    621         rc = RTSocketGetAddrInfo(pszVNCAddress4, pszGetAddrInfo4, &resSize, &iAddrType);
     615        pszGetAddrInfo4 = (char *) RTMemTmpAllocZ(resSize);
     616        enmAddrType = RTNETADDRTYPE_IPV4;
     617
     618        rc = RTSocketQueryAddressStr(pszVNCAddress4, pszGetAddrInfo4, &resSize, &enmAddrType);
    622619
    623620        if (RT_SUCCESS(rc))
     
    628625    if (!pszServerAddress6 && strlen(pszVNCAddress6) > 0)
    629626    {
    630         pszGetAddrInfo6 = (char *) RTMemTmpAlloc(42);
    631         memset(pszGetAddrInfo6, '\0', 42);
    632627        resSize = 42;
    633         iAddrType = RTNETADDRTYPE_IPV6;
    634 
    635         rc = RTSocketGetAddrInfo(pszVNCAddress6, pszGetAddrInfo6, &resSize, &iAddrType);
     628        pszGetAddrInfo6 = (char *) RTMemTmpAllocZ(resSize);
     629        enmAddrType = RTNETADDRTYPE_IPV6;
     630
     631        rc = RTSocketQueryAddressStr(pszVNCAddress6, pszGetAddrInfo6, &resSize, &enmAddrType);
    636632
    637633        if (RT_SUCCESS(rc))
  • trunk/src/VBox/Runtime/r3/socket.cpp

    r43206 r43213  
    685685
    686686/*
    687  * new function to allow both ipv4 and ipv6 addresses to be resolved.
    688  * breaks compatibility with windows before 2000
    689  * will change when the new ipv6 struct will be added
    690  * temporary solution
    691  */
    692 RTDECL(int) RTSocketGetAddrInfo(const char *pszHost, char *pszResult, size_t *pcbResult, PRTNETADDRTYPE penmAddrType)
     687 * New function to allow both ipv4 and ipv6 addresses to be resolved.
     688 * Breaks compatibility with windows before 2000.
     689 */
     690RTDECL(int) RTSocketQueryAddressStr(const char *pszHost, char *pszResult, size_t *pcbResult, PRTNETADDRTYPE penmAddrType)
    693691{
    694692    AssertPtrReturn(pszHost, VERR_INVALID_POINTER);
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