From 6758589f5ff68b1775d5a83b01d7ac49f1b612ef Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Fri, 2 Jun 2006 17:59:18 +0000 Subject: [PATCH] Se cambia el logueo de paquetes dropeados a std::cerr para diferenciar de mensajes de debug. --- practicas/pipi/src/ipin.cpp | 9 ++++++--- practicas/pipi/src/ipout.cpp | 9 ++++++--- practicas/pipi/src/test_ipin.cpp | 2 +- practicas/pipi/src/test_ipout.cpp | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/practicas/pipi/src/ipin.cpp b/practicas/pipi/src/ipin.cpp index 55bc856..c191b90 100644 --- a/practicas/pipi/src/ipin.cpp +++ b/practicas/pipi/src/ipin.cpp @@ -1,6 +1,9 @@ #include "ipin.h" #include "ipheader.h" +#ifdef DEBUG +#include +#endif /// Constructor IPIn::IPIn(const IPAddr& ip, Dev& dev, Dev& forward_que, bool router, @@ -35,9 +38,9 @@ std::string IPIn::recv(uint8_t proto, IPAddr& src, IPAddr& dst) throw (std::runt } IPHeader iph(buf); #ifdef DEBUG - log << "IPIn::recv: IPHeader: " << iph << "\n"; + std::cout << "IPIn::recv: IPHeader: " << iph << "\n"; std::string tmp = buf.substr(iph.header_len()); - log << "\tdata (" << tmp.size() << ") = " << tmp << "\n"; + std::cout << "\tdata (" << tmp.size() << ") = " << tmp << "\n"; #endif if (iph.version != 4) { @@ -82,7 +85,7 @@ std::string IPIn::recv(uint8_t proto, IPAddr& src, IPAddr& dst) throw (std::runt data += i->second; } #ifdef DEBUG - log << "IPIn::recv: Paquete completo: data = '" << data << "'\n"; + std::cout << "IPIn::recv: Paquete completo: data = '" << data << "'\n"; #endif buffer.erase(iph); //TODO faltaría limpiar fragmentos viejos cada tanto (timer?) diff --git a/practicas/pipi/src/ipout.cpp b/practicas/pipi/src/ipout.cpp index 3e8dadc..6e0c807 100644 --- a/practicas/pipi/src/ipout.cpp +++ b/practicas/pipi/src/ipout.cpp @@ -7,6 +7,9 @@ #include #include #include +#ifdef DEBUG +#include +#endif /// Constructor IPOut::IPOut(const IPAddr& ip, RouteTable& rtable, Dev& forward_que, std::ostream& log): @@ -35,7 +38,7 @@ bool IPOut::send(const std::string& data, uint8_t proto, IPAddr dst, IPAddr src, std::string buf = forward_que.receive(); IPHeader iph(buf); #ifdef DEBUG - log << "IPOut::send: A forwardear\n"; + std::cout << "IPOut::send: A forwardear\n"; #endif send(iph, buf.substr(iph.header_len())); } @@ -82,9 +85,9 @@ bool IPOut::send(IPHeader iph, std::string data) throw (std::runtime_error) std::string buf((char*) &iph2, sizeof(IPHeader)); buf += data.substr(i * max_payload, max_payload); #ifdef DEBUG - log << "IPOut::send: Fragmento 0 => IPHeader: " << iph2 << "\n"; + std::cout << "IPOut::send: Fragmento 0 => IPHeader: " << iph2 << "\n"; std::string tmp = data.substr(i * max_payload, max_payload); - log << "\tdata (" << tmp.size() << ") = " << tmp << "\n"; + std::cout << "\tdata (" << tmp.size() << ") = " << tmp << "\n"; #endif r->iface->transmit(buf, r->gateway ? r->gateway : IPAddr(iph.dst)); } diff --git a/practicas/pipi/src/test_ipin.cpp b/practicas/pipi/src/test_ipin.cpp index 1d21ab6..eb15d0f 100644 --- a/practicas/pipi/src/test_ipin.cpp +++ b/practicas/pipi/src/test_ipin.cpp @@ -36,7 +36,7 @@ int main(int argc, char* argv[]) int que_id = msgget(queue_id+1, IPC_CREAT | 0666); assert(que_id != -1); Dev fwque(addr, DEV_MAX_MTU, queue_id+1); - IPIn ipin(addr, dev, fwque, router, forward); + IPIn ipin(addr, dev, fwque, router, forward, std::cerr); struct msqid_ds minfo; for (msgctl(dev.que_id, IPC_STAT, &minfo); minfo.msg_qnum; msgctl(dev.que_id, IPC_STAT, &minfo)) diff --git a/practicas/pipi/src/test_ipout.cpp b/practicas/pipi/src/test_ipout.cpp index 1dd289f..b8e75c9 100644 --- a/practicas/pipi/src/test_ipout.cpp +++ b/practicas/pipi/src/test_ipout.cpp @@ -45,7 +45,7 @@ int main(int argc, char* argv[]) Dev fwque(addr, DEV_MAX_MTU, queue_id+1); RouteTable table(dev); add_routes(table, ifs, dev); - IPOut ipout(addr, table, fwque); + IPOut ipout(addr, table, fwque, std::cerr); std::string msg; while (std::getline(std::cin, msg)) { -- 2.43.0