/*
- * Copyright (c) 2003 The Regents of The University of Michigan
+ * Copyright (c) 2003-2005 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* Interface to connect a simulated ethernet device to the real world
*/
-#if defined(__OpenBSD__)
+#if defined(__OpenBSD__) || defined(__APPLE__)
#include <sys/param.h>
#endif
#include <netinet/in.h>
}
bool
-EtherTap::recvPacket(PacketPtr &packet)
+EtherTap::recvPacket(PacketPtr packet)
{
if (dump)
dump->dump(packet);
while (data_len != 0 && buffer_offset >= data_len + sizeof(u_int32_t)) {
PacketPtr packet;
- packet = new EtherPacket;
- packet->data = new uint8_t[data_len];
+ packet = new PacketData(data_len);
packet->length = data_len;
memcpy(packet->data, data, data_len);
DPRINTF(Ethernet, "bus busy...buffer for retransmission\n");
packetBuffer.push(packet);
if (!txEvent.scheduled())
- txEvent.schedule(curTick + 1000);
- } else if (dump)
+ txEvent.schedule(curTick + retryTime);
+ } else if (dump) {
dump->dump(packet);
+ }
}
}
}
if (!packetBuffer.empty() && !txEvent.scheduled())
- txEvent.schedule(curTick + 1000);
+ txEvent.schedule(curTick + retryTime);
}
//=====================================================================
{
SERIALIZE_SCALAR(socket);
SERIALIZE_SCALAR(buflen);
- SERIALIZE_ARRAY((uint8_t *)buffer,buflen);
+ uint8_t *buffer = (uint8_t *)this->buffer;
+ SERIALIZE_ARRAY(buffer, buflen);
SERIALIZE_SCALAR(buffer_offset);
SERIALIZE_SCALAR(data_len);
{
UNSERIALIZE_SCALAR(socket);
UNSERIALIZE_SCALAR(buflen);
- UNSERIALIZE_ARRAY((uint8_t *)buffer,buflen);
+ uint8_t *buffer = (uint8_t *)this->buffer;
+ UNSERIALIZE_ARRAY(buffer, buflen);
UNSERIALIZE_SCALAR(buffer_offset);
UNSERIALIZE_SCALAR(data_len);
BEGIN_DECLARE_SIM_OBJECT_PARAMS(EtherTap)
SimObjectParam<EtherInt *> peer;
- SimObjectParam<EtherDump *> packet_dump;
+ SimObjectParam<EtherDump *> dump;
Param<unsigned> port;
Param<unsigned> bufsz;
BEGIN_INIT_SIM_OBJECT_PARAMS(EtherTap)
INIT_PARAM_DFLT(peer, "peer interface", NULL),
- INIT_PARAM_DFLT(packet_dump, "object to dump network packets to", NULL),
+ INIT_PARAM_DFLT(dump, "object to dump network packets to", NULL),
INIT_PARAM_DFLT(port, "tap port", 3500),
INIT_PARAM_DFLT(bufsz, "tap buffer size", 10000)
CREATE_SIM_OBJECT(EtherTap)
{
- EtherTap *tap = new EtherTap(getInstanceName(), packet_dump, port, bufsz);
+ EtherTap *tap = new EtherTap(getInstanceName(), dump, port, bufsz);
if (peer) {
tap->setPeer(peer);