X-Git-Url: https://git.llucax.com/z.facultad/75.74/practicos.git/blobdiff_plain/c4bef2a8143ddaf4ab2a57084455f5617bc39399..c1b28b595a388df043997c87faf75c06959405d0:/practicas/pipi/src/ip.cpp?ds=inline diff --git a/practicas/pipi/src/ip.cpp b/practicas/pipi/src/ip.cpp index db99e1a..b131524 100644 --- a/practicas/pipi/src/ip.cpp +++ b/practicas/pipi/src/ip.cpp @@ -3,6 +3,7 @@ #include "ipin.h" #include "ipaddr.h" #include "routetable.h" +#include "devtcp.h" #include "devque.h" #include #include @@ -17,7 +18,7 @@ #include #include -// Uso: ./test_ipout ip [router forward routes_file queue_id proto] +// Uso: ./test_ipout ip [router forward routes_file port proto] void send_loop(IPOut& ipout, unsigned proto); @@ -28,12 +29,12 @@ int main(int argc, char* argv[]) bool router = false; bool forward = false; unsigned proto = 0; - key_t queue_id = DEVQUE_DEFAULT_KEY; + uint16_t port = DEVTCP_DEFAULT_PORT; std::string fname = "route.txt"; if (argc < 2) { std::cerr << "Uso: ./test_ipout ip [router forward routes_file " - "queue_id proto]\n"; + "port proto]\n"; return 1; } IPAddr addr(argv[1]); @@ -44,16 +45,15 @@ int main(int argc, char* argv[]) if (argc > 4) fname = argv[4]; if (argc > 5) - queue_id = atoi(argv[5]); + port = atoi(argv[5]); if (argc > 6) proto = atoi(argv[6]); - // Creo colas - int que_id = msgget(queue_id, IPC_CREAT | 0666); assert(que_id != -1); - que_id = msgget(DEVQUE_DEFAULT_KEY-1, IPC_CREAT | 0666); assert(que_id != -1); + // Creo cola para comunicar el IPIn con IPOut + int que_id = msgget(DEVQUE_DEFAULT_KEY-1, IPC_CREAT | 0666); assert(que_id != -1); // Abro archivo con rutas std::ifstream ifs(fname.c_str()); assert(ifs); // Creo medio físico y cola para forwarding - DevQue dev(addr, queue_id); + DevTCP dev(addr, port); DevQue fwque(addr, DEVQUE_DEFAULT_KEY-1); // Creo procesos pid_t pid_send = fork(); @@ -132,7 +132,7 @@ void add_routes(RouteTable& rt, std::istream& is, Dev& dev) iss >> net >> gw >> mtu >> metric; if (net == "0") net = "0.0.0.0"; if (gw == "0") gw = "0.0.0.0"; - rt.add(net.c_str(), gw.c_str(), metric, mtu, dev); + rt.add(net, gw, metric, mtu, dev); } }