From: Leandro Lucarella Date: Sun, 2 Jul 2006 06:02:05 +0000 (+0000) Subject: Se mueve add_routes() a routetable porque estaba duplicado. X-Git-Tag: svn_import~18 X-Git-Url: https://git.llucax.com/z.facultad/75.74/practicos.git/commitdiff_plain/cc20509697bcad0600d4622c275b53ac65445776?ds=sidebyside Se mueve add_routes() a routetable porque estaba duplicado. --- diff --git a/practicas/pipi/src/dns.cpp b/practicas/pipi/src/dns.cpp index 5b3c66c..f0846d4 100644 --- a/practicas/pipi/src/dns.cpp +++ b/practicas/pipi/src/dns.cpp @@ -23,8 +23,6 @@ void send_loop(NameServer& ns); -void add_routes(RouteTable& rt, std::istream& is, Dev& dev); - int main(int argc, char* argv[]) { uint16_t port = DEVTCP_DEFAULT_PORT; @@ -108,21 +106,4 @@ void send_loop(NameServer& ns) } } -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 : diff --git a/practicas/pipi/src/ip.cpp b/practicas/pipi/src/ip.cpp index 6988169..5a538ce 100644 --- a/practicas/pipi/src/ip.cpp +++ b/practicas/pipi/src/ip.cpp @@ -22,8 +22,6 @@ void send_loop(IPOut& ipout, unsigned proto); -void add_routes(RouteTable& rt, std::istream& is, Dev& dev); - int main(int argc, char* argv[]) { bool router = false; @@ -120,21 +118,4 @@ void send_loop(IPOut& ipout, unsigned proto) } } -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 : 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 : diff --git a/practicas/pipi/src/routetable.h b/practicas/pipi/src/routetable.h index 20f62e8..d534d16 100644 --- a/practicas/pipi/src/routetable.h +++ b/practicas/pipi/src/routetable.h @@ -4,6 +4,7 @@ #include "dev.h" #include "ipaddr.h" #include +#include /// Tabla de ruteo struct RouteTable @@ -41,6 +42,9 @@ struct RouteTable }; +/// Agrega rutas desde un stream de datos con un cierto dispositivo +void add_routes(RouteTable& rt, std::istream& is, Dev& dev); + #endif // _ROUTETABLE_H_ // vim: set et sw=4 sts=4 :