Commit fa52e94b authored by Jonathon Duerig's avatar Jonathon Duerig

Fixed bug which produced duplicate routes.

parent b369d679
......@@ -104,22 +104,24 @@ void print_route(graph * g, int source, int dest)
cerr << "ddijk: internal error: route not found" << endl;
exit(1);
}
string sourceIp = sourcePos->second.first;
string firstHopIp = sourcePos->second.second;
multimap< int, pair<string, string> >::iterator pos;
pos = g->ip[dest].begin();
multimap< int, pair<string, string> >::iterator limit;
limit = g->ip[dest].end();
string previous;
string sourceIp = sourcePos->second.first;
string firstHopIp = sourcePos->second.second;
for ( ; pos != limit; ++pos)
{
if (pos->second.first != firstHopIp)
if (pos->second.first != firstHopIp && pos->second.first != previous)
{
cout << "ROUTE DEST=" << pos->second.first
<< " DESTTYPE=host DESTMASK=255.255.255.255 NEXTHOP="
<< firstHopIp << " COST=" << distanceList[dest] << " SRC="
<< sourceIp << endl;
previous = pos->second.first;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment