VirtualBox

Ignore:
Timestamp:
Jan 23, 2021 12:02:01 AM (4 years ago)
Author:
vboxsync
Message:

NAT/Net: Insertion-sort VBoxNetLwipNAT::parseOpt() where it belongs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp

    r87386 r87393  
    175175    static int logInit(int argc, char **argv);
    176176
    177     void usage(){                /** @todo should be implemented */ };
     177    virtual void usage() { /** @todo should be implemented */ };
     178    virtual int parseOpt(int rc, const RTGETOPTUNION& getOptVal);
     179
    178180    int run();
    179181    virtual int init(void);
    180     virtual int parseOpt(int rc, const RTGETOPTUNION& getOptVal);
    181182    /* VBoxNetNAT always needs Main */
    182183    virtual bool isMainNeeded() const { return true; }
     
    273274        m_ProxyOptions.nameservers = NULL;
    274275    }
     276}
     277
     278
     279/**
     280 * Hook into the option processing.
     281 *
     282 * Called by VBoxNetBaseService::parseArgs() for options that are not
     283 * recognized by the base class.
     284 */
     285int VBoxNetLwipNAT::parseOpt(int rc, const RTGETOPTUNION& Val)
     286{
     287    switch (rc)
     288    {
     289        case 'p':
     290        case 'P':
     291        {
     292            NATSERVICEPORTFORWARDRULE Rule;
     293            VECNATSERVICEPF& rules = (rc == 'P'?
     294                                        m_vecPortForwardRule6
     295                                      : m_vecPortForwardRule4);
     296
     297            fDontLoadRulesOnStartup = true;
     298
     299            RT_ZERO(Rule);
     300
     301            int rc2 = netPfStrToPf(Val.psz, (rc == 'P'), &Rule.Pfr);
     302            RT_NOREF_PV(rc2);
     303            rules.push_back(Rule);
     304            return VINF_SUCCESS;
     305        }
     306        default:;
     307    }
     308    return VERR_NOT_FOUND;
    275309}
    276310
     
    10041038
    10051039
    1006 int VBoxNetLwipNAT::parseOpt(int rc, const RTGETOPTUNION& Val)
    1007 {
    1008     switch (rc)
    1009     {
    1010         case 'p':
    1011         case 'P':
    1012         {
    1013             NATSERVICEPORTFORWARDRULE Rule;
    1014             VECNATSERVICEPF& rules = (rc == 'P'?
    1015                                         m_vecPortForwardRule6
    1016                                       : m_vecPortForwardRule4);
    1017 
    1018             fDontLoadRulesOnStartup = true;
    1019 
    1020             RT_ZERO(Rule);
    1021 
    1022             int rc2 = netPfStrToPf(Val.psz, (rc == 'P'), &Rule.Pfr);
    1023             RT_NOREF_PV(rc2);
    1024             rules.push_back(Rule);
    1025             return VINF_SUCCESS;
    1026         }
    1027         default:;
    1028     }
    1029     return VERR_NOT_FOUND;
    1030 }
    1031 
    1032 
    10331040int VBoxNetLwipNAT::processFrame(void *pvFrame, size_t cbFrame)
    10341041{
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette