int ConfigurationManager::commitLease4Client(Client& client) { Lease l = client.lease(); AssertReturn(l != Lease::NullLease, VERR_INTERNAL_ERROR); l.bindingPhase(false); const NetworkConfigEntity *pCfg = l.getConfig(); AssertPtr(pCfg); l.setExpiration(pCfg->expirationPeriod()); l.phaseStart(RTTimeMilliTS()); saveToFile(); return VINF_SUCCESS; }
/** * The client is requesting an offer. * * @returns true. * * @param pDhcpMsg The message. * @param cb The message size. */ bool NetworkManager::handleDhcpReqDiscover(PCRTNETBOOTP pDhcpMsg, size_t cb) { RawOption opt; RT_ZERO(opt); /* 1. Find client */ ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager(); Client client = confManager->getClientByDhcpPacket(pDhcpMsg, cb); /* 2. Find/Bind lease for client */ Lease lease = confManager->allocateLease4Client(client, pDhcpMsg, cb); AssertReturn(lease != Lease::NullLease, VINF_SUCCESS); int rc = ConfigurationManager::extractRequestList(pDhcpMsg, cb, opt); /* 3. Send of offer */ lease.bindingPhase(true); lease.phaseStart(RTTimeMilliTS()); lease.setExpiration(300); /* 3 min. */ offer4Client(client, pDhcpMsg->bp_xid, opt.au8RawOpt, opt.cbRawOpt); return VINF_SUCCESS; }