Changeset 54700 in vbox
- Timestamp:
- Mar 9, 2015 4:14:52 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 98859
- Location:
- trunk/src/VBox/NetworkServices
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp
r54671 r54700 93 93 94 94 int init(); 95 void done(); 95 96 void usage(void) { /* XXX: document options */ }; 96 97 int parseOpt(int rc, const RTGETOPTUNION& getOptVal); … … 129 130 130 131 /** Listener for Host DNS changes */ 131 ComPtr<NATNetworkListenerImpl> m_vboxListener; 132 ComNatListenerPtr m_VBoxListener; 133 ComNatListenerPtr m_VBoxClientListener; 132 134 133 135 NetworkManager *m_NetworkManager; … … 303 305 } 304 306 307 void VBoxNetDhcp::done() 308 { 309 destroyNatListener(m_VBoxListener, virtualbox); 310 destroyClientListener(m_VBoxClientListener, virtualboxClient); 311 } 305 312 306 313 int VBoxNetDhcp::processUDP(void *pv, size_t cbPv) … … 517 524 AssertMsgRCReturn(rc, ("Wasn't able to fetch Dns info"), rc); 518 525 519 ComEventTypeArray aVBoxEvents; 520 aVBoxEvents.push_back(VBoxEventType_OnHostNameResolutionConfigurationChange); 521 aVBoxEvents.push_back(VBoxEventType_OnNATNetworkStartStop); 522 rc = createNatListener(m_vboxListener, virtualbox, this, aVBoxEvents); 523 AssertRCReturn(rc, rc); 526 { 527 ComEventTypeArray eventTypes; 528 eventTypes.push_back(VBoxEventType_OnHostNameResolutionConfigurationChange); 529 eventTypes.push_back(VBoxEventType_OnNATNetworkStartStop); 530 rc = createNatListener(m_VBoxListener, virtualbox, this, eventTypes); 531 AssertRCReturn(rc, rc); 532 } 533 534 { 535 ComEventTypeArray eventTypes; 536 eventTypes.push_back(VBoxEventType_OnVBoxSVCAvailabilityChanged); 537 rc = createClientListener(m_VBoxClientListener, virtualboxClient, this, eventTypes); 538 AssertRCReturn(rc, rc); 539 } 524 540 525 541 RTNETADDRIPV4 LowerAddress; … … 588 604 return VINF_SUCCESS; 589 605 } 590 591 606 592 607 HRESULT VBoxNetDhcp::HandleEvent(VBoxEventType_T aEventType, IEvent *pEvent) … … 607 622 break; 608 623 } 624 625 case VBoxEventType_OnVBoxSVCAvailabilityChanged: 626 { 627 shutdown(); 628 break; 629 } 609 630 } 610 631 … … 648 669 g_pDhcp = pDhcp; 649 670 rc = pDhcp->run(); 671 pDhcp->done(); 672 650 673 g_pDhcp = NULL; 651 674 delete pDhcp; -
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r54671 r54700 17 17 18 18 /* Must be included before winutils.h (lwip/def.h), otherwise Windows build breaks. */ 19 #define LOG_GROUP LOG_GROUP_NAT_SERVICE 20 19 21 #include <iprt/cpp/mem.h> 20 22 … … 53 55 #include <iprt/semaphore.h> 54 56 #include <iprt/cpp/utils.h> 55 #define LOG_GROUP LOG_GROUP_NAT_SERVICE56 57 #include <VBox/log.h> 57 58 … … 167 168 /* Our NAT network descriptor in Main */ 168 169 ComPtr<INATNetwork> m_net; 169 ComNatListenerPtr m_listener;170 171 170 ComPtr<IHost> m_host; 172 ComNatListenerPtr m_vboxListener; 171 172 ComNatListenerPtr m_NatListener; 173 ComNatListenerPtr m_VBoxListener; 174 ComNatListenerPtr m_VBoxClientListener; 173 175 static INTNETSEG aXmitSeg[64]; 174 176 … … 399 401 break; 400 402 } 403 404 case VBoxEventType_OnVBoxSVCAvailabilityChanged: 405 { 406 LogRel(("VBoxSVC became unavailable, exiting.\n")); 407 shutdown(); 408 break; 409 } 401 410 } 402 411 return hrc; … … 780 789 AssertRCReturn(rc, rc); 781 790 782 ComEventTypeArray aNetEvents; 783 aNetEvents.push_back(VBoxEventType_OnNATNetworkPortForward); 784 aNetEvents.push_back(VBoxEventType_OnNATNetworkSetting); 785 rc = createNatListener(m_listener, virtualbox, this, aNetEvents); 786 AssertRCReturn(rc, rc); 791 { 792 ComEventTypeArray eventTypes; 793 eventTypes.push_back(VBoxEventType_OnNATNetworkPortForward); 794 eventTypes.push_back(VBoxEventType_OnNATNetworkSetting); 795 rc = createNatListener(m_NatListener, virtualbox, this, eventTypes); 796 AssertRCReturn(rc, rc); 797 } 787 798 788 799 … … 792 803 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 793 804 794 ComEventTypeArray aVBoxEvents; 795 aVBoxEvents.push_back(VBoxEventType_OnHostNameResolutionConfigurationChange); 796 aVBoxEvents.push_back(VBoxEventType_OnNATNetworkStartStop); 797 rc = createNatListener(m_vboxListener, virtualbox, this, aVBoxEvents); 798 AssertRCReturn(rc, rc); 805 { 806 ComEventTypeArray eventTypes; 807 eventTypes.push_back(VBoxEventType_OnHostNameResolutionConfigurationChange); 808 eventTypes.push_back(VBoxEventType_OnNATNetworkStartStop); 809 rc = createNatListener(m_VBoxListener, virtualbox, this, eventTypes); 810 AssertRCReturn(rc, rc); 811 } 812 813 { 814 ComEventTypeArray eventTypes; 815 eventTypes.push_back(VBoxEventType_OnVBoxSVCAvailabilityChanged); 816 rc = createClientListener(m_VBoxClientListener, virtualboxClient, this, eventTypes); 817 AssertRCReturn(rc, rc); 818 } 799 819 800 820 BOOL fIPv6Enabled = FALSE; … … 1045 1065 m_vecPortForwardRule4.clear(); 1046 1066 m_vecPortForwardRule6.clear(); 1067 1068 destroyNatListener(m_NatListener, virtualbox); 1069 destroyNatListener(m_VBoxListener, virtualbox); 1070 destroyClientListener(m_VBoxClientListener, virtualboxClient); 1047 1071 1048 1072 return VINF_SUCCESS; … … 1370 1394 { 1371 1395 /* Create the window. */ 1372 hwnd = CreateWindowEx (WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT | WS_EX_TOPMOST, 1373 g_WndClassName, g_WndClassName, 1374 WS_POPUPWINDOW, 1375 -200, -200, 100, 100, NULL, NULL, hInstance, NULL); 1396 hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT | WS_EX_TOPMOST, 1397 g_WndClassName, g_WndClassName, WS_POPUPWINDOW, 1398 -200, -200, 100, 100, NULL, NULL, hInstance, NULL); 1376 1399 1377 1400 if (hwnd) -
trunk/src/VBox/NetworkServices/NetLib/ComHostUtils.cpp
r54696 r54700 214 214 return VINF_SUCCESS; 215 215 } 216 217 int destroyNatListener(ComNatListenerPtr& listener, const ComVirtualBoxPtr& vboxptr) 218 { 219 if (listener) 220 { 221 ComPtr<IEventSource> esVBox; 222 HRESULT hrc = vboxptr->COMGETTER(EventSource)(esVBox.asOutParam()); 223 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 224 if (!esVBox.isNull()) 225 { 226 hrc = esVBox->UnregisterListener(listener); 227 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 228 } 229 listener.setNull(); 230 } 231 return VINF_SUCCESS; 232 } 233 234 int createClientListener(ComNatListenerPtr& listener, const ComVirtualBoxClientPtr& vboxclientptr, 235 NATNetworkEventAdapter *adapter, /* const */ ComEventTypeArray& events) 236 { 237 ComObjPtr<NATNetworkListenerImpl> obj; 238 HRESULT hrc = obj.createObject(); 239 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 240 241 hrc = obj->init(new NATNetworkListener(), adapter); 242 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 243 244 ComPtr<IEventSource> esVBox; 245 hrc = vboxclientptr->COMGETTER(EventSource)(esVBox.asOutParam()); 246 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 247 248 listener = obj; 249 250 hrc = esVBox->RegisterListener(listener, ComSafeArrayAsInParam(events), true); 251 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 252 253 return VINF_SUCCESS; 254 } 255 256 int destroyClientListener(ComNatListenerPtr& listener, const ComVirtualBoxClientPtr& vboxclientptr) 257 { 258 if (listener) 259 { 260 ComPtr<IEventSource> esVBox; 261 HRESULT hrc = vboxclientptr->COMGETTER(EventSource)(esVBox.asOutParam()); 262 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 263 if (!esVBox.isNull()) 264 { 265 hrc = esVBox->UnregisterListener(listener); 266 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 267 } 268 listener.setNull(); 269 } 270 return VINF_SUCCESS; 271 } -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.cpp
r53502 r54700 208 208 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 209 209 210 hrc = virtualbox.createLocalObject(CLSID_VirtualBox); 210 hrc = virtualboxClient.createInprocObject(CLSID_VirtualBoxClient); 211 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 212 213 hrc = virtualboxClient->COMGETTER(VirtualBox)(virtualbox.asOutParam()); 211 214 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 212 215 } -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h
r50213 r54700 132 132 /* VirtualBox instance */ 133 133 ComPtr<IVirtualBox> virtualbox; 134 ComPtr<IVirtualBoxClient> virtualboxClient; 134 135 135 136 private: -
trunk/src/VBox/NetworkServices/NetLib/utils.h
r54696 r54700 25 25 26 26 typedef ComPtr<IVirtualBox> ComVirtualBoxPtr; 27 typedef ComPtr<IVirtualBoxClient> ComVirtualBoxClientPtr; 27 28 typedef ComPtr<IDHCPServer> ComDhcpServerPtr; 28 29 typedef ComPtr<IHost> ComHostPtr; … … 131 132 int createNatListener(ComNatListenerPtr& listener, const ComVirtualBoxPtr& vboxptr, 132 133 NATNetworkEventAdapter *adapter, /* const */ ComEventTypeArray& events); 134 int destroyNatListener(ComNatListenerPtr& listener, const ComVirtualBoxPtr& vboxptr); 135 int createClientListener(ComNatListenerPtr& listener, const ComVirtualBoxClientPtr& vboxclientptr, 136 NATNetworkEventAdapter *adapter, /* const */ ComEventTypeArray& events); 137 int destroyClientListener(ComNatListenerPtr& listener, const ComVirtualBoxClientPtr& vboxclientptr); 138 133 139 #endif
Note:
See TracChangeset
for help on using the changeset viewer.