VirtualBox

Changeset 47020 in vbox for trunk


Ignore:
Timestamp:
Jul 6, 2013 5:42:33 PM (12 years ago)
Author:
vboxsync
Message:

previous r87050, was re-commit of r86970

DHCP becomes Main client, internals changed to let more flexible managment and describing more complex networks (current state, so it should not brake a lot things, but something could stop working).
more stuff moved to BaseNetworkService class.

and r87051 nukes trailing whitespaces.

Location:
trunk/src/VBox/NetworkServices/DHCP
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/DHCP/Config.cpp

    r47019 r47020  
    6565}
    6666
    67 /* Configs 
     67/* Configs
    6868    NetworkConfigEntity(std::string name,
    6969                        ConfigEntity* pCfg,
    7070                        ClientMatchCriteria* criteria,
    71                         RTNETADDRIPV4& networkID, 
     71                        RTNETADDRIPV4& networkID,
    7272                        RTNETADDRIPV4& networkMask)
    7373*/
     
    8989
    9090/*
    91  *  XXX: it sounds like a hack, we use packet descriptor to get the session, 
    92  * instead use corresponding functions in NetworkManager to fetch client identification 
     91 *  XXX: it sounds like a hack, we use packet descriptor to get the session,
     92 * instead use corresponding functions in NetworkManager to fetch client identification
    9393 * (note: it isn't only mac driven) and XID for the session.
    9494 */
    9595
    9696/**
    97  * XXX: what about leases ... Lease is a committed Session.... 
     97 * XXX: what about leases ... Lease is a committed Session....
    9898 */
    9999Session& SessionManager::getClientSessionByDhcpPacket(const RTNETBOOTP *pDhcpMsg, size_t cbDhcpMsg)
    100100{
    101    
     101
    102102    VecClientIterator it;
    103103    bool fDhcpValid = false;
     
    121121    {
    122122        /* We hasn't got any session for this client */
    123         m_clients.push_back(Client(pDhcpMsg->bp_chaddr.Mac, 
     123        m_clients.push_back(Client(pDhcpMsg->bp_chaddr.Mac,
    124124                                   pDhcpMsg->bp_xid));
    125125        Client& client = m_clients.back();
    126         client.m_sessions.insert(Map2ClientSessionType(xid, Session(&client, xid)));                         
     126        client.m_sessions.insert(Map2ClientSessionType(xid, Session(&client, xid)));
    127127        Assert(client.m_sessions[xid].m_pClient);
    128128        return client.m_sessions[xid];
     
    149149            /* MAY: todo */
    150150            rc = ConfigurationManager::findOption(RTNET_DHCP_OPT_LEASE_TIME, pDhcpMsg, cbDhcpMsg, opt);
    151            
     151
    152152            /* MAY: not now  */
    153153            rc = ConfigurationManager::findOption(RTNET_DHCP_OPT_CLIENT_ID, pDhcpMsg, cbDhcpMsg, opt);
    154             /* XXX: MAY 
     154            /* XXX: MAY
    155155            ConfigurationManager::findOption(RTNET_DHCP_OPT_VENDOR_CLASS_IDENTIFIER, pDhcpMsg, opt);
    156156            */
     
    179179            /* MAY */
    180180            ConfigurationManager::findOption(RTNET_DHCP_OPT_CLIENT_ID, pDhcpMsg, cbDhcpMsg, opt);
    181             /* XXX: MAY 
     181            /* XXX: MAY
    182182            ConfigurationManager::findOption(RTNET_DHCP_OPT_VENDOR_CLASS_IDENTIFIER, pDhcpMsg, opt);
    183183            */
     
    219219    if (!g_ConfigurationManager)
    220220        g_ConfigurationManager = new ConfigurationManager();
    221    
     221
    222222    return g_ConfigurationManager;
    223223}
     
    294294
    295295/**
    296  * We've find the config for session ... 
    297  * XXX: using Session's private members 
     296 * We've find the config for session ...
     297 * XXX: using Session's private members
    298298 */
    299299int ConfigurationManager::findConfiguration4Session(Session& session)
    300300{
    301     /* XXX: state switching broken? 
     301    /* XXX: state switching broken?
    302302     * XXX: DHCPDECLINE and DHCPINFO should we support them.
    303303     */
     
    313313    else
    314314        return VERR_INTERNAL_ERROR; /* XXX: is it really *internal* error? Perhaps some misconfiguration */
    315    
     315
    316316}
    317317
     
    322322{
    323323    /**
    324      * Well, session hasn't get the config. 
     324     * Well, session hasn't get the config.
    325325     */
    326326    AssertPtrReturn(session.m_pCfg, VERR_INTERNAL_ERROR);
    327327
    328328    bool fWithAddressHint = (session.addressHint.u != 0);
    329    
     329
    330330    if (fWithAddressHint)
    331331    {
     
    349349     */
    350350    AssertReturn(session.m_state == DHCPDISCOVERRECEIEVED, VERR_INTERNAL_ERROR);
    351    
     351
    352352    /**
    353353     * XXX: this is wrong allocation check...
     
    355355     */
    356356    MapSession2Ip4AddressIterator it = m_allocations.find(session);
    357    
     357
    358358    if (it == m_allocations.end())
    359359    {
    360360        /* XXX: not optimal allocation */
    361361        const NetworkConfigEntity *pNetCfg = dynamic_cast<const NetworkConfigEntity *>(session.m_pCfg);
    362        
     362
    363363        /**
    364364         * Check config class.
    365365         */
    366366        AssertPtrReturn(pNetCfg, VERR_INTERNAL_ERROR);
    367        
     367
    368368        uint32_t u32Address = RT_N2H_U32(pNetCfg->lowerIp().u);
    369369        while (u32Address < RT_N2H_U32(pNetCfg->upperIp().u))
     
    380380                if (RT_N2H_U32(addressIterator->second.u) == u32Address)
    381381                {
    382                     /* 
    383                      * This address is taken 
    384                      * XXX: check if session isn't expired... if expired we can 
    385                      * reuse it for this request 
     382                    /*
     383                     * This address is taken
     384                     * XXX: check if session isn't expired... if expired we can
     385                     * reuse it for this request
    386386                     */
    387387                    /* XXX: fTakeAddress = true; owning session is expired */
     
    390390                }
    391391            } /* end of for over allocations */
    392            
     392
    393393            if (!fFound)
    394394            {
     
    401401            u32Address ++;
    402402        } /* end of while over candidates */
    403        
    404     }
    405    
     403
     404    }
     405
    406406    /* XXX: really??? */
    407407    session.switchTo(DHCPOFFERPREPARED);
     
    414414    /**/
    415415    session.switchTo(DHCPACKNAKPREPARED);
    416    
     416
    417417    /* XXX: clean up the rest of the session, now this session LEASE!!! */
    418418    return VINF_SUCCESS;
     
    425425
    426426
    427 NetworkConfigEntity *ConfigurationManager::addNetwork(NetworkConfigEntity *pCfg, 
     427NetworkConfigEntity *ConfigurationManager::addNetwork(NetworkConfigEntity *pCfg,
    428428                                    const RTNETADDRIPV4& networkId,
    429429                                    const RTNETADDRIPV4& netmask,
    430                                     RTNETADDRIPV4& LowerAddress, 
     430                                    RTNETADDRIPV4& LowerAddress,
    431431                                    RTNETADDRIPV4& UpperAddress)
    432432{
    433433        static int id;
    434434        char name[64];
    435        
     435
    436436        RTStrPrintf(name, RT_ELEMENTS(name), "network-%d", id);
    437437        std::string strname(name);
    438438        id++;
    439439
    440        
     440
    441441        if (!LowerAddress.u)
    442442            LowerAddress = networkId;
     
    445445            UpperAddress.u = networkId.u | (~netmask.u);
    446446
    447         return new NetworkConfigEntity(strname, 
    448                             g_RootConfig, 
     447        return new NetworkConfigEntity(strname,
     448                            g_RootConfig,
    449449                            g_AnyClient,
    450450                            5,
    451451                            networkId,
    452452                            netmask,
    453                             LowerAddress, 
     453                            LowerAddress,
    454454                            UpperAddress);
    455455}
    456456
    457 HostConfigEntity *ConfigurationManager::addHost(NetworkConfigEntity* pCfg, 
    458                                                 const RTNETADDRIPV4& address, 
     457HostConfigEntity *ConfigurationManager::addHost(NetworkConfigEntity* pCfg,
     458                                                const RTNETADDRIPV4& address,
    459459                                                ClientMatchCriteria *criteria)
    460460{
    461461    static int id;
    462462    char name[64];
    463    
     463
    464464    RTStrPrintf(name, RT_ELEMENTS(name), "host-%d", id);
    465465    std::string strname(name);
    466466    id++;
    467        
     467
    468468    return new HostConfigEntity(address, strname, pCfg, criteria);
    469 } 
     469}
    470470
    471471/**
     
    495495    /* Ubuntu ???*/
    496496    BootPReplyMsg.BootPHeader.bp_ciaddr =  address;
    497    
    498     /* options: 
     497
     498    /* options:
    499499     * - IP lease time
    500500     * - message type
     
    503503    RawOption opt;
    504504    RT_ZERO(opt);
    505    
     505
    506506    /* XXX: can't store options per session */
    507507    Client *client = unconst(session.m_pClient);
    508508    AssertPtr(client);
    509    
     509
    510510    opt.u8OptId = RTNET_DHCP_OPT_MSG_TYPE;
    511511    opt.au8RawOpt[0] = RTNET_DHCP_MT_OFFER;
     
    523523    client->rawOptions.push_back(opt);
    524524
    525     processParameterReqList(session);     
     525    processParameterReqList(session);
    526526
    527527    return doReply(session);
     
    541541    address = ConfigurationManager::getConfigurationManager()->getSessionAddress(session);
    542542    BootPReplyMsg.BootPHeader.bp_ciaddr =  address;
    543      
    544  
    545     /* rfc2131 4.3.1 is about DHCPDISCOVER and this value is equal to ciaddr from 
    546      * DHCPREQUEST or 0 ... 
     543
     544
     545    /* rfc2131 4.3.1 is about DHCPDISCOVER and this value is equal to ciaddr from
     546     * DHCPREQUEST or 0 ...
    547547     * XXX: Using addressHint is not correct way to initialize [cy]iaddress...
    548548     */
     
    551551
    552552    Assert(BootPReplyMsg.BootPHeader.bp_yiaddr.u);
    553  
    554     /* options: 
     553
     554    /* options:
    555555     * - IP address lease time (if DHCPREQUEST)
    556556     * - message type
     
    585585    prepareReplyPacket4Session(session);
    586586
    587     /* this field filed in prepareReplyPacket4Session, and 
     587    /* this field filed in prepareReplyPacket4Session, and
    588588     * RFC 2131 require to have it zero fo NAK.
    589589     */
    590590    BootPReplyMsg.BootPHeader.bp_yiaddr.u = 0;
    591591
    592     /* options: 
     592    /* options:
    593593     * - message type (if DHCPREQUEST)
    594594     * - server identifier
     
    611611
    612612/**
    613  * 
     613 *
    614614 */
    615615int NetworkManager::prepareReplyPacket4Session(const Session& session)
     
    624624    BootPReplyMsg.BootPHeader.bp_secs   = 0;
    625625    /* XXX: bp_flags should be processed specially */
    626     BootPReplyMsg.BootPHeader.bp_flags  = 0; 
     626    BootPReplyMsg.BootPHeader.bp_flags  = 0;
    627627    BootPReplyMsg.BootPHeader.bp_ciaddr.u = 0;
    628628    BootPReplyMsg.BootPHeader.bp_giaddr.u = 0;
     
    631631    BootPReplyMsg.BootPHeader.bp_chaddr.Mac = session.m_pClient->m_mac;
    632632
    633     BootPReplyMsg.BootPHeader.bp_yiaddr = 
    634       ConfigurationManager::getConfigurationManager()->getSessionAddress(session); 
     633    BootPReplyMsg.BootPHeader.bp_yiaddr =
     634      ConfigurationManager::getConfigurationManager()->getSessionAddress(session);
    635635
    636636    BootPReplyMsg.BootPHeader.bp_siaddr.u = 0;
    637    
     637
    638638
    639639    BootPReplyMsg.BootPHeader.bp_vend.Dhcp.dhcp_cookie = RT_H2N_U32_C(RTNET_DHCP_COOKIE);
    640640
    641     memset(&BootPReplyMsg.BootPHeader.bp_vend.Dhcp.dhcp_opts[0], 
    642            '\0', 
     641    memset(&BootPReplyMsg.BootPHeader.bp_vend.Dhcp.dhcp_opts[0],
     642           '\0',
    643643           RTNET_DHCP_OPT_SIZE);
    644644
     
    650650{
    651651    int rc;
    652    
     652
    653653    /*
    654654      Options....
     
    663663
    664664    Cursor.optIPv4Addr(RTNET_DHCP_OPT_SERVER_ID, m_OurAddress);
    665    
     665
    666666    while(!cl->rawOptions.empty())
    667667    {
     
    694694    }
    695695
    696     /* 
     696    /*
    697697     */
    698698#if 0
    699699    if (!(pDhcpMsg->bp_flags & RTNET_DHCP_FLAGS_NO_BROADCAST)) /** @todo need to see someone set this flag to check that it's correct. */
    700700    {
    701         rc = VBoxNetUDPUnicast(m_pSession, 
    702                                m_hIf, 
     701        rc = VBoxNetUDPUnicast(m_pSession,
     702                               m_hIf,
    703703                               m_pIfBuf,
    704                                m_OurAddress, 
    705                                &m_OurMac, 
     704                               m_OurAddress,
     705                               &m_OurMac,
    706706                               RTNETIPV4_PORT_BOOTPS,                 /* sender */
    707                                IPv4AddrBrdCast, 
    708                                &BootPReplyMsg.BootPHeader->bp_chaddr.Mac, 
     707                               IPv4AddrBrdCast,
     708                               &BootPReplyMsg.BootPHeader->bp_chaddr.Mac,
    709709                               RTNETIPV4_PORT_BOOTPC,    /* receiver */
    710710                               &BootPReplyMsg, cbBooPReplyMsg);
     
    712712    else
    713713#endif
    714         rc = VBoxNetUDPBroadcast(m_pSession, 
    715                                  m_hIf, 
     714        rc = VBoxNetUDPBroadcast(m_pSession,
     715                                 m_hIf,
    716716                                 m_pIfBuf,
    717                                  m_OurAddress, 
    718                                  &m_OurMac, 
     717                                 m_OurAddress,
     718                                 &m_OurMac,
    719719                                 RTNETIPV4_PORT_BOOTPS,               /* sender */
    720                                  RTNETIPV4_PORT_BOOTPC, 
     720                                 RTNETIPV4_PORT_BOOTPC,
    721721                                 &BootPReplyMsg, RTNET_DHCP_NORMAL_SIZE);
    722722
    723723    AssertRCReturn(rc,rc);
    724    
     724
    725725    return VINF_SUCCESS;
    726726}
     
    730730{
    731731    /* request parameter list */
    732     RawOption opt;   
     732    RawOption opt;
    733733    int idxParam = 0;
    734734
     
    745745    {
    746746
    747         RT_ZERO(opt);       
     747        RT_ZERO(opt);
    748748        opt.u8OptId = pReqList[idxParam];
    749749        switch(pReqList[idxParam])
  • trunk/src/VBox/NetworkServices/DHCP/Config.h

    r47019 r47020  
    3333   */
    3434  DHCPNONSENSE,
    35   /** We've received dhcp discover => 
     35  /** We've received dhcp discover =>
    3636   * we're starting new client and/or session.
    3737   * Using XID (we record session)
     
    4444  DHCPOFFERPREPARED,
    4545  /**
    46    * This more, session state, we responsed, to 
     46   * This more, session state, we responsed, to
    4747   * client with DHCPOFFER using session's XID
    4848   */
     
    5858  /**
    5959   * We've been able to furfill client's request for (XID) session, erased others Client
    60    * 's sessions ... and send DHCPACK (should be Lease bind at this point?) 
     60   * 's sessions ... and send DHCPACK (should be Lease bind at this point?)
    6161   */
    6262  DHCPACKSENT,
     
    9090
    9191/**
    92  * This class joins client and the lease ... 
     92 * This class joins client and the lease ...
    9393 * at the begining client might request several address assignments...
    94  * 
     94 *
    9595 * So session here is descriptor joining client to each of it's requests.
    9696 * When client finalizes its selection ... only single assignment is chosen,
     
    100100{
    101101public:
    102     Session(const Client *client = NULL, 
    103             uint32_t xid = 0, 
    104             CLIENTSESSIONSTATE enmState = DHCPNONSENSE): 
     102    Session(const Client *client = NULL,
     103            uint32_t xid = 0,
     104            CLIENTSESSIONSTATE enmState = DHCPNONSENSE):
    105105      m_pClient(client),
    106106      m_state(enmState),
     
    112112        RT_ZERO(reqParamList);
    113113    }
    114    
     114
    115115    bool operator < (const Session& s) const;
    116    
     116
    117117    int switchTo(CLIENTSESSIONSTATE);
    118118    /* XXX private: */
     
    120120    /**/
    121121    const Client* m_pClient;
    122     /* We don't store the state in the client, because client might initiate several 
     122    /* We don't store the state in the client, because client might initiate several
    123123     * sessions.
    124124     */
    125125    CLIENTSESSIONSTATE m_state;
    126     /** 
    127      * uniq identificator of session 
     126    /**
     127     * uniq identificator of session
    128128     */
    129129    uint32_t m_u32Xid;
    130    
     130
    131131    /* dhcp-opts: request address */
    132132    RTNETADDRIPV4 addressHint;
     
    156156private:
    157157    const Client *m_pClient;
    158    
     158
    159159    bool operator == (const Session& session) const
    160160    {
     
    168168typedef MapLease2Ip4Address::iterator MapLease2Ip4AddressIterator;
    169169
    170 /* 
    171  * it's a basic representation of 
     170/*
     171 * it's a basic representation of
    172172 * of out undestanding what client is
    173  * XXX: Client might sends Option 61 (RFC2132 9.14 "Client-identifier") signalling 
     173 * XXX: Client might sends Option 61 (RFC2132 9.14 "Client-identifier") signalling
    174174 * that we may identify it in special way
    175  * 
     175 *
    176176 * XXX: Client might send Option 60 (RFC2132 9.13 "Vendor class undentifier")
    177  * in response it's expected server sends Option 43 (RFC2132 8.4. "Vendor Specific Information") 
     177 * in response it's expected server sends Option 43 (RFC2132 8.4. "Vendor Specific Information")
    178178 */
    179 class Client 
     179class Client
    180180{
    181181    public:
     
    183183    /* XXX: Option 60 and 61 */
    184184    Client(const RTMAC& mac, uint32_t xid = 0);
    185    
    186     bool operator== (const RTMAC& mac) const 
    187     {
    188         return (  m_mac.au16[0] == mac.au16[0] 
    189                 && m_mac.au16[1] == mac.au16[1] 
     185
     186    bool operator== (const RTMAC& mac) const
     187    {
     188        return (  m_mac.au16[0] == mac.au16[0]
     189                && m_mac.au16[1] == mac.au16[1]
    190190                && m_mac.au16[2] == mac.au16[2]);
    191191    }
    192192    /** Dumps client query */
    193193    void dump();
    194    
     194
    195195    /* XXX! private: */
    196    
     196
    197197    RTMAC m_mac;
    198198    Map2ClientSession m_sessions;
     
    213213
    214214    static SessionManager* getSessionManager();
    215    
     215
    216216    /**
    217217     * This method we call on every DHCP packet we've received.
     
    219219     */
    220220    Session& getClientSessionByDhcpPacket(const RTNETBOOTP* pDhcpMsg, size_t cbPacket);
    221    
     221
    222222    /* XXX: DHCPDECLINE */
    223223    void releaseClientSession(Session& session);
     
    226226
    227227    private:
    228    
     228
    229229    VecClient m_clients;
    230230
     
    251251     */
    252252    int findConfiguration4Session(Session& session);
    253    
     253
    254254    /**
    255255     * XXX: it's could be done on DHCPOFFER or on DHCPACK (rfc2131 gives freedom here
    256      * 3.1.2, what is strict that allocation should do address check before real 
    257      * allocation)... 
     256     * 3.1.2, what is strict that allocation should do address check before real
     257     * allocation)...
    258258     */
    259259    int allocateConfiguration4Session(Session& session);
    260        
     260
    261261    /*
    262262     * We call this before DHCPACK sent and after DHCPREQUEST received ...
     
    266266
    267267    static int findOption(uint8_t uOption, PCRTNETBOOTP pDhcpMsg, size_t cbDhcpMsg, RawOption& opt);
    268    
    269     NetworkConfigEntity *addNetwork(NetworkConfigEntity *pCfg, 
     268
     269    NetworkConfigEntity *addNetwork(NetworkConfigEntity *pCfg,
    270270                                    const RTNETADDRIPV4& networkId,
    271271                                    const RTNETADDRIPV4& netmask,
    272                                     RTNETADDRIPV4& UpperAddress, 
     272                                    RTNETADDRIPV4& UpperAddress,
    273273                                    RTNETADDRIPV4& LowerAddress);
    274274
    275275    HostConfigEntity *addHost(NetworkConfigEntity*, const RTNETADDRIPV4&, ClientMatchCriteria*);
    276    
     276
    277277    RTNETADDRIPV4  getSessionAddress(const Session& session);
    278278
     
    321321           case RTNET_DHCP_OPT_ROUTERS:
    322322               return m_routers;
    323                
     323
    324324       }
    325325       /* XXX: Grrr !!! */
     
    345345    public:
    346346    static NetworkManager *getNetworkManager();
    347    
     347
    348348    int offer4Session(Session& ses);
    349349    int ack(Session& ses);
     
    352352    const RTNETADDRIPV4& getOurAddress(){ return m_OurAddress;}
    353353    const RTNETADDRIPV4& getOurNetmask(){ return m_OurNetmask;}
    354     const RTMAC& getOurMac() {return m_OurMac;} 
     354    const RTMAC& getOurMac() {return m_OurMac;}
    355355
    356356    void setOurAddress(const RTNETADDRIPV4& aAddress){ m_OurAddress = aAddress;}
    357357    void setOurNetmask(const RTNETADDRIPV4& aNetmask){ m_OurNetmask = aNetmask;}
    358     void setOurMac(const RTMAC& aMac) {m_OurMac = aMac;} 
     358    void setOurMac(const RTMAC& aMac) {m_OurMac = aMac;}
    359359
    360360    /* XXX: artifacts should be hidden or removed from here. */
     
    377377    RTNETADDRIPV4 m_OurNetmask;
    378378    RTMAC m_OurMac;
    379    
     379
    380380    NetworkManager(){}
    381381    virtual ~NetworkManager(){}
     
    401401        m_right = right;
    402402    }
    403    
     403
    404404    virtual bool check(const Client& client) const
    405405    {
     
    418418        m_right = right;
    419419    }
    420    
     420
    421421    virtual bool check(const Client& client) const
    422422    {
     
    440440    public:
    441441    MACClientMatchCriteria(const RTMAC& mac):m_mac(mac){}
    442    
     442
    443443    virtual bool check(const Client& client) const
    444444    {
     
    475475{
    476476public:
    477     BaseConfigEntity(const ClientMatchCriteria *criteria = NULL, 
     477    BaseConfigEntity(const ClientMatchCriteria *criteria = NULL,
    478478                     int matchingLevel = 0)
    479479      : m_criteria(criteria),
     
    486486        return 0;
    487487    }
    488    
     488
    489489    /* Should return how strong matching */
    490     virtual int match(const Client& client, const BaseConfigEntity **cfg) const 
     490    virtual int match(const Client& client, const BaseConfigEntity **cfg) const
    491491    {
    492492        int iMatch = (m_criteria && m_criteria->check(client)? m_MatchLevel: 0);
     
    557557        unconst(m_parentCfg)->add(this);
    558558    }
    559      
     559
    560560    std::string m_name;
    561561    const BaseConfigEntity *m_parentCfg;
     
    564564
    565565/**
    566  * Network specific entries 
     566 * Network specific entries
    567567 */
    568568class NetworkConfigEntity:public ConfigEntity
     
    574574                        const ClientMatchCriteria *criteria,
    575575                        int matchlvl,
    576                         const RTNETADDRIPV4& networkID, 
     576                        const RTNETADDRIPV4& networkID,
    577577                        const RTNETADDRIPV4& networkMask,
    578578                        const RTNETADDRIPV4& lowerIP,
     
    585585    {
    586586    };
    587    
     587
    588588    NetworkConfigEntity(std::string name,
    589589                        const BaseConfigEntity *cfg,
    590590                        const ClientMatchCriteria *criteria,
    591                         const RTNETADDRIPV4& networkID, 
     591                        const RTNETADDRIPV4& networkID,
    592592                        const RTNETADDRIPV4& networkMask):
    593593      ConfigEntity(name, cfg, criteria, 5),
     
    612612
    613613
    614 /** 
     614/**
    615615 * Host specific entry
    616616 * Address pool is contains one element
     
    622622    HostConfigEntity(const RTNETADDRIPV4& addr,
    623623                     std::string name,
    624                      const NetworkConfigEntity *cfg, 
     624                     const NetworkConfigEntity *cfg,
    625625                     const ClientMatchCriteria *criteria):
    626       NetworkConfigEntity(name, 
    627                           static_cast<const ConfigEntity*>(cfg), 
    628                           criteria, 
    629                           10, 
    630                           cfg->networkId(), 
    631                           cfg->netmask(), 
    632                           addr, 
     626      NetworkConfigEntity(name,
     627                          static_cast<const ConfigEntity*>(cfg),
     628                          criteria,
     629                          10,
     630                          cfg->networkId(),
     631                          cfg->netmask(),
     632                          addr,
    633633                          addr)
    634634    {
     
    636636    }
    637637
    638     virtual int match(const Client& client) const 
    639     { 
     638    virtual int match(const Client& client) const
     639    {
    640640        return (m_criteria->check(client) ? 10 : 0);
    641641    }
     
    653653#if 0
    654654/**
    655  * Shared regions e.g. some of configured networks declarations 
     655 * Shared regions e.g. some of configured networks declarations
    656656 * are cover each other.
    657  * XXX: Shared Network is join on Network config entities with possible 
    658  * overlaps in address pools. for a moment we won't configure and use them them 
     657 * XXX: Shared Network is join on Network config entities with possible
     658 * overlaps in address pools. for a moment we won't configure and use them them
    659659 */
    660660class SharedNetworkConfigEntity: public NetworkEntity
     
    663663    SharedNetworkConfigEntity(){}
    664664    int match(const Client& client) const { return m_criteria.match(client)? 3 : 0;}
    665    
     665
    666666    SharedNetworkConfigEntity(NetworkEntity& network)
    667667    {
     
    669669    }
    670670    virtual ~SharedNetworkConfigEntity(){}
    671        
     671
    672672    std::vector<NetworkConfigEntity> Networks;
    673    
     673
    674674};
    675675#endif
  • trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp

    r47019 r47020  
    8080 * DHCP server instance.
    8181 */
    82 class VBoxNetDhcp: public VBoxNetBaseService 
     82class VBoxNetDhcp: public VBoxNetBaseService
    8383{
    8484public:
     
    104104    /** @name The DHCP server specific configuration data members.
    105105     * @{ */
    106     /* 
     106    /*
    107107     * XXX: what was the plan? SQL3 or plain text file?
    108      * How it will coexists with managment from VBoxManagement, who should manage db 
     108     * How it will coexists with managment from VBoxManagement, who should manage db
    109109     * in that case (VBoxManage, VBoxSVC ???)
    110110     */
     
    117117
    118118    ComPtr<INATNetwork> m_NATNetwork;
    119    
     119
    120120    /*
    121121     * We will ignore cmd line parameters IFF there will be some DHCP specific arguments
     
    125125
    126126    /*
    127      * -b -n 10.0.1.2 -m 255.255.255.0 -> to the list processing in 
    128      */
    129     typedef struct 
     127     * -b -n 10.0.1.2 -m 255.255.255.0 -> to the list processing in
     128     */
     129    typedef struct
    130130    {
    131131        char Key;
     
    302302/**
    303303 * Parse the DHCP specific arguments.
    304  * 
     304 *
    305305 * This callback caled for each paramenter so
    306306 * ....
    307  * we nee post analisys of the parameters, at least 
    308  *    for -b, -g, -l, -u, -m 
     307 * we nee post analisys of the parameters, at least
     308 *    for -b, -g, -l, -u, -m
    309309 */
    310310int VBoxNetDhcp::parseOpt(int rc, const RTGETOPTUNION& Val)
     
    320320    {
    321321            /* Begin config. */
    322         case 'b': 
     322        case 'b':
    323323            CmdParameterll.push_back(prm);
    324324            break;
     
    347347{
    348348    HRESULT hrc = S_OK;
    349     /* ok, here we should initiate instance of dhcp server 
    350      * and listener for Dhcp configuration events 
     349    /* ok, here we should initiate instance of dhcp server
     350     * and listener for Dhcp configuration events
    351351     */
    352352    AssertRCReturn(virtualbox.isNull(), VERR_INTERNAL_ERROR);
    353353
    354     hrc = virtualbox->FindDHCPServerByNetworkName(com::Bstr(m_Network.c_str()).raw(), 
     354    hrc = virtualbox->FindDHCPServerByNetworkName(com::Bstr(m_Network.c_str()).raw(),
    355355                                                  m_DhcpServer.asOutParam());
    356356    AssertComRCReturn(hrc, VERR_INTERNAL_ERROR);
    357357
    358     hrc = virtualbox->FindNATNetworkByName(com::Bstr(m_Network.c_str()).raw(), 
     358    hrc = virtualbox->FindNATNetworkByName(com::Bstr(m_Network.c_str()).raw(),
    359359                                           m_NATNetwork.asOutParam());
    360360
     
    367367
    368368    /**
    369      * if we have nat netework of the same name 
     369     * if we have nat netework of the same name
    370370     * this is good chance that we are assigned to this network.
    371371     */
     
    395395    {
    396396        /* just fetch option array and add options to config */
    397         /* per VM-settings ??? 
    398          * 
    399          * - we have vms with attached adapters with known mac-addresses 
     397        /* per VM-settings ???
     398         *
     399         * - we have vms with attached adapters with known mac-addresses
    400400         * - mac-addresses might be changed as well as names, how keep our config cleaned ????
    401401         */
     
    404404        AssertComRCReturn(hrc, VERR_INTERNAL_ERROR);
    405405
    406 #if 0       
     406#if 0
    407407        for (int i = 0; i < sf.size(); ++i)
    408408        {
    409409            RTPrintf("%d: %s\n", i, com::Utf8Str(sf[i]).c_str());
    410410        }
    411      
    412 #endif   
     411
     412#endif
    413413        com::Bstr strUpperIp, strLowerIp;
    414        
     414
    415415        RTNETADDRIPV4 LowerAddress;
    416416        RTNETADDRIPV4 UpperAddress;
     
    419419        AssertComRCReturn(hrc, VERR_INTERNAL_ERROR);
    420420        RTNetStrToIPv4Addr(com::Utf8Str(strUpperIp).c_str(), &UpperAddress);
    421        
     421
    422422
    423423        hrc = m_DhcpServer->COMGETTER(LowerIP)(strLowerIp.asOutParam());
     
    428428        networkId.u = m_Ipv4Address.u & m_Ipv4Netmask.u;
    429429        std::string name = std::string("default");
    430        
    431         NetworkConfigEntity *pCfg = confManager->addNetwork(unconst(g_RootConfig), 
     430
     431        NetworkConfigEntity *pCfg = confManager->addNetwork(unconst(g_RootConfig),
    432432                                                            networkId,
    433433                                                            m_Ipv4Netmask,
    434                                                             LowerAddress, 
     434                                                            LowerAddress,
    435435                                                            UpperAddress);
    436436
     
    439439    {
    440440        CmdParameterIterator it;
    441        
     441
    442442        RTNETADDRIPV4 networkId;
    443443        networkId.u = m_Ipv4Address.u & m_Ipv4Netmask.u;
     
    445445        RTNETADDRIPV4 LowerAddress;
    446446        RTNETADDRIPV4 UpperAddress;
    447        
     447
    448448        LowerAddress = networkId;
    449449        UpperAddress.u = RT_H2N_U32(RT_N2H_U32(LowerAddress.u) | RT_N2H_U32(netmask.u));
     
    463463                case 'b':
    464464                    /* config */
    465                     NetworkConfigEntity(strname, 
     465                    NetworkConfigEntity(strname,
    466466                                        g_RootConfig,
    467467                                        g_AnyClient,
     
    633633            /* XXX: per-host configuration */
    634634        }
    635        
     635
    636636        SessionManager *sesionManager = SessionManager::getSessionManager();
    637637        Session& session = sesionManager->getClientSessionByDhcpPacket(pDhcpMsg, cb);
    638638        /* XXX: switch -> private */
    639639        session.switchTo(DHCPDISCOVERRECEIEVED);
    640        
     640
    641641        ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager();
    642642        int rc = confManager->findConfiguration4Session(session);
     
    671671    /* XXX: switch -> private */
    672672    session.switchTo(DHCPREQUESTRECEIVED);
    673        
     673
    674674    ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager();
    675675    int rc = confManager->findConfiguration4Session(session);
     
    683683    else
    684684        rc = netManager->nak(session);
    685    
     685
    686686    AssertRCReturn(rc, false);
    687687
     
    773773            &&  m_pCurMsg)
    774774        {
    775             /* XXX: export this to debugPrinfDhcpMsg or variant and other method export 
     775            /* XXX: export this to debugPrinfDhcpMsg or variant and other method export
    776776             *  to base class
    777777             */
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