Changeset 21019 in vbox for trunk/src/VBox
- Timestamp:
- Jun 29, 2009 10:26:11 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r21018 r21019 58 58 #define VBOX_NAT_DELAY_HACK 59 59 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) \ 61 61 do { \ 62 62 (rc) = CFGMR3Query ## type((node), name, &(var)); \ 63 63 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); \ 66 66 }while(0) 67 67 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) \ 69 69 do { \ 70 70 (rc) = CFGMR3Query ## type((node), name, &(var)); \ 71 71 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); \ 74 74 }while(0) 75 75 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) \ 77 77 do { \ 78 78 (rc) = CFGMR3Query ## type((node), name, &(var), var_size); \ 79 79 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); \ 82 82 }while(0) 83 83 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)) 94 94 95 95 … … 702 702 char szProtocol[32]; 703 703 int rc; 704 GET_STRING(rc, p Node, iInstance, "Protocol", szProtocol[0], sizeof(szProtocol));704 GET_STRING(rc, pThis, pNode, "Protocol", szProtocol[0], sizeof(szProtocol)); 705 705 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 706 706 { 707 707 fUDP = false; 708 GET_BOOL(rc, p Node, iInstance, "UDP", fUDP);708 GET_BOOL(rc, pThis, pNode, "UDP", fUDP); 709 709 } 710 710 else if (RT_SUCCESS(rc)) … … 721 721 /* host port */ 722 722 int32_t iHostPort; 723 GET_S32_STRICT(rc, p Node, iInstance, "HostPort", iHostPort);723 GET_S32_STRICT(rc, pThis, pNode, "HostPort", iHostPort); 724 724 725 725 /* guest port */ 726 726 int32_t iGuestPort; 727 GET_S32_STRICT(rc, p Node, iInstance, "GuestPort", iGuestPort);727 GET_S32_STRICT(rc, pThis, pNode, "GuestPort", iGuestPort); 728 728 729 729 /* guest address */ 730 730 struct in_addr GuestIP; 731 731 /* @todo (vvl) use CTL_* */ 732 GETIP_DEF(rc, p Node, iInstance, GuestIP, htonl(ntohl(Network) | 15));732 GETIP_DEF(rc, pThis, pNode, GuestIP, htonl(ntohl(Network) | 15)); 733 733 734 734 /* … … 736 736 */ 737 737 struct in_addr BindIP; 738 GETIP_DEF(rc, p Node, iInstance, BindIP, INADDR_ANY);738 GETIP_DEF(rc, pThis, pNode, BindIP, INADDR_ANY); 739 739 if (slirp_redir(pThis->pNATState, fUDP, BindIP, iHostPort, GuestIP, iGuestPort) < 0) 740 740 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_NAT_REDIR_SETUP, RT_SRC_POS, … … 820 820 int rc; 821 821 bool fPassDomain = true; 822 GET_BOOL(rc, p CfgHandle, pDrvIns->iInstance, "PassDomain", fPassDomain);822 GET_BOOL(rc, pThis, pCfgHandle, "PassDomain", fPassDomain); 823 823 824 GET_STRING_ALLOC(rc, p CfgHandle, pDrvIns->iInstance, "TFTPPrefix", pThis->pszTFTPPrefix);825 GET_STRING_ALLOC(rc, p CfgHandle, pDrvIns->iInstance, "BootFile", pThis->pszBootFile);826 GET_STRING_ALLOC(rc, p CfgHandle, 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); 827 827 828 828 int fDNSProxy = 0; 829 GET_S32(rc, p CfgHandle, pDrvIns->iInstance, "DNSProxy", fDNSProxy);829 GET_S32(rc, pThis, pCfgHandle, "DNSProxy", fDNSProxy); 830 830 831 831 /* … … 848 848 849 849 /* Generate a network address for this network card. */ 850 GET_STRING(rc, p CfgHandle, pDrvIns->iInstance, "Network", szNetwork[0], sizeof(szNetwork));850 GET_STRING(rc, pThis, pCfgHandle, "Network", szNetwork[0], sizeof(szNetwork)); 851 851 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 852 852 RTStrPrintf(szNetwork, sizeof(szNetwork), "10.0.%d.0/24", pDrvIns->iInstance + 2); … … 875 875 slirp_set_dhcp_dns_proxy(pThis->pNATState, !!fDNSProxy); 876 876 char *pszBindIP = NULL; 877 GET_STRING_ALLOC(rc, p CfgHandle, pDrvIns->iInstance, "BindIP", pszBindIP);877 GET_STRING_ALLOC(rc, pThis, pCfgHandle, "BindIP", pszBindIP); 878 878 rc = slirp_set_binding_address(pThis->pNATState, pszBindIP); 879 879 if (rc != 0)
Note:
See TracChangeset
for help on using the changeset viewer.