protected:
ListenSocket listener;
- EtherTap *tap;
+ EtherTapStub *tap;
int port;
public:
- TapListener(EtherTap *t, int p)
+ TapListener(EtherTapStub *t, int p)
: event(NULL), tap(t), port(p) {}
~TapListener() { if (event) delete event; }
class TapEvent : public PollEvent
{
protected:
- EtherTap *tap;
+ EtherTapStub *tap;
public:
- TapEvent(EtherTap *_tap, int fd, int e)
+ TapEvent(EtherTapStub *_tap, int fd, int e)
: PollEvent(fd, e), tap(_tap) {}
virtual void process(int revent) { tap->process(revent); }
};
-EtherTap::EtherTap(const Params *p)
+EtherTapStub::EtherTapStub(const Params *p)
: EtherObject(p), event(NULL), socket(-1), buflen(p->bufsz), dump(p->dump),
interface(NULL), txEvent(this)
{
if (ListenSocket::allDisabled())
- fatal("All listeners are disabled! EtherTap can't work!");
+ fatal("All listeners are disabled! EtherTapStub can't work!");
buffer = new char[buflen];
listener = new TapListener(this, p->port);
interface = new EtherTapInt(name() + ".interface", this);
}
-EtherTap::~EtherTap()
+EtherTapStub::~EtherTapStub()
{
if (event)
delete event;
}
void
-EtherTap::attach(int fd)
+EtherTapStub::attach(int fd)
{
if (socket != -1)
close(fd);
buffer_offset = 0;
data_len = 0;
socket = fd;
- DPRINTF(Ethernet, "EtherTap attached\n");
+ DPRINTF(Ethernet, "EtherTapStub attached\n");
event = new TapEvent(this, socket, POLLIN|POLLERR);
pollQueue.schedule(event);
}
void
-EtherTap::detach()
+EtherTapStub::detach()
{
- DPRINTF(Ethernet, "EtherTap detached\n");
+ DPRINTF(Ethernet, "EtherTapStub detached\n");
delete event;
event = 0;
close(socket);
}
bool
-EtherTap::recvPacket(EthPacketPtr packet)
+EtherTapStub::recvPacket(EthPacketPtr packet)
{
if (dump)
dump->dump(packet);
- DPRINTF(Ethernet, "EtherTap output len=%d\n", packet->length);
+ DPRINTF(Ethernet, "EtherTapStub output len=%d\n", packet->length);
DDUMP(EthernetData, packet->data, packet->length);
uint32_t len = htonl(packet->length);
ssize_t ret = write(socket, &len, sizeof(len));
}
void
-EtherTap::sendDone()
+EtherTapStub::sendDone()
{}
void
-EtherTap::process(int revent)
+EtherTapStub::process(int revent)
{
if (revent & POLLERR) {
detach();
} else
data_len = 0;
- DPRINTF(Ethernet, "EtherTap input len=%d\n", packet->length);
+ DPRINTF(Ethernet, "EtherTapStub input len=%d\n", packet->length);
DDUMP(EthernetData, packet->data, packet->length);
if (!interface->sendPacket(packet)) {
DPRINTF(Ethernet, "bus busy...buffer for retransmission\n");
}
void
-EtherTap::retransmit()
+EtherTapStub::retransmit()
{
if (packetBuffer.empty())
return;
if (interface->sendPacket(packet)) {
if (dump)
dump->dump(packet);
- DPRINTF(Ethernet, "EtherTap retransmit\n");
+ DPRINTF(Ethernet, "EtherTapStub retransmit\n");
packetBuffer.front() = NULL;
packetBuffer.pop();
}
}
EtherInt*
-EtherTap::getEthPort(const std::string &if_name, int idx)
+EtherTapStub::getEthPort(const std::string &if_name, int idx)
{
if (if_name == "tap") {
if (interface->getPeer())
//=====================================================================
void
-EtherTap::serialize(CheckpointOut &cp) const
+EtherTapStub::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(socket);
SERIALIZE_SCALAR(buflen);
}
void
-EtherTap::unserialize(CheckpointIn &cp)
+EtherTapStub::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(socket);
UNSERIALIZE_SCALAR(buflen);
//=====================================================================
-EtherTap *
-EtherTapParams::create()
+EtherTapStub *
+EtherTapStubParams::create()
{
- return new EtherTap(this);
+ return new EtherTapStub(this);
}
#include "dev/net/etherint.hh"
#include "dev/net/etherobject.hh"
#include "dev/net/etherpkt.hh"
-#include "params/EtherTap.hh"
+#include "params/EtherTapStub.hh"
#include "sim/eventq.hh"
#include "sim/sim_object.hh"
class EtherTapInt;
/*
- * Interface to connect a simulated ethernet device to the real world
+ * Interface to connect a simulated ethernet device to the real world. An
+ * external helper program bridges between this object's TCP port and a
+ * source/sink for Ethernet frames. Each frame going in either direction is
+ * prepended with the frame's length in a 32 bit integer in network byte order.
*/
-class EtherTap : public EtherObject
+class EtherTapStub : public EtherObject
{
protected:
friend class TapEvent;
class TxEvent : public Event
{
protected:
- EtherTap *tap;
+ EtherTapStub *tap;
public:
- TxEvent(EtherTap *_tap) : tap(_tap) {}
+ TxEvent(EtherTapStub *_tap) : tap(_tap) {}
void process() { tap->retransmit(); }
virtual const char *description() const
- { return "EtherTap retransmit"; }
+ { return "EtherTapStub retransmit"; }
};
friend class TxEvent;
TxEvent txEvent;
public:
- typedef EtherTapParams Params;
- EtherTap(const Params *p);
- virtual ~EtherTap();
+ typedef EtherTapStubParams Params;
+ EtherTapStub(const Params *p);
+ virtual ~EtherTapStub();
const Params *
params() const
class EtherTapInt : public EtherInt
{
private:
- EtherTap *tap;
+ EtherTapStub *tap;
public:
- EtherTapInt(const std::string &name, EtherTap *t)
+ EtherTapInt(const std::string &name, EtherTapStub *t)
: EtherInt(name), tap(t)
{ }