本文整理汇总了C++中Router::addInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ Router::addInterface方法的具体用法?C++ Router::addInterface怎么用?C++ Router::addInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::addInterface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inferRouters
void NetworkTreeNode::inferRouters()
{
if(inferredRouters.size() > 0)
{
return;
}
list<InetAddress*> interfaces = this->listInterfaces();
// Remove duplicata (possible because ingress interface of neighborhood can be a contra-pivot)
InetAddress previous(0);
bool previousAssigned = false;
for(list<InetAddress*>::iterator i = interfaces.begin(); i != interfaces.end(); ++i)
{
InetAddress *current = (*i);
if(current == NULL)
continue;
if(previousAssigned && (*current) == previous)
interfaces.erase(i--);
previous = (*current);
if(!previousAssigned)
previousAssigned = true;
}
// First compute the smallest gap between IP IDs.
unsigned short smallestGap = 65335;
bool noHostNames = true;
for(list<InetAddress*>::iterator i = interfaces.begin(); i != interfaces.end(); ++i)
{
for(list<InetAddress*>::iterator j = i; j != interfaces.end(); ++j)
{
if((*i) == (*j))
continue;
if(!(*i)->getStoredHostName().empty() && !(*j)->getStoredHostName().empty())
noHostNames = false;
if((*i)->hasIPIdentifier() && (*j)->hasIPIdentifier())
{
unsigned short thisGap = 0;
unsigned short IPId1 = (*i)->getIPIdentifier();
unsigned short IPId2 = (*j)->getIPIdentifier();
if(IPId1 > IPId2)
thisGap = IPId1 - IPId2;
else
thisGap = IPId2 - IPId1;
if(thisGap > (65535 - MAX_IP_ID_DIFFERENCE))
{
if(IPId1 > 60000)
thisGap = (65535 - IPId1) + IPId2;
else
thisGap = (65535 - IPId2) + IPId1;
}
if(thisGap < smallestGap)
smallestGap = thisGap;
}
}
}
// If not enough host names, above a threshold (for the gap), infers a router per interface.
if(noHostNames && smallestGap > NO_ASSOCIATION_THRESHOLD)
{
for(list<InetAddress*>::iterator i = interfaces.begin(); i != interfaces.end(); ++i)
{
Router *curRouter = new Router();
curRouter->addInterface(InetAddress(*(*i)));
inferredRouters.push_back(curRouter);
}
/*
* Some post-processing: removes the routers consisting of a single interface which happens
* to be a candidate contra-pivot of an ODD subnet.
*
* N.B.: checking the interface appears in the subnet responsive IPs list is enough, as the
* pivots were not listed at all in the potential interfaces.
*/
for(list<Router*>::iterator i = inferredRouters.begin(); i != inferredRouters.end(); ++i)
{
if((*i)->getNbInterfaces() == 1)
{
InetAddress singleInterface = (*i)->getInterfacesList()->front();
for(list<NetworkTreeNode*>::iterator j = children.begin(); j != children.end(); ++j)
{
if((*j)->getType() == NetworkTreeNode::T_SUBNET)
{
SubnetSite *ss = (*j)->getAssociatedSubnet();
if(ss->getStatus() == SubnetSite::ODD_SUBNET &&
ss->hasLiveInterface(singleInterface))
{
bool isALabel = false;
for(list<InetAddress>::iterator k = labels.begin();
k != labels.end();
++k)
//.........这里部分代码省略.........