本文整理汇总了C++中SPtr::checkReservedPrefix方法的典型用法代码示例。如果您正苦于以下问题:C++ SPtr::checkReservedPrefix方法的具体用法?C++ SPtr::checkReservedPrefix怎么用?C++ SPtr::checkReservedPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPtr
的用法示例。
在下文中一共展示了SPtr::checkReservedPrefix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: List
/**
* @brief returns list of free prefixes for this client
*
* return free prefixes for a client. There are several ways that method may work:
* 1 - client didn't provide any hints:
* => one prefix from each pool will be granted
* 2 - client has provided hint and that is valid (supported and unused):
* => requested prefix will be granted
* 3 - client has provided hint, which belongs to supported pool, but this prefix is used:
* => other prefix from that pool will be asigned
* 4 - client has provided hint, but it is invalid (not beloninging to a supported pool,
* multicast or link-local):
* => see 1
*
* @param clientMsg message received from a client
* @param cli_hint hint provided by client (or ::)
*
* @return - list of prefixes
*/
List(TIPv6Addr) TSrvOptIA_PD::getFreePrefixes(SPtr<TSrvMsg> clientMsg, SPtr<TIPv6Addr> cli_hint) {
SPtr<TSrvCfgIface> ptrIface;
SPtr<TIPv6Addr> prefix;
SPtr<TSrvCfgPD> ptrPD;
bool validHint = true;
List(TIPv6Addr) lst;
lst.clear();
ptrIface = SrvCfgMgr().getIfaceByID(this->Iface);
if (!ptrIface) {
Log(Error) << "PD: Trying to find free prefix on non-existent interface (ifindex="
<< this->Iface << ")." << LogEnd;
return lst; // empty list
}
if (!ptrIface->supportPrefixDelegation()) {
// this method should not be called anyway
Log(Error) << "PD: Prefix delegation is not supported on the " << ptrIface->getFullName()
<< "." << LogEnd;
return lst; // empty list
}
ptrIface->firstPD();
ptrPD = ptrIface->getPD();
// should be ==, asigned>total should never happen
if (ptrPD->getAssignedCount() >= ptrPD->getTotalCount()) {
Log(Error) << "PD: Unable to grant any prefixes: Already asigned " << ptrPD->getAssignedCount()
<< " out of " << ptrPD->getTotalCount() << "." << LogEnd;
return lst; // empty list
}
// check if this prefix is ok
// is it anyaddress (::)?
SPtr<TIPv6Addr> anyaddr = new TIPv6Addr();
if (*anyaddr==*cli_hint) {
Log(Debug) << "PD: Client requested unspecified (" << *cli_hint
<< ") prefix. Hint ignored." << LogEnd;
validHint = false;
}
// is it multicast address (ff...)?
if ((*(cli_hint->getAddr()))==0xff) {
Log(Debug) << "PD: Client requested multicast (" << *cli_hint
<< ") prefix. Hint ignored." << LogEnd;
validHint = false;
}
// is it link-local address (fe80::...)?
char linklocal[]={0xfe, 0x80};
if (!memcmp(cli_hint->getAddr(),linklocal,2)) {
Log(Debug) << "PD: Client requested link-local (" << *cli_hint
<< ") prefix. Hint ignored." << LogEnd;
validHint = false;
}
SPtr<TOptVendorData> remoteID;
TSrvMsg * par = (TSrvMsg*)(Parent);
if (par) {
remoteID = par->getRemoteID();
}
if ( validHint ) {
// hint is valid, try to use it
ptrPD = SrvCfgMgr().getClassByPrefix(this->Iface, cli_hint);
// if the PD allow the hint, based on DUID, Addr, and Msg from client
if (ptrPD && ptrPD->clntSupported(ClntDuid, ClntAddr, clientMsg)) {
// Let's make a copy of the hint (we may need to tweak the hint in a second)
SPtr<TIPv6Addr> hint(new TIPv6Addr(cli_hint->getAddr()));
// Now zero the remaining part
hint->truncate(0, ptrPD->getPD_Length());
// Is this hint reserved for someone else?
if (!ptrIface->checkReservedPrefix(hint, ClntDuid, remoteID, ClntAddr))
{
// Nope, not reserved.
//.........这里部分代码省略.........