VirtualBox

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


Ignore:
Timestamp:
Jun 29, 2009 10:26:11 AM (16 years ago)
Author:
vboxsync
Message:

NAT: pThis as explicit parameter to extradata macro definitions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DrvNAT.cpp

    r21018 r21019  
    5858#define VBOX_NAT_DELAY_HACK
    5959
    60 #define GET_EXTRADATA(node, drv_inst, name, rc, type, type_name, var)                               \
     60#define GET_EXTRADATA(pthis, node, name, rc, type, type_name, var)                                  \
    6161do {                                                                                                \
    6262    (rc) = CFGMR3Query ## type((node), name, &(var));                                               \
    6363    if (RT_FAILURE((rc)) && (rc) != VERR_CFGM_VALUE_NOT_FOUND)                                      \
    64         return PDMDrvHlpVMSetError(pThis->pDrvIns, (rc), RT_SRC_POS, N_("NAT#%d: configuration"    \
    65             " query for \""name"\" " #type_name " failed"), (drv_inst));                            \
     64        return PDMDrvHlpVMSetError((pthis)->pDrvIns, (rc), RT_SRC_POS, N_("NAT#%d: configuration query for \""name"\" " #type_name " failed"), \
     65                                   (pthis)->pDrvIns->iInstance);                                    \
    6666}while(0)
    6767
    68 #define GET_ED_STRICT(node, drv_inst, name, rc, type, type_name, var)                               \
     68#define GET_ED_STRICT(pthis, node, name, rc, type, type_name, var)                                  \
    6969do {                                                                                                \
    7070    (rc) = CFGMR3Query ## type((node), name, &(var));                                               \
    7171    if (RT_FAILURE((rc)))                                                                           \
    72         return PDMDrvHlpVMSetError(pThis->pDrvIns, (rc), RT_SRC_POS, N_("NAT#%d: configuration"    \
    73             " query for \""name"\" " #type_name " failed"), (drv_inst));                            \
     72        return PDMDrvHlpVMSetError((pthis)->pDrvIns, (rc), RT_SRC_POS, N_("NAT#%d: configuration query for \""name"\" " #type_name " failed"), \
     73                                  (pthis)->pDrvIns->iInstance);                                     \
    7474}while(0)
    7575
    76 #define GET_EXTRADATA_N(node, drv_inst, name, rc, type, type_name, var, var_size)                   \
     76#define GET_EXTRADATA_N(pthis, node, name, rc, type, type_name, var, var_size)                      \
    7777do {                                                                                                \
    7878    (rc) = CFGMR3Query ## type((node), name, &(var), var_size);                                     \
    7979    if (RT_FAILURE((rc)) && (rc) != VERR_CFGM_VALUE_NOT_FOUND)                                      \
    80         return PDMDrvHlpVMSetError(pThis->pDrvIns, (rc), RT_SRC_POS, N_("NAT#%d: configuration"    \
    81             " query for \""name"\" " #type_name " failed"), (drv_inst));                            \
     80        return PDMDrvHlpVMSetError((pthis)->pDrvIns, (rc), RT_SRC_POS, N_("NAT#%d: configuration query for \""name"\" " #type_name " failed"), \
     81                                  (pthis)->pDrvIns->iInstance);                                     \
    8282}while(0)
    8383
    84 #define GET_BOOL(rc, node, drv_inst, name, var) \
    85     GET_EXTRADATA(node, drv_inst, name, (rc), Bool, bolean, (var))
    86 #define GET_STRING(rc, node, drv_inst, name, var, var_size) \
    87     GET_EXTRADATA_N(node, drv_inst, name, (rc), String, string, (var), (var_size))
    88 #define GET_STRING_ALLOC(rc, node, drv_inst, name, var) \
    89     GET_EXTRADATA(node, drv_inst, name, (rc), StringAlloc, string, (var))
    90 #define GET_S32(rc, node, drv_inst, name, var) \
    91     GET_EXTRADATA(node, drv_inst, name, (rc), S32, int, (var))
    92 #define GET_S32_STRICT(rc, node, drv_inst, name, var) \
    93     GET_ED_STRICT(node, drv_inst, name, (rc), S32, int, (var))
     84#define GET_BOOL(rc, pthis, node, name, var) \
     85    GET_EXTRADATA(pthis, node, name, (rc), Bool, bolean, (var))
     86#define GET_STRING(rc, pthis, node, name, var, var_size) \
     87    GET_EXTRADATA_N(pthis, node, name, (rc), String, string, (var), (var_size))
     88#define GET_STRING_ALLOC(rc, pthis, node, name, var) \
     89    GET_EXTRADATA(pthis, node, name, (rc), StringAlloc, string, (var))
     90#define GET_S32(rc, pthis, node, name, var) \
     91    GET_EXTRADATA(pthis, node, name, (rc), S32, int, (var))
     92#define GET_S32_STRICT(rc, pthis, node, name, var) \
     93    GET_ED_STRICT(pthis, node, name, (rc), S32, int, (var))
    9494
    9595
     
    702702        char szProtocol[32];
    703703        int rc;
    704         GET_STRING(rc, pNode, iInstance, "Protocol", szProtocol[0], sizeof(szProtocol));
     704        GET_STRING(rc, pThis, pNode, "Protocol", szProtocol[0], sizeof(szProtocol));
    705705        if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    706706        {
    707707            fUDP = false;
    708             GET_BOOL(rc, pNode, iInstance, "UDP", fUDP);
     708            GET_BOOL(rc, pThis, pNode, "UDP", fUDP);
    709709        }
    710710        else if (RT_SUCCESS(rc))
     
    721721        /* host port */
    722722        int32_t iHostPort;
    723         GET_S32_STRICT(rc, pNode, iInstance, "HostPort", iHostPort);
     723        GET_S32_STRICT(rc, pThis, pNode, "HostPort", iHostPort);
    724724
    725725        /* guest port */
    726726        int32_t iGuestPort;
    727         GET_S32_STRICT(rc, pNode, iInstance, "GuestPort", iGuestPort);
     727        GET_S32_STRICT(rc, pThis, pNode, "GuestPort", iGuestPort);
    728728
    729729        /* guest address */
    730730        struct in_addr GuestIP;
    731731        /* @todo (vvl) use CTL_* */
    732         GETIP_DEF(rc, pNode, iInstance, GuestIP, htonl(ntohl(Network) | 15));
     732        GETIP_DEF(rc, pThis, pNode, GuestIP, htonl(ntohl(Network) | 15));
    733733
    734734        /*
     
    736736         */
    737737        struct in_addr BindIP;
    738         GETIP_DEF(rc, pNode, iInstance, BindIP, INADDR_ANY);
     738        GETIP_DEF(rc, pThis, pNode, BindIP, INADDR_ANY);
    739739        if (slirp_redir(pThis->pNATState, fUDP, BindIP, iHostPort, GuestIP, iGuestPort) < 0)
    740740            return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_NAT_REDIR_SETUP, RT_SRC_POS,
     
    820820    int rc;
    821821    bool fPassDomain = true;
    822     GET_BOOL(rc, pCfgHandle, pDrvIns->iInstance, "PassDomain", fPassDomain);
     822    GET_BOOL(rc, pThis, pCfgHandle, "PassDomain", fPassDomain);
    823823   
    824     GET_STRING_ALLOC(rc, pCfgHandle, pDrvIns->iInstance, "TFTPPrefix", pThis->pszTFTPPrefix);
    825     GET_STRING_ALLOC(rc, pCfgHandle, pDrvIns->iInstance, "BootFile", pThis->pszBootFile);
    826     GET_STRING_ALLOC(rc, pCfgHandle, pDrvIns->iInstance, "NextServer", pThis->pszNextServer);
     824    GET_STRING_ALLOC(rc, pThis, pCfgHandle, "TFTPPrefix", pThis->pszTFTPPrefix);
     825    GET_STRING_ALLOC(rc, pThis, pCfgHandle, "BootFile", pThis->pszBootFile);
     826    GET_STRING_ALLOC(rc, pThis, pCfgHandle, "NextServer", pThis->pszNextServer);
    827827
    828828    int fDNSProxy = 0;
    829     GET_S32(rc, pCfgHandle, pDrvIns->iInstance, "DNSProxy", fDNSProxy);
     829    GET_S32(rc, pThis, pCfgHandle, "DNSProxy", fDNSProxy);
    830830
    831831    /*
     
    848848
    849849    /* Generate a network address for this network card. */
    850     GET_STRING(rc, pCfgHandle, pDrvIns->iInstance, "Network", szNetwork[0], sizeof(szNetwork));
     850    GET_STRING(rc, pThis, pCfgHandle, "Network", szNetwork[0], sizeof(szNetwork));
    851851    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    852852        RTStrPrintf(szNetwork, sizeof(szNetwork), "10.0.%d.0/24", pDrvIns->iInstance + 2);
     
    875875        slirp_set_dhcp_dns_proxy(pThis->pNATState, !!fDNSProxy);
    876876        char *pszBindIP = NULL;
    877         GET_STRING_ALLOC(rc, pCfgHandle, pDrvIns->iInstance, "BindIP", pszBindIP);
     877        GET_STRING_ALLOC(rc, pThis, pCfgHandle, "BindIP", pszBindIP);
    878878        rc = slirp_set_binding_address(pThis->pNATState, pszBindIP);
    879879        if (rc != 0)
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