mensajes de debug.
#include "ipin.h"
#include "ipheader.h"
+#ifdef DEBUG
+#include <iostream>
+#endif
/// Constructor
IPIn::IPIn(const IPAddr& ip, Dev& dev, Dev& forward_que, bool router,
}
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)
{
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?)
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
+#ifdef DEBUG
+#include <iostream>
+#endif
/// Constructor
IPOut::IPOut(const IPAddr& ip, RouteTable& rtable, Dev& forward_que, std::ostream& log):
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()));
}
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));
}
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))
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))
{