本文整理汇总了C++中Binding::leaseTime方法的典型用法代码示例。如果您正苦于以下问题:C++ Binding::leaseTime方法的具体用法?C++ Binding::leaseTime怎么用?C++ Binding::leaseTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Binding
的用法示例。
在下文中一共展示了Binding::leaseTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: optlist
DhcpServerMessage *DHCPD::doDiscover(DhcpClientMessage &req)
{
/*
* XXX: TODO: Windows iSCSI initiator sends DHCPDISCOVER first and
* it has ciaddr filled. Shouldn't let it screw up the normal
* lease we already have for that client, but we should probably
* reply with a pro-forma offer.
*/
if (req.ciaddr().u != 0)
return NULL;
Binding *b = m_db.allocateBinding(req);
if (b == NULL)
return NULL;
std::unique_ptr<DhcpServerMessage> reply;
bool fRapidCommit = OptRapidCommit(req).present();
if (!fRapidCommit)
{
reply.reset(createMessage(RTNET_DHCP_MT_OFFER, req));
if (b->state() < Binding::OFFERED)
b->setState(Binding::OFFERED);
/* use small lease time internally to quickly free unclaimed offers? */
}
else
{
reply.reset(createMessage(RTNET_DHCP_MT_ACK, req));
reply->addOption(OptRapidCommit(true));
b->setState(Binding::ACKED);
saveLeases();
}
reply->setYiaddr(b->addr());
reply->addOption(OptLeaseTime(b->leaseTime()));
OptParameterRequest optlist(req);
reply->addOptions(m_pConfig->getOptions(optlist, req.clientId()));
// reply->maybeUnicast(req); /* XXX: we reject ciaddr != 0 above */
return reply.release();
}
示例2: reqAddr
DhcpServerMessage *DHCPD::doRequest(DhcpClientMessage &req)
{
OptRequestedAddress reqAddr(req);
if (req.ciaddr().u != 0 && reqAddr.present() && reqAddr.value().u != req.ciaddr().u)
{
std::unique_ptr<DhcpServerMessage> nak (
createMessage(RTNET_DHCP_MT_NAC, req)
);
nak->addOption(OptMessage("Requested address does not match ciaddr"));
return nak.release();
}
Binding *b = m_db.allocateBinding(req);
if (b == NULL)
{
return createMessage(RTNET_DHCP_MT_NAC, req);
}
std::unique_ptr<DhcpServerMessage> ack (
createMessage(RTNET_DHCP_MT_ACK, req)
);
b->setState(Binding::ACKED);
saveLeases();
ack->setYiaddr(b->addr());
ack->addOption(OptLeaseTime(b->leaseTime()));
OptParameterRequest optlist(req);
ack->addOptions(m_pConfig->getOptions(optlist, req.clientId()));
ack->addOption(OptMessage("Ok, ok, here it is"));
ack->maybeUnicast(req);
return ack.release();
}