vbox的更動 55365 路徑 trunk/src/VBox/NetworkServices
- 時間撮記:
- 2015-4-22 上午09:34:46 (10 年 以前)
- 位置:
- trunk/src/VBox/NetworkServices
- 檔案:
-
- 修改 7 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/NetworkServices/DHCP/NetworkManagerDhcp.cpp
r49735 r55365 55 55 { 56 56 RawOption opt; 57 memset(&opt, 0, sizeof(RawOption)); 57 RT_ZERO(opt); 58 58 59 /* 1. Find client */ 59 60 ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager(); -
trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp
r54700 r55365 221 221 m_cbCurMsg = 0; 222 222 m_pCurMsg = NULL; 223 memset(&m_CurHdrs, '\0', sizeof(m_CurHdrs));223 RT_ZERO(m_CurHdrs); 224 224 225 225 m_fIgnoreCmdLineParameters = true; … … 499 499 */ 500 500 AssertRCReturn(virtualbox.isNull(), VERR_INTERNAL_ERROR); 501 std::string networkName = getNetwork ();501 std::string networkName = getNetworkName(); 502 502 503 503 int rc = findDhcpServer(virtualbox, networkName, m_DhcpServer); … … 616 616 { 617 617 ComPtr <INATNetworkStartStopEvent> pStartStopEvent = pEvent; 618 619 com::Bstr networkName; 620 HRESULT hrc = pStartStopEvent->COMGETTER(NetworkName)(networkName.asOutParam()); 621 AssertComRCReturn(hrc, hrc); 622 if (networkName.compare(getNetworkName().c_str())) 623 break; /* change not for our network */ 624 618 625 BOOL fStart = TRUE; 619 HRESULT hrc = pStartStopEvent->COMGETTER(StartEvent)(&fStart); 626 hrc = pStartStopEvent->COMGETTER(StartEvent)(&fStart); 627 AssertComRCReturn(hrc, hrc); 620 628 if (!fStart) 621 629 shutdown(); -
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r54700 r55365 203 203 * @note: this work on Event thread. 204 204 */ 205 HRESULT VBoxNetLwipNAT::HandleEvent(VBoxEventType_T aEventType, 206 IEvent *pEvent) 205 HRESULT VBoxNetLwipNAT::HandleEvent(VBoxEventType_T aEventType, IEvent *pEvent) 207 206 { 208 207 HRESULT hrc = S_OK; … … 211 210 case VBoxEventType_OnNATNetworkSetting: 212 211 { 213 ComPtr<INATNetworkSettingEvent> evSettings(pEvent); 212 ComPtr<INATNetworkSettingEvent> pSettingsEvent(pEvent); 213 214 com::Bstr networkName; 215 hrc = pSettingsEvent->COMGETTER(NetworkName)(networkName.asOutParam()); 216 AssertComRCReturn(hrc, hrc); 217 if (networkName.compare(getNetworkName().c_str())) 218 break; /* change not for our network */ 219 214 220 // XXX: only handle IPv6 default route for now 215 216 221 if (!m_ProxyOptions.ipv6_enabled) 217 {218 222 break; 219 }220 223 221 224 BOOL fIPv6DefaultRoute = FALSE; 222 hrc = evSettings->COMGETTER(AdvertiseDefaultIPv6RouteEnabled)(&fIPv6DefaultRoute);223 Assert Return(SUCCEEDED(hrc), hrc);225 hrc = pSettingsEvent->COMGETTER(AdvertiseDefaultIPv6RouteEnabled)(&fIPv6DefaultRoute); 226 AssertComRCReturn(hrc, hrc); 224 227 225 228 if (m_ProxyOptions.ipv6_defroute == fIPv6DefaultRoute) 226 {227 229 break; 228 }229 230 230 231 m_ProxyOptions.ipv6_defroute = fIPv6DefaultRoute; 231 232 tcpip_callback_with_block(proxy_rtadvd_do_quick, &m_LwipNetIf, 0); 232 233 233 break; 234 234 } … … 236 236 case VBoxEventType_OnNATNetworkPortForward: 237 237 { 238 com::Bstr name, strHostAddr, strGuestAddr; 239 LONG lHostPort, lGuestPort; 240 BOOL fCreateFW, fIPv6FW; 238 ComPtr<INATNetworkPortForwardEvent> pForwardEvent = pEvent; 239 240 com::Bstr networkName; 241 hrc = pForwardEvent->COMGETTER(NetworkName)(networkName.asOutParam()); 242 AssertComRCReturn(hrc, hrc); 243 if (networkName.compare(getNetworkName().c_str())) 244 break; /* change not for our network */ 245 246 BOOL fCreateFW; 247 hrc = pForwardEvent->COMGETTER(Create)(&fCreateFW); 248 AssertComRCReturn(hrc, hrc); 249 250 BOOL fIPv6FW; 251 hrc = pForwardEvent->COMGETTER(Ipv6)(&fIPv6FW); 252 AssertComRCReturn(hrc, hrc); 253 254 com::Bstr name; 255 hrc = pForwardEvent->COMGETTER(Name)(name.asOutParam()); 256 AssertComRCReturn(hrc, hrc); 257 241 258 NATProtocol_T proto = NATProtocol_TCP; 242 243 244 ComPtr<INATNetworkPortForwardEvent> pfEvt = pEvent; 245 246 hrc = pfEvt->COMGETTER(Create)(&fCreateFW); 247 AssertReturn(SUCCEEDED(hrc), hrc); 248 249 hrc = pfEvt->COMGETTER(Ipv6)(&fIPv6FW); 250 AssertReturn(SUCCEEDED(hrc), hrc); 251 252 hrc = pfEvt->COMGETTER(Name)(name.asOutParam()); 253 AssertReturn(SUCCEEDED(hrc), hrc); 254 255 hrc = pfEvt->COMGETTER(Proto)(&proto); 256 AssertReturn(SUCCEEDED(hrc), hrc); 257 258 hrc = pfEvt->COMGETTER(HostIp)(strHostAddr.asOutParam()); 259 AssertReturn(SUCCEEDED(hrc), hrc); 260 261 hrc = pfEvt->COMGETTER(HostPort)(&lHostPort); 262 AssertReturn(SUCCEEDED(hrc), hrc); 263 264 hrc = pfEvt->COMGETTER(GuestIp)(strGuestAddr.asOutParam()); 265 AssertReturn(SUCCEEDED(hrc), hrc); 266 267 hrc = pfEvt->COMGETTER(GuestPort)(&lGuestPort); 268 AssertReturn(SUCCEEDED(hrc), hrc); 269 270 VECNATSERVICEPF& rules = (fIPv6FW ? 271 m_vecPortForwardRule6 : 272 m_vecPortForwardRule4); 259 hrc = pForwardEvent->COMGETTER(Proto)(&proto); 260 AssertComRCReturn(hrc, hrc); 261 262 com::Bstr strHostAddr; 263 hrc = pForwardEvent->COMGETTER(HostIp)(strHostAddr.asOutParam()); 264 AssertComRCReturn(hrc, hrc); 265 266 LONG lHostPort; 267 hrc = pForwardEvent->COMGETTER(HostPort)(&lHostPort); 268 AssertComRCReturn(hrc, hrc); 269 270 com::Bstr strGuestAddr; 271 hrc = pForwardEvent->COMGETTER(GuestIp)(strGuestAddr.asOutParam()); 272 AssertComRCReturn(hrc, hrc); 273 274 LONG lGuestPort; 275 hrc = pForwardEvent->COMGETTER(GuestPort)(&lGuestPort); 276 AssertComRCReturn(hrc, hrc); 277 278 VECNATSERVICEPF& rules = fIPv6FW ? m_vecPortForwardRule6 279 : m_vecPortForwardRule4; 273 280 274 281 NATSEVICEPORTFORWARDRULE r; … … 320 327 321 328 RTStrPrintf(r.Pfr.szPfrName, sizeof(r.Pfr.szPfrName), 322 "%s", com::Utf8Str(name).c_str());329 "%s", com::Utf8Str(name).c_str()); 323 330 324 331 RTStrPrintf(r.Pfr.szPfrHostAddr, sizeof(r.Pfr.szPfrHostAddr), 325 "%s", com::Utf8Str(strHostAddr).c_str());332 "%s", com::Utf8Str(strHostAddr).c_str()); 326 333 327 334 /* XXX: limits should be checked */ … … 329 336 330 337 RTStrPrintf(r.Pfr.szPfrGuestAddr, sizeof(r.Pfr.szPfrGuestAddr), 331 "%s", com::Utf8Str(strGuestAddr).c_str());338 "%s", com::Utf8Str(strGuestAddr).c_str()); 332 339 333 340 /* XXX: limits should be checked */ … … 386 393 /* :block */ 0); 387 394 if (error != ERR_OK && ppcszNameServers != NULL) 388 {389 395 RTMemFree(ppcszNameServers); 390 }391 396 break; 392 397 } … … 395 400 { 396 401 ComPtr <INATNetworkStartStopEvent> pStartStopEvent = pEvent; 402 403 com::Bstr networkName; 404 hrc = pStartStopEvent->COMGETTER(NetworkName)(networkName.asOutParam()); 405 AssertComRCReturn(hrc, hrc); 406 if (networkName.compare(getNetworkName().c_str())) 407 break; /* change not for our network */ 408 397 409 BOOL fStart = TRUE; 398 410 hrc = pStartStopEvent->COMGETTER(StartEvent)(&fStart); 411 AssertComRCReturn(hrc, hrc); 412 399 413 if (!fStart) 400 414 shutdown(); … … 641 655 m_ProxyOptions.src4 = NULL; 642 656 m_ProxyOptions.src6 = NULL; 643 memset(&m_src4, 0, sizeof(m_src4));644 memset(&m_src6, 0, sizeof(m_src6));657 RT_ZERO(m_src4); 658 RT_ZERO(m_src6); 645 659 m_src4.sin_family = AF_INET; 646 660 m_src6.sin6_family = AF_INET6; … … 774 788 775 789 776 /** This method executed on main thread, only at the end threr're one threads started explcitly (LWIP and later in ::run()777 * RECV)790 /** 791 * Main thread. Starts also the LWIP thread. 778 792 */ 779 793 int VBoxNetLwipNAT::init() … … 785 799 AssertRCReturn(rc, rc); 786 800 787 std::string networkName = getNetwork ();801 std::string networkName = getNetworkName(); 788 802 rc = findNatNetwork(virtualbox, networkName, m_net); 789 803 AssertRCReturn(rc, rc); … … 894 908 rc = g_pLwipNat->tryGoOnline(); 895 909 if (RT_FAILURE(rc)) 896 {897 910 return rc; 898 }899 911 900 912 /* this starts LWIP thread */ … … 908 920 const char **VBoxNetLwipNAT::getHostNameservers() 909 921 { 910 HRESULT hrc;911 912 922 if (m_host.isNull()) 913 {914 923 return NULL; 915 }916 924 917 925 com::SafeArray<BSTR> aNameServers; 918 hrc = m_host->COMGETTER(NameServers)(ComSafeArrayAsOutParam(aNameServers));926 HRESULT hrc = m_host->COMGETTER(NameServers)(ComSafeArrayAsOutParam(aNameServers)); 919 927 if (FAILED(hrc)) 920 {921 928 return NULL; 922 }923 929 924 930 const size_t cNameServers = aNameServers.size(); 925 931 if (cNameServers == 0) 926 {927 932 return NULL; 928 }929 933 930 934 const char **ppcszNameServers = 931 935 (const char **)RTMemAllocZ(sizeof(char *) * (cNameServers + 1)); 932 936 if (ppcszNameServers == NULL) 933 {934 937 return NULL; 935 }936 938 937 939 size_t idxLast = 0; … … 941 943 ppcszNameServers[idxLast] = RTStrDup(strNameServer.c_str()); 942 944 if (ppcszNameServers[idxLast] != NULL) 943 {944 945 ++idxLast; 945 }946 946 } 947 947 … … 989 989 struct pbuf *p = pbuf_alloc(PBUF_RAW, cbFrame + ETH_PAD_SIZE, PBUF_POOL); 990 990 if (RT_UNLIKELY(p == NULL)) 991 {992 991 return VERR_NO_MEMORY; 993 }994 992 995 993 /* … … 1200 1198 1201 1199 if (RT_SUCCESS(rc)) 1202 {1203 1200 rc = g_pLwipNat->init(); 1204 }1205 1201 1206 1202 if (RT_SUCCESS(rc)) 1207 {1208 1203 g_pLwipNat->run(); 1209 }1210 1204 1211 1205 delete g_pLwipNat; … … 1249 1243 1250 1244 if (pcszNetwork == NULL) 1251 {1252 1245 return VERR_MISSING; 1253 }1254 1246 1255 1247 char szNetwork[RTPATH_MAX]; 1256 1248 rc = RTStrCopy(szNetwork, sizeof(szNetwork), pcszNetwork); 1257 1249 if (RT_FAILURE(rc)) 1258 {1259 1250 return rc; 1260 }1261 1251 1262 1252 // sanitize network name to be usable as a path component … … 1264 1254 { 1265 1255 if (RTPATH_IS_SEP(*p)) 1266 {1267 1256 *p = '_'; 1268 }1269 1257 } 1270 1258 … … 1293 1281 "VBOXNET_%s_RELEASE_LOG", szNetwork); 1294 1282 if (cch >= sizeof(szEnvVarBase)) 1295 {1296 1283 return VERR_BUFFER_OVERFLOW; 1297 }1298 1284 1299 1285 char szError[RTPATH_MAX + 128]; … … 1321 1307 else 1322 1308 hrc = nat->COMGETTER(PortForwardRules4)(ComSafeArrayAsOutParam(rules)); 1323 Assert Return(SUCCEEDED(hrc), VERR_INTERNAL_ERROR);1309 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 1324 1310 1325 1311 NATSEVICEPORTFORWARDRULE Rule; -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetARP.cpp
r46904 r55365 136 136 137 137 uint8_t abTrailer[60 - sizeof(Reply) - sizeof(EthHdr)]; 138 memset(abTrailer, '\0', sizeof(abTrailer));138 RT_ZERO(abTrailer); 139 139 140 140 INTNETSEG aSegs[3]; -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.cpp
r54741 r55365 73 73 struct VBoxNetBaseService::Data 74 74 { 75 Data(const std::string& a Name, const std::string& aNetworkName):76 m_ Name(aName),77 m_Network (aNetworkName),75 Data(const std::string& aServiceName, const std::string& aNetworkName): 76 m_ServiceName(aServiceName), 77 m_NetworkName(aNetworkName), 78 78 m_enmTrunkType(kIntNetTrunkType_WhateverNone), 79 79 m_pSession(NIL_RTR0PTR), … … 92 92 }; 93 93 94 std::string m_ Name;95 std::string m_Network ;94 std::string m_ServiceName; 95 std::string m_NetworkName; 96 96 std::string m_TrunkName; 97 97 INTNETTRUNKTYPE m_enmTrunkType; … … 268 268 { 269 269 case 'N': // --name 270 m->m_ Name = Val.psz;270 m->m_ServiceName = Val.psz; 271 271 break; 272 272 273 273 case 'n': // --network 274 m->m_Network = Val.psz;274 m->m_NetworkName = Val.psz; 275 275 break; 276 276 … … 393 393 OpenReq.Hdr.cbReq = sizeof(OpenReq); 394 394 OpenReq.pSession = m->m_pSession; 395 strncpy(OpenReq.szNetwork, m->m_Network.c_str(), sizeof(OpenReq.szNetwork));395 RTStrCopy(OpenReq.szNetwork, sizeof(OpenReq.szNetwork), m->m_NetworkName.c_str()); 396 396 OpenReq.szNetwork[sizeof(OpenReq.szNetwork) - 1] = '\0'; 397 strncpy(OpenReq.szTrunk, m->m_TrunkName.c_str(), sizeof(OpenReq.szTrunk));397 RTStrCopy(OpenReq.szTrunk, sizeof(OpenReq.szTrunk), m->m_TrunkName.c_str()); 398 398 OpenReq.szTrunk[sizeof(OpenReq.szTrunk) - 1] = '\0'; 399 399 OpenReq.enmTrunkType = m->m_enmTrunkType; … … 581 581 582 582 583 const std::string VBoxNetBaseService::get Name() const584 { 585 return m->m_ Name;586 } 587 588 589 void VBoxNetBaseService::set Name(const std::string& aName)590 { 591 m->m_ Name = aName;592 } 593 594 595 const std::string VBoxNetBaseService::getNetwork () const596 { 597 return m->m_Network ;598 } 599 600 601 void VBoxNetBaseService::setNetwork (const std::string& aNetwork)602 { 603 m->m_Network = aNetwork;583 const std::string VBoxNetBaseService::getServiceName() const 584 { 585 return m->m_ServiceName; 586 } 587 588 589 void VBoxNetBaseService::setServiceName(const std::string& aName) 590 { 591 m->m_ServiceName = aName; 592 } 593 594 595 const std::string VBoxNetBaseService::getNetworkName() const 596 { 597 return m->m_NetworkName; 598 } 599 600 601 void VBoxNetBaseService::setNetworkName(const std::string& aName) 602 { 603 m->m_NetworkName = aName; 604 604 } 605 605 -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h
r54723 r55365 87 87 88 88 protected: 89 const std::string get Name() const;90 void set Name(const std::string&);89 const std::string getServiceName() const; 90 void setServiceName(const std::string&); 91 91 92 const std::string getNetwork () const;93 void setNetwork (const std::string&);92 const std::string getNetworkName() const; 93 void setNetworkName(const std::string&); 94 94 95 95 const RTMAC getMacAddress() const; -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetPortForwardString.cpp
r54944 r55365 234 234 AssertPtrReturn(pPfr, VERR_INVALID_PARAMETER); 235 235 236 memset(pPfr, 0, sizeof(PORTFORWARDRULE));236 RT_ZERO(*pPfr); 237 237 238 238 pszHostAddr = &pPfr->szPfrHostAddr[0]; … … 271 271 pszRaw); 272 272 pszRaw += cbToken; /* move to separator */ 273 cbRaw -= cbToken; 273 274 } 274 275 … … 277 278 278 279 pszRaw++; /* skip separator */ 280 cbRaw--; 279 281 idxRaw = 0; 280 281 cbRaw--;282 282 283 283 if ( ( (fTcpProto = (RTStrNICmp(pszRaw, "tcp", 3) == 0)) … … 293 293 pszRaw += idxRaw; 294 294 cbRaw -= idxRaw; 295 idxRaw = 0;296 295 297 296 idxRaw = netPfStrAddressPortPairParse(pszRaw, cbRaw, … … 306 305 Assert(pszRaw[0] == PF_FIELD_SEPARATOR); 307 306 308 idxRaw = 0;309 310 307 idxRaw = netPfStrAddressPortPairParse(pszRaw, cbRaw, 311 pszGuestAddr, 312 INET6_ADDRSTRLEN, 313 false, 314 &u16GuestPort); 308 pszGuestAddr, INET6_ADDRSTRLEN, 309 false, &u16GuestPort); 315 310 316 311 if (idxRaw < 0) … … 344 339 RTStrFree(pszRawBegin); 345 340 if (pPfr) 346 memset(pPfr, 0, sizeof(PORTFORWARDRULE));341 RT_ZERO(*pPfr); 347 342 return VERR_INVALID_PARAMETER; 348 343 }
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器