X-Git-Url: https://git.llucax.com/z.facultad/75.74/practicos.git/blobdiff_plain/49f488eb5e757db401a81bc40a30a84d1abcaf88..55584999e396fae97c47a9d83d35d6b45c7bed97:/practicas/pipi/src/ipin.cpp?ds=sidebyside diff --git a/practicas/pipi/src/ipin.cpp b/practicas/pipi/src/ipin.cpp index 55bc856..15e102c 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, @@ -13,12 +16,14 @@ IPIn::IPIn(const IPAddr& ip, Dev& dev, Dev& forward_que, bool router, void IPIn::drop(const std::string& msg, const std::string& buf) { - log << "IPIn::drop: " << msg << "\n\tBuffer: " << buf << "\n"; + log << "IPIn::drop (" << ip << "): " << msg << "\n\tBuffer: " << buf + << "\n"; } void IPIn::drop(const std::string& msg, const IPHeader& iph) { - log << "IPIn::drop: " << msg << "\n\tIPHeader: " << iph << "\n"; + log << "IPIn::drop (" << ip << "): " << msg << "\n\tIPHeader: " << iph + << "\n"; } /// Recibe un paquete IP @@ -35,9 +40,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 (" << ip << "): 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 +87,8 @@ 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 (" << ip << "): Paquete completo: data = '" + << data << "'\n"; #endif buffer.erase(iph); //TODO faltaría limpiar fragmentos viejos cada tanto (timer?)