Changeset 107821 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jan 16, 2025 2:46:39 PM (4 months ago)
- svn:sync-xref-src-repo-rev:
- 166987
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNATlibslirp.cpp
r107817 r107821 268 268 static DECLCALLBACK(int64_t) drvNAT_ClockGetNsCb(void *opaque); 269 269 static DECLCALLBACK(int) drvNAT_GetREventsCb(int idx, void *opaque); 270 static DECLCALLBACK(int) drvNATNotifyApplyPortForwardCommand(PDRVNAT pThis, bool fRemove, 271 bool fUdp, const char *pHostIp, 272 uint16_t u16HostPort, const char *pGuestIp, uint16_t u16GuestPort); 270 static DECLCALLBACK(int) drvNATNotifyApplyPortForwardCommand(PDRVNAT pThis, bool fRemove, bool fUdp, const char *pszHostIp, 271 uint16_t u16HostPort, const char *pszGuestIp, uint16_t u16GuestPort); 273 272 274 273 … … 938 937 /** @todo r=jack: why are we using IP INADD_ANY for port forward when FE does not do so. */ 939 938 /* host address ("BindIP" name is rather unfortunate given "HostPort" to go with it) */ 940 char mHostIp[MAX_IP_ADDRESS_STR_LEN_W_NULL]; 941 RT_ZERO(mHostIp); 942 // GETIP_DEF(rc, pDrvIns, pNode, mHostIp, INADDR_ANY); 943 GET_STRING(rc, pDrvIns, pNode, "BindIP", mHostIp[0], sizeof(mHostIp)); 939 char szHostIp[MAX_IP_ADDRESS_STR_LEN_W_NULL] = {0}; 940 // GETIP_DEF(rc, pDrvIns, pNode, szHostIp, INADDR_ANY); 941 GET_STRING(rc, pDrvIns, pNode, "BindIP", szHostIp[0], sizeof(szHostIp)); 944 942 945 943 /* guest address */ 946 char mGuestIp[MAX_IP_ADDRESS_STR_LEN_W_NULL]; 947 RT_ZERO(mGuestIp); 948 // GETIP_DEF(rc, pDrvIns, pNode, mGuestIp, INADDR_ANY); 949 GET_STRING(rc, pDrvIns, pNode, "GuestIP", mGuestIp[0], sizeof(mGuestIp)); 950 951 LogRelMax(256, ("Preconfigured port forward rule discovered on startup: " 952 "fUdp=%d, pHostIp=%s, u16HostPort=%u, pGuestIp=%s, u16GuestPort=%u\n", 953 RT_BOOL(fUDP), mHostIp, iHostPort, mGuestIp, iGuestPort)); 944 char szGuestIp[MAX_IP_ADDRESS_STR_LEN_W_NULL] = {0}; 945 // GETIP_DEF(rc, pDrvIns, pNode, szGuestIp, INADDR_ANY); 946 GET_STRING(rc, pDrvIns, pNode, "GuestIP", szGuestIp[0], sizeof(szGuestIp)); 947 948 LogRelMax(256, ("Preconfigured port forward rule discovered on startup: fUdp=%d, HostIp=%s, u16HostPort=%u, GuestIp=%s, u16GuestPort=%u\n", 949 RT_BOOL(fUDP), szHostIp, iHostPort, szGuestIp, iGuestPort)); 954 950 955 951 /* 956 952 * Apply port forward. 957 953 */ 958 if (drvNATNotifyApplyPortForwardCommand(pThis, false /* fRemove */, fUDP, 959 mHostIp, iHostPort, mGuestIp, iGuestPort) < 0) 954 if (drvNATNotifyApplyPortForwardCommand(pThis, false /* fRemove */, fUDP, szHostIp, iHostPort, szGuestIp, iGuestPort) < 0) 960 955 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_NAT_REDIR_SETUP, RT_SRC_POS, 961 N_("NAT#%d: configuration error: failed to set up " 962 "redirection of %d to %d. Probably a conflict with " 963 "existing services or other rules"), iInstance, iHostPort, 964 iGuestPort); 956 N_("NAT#%d: configuration error: failed to set up redirection of %d to %d. " 957 "Probably a conflict with existing services or other rules"), 958 iInstance, iHostPort, iGuestPort); 965 959 } /* for each redir rule */ 966 960 … … 974 968 * @param fRemove Flag to remove port forward instead of create. 975 969 * @param fUdp Flag specifying if UDP. If false, TCP. 976 * @param p HostIpString of host IP address.970 * @param pszHostIp String of host IP address. 977 971 * @param u16HostPort Host port to forward to. 978 * @param p GuestIpString of guest IP address.972 * @param pszGuestIp String of guest IP address. 979 973 * @param u16GuestPort Guest port to forward. 980 974 * 981 975 * @thread ? 982 976 */ 983 static DECLCALLBACK(int) drvNATNotifyApplyPortForwardCommand(PDRVNAT pThis, bool fRemove, 984 bool fUdp, const char *pHostIp, 985 uint16_t u16HostPort, const char *pGuestIp, uint16_t u16GuestPort) 977 static DECLCALLBACK(int) drvNATNotifyApplyPortForwardCommand(PDRVNAT pThis, bool fRemove, bool fUdp, const char *pszHostIp, 978 uint16_t u16HostPort, const char *pszGuestIp, uint16_t u16GuestPort) 986 979 { 987 980 /** @todo r=jack: … … 990 983 */ 991 984 struct in_addr guestIp, hostIp; 992 int rc = VINF_SUCCESS; 993 994 if ( pHostIp == NULL 995 || inet_aton(pHostIp, &hostIp) == 0) 985 986 if ( pszHostIp == NULL 987 || inet_aton(pszHostIp, &hostIp) == 0) 996 988 hostIp.s_addr = INADDR_ANY; 997 989 998 if ( p GuestIp == NULL999 || inet_aton(p GuestIp, &guestIp) == 0)990 if ( pszGuestIp == NULL 991 || inet_aton(pszGuestIp, &guestIp) == 0) 1000 992 guestIp.s_addr = pThis->GuestIP; 1001 993 994 int rc; 1002 995 if (fRemove) 1003 996 rc = slirp_remove_hostfwd(pThis->pNATState->pSlirp, fUdp, hostIp, u16HostPort); … … 1005 998 rc = slirp_add_hostfwd(pThis->pNATState->pSlirp, fUdp, hostIp, 1006 999 u16HostPort, guestIp, u16GuestPort); 1007 1008 1000 if (rc < 0) 1009 1001 { 1010 LogRelFunc(("Port forward modify FAIL! Details: fRemove=%d, fUdp=%d, pHostIp=%s, u16HostPort=%u, pGuestIp=%s, u16GuestPort=%u\n", 1011 RT_BOOL(fRemove), RT_BOOL(fUdp), pHostIp, u16HostPort, pGuestIp, u16GuestPort)); 1012 1002 LogRelFunc(("Port forward modify FAIL! Details: fRemove=%d, fUdp=%d, pszHostIp=%s, u16HostPort=%u, pszGuestIp=%s, u16GuestPort=%u\n", 1003 RT_BOOL(fRemove), RT_BOOL(fUdp), pszHostIp, u16HostPort, pszGuestIp, u16GuestPort)); 1013 1004 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_NAT_REDIR_SETUP, RT_SRC_POS, 1014 N_("NAT#%d: configuration error: failed to set up "1015 "redirection of %d to %d. Probably a conflict with "1016 "existing services or other rules"),pThis->pDrvIns->iInstance, u16HostPort, u16GuestPort);1005 N_("NAT#%d: configuration error: failed to set up redirection of %d to %d. " 1006 "Probably a conflict with existing services or other rules"), 1007 pThis->pDrvIns->iInstance, u16HostPort, u16GuestPort); 1017 1008 } 1018 1009 … … 1034 1025 int rc; 1035 1026 if (pThis->pSlirpThread->enmState != PDMTHREADSTATE_RUNNING) 1036 rc = drvNATNotifyApplyPortForwardCommand(pThis, fRemove, fUdp, pHostIp, 1037 u16HostPort, pGuestIp,u16GuestPort); 1027 rc = drvNATNotifyApplyPortForwardCommand(pThis, fRemove, fUdp, pHostIp, u16HostPort, pGuestIp,u16GuestPort); 1038 1028 else 1039 1029 { 1040 1030 PRTREQ pReq; 1041 1031 rc = RTReqQueueCallEx(pThis->hSlirpReqQueue, &pReq, 0 /*cMillies*/, RTREQFLAGS_VOID, 1042 (PFNRT)drvNATNotifyApplyPortForwardCommand, 7, pThis, fRemove,1043 fUdp, pHostIp, u16HostPort, pGuestIp, u16GuestPort);1032 (PFNRT)drvNATNotifyApplyPortForwardCommand, 7, 1033 pThis, fRemove, fUdp, pHostIp, u16HostPort, pGuestIp, u16GuestPort); 1044 1034 if (rc == VERR_TIMEOUT) 1045 1035 {
Note:
See TracChangeset
for help on using the changeset viewer.