Changeset 49110 in vbox for trunk/src/VBox/NetworkServices
- Timestamp:
- Oct 15, 2013 8:56:52 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r49109 r49110 26 26 #include <VBox/com/errorprint.h> 27 27 #include <VBox/com/VirtualBox.h> 28 #include <VBox/com/NativeEventQueue.h> 28 29 29 30 #include <iprt/net.h> … … 120 121 typedef VECNATSERVICEPF::const_iterator CITERATORNATSERVICEPF; 121 122 122 class NATNetworkListener; 123 124 class VBoxNetLwipNAT; 125 126 127 class NATNetworkListener 128 { 129 public: 130 NATNetworkListener():m_pNAT(NULL){} 131 132 HRESULT init(VBoxNetLwipNAT *pNAT) 133 { 134 AssertPtrReturn(pNAT, E_INVALIDARG); 135 136 m_pNAT = pNAT; 137 return S_OK; 138 } 139 140 HRESULT init() 141 { 142 m_pNAT = NULL; 143 return S_OK; 144 } 145 146 void uninit() { m_pNAT = NULL; } 147 148 STDMETHOD(HandleEvent)(VBoxEventType_T aEventType, IEvent *pEvent); 149 150 private: 151 VBoxNetLwipNAT *m_pNAT; 152 }; 153 typedef ListenerImpl<NATNetworkListener, VBoxNetLwipNAT *> NATNetworkListenerImpl; 154 VBOX_LISTENER_DECLARE(NATNetworkListenerImpl) 155 123 156 124 157 class VBoxNetLwipNAT: public VBoxNetBaseService … … 153 186 /* Our NAT network descriptor in Main */ 154 187 ComPtr<INATNetwork> net; 188 ComPtr<NATNetworkListenerImpl> m_listener; 155 189 STDMETHOD(HandleEvent)(VBoxEventType_T aEventType, IEvent *pEvent); 156 190 … … 175 209 176 210 177 class NATNetworkListener178 {179 public:180 NATNetworkListener():m_pNAT(NULL){}181 182 HRESULT init(VBoxNetLwipNAT *pNAT)183 {184 AssertPtrReturn(pNAT, E_INVALIDARG);185 186 m_pNAT = pNAT;187 return S_OK;188 }189 190 HRESULT init()191 {192 m_pNAT = NULL;193 return S_OK;194 }195 196 void uninit() { m_pNAT = NULL; }197 198 STDMETHOD(HandleEvent)(VBoxEventType_T aEventType, IEvent *pEvent)199 {200 if (m_pNAT)201 return m_pNAT->HandleEvent(aEventType, pEvent);202 else203 return E_FAIL;204 }205 206 private:207 VBoxNetLwipNAT *m_pNAT;208 };209 210 211 typedef ListenerImpl<NATNetworkListener, VBoxNetLwipNAT *> NATNetworkListenerImpl;212 VBOX_LISTENER_DECLARE(NATNetworkListenerImpl)213 214 215 216 211 static VBoxNetLwipNAT *g_pLwipNat; 212 213 STDMETHODIMP NATNetworkListener::HandleEvent(VBoxEventType_T aEventType, IEvent *pEvent) 214 { 215 if (m_pNAT) 216 return m_pNAT->HandleEvent(aEventType, pEvent); 217 else 218 return E_FAIL; 219 } 220 217 221 218 222 … … 912 916 hrc = pES->RegisterListener(listener, ComSafeArrayAsInParam(events), true); 913 917 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 918 919 m_listener = listener; 914 920 #endif 915 921
Note:
See TracChangeset
for help on using the changeset viewer.