char frame[1];
};
-Dev::Dev(mac_type mac, size_t mtu, key_t key) throw (std::runtime_error):
+Dev::Dev(mac_type mac, size_t mtu, key_t key)
+ throw (std::runtime_error, std::logic_error):
mac(mac), mtu(mtu)
{
+ if (mtu > DEV_MAX_MTU)
+ throw std::logic_error("MTU más grande que DEV_MAX_MTU");
que_id = msgget(key, 0666); // Debe estar previamente creada
if (que_id == -1)
throw std::runtime_error("No se pudo crear la cola");
int res = msgsnd(que_id, f, mtu + sizeof(size_t), 0);
#ifdef DEBUG
std::cout << "Dev::transmit(msgtype/mac = " << f->mac << ", size = "
- << f->size << ", data = " << f->frame << ")\n";
+ << f->size << ")\n";
#endif
free(f);
if (res == -1)
free(f);
#ifdef DEBUG
std::cout << "Dev::receive(msgtype/mac = " << mac << ", size = "
- << s.size() << ", data = " << s << ")\n";
+ << s.size() << ")\n";
#endif
return s;
}