Changeset 87450 in vbox for trunk/src/VBox/NetworkServices
- Timestamp:
- Jan 27, 2021 2:00:34 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 142468
- Location:
- trunk/src/VBox/NetworkServices
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r87449 r87450 113 113 114 114 115 static RTGETOPTDEF g_aGetOptDef[] =116 {117 { "--port-forward4", 'p', RTGETOPT_REQ_STRING },118 { "--port-forward6", 'P', RTGETOPT_REQ_STRING }119 };120 115 121 116 typedef struct NATSERVICEPORTFORWARDRULE … … 156 151 ComNatListenerPtr m_VBoxClientListener; 157 152 158 /* Only for debug needs, by default NAT service should load rules from SVC159 * on startup, and then on sync them on events.160 */161 bool fDontLoadRulesOnStartup;162 163 153 VECNATSERVICEPF m_vecPortForwardRule4; 164 154 VECNATSERVICEPF m_vecPortForwardRule6; … … 166 156 static INTNETSEG aXmitSeg[64]; 167 157 158 static RTGETOPTDEF s_aGetOptDef[]; 168 159 169 160 public: … … 174 165 175 166 virtual void usage() { /** @todo should be implemented */ }; 176 virtual int parseOpt(int rc, const RTGETOPTUNION& getOptVal);167 virtual int parseOpt(int c, const RTGETOPTUNION &Value); 177 168 178 169 virtual bool isMainNeeded() const { return true; } … … 207 198 208 199 INTNETSEG VBoxNetLwipNAT::aXmitSeg[64]; 200 201 /** 202 * Additional command line options. 203 * 204 * Our parseOpt() will be called by the base class if any of these are 205 * supplied. 206 */ 207 RTGETOPTDEF VBoxNetLwipNAT::s_aGetOptDef[] = 208 { 209 /* 210 * Currently there are no extra options and since arrays can't be 211 * empty use a sentinel entry instead, so that the placeholder 212 * code to process the options can be supplied nonetheless. 213 */ 214 {} /* sentinel */ 215 }; 209 216 210 217 … … 251 258 setIpv4Netmask(address); 252 259 253 fDontLoadRulesOnStartup = false; 254 255 for (size_t i = 0; i < RT_ELEMENTS(g_aGetOptDef); ++i) 256 addCommandLineOption(&g_aGetOptDef[i]); 260 /* tell the base class about our command line options */ 261 for (PCRTGETOPTDEF pcOpt = &s_aGetOptDef[0]; pcOpt->iShort != 0; ++pcOpt) 262 addCommandLineOption(pcOpt); 257 263 258 264 LogFlowFuncLeave(); … … 285 291 * 286 292 * Called by VBoxNetBaseService::parseArgs() for options that are not 287 * recognized by the base class. 288 */ 289 int VBoxNetLwipNAT::parseOpt(int rc, const RTGETOPTUNION& Val) 290 { 291 switch (rc) 292 { 293 case 'p': 294 case 'P': 295 { 296 NATSERVICEPORTFORWARDRULE Rule; 297 VECNATSERVICEPF& rules = (rc == 'P'? 298 m_vecPortForwardRule6 299 : m_vecPortForwardRule4); 300 301 fDontLoadRulesOnStartup = true; 302 303 RT_ZERO(Rule); 304 305 int rc2 = netPfStrToPf(Val.psz, (rc == 'P'), &Rule.Pfr); 306 RT_NOREF_PV(rc2); 307 rules.push_back(Rule); 308 return VINF_SUCCESS; 309 } 310 default:; 311 } 312 return VERR_NOT_FOUND; 293 * recognized by the base class. See s_aGetOptDef[]. 294 */ 295 int VBoxNetLwipNAT::parseOpt(int c, const RTGETOPTUNION &Value) 296 { 297 RT_NOREF(c, Value); 298 return VERR_NOT_FOUND; /* not recognized */ 313 299 } 314 300 … … 436 422 437 423 438 if (!fDontLoadRulesOnStartup) 439 { 440 fetchNatPortForwardRules(m_vecPortForwardRule4, /* :fIsIPv6 */ false); 424 fetchNatPortForwardRules(m_vecPortForwardRule4, /* :fIsIPv6 */ false); 425 if (fIPv6Enabled) 441 426 fetchNatPortForwardRules(m_vecPortForwardRule6, /* :fIsIPv6 */ true); 442 }443 427 444 428 AddressToOffsetMapping tmp; -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.cpp
r85506 r87450 108 108 PINTNETBUF m_pIfBuf; /**< Interface buffer. */ 109 109 110 std::vector<P RTGETOPTDEF> m_vecOptionDefs;110 std::vector<PCRTGETOPTDEF> m_vecOptionDefs; 111 111 112 112 int32_t m_cVerbosity; … … 682 682 683 683 684 void VBoxNetBaseService::addCommandLineOption( const PRTGETOPTDEF optDef)684 void VBoxNetBaseService::addCommandLineOption(PCRTGETOPTDEF optDef) 685 685 { 686 686 m->m_vecOptionDefs.push_back(optDef); … … 843 843 for (unsigned int i = 0; i < m->m_vecOptionDefs.size(); ++i) 844 844 { 845 P RTGETOPTDEF pOpt = m->m_vecOptionDefs[i];845 PCRTGETOPTDEF pOpt = m->m_vecOptionDefs[i]; 846 846 memcpy(&pOptArray[i], pOpt, sizeof(*pOpt)); 847 847 } -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h
r84364 r87450 115 115 void setVerbosityLevel(int32_t); 116 116 117 void addCommandLineOption( const PRTGETOPTDEF);117 void addCommandLineOption(PCRTGETOPTDEF); 118 118 119 119 /**
Note:
See TracChangeset
for help on using the changeset viewer.