Ejemplo n.º 1
0
 inline bool
 operator==(RoutingTableEntry& rhs)
 {
   return ((*this).getDestination() == rhs.getDestination()
           &&
          (*this).getNexthopList() == rhs.getNexthopList());
 }
Ejemplo n.º 2
0
// function related to manipulation of routing table
void
RoutingTable::addNextHop(const ndn::Name& destRouter, NextHop& nh)
{
  _LOG_DEBUG("Adding " << nh << " for destination: " << destRouter);

  RoutingTableEntry* rteChk = findRoutingTableEntry(destRouter);
  if (rteChk == 0) {
    RoutingTableEntry rte(destRouter);
    rte.getNexthopList().addNextHop(nh);
    m_rTable.push_back(rte);
  }
  else {
    rteChk->getNexthopList().addNextHop(nh);
  }
}
Ejemplo n.º 3
0
void
NamePrefixTable::addEntry(const ndn::Name& name, RoutingTableEntry& rte)
{
  NptEntryList::iterator it = std::find_if(m_table.begin(),
                                           m_table.end(),
                                           bind(&npteCompare, _1, name));
  if (it == m_table.end()) {
    _LOG_TRACE("Adding origin: " << rte.getDestination() << " to new name prefix: " << name);

    NamePrefixTableEntry entry(name);

    entry.addRoutingTableEntry(rte);

    entry.generateNhlfromRteList();
    entry.getNexthopList().sort();

    m_table.push_back(entry);

    if (rte.getNexthopList().getSize() > 0) {
      _LOG_TRACE("Updating FIB with next hops for " << entry);
      m_nlsr.getFib().update(name, entry.getNexthopList());
    }
  }
  else {
    _LOG_TRACE("Adding origin: " << rte.getDestination() << " to existing prefix: " << *it);

    it->addRoutingTableEntry(rte);

    it->generateNhlfromRteList();
    it->getNexthopList().sort();

    if (it->getNexthopList().getSize() > 0) {
      _LOG_TRACE("Updating FIB with next hops for " << *it);
      m_nlsr.getFib().update(name, it->getNexthopList());
    }
    else {
      // The routing table may recalculate and add a routing table entry with no next hops to
      // replace an existing routing table entry. In this case, the name prefix is no longer
      // reachable through a next hop and should be removed from the FIB. But, the prefix
      // should remain in the Name Prefix Table as a future routing table calculation may
      // add next hops.
      _LOG_TRACE(*it << " has no next hops; removing from FIB");
      m_nlsr.getFib().remove(name);
    }
  }
}