X-Git-Url: https://git.llucax.com/z.facultad/75.74/practicos.git/blobdiff_plain/7a01801db38786c0f1cab79b3867b8b529d5cb1c..91fb3ca6b56328c626dabb35e2de9a5ae525b1b1:/practicas/pipi/src/ipin.h?ds=inline diff --git a/practicas/pipi/src/ipin.h b/practicas/pipi/src/ipin.h index 2c64911..8a452b2 100644 --- a/practicas/pipi/src/ipin.h +++ b/practicas/pipi/src/ipin.h @@ -4,32 +4,59 @@ #include "ipaddr.h" #include "ipheader.h" #include "dev.h" -#include +#include #include +#include #include /// IP de recepción struct IPIn { - /// Dirección MAC + /// Dirección IP IPAddr ip; /// Dispositivo de red Dev& dev; + /// Cola para forwardear paquetes + Dev& forward_que; + + /// Indica si es un router + bool router; + + /// Indica si hace forwarding + bool forward; + /// Dispositivo de logging std::ostream& log; + /// Buffers de recepción + struct BufferKey + { + uint16_t id; + uint32_t src, dst; + uint8_t proto; + BufferKey(const IPHeader& h): + id(h.id), src(h.src), dst(h.dst), proto(h.proto) + {} + bool operator< (const BufferKey& b) const + { return id < b.id && src < b.src && dst < b.dst && proto < b.proto; } + }; + typedef std::map< uint16_t, std::string > offsetmap_type; + typedef std::map< BufferKey, offsetmap_type > buffer_type; + buffer_type buffer; + /// Constructor - IPIn(const IPAddr& ip, Dev& dev, std::ostream& log = std::cout); + IPIn(const IPAddr& ip, Dev& dev, Dev& forward_que, bool router = false, + bool forward = false, std::ostream& log = std::cout); /// Descarta un paquete void drop(const std::string& msg, const std::string& buf); void drop(const std::string& msg, const IPHeader& iph); /// Recibe un paquete IP - std::string recv(uint8_t proto, IPAddr& src, IPAddr& dst) + std::string recv(uint8_t& proto, IPAddr& src, IPAddr& dst) throw (std::runtime_error); // Nada de andar copiando placas...