#include <ExtInterface.h>
List of all members.
Member Function Documentation
void ExtInterface::displayBusy |
( |
| ) |
[protected] |
{
getDisplayString().setTagArg("i",1, "yellow");
gate("physOut")->getDisplayString().setTagArg("ls",0,"yellow");
gate("physOut")->getDisplayString().setTagArg("ls",1,"3");
}
void ExtInterface::displayIdle |
( |
| ) |
[protected] |
{
getDisplayString().setTagArg("i",1,"");
gate("physOut")->getDisplayString().setTagArg("ls",0,"black");
gate("physOut")->getDisplayString().setTagArg("ls",1,"1");
}
void ExtInterface::finish |
( |
| ) |
[virtual] |
{
std::cout << getFullPath() << ": " << numSent << " packets sent, " <<
numRcvd << " packets received, " << numDropped <<" packets dropped.\n";
}
void ExtInterface::handleMessage |
( |
cMessage * |
msg | ) |
[virtual] |
{
if(dynamic_cast<ExtFrame *>(msg) != NULL)
{
uint32 packetLength;
ExtFrame *rawPacket = check_and_cast<ExtFrame *>(msg);
packetLength = rawPacket->getDataArraySize();
for(uint32 i=0; i < packetLength; i++)
buffer[i] = rawPacket->getData(i);
IPDatagram *ipPacket = new IPDatagram("ip-from-wire");
IPSerializer().parse(buffer, packetLength, (IPDatagram *)ipPacket);
EV << "Delivering an IP packet from "
<< ipPacket->getSrcAddress()
<< " to "
<< ipPacket->getDestAddress()
<< " and length of"
<< ipPacket->getByteLength()
<< " bytes to IP layer.\n";
send(ipPacket, "netwOut");
numRcvd++;
}
else
{
memset(buffer, 0, 1<<16);
IPDatagram *ipPacket = check_and_cast<IPDatagram *>(msg);
if ((ipPacket->getTransportProtocol() != IP_PROT_ICMP) &&
(ipPacket->getTransportProtocol() != IPPROTO_SCTP) &&
(ipPacket->getTransportProtocol() != IPPROTO_TCP) &&
(ipPacket->getTransportProtocol() != IPPROTO_UDP))
{
EV << "Can not send packet. Protocol " << ipPacket->getTransportProtocol() << " is not supported.\n";
numDropped++;
delete(msg);
return;
}
if(connected)
{
struct sockaddr_in addr;
addr.sin_family = AF_INET;
#if !defined(linux) && !defined(_WIN32)
addr.sin_len = sizeof(struct sockaddr_in);
#endif
addr.sin_port = 0;
addr.sin_addr.s_addr = htonl(ipPacket->getDestAddress().getInt());
int32 packetLength = IPSerializer().serialize(ipPacket,buffer, sizeof(buffer));
EV << "Delivering an IP packet from "
<< ipPacket->getSrcAddress()
<< " to "
<< ipPacket->getDestAddress()
<< " and length of "
<< ipPacket->getByteLength()
<< " bytes to link layer.\n";
rtScheduler->sendBytes(buffer, packetLength, (struct sockaddr *) &addr, sizeof(struct sockaddr_in));
numSent++;
}
else
{
EV << "Interface is not connected, dropping packet " << msg << endl;
numDropped++;
}
}
delete(msg);
if (ev.isGUI())
updateDisplayString();
}
void ExtInterface::initialize |
( |
int |
stage | ) |
[virtual] |
virtual int32 ExtInterface::numInitStages |
( |
| ) |
const [inline, virtual] |
void ExtInterface::updateDisplayString |
( |
| ) |
[protected] |
Referenced by handleMessage(), and initialize().
{
char buf[80];
if (ev.disable_tracing)
getDisplayString().setTagArg("t",0,"");
if(connected)
sprintf(buf, "pcap device: %s\nrcv:%d snt:%d", device, numRcvd, numSent);
else
sprintf(buf, "not connected");
getDisplayString().setTagArg("t", 0, buf);
}
Member Data Documentation
The documentation for this class was generated from the following files: