本文整理汇总了C++中SPtr::addPD方法的典型用法代码示例。如果您正苦于以下问题:C++ SPtr::addPD方法的具体用法?C++ SPtr::addPD怎么用?C++ SPtr::addPD使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPtr
的用法示例。
在下文中一共展示了SPtr::addPD方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addPrefix
bool TAddrMgr::addPrefix(SPtr<TAddrClient> client, SPtr<TDUID> duid , SPtr<TIPv6Addr> addr,
const std::string& ifname, int ifindex, unsigned long IAID,
unsigned long T1, unsigned long T2,
SPtr<TIPv6Addr> prefix, unsigned long pref, unsigned long valid,
int length, bool quiet) {
if (!prefix) {
Log(Error) << "Attempt to add null prefix failed." << LogEnd;
return false;
}
if (!client) {
Log(Error) << "Unable to add prefix, client not defined." << LogEnd;
return false;
}
// find this PD
SPtr <TAddrIA> ptrPD;
client->firstPD();
while ( ptrPD = client->getPD() ) {
if ( ptrPD->getIAID() == IAID)
break;
}
// have we found this PD?
if (!ptrPD) {
ptrPD = new TAddrIA(ifname, ifindex, IATYPE_PD, addr, duid, T1, T2, IAID);
/// @todo: This setState() was used on reconfigure branch, but not on master
ptrPD->setState(STATE_CONFIGURED);
client->addPD(ptrPD);
if (!quiet)
Log(Debug) << "PD: Adding PD (iaid=" << IAID << ") to addrDB." << LogEnd;
}
ptrPD->setT1(T1);
ptrPD->setT2(T2);
SPtr <TAddrPrefix> ptrPrefix;
ptrPD->firstPrefix();
while ( ptrPrefix = ptrPD->getPrefix() ) {
if (*ptrPrefix->get()==*prefix)
break;
}
// address already exists
if (ptrPrefix) {
Log(Warning) << "PD: Prefix " << ptrPrefix->get()->getPlain() << "/" << ptrPrefix->getLength()
<< " is already assigned to this PD." << LogEnd;
return false;
}
// add address
ptrPD->addPrefix(prefix, pref, valid, length);
if (!quiet)
Log(Debug) << "PD: Adding " << prefix->getPlain()
<< " prefix to PD (iaid=" << IAID
<< ") to addrDB." << LogEnd;
ptrPD->setDUID(duid);
return true;
}