Changeset 21018 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Jun 29, 2009 10:07:11 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r21011 r21018 92 92 #define GET_S32_STRICT(rc, node, drv_inst, name, var) \ 93 93 GET_ED_STRICT(node, drv_inst, name, (rc), S32, int, (var)) 94 95 96 97 #define DOGETIP(rc, node, instance, status, x) \ 98 do { \ 99 char sz##x[32]; \ 100 GET_STRING((rc), (node), (instance), #x, sz ## x[0], sizeof(sz ## x)); \ 101 if (rc != VERR_CFGM_VALUE_NOT_FOUND) \ 102 (status) = inet_aton(sz ## x, &x); \ 103 }while(0) 104 105 #define GETIP_DEF(rc, node, instance, x, def) \ 106 do \ 107 { \ 108 int status = 0; \ 109 DOGETIP((rc), (node), (instance), status, x); \ 110 if (status == 0 || rc == VERR_CFGM_VALUE_NOT_FOUND) \ 111 x.s_addr = def; \ 112 }while(0) 94 113 95 114 /******************************************************************************* … … 700 719 iInstance, szProtocol); 701 720 } 702 703 #define DOGETIP(rc, status, x) \704 do { \705 char sz##x[32]; \706 GET_STRING(rc, pNode, iInstance, #x, sz ## x[0], sizeof(sz ## x)); \707 if (rc == VERR_CFGM_VALUE_NOT_FOUND) \708 RTStrPrintf(sz ## x, sizeof(sz ## x), "%d.%d.%d.%d", \709 (Network & 0xFF000000) >> 24, (Network & 0xFF0000) >> 16, \710 (Network & 0xFF00) >> 8, (Network & 0xE0) | 15); \711 status = inet_aton(sz ## x, &x); \712 }while(0)713 714 #define GETIP(x) \715 do \716 { \717 int status = 0; \718 DOGETIP(rc, status, x); \719 if (status == 0) \720 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_NAT_REDIR_GUEST_IP, RT_SRC_POS, \721 N_("NAT#%d: configuration error: invalid \"" #x \722 "\" inet_aton failed"), iInstance); \723 }while(0)724 725 #define GETIP_DEF(x, def) \726 do \727 { \728 int status = 0; \729 DOGETIP(rc, status, x); \730 if (status == 0 || rc == VERR_CFGM_VALUE_NOT_FOUND) \731 x.s_addr = def; \732 }while(0)733 721 /* host port */ 734 722 int32_t iHostPort; … … 741 729 /* guest address */ 742 730 struct in_addr GuestIP; 743 GETIP(GuestIP); 731 /* @todo (vvl) use CTL_* */ 732 GETIP_DEF(rc, pNode, iInstance, GuestIP, htonl(ntohl(Network) | 15)); 744 733 745 734 /* … … 747 736 */ 748 737 struct in_addr BindIP; 749 GETIP_DEF( BindIP, INADDR_ANY);738 GETIP_DEF(rc, pNode, iInstance, BindIP, INADDR_ANY); 750 739 if (slirp_redir(pThis->pNATState, fUDP, BindIP, iHostPort, GuestIP, iGuestPort) < 0) 751 740 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_NAT_REDIR_SETUP, RT_SRC_POS, … … 754 743 "existing services or other rules"), iInstance, iHostPort, 755 744 iGuestPort); 756 #undef GETIP757 745 } /* for each redir rule */ 758 746
Note:
See TracChangeset
for help on using the changeset viewer.