X-Git-Url: https://git.llucax.com/z.facultad/75.74/practicos.git/blobdiff_plain/918a7b42017533f6f18edc8735d6d82a5494f055..ac1d74a402f344ad8135f125cbac73ecda46172e:/practicas/pipi/src/routetable.cpp?ds=sidebyside diff --git a/practicas/pipi/src/routetable.cpp b/practicas/pipi/src/routetable.cpp index 40de2d3..43e3377 100644 --- a/practicas/pipi/src/routetable.cpp +++ b/practicas/pipi/src/routetable.cpp @@ -1,4 +1,6 @@ #include "routetable.h" +#include +#include #ifdef DEBUG #include #endif @@ -30,4 +32,21 @@ RouteTable::Route* RouteTable::get(const IPAddr& dst) return &table[dst]; } +void add_routes(RouteTable& rt, std::istream& is, Dev& dev) +{ + std::string line; + while (std::getline(is, line)) + { + std::istringstream iss(line); + std::string net; + std::string gw; + unsigned mtu; + unsigned metric; + iss >> net >> gw >> mtu >> metric; + if (net == "0") net = "0.0.0.0"; + if (gw == "0") gw = "0.0.0.0"; + rt.add(net, gw, metric, mtu, dev); + } +} + // vim: set et sw=4 sts=4 :