Changeset 87381 in vbox
- Timestamp:
- Jan 22, 2021 10:27:07 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r87380 r87381 133 133 134 134 135 class VBoxNetLwipNAT: public VBoxNetBaseService, public NATNetworkEventAdapter 135 class VBoxNetLwipNAT 136 : public VBoxNetBaseService, 137 public NATNetworkEventAdapter 136 138 { 137 139 friend class NATNetworkListener; … … 196 198 }; 197 199 200 INTNETSEG VBoxNetLwipNAT::aXmitSeg[64]; 198 201 199 202 static VBoxNetLwipNAT *g_pLwipNat; 200 INTNETSEG VBoxNetLwipNAT::aXmitSeg[64]; 203 204 205 206 VBoxNetLwipNAT::VBoxNetLwipNAT(SOCKET icmpsock4, SOCKET icmpsock6) 207 : VBoxNetBaseService("VBoxNetNAT", "nat-network") 208 { 209 LogFlowFuncEnter(); 210 211 m_ProxyOptions.ipv6_enabled = 0; 212 m_ProxyOptions.ipv6_defroute = 0; 213 m_ProxyOptions.icmpsock4 = icmpsock4; 214 m_ProxyOptions.icmpsock6 = icmpsock6; 215 m_ProxyOptions.tftp_root = NULL; 216 m_ProxyOptions.src4 = NULL; 217 m_ProxyOptions.src6 = NULL; 218 RT_ZERO(m_src4); 219 RT_ZERO(m_src6); 220 m_src4.sin_family = AF_INET; 221 m_src6.sin6_family = AF_INET6; 222 #if HAVE_SA_LEN 223 m_src4.sin_len = sizeof(m_src4); 224 m_src6.sin6_len = sizeof(m_src6); 225 #endif 226 m_ProxyOptions.nameservers = NULL; 227 228 m_LwipNetIf.name[0] = 'N'; 229 m_LwipNetIf.name[1] = 'T'; 230 231 RTMAC mac; 232 mac.au8[0] = 0x52; 233 mac.au8[1] = 0x54; 234 mac.au8[2] = 0; 235 mac.au8[3] = 0x12; 236 mac.au8[4] = 0x35; 237 mac.au8[5] = 0; 238 setMacAddress(mac); 239 240 RTNETADDRIPV4 address; 241 address.u = RT_MAKE_U32_FROM_U8( 10, 0, 2, 2); // NB: big-endian 242 setIpv4Address(address); 243 244 address.u = RT_H2N_U32_C(0xffffff00); 245 setIpv4Netmask(address); 246 247 fDontLoadRulesOnStartup = false; 248 249 for (size_t i = 0; i < RT_ELEMENTS(g_aGetOptDef); ++i) 250 addCommandLineOption(&g_aGetOptDef[i]); 251 252 LogFlowFuncLeave(); 253 } 254 255 256 VBoxNetLwipNAT::~VBoxNetLwipNAT() 257 { 258 if (m_ProxyOptions.tftp_root) 259 { 260 RTStrFree((char *)m_ProxyOptions.tftp_root); 261 m_ProxyOptions.tftp_root = NULL; 262 } 263 if (m_ProxyOptions.nameservers) 264 { 265 const char **pv = m_ProxyOptions.nameservers; 266 while (*pv) 267 { 268 RTStrFree((char*)*pv); 269 pv++; 270 } 271 RTMemFree(m_ProxyOptions.nameservers); 272 m_ProxyOptions.nameservers = NULL; 273 } 274 } 275 201 276 202 277 /** … … 641 716 642 717 643 VBoxNetLwipNAT::VBoxNetLwipNAT(SOCKET icmpsock4, SOCKET icmpsock6) : VBoxNetBaseService("VBoxNetNAT", "nat-network")644 {645 LogFlowFuncEnter();646 647 m_ProxyOptions.ipv6_enabled = 0;648 m_ProxyOptions.ipv6_defroute = 0;649 m_ProxyOptions.icmpsock4 = icmpsock4;650 m_ProxyOptions.icmpsock6 = icmpsock6;651 m_ProxyOptions.tftp_root = NULL;652 m_ProxyOptions.src4 = NULL;653 m_ProxyOptions.src6 = NULL;654 RT_ZERO(m_src4);655 RT_ZERO(m_src6);656 m_src4.sin_family = AF_INET;657 m_src6.sin6_family = AF_INET6;658 #if HAVE_SA_LEN659 m_src4.sin_len = sizeof(m_src4);660 m_src6.sin6_len = sizeof(m_src6);661 #endif662 m_ProxyOptions.nameservers = NULL;663 664 m_LwipNetIf.name[0] = 'N';665 m_LwipNetIf.name[1] = 'T';666 667 RTMAC mac;668 mac.au8[0] = 0x52;669 mac.au8[1] = 0x54;670 mac.au8[2] = 0;671 mac.au8[3] = 0x12;672 mac.au8[4] = 0x35;673 mac.au8[5] = 0;674 setMacAddress(mac);675 676 RTNETADDRIPV4 address;677 address.u = RT_MAKE_U32_FROM_U8( 10, 0, 2, 2); // NB: big-endian678 setIpv4Address(address);679 680 address.u = RT_H2N_U32_C(0xffffff00);681 setIpv4Netmask(address);682 683 fDontLoadRulesOnStartup = false;684 685 for(unsigned int i = 0; i < RT_ELEMENTS(g_aGetOptDef); ++i)686 addCommandLineOption(&g_aGetOptDef[i]);687 688 LogFlowFuncLeave();689 }690 691 692 VBoxNetLwipNAT::~VBoxNetLwipNAT()693 {694 if (m_ProxyOptions.tftp_root)695 {696 RTStrFree((char *)m_ProxyOptions.tftp_root);697 m_ProxyOptions.tftp_root = NULL;698 }699 if (m_ProxyOptions.nameservers)700 {701 const char **pv = m_ProxyOptions.nameservers;702 while (*pv)703 {704 RTStrFree((char*)*pv);705 pv++;706 }707 RTMemFree(m_ProxyOptions.nameservers);708 m_ProxyOptions.nameservers = NULL;709 }710 }711 712 713 718 /*static*/ int VBoxNetLwipNAT::natServicePfRegister(NATSEVICEPORTFORWARDRULE& natPf) 714 719 {
Note:
See TracChangeset
for help on using the changeset viewer.