TCPDump Class Reference

#include <TCPDump.h>

List of all members.


Detailed Description

Dumps every packet using the TCPDumper class


Public Member Functions

 TCPDump (const char *name=NULL, cModule *parent=NULL)
virtual void handleMessage (cMessage *msg)
virtual void finish ()

Protected Attributes

TCPDumper tcpdump


Constructor & Destructor Documentation

TCPDump::TCPDump ( const char *  name = NULL,
cModule *  parent = NULL 
)

00148                                                   :
00149   cSimpleModule(name, parent, 0), tcpdump(ev)
00150 {
00151 }


Member Function Documentation

void TCPDump::finish (  )  [virtual]

00192 {
00193     tcpdump.dump("", "tcpdump finished");
00194 }

void TCPDump::handleMessage ( cMessage *  msg  )  [virtual]

00154 {
00155     // dump
00156     if (!ev.disabled())
00157     {
00158         bool l2r = msg->arrivedOn("in1");
00159         if (dynamic_cast<TCPSegment *>(msg))
00160         {
00161             tcpdump.dump(l2r, "", (TCPSegment *)msg, std::string(l2r?"A":"B"),std::string(l2r?"B":"A"));
00162         }
00163         else
00164         {
00165             // search for encapsulated IP[v6]Datagram in it
00166             cMessage *encapmsg = msg;
00167             while (encapmsg && dynamic_cast<IPDatagram *>(encapmsg)==NULL && dynamic_cast<IPv6Datagram_Base *>(encapmsg)==NULL)
00168                 encapmsg = encapmsg->encapsulatedMsg();
00169             if (!encapmsg)
00170             {
00171                 //We do not want this to end in an error if EtherAutoconf messages
00172                 //are passed, so just print a warning. -WEI
00173                 EV << "CANNOT DECODE: packet " << msg->name() << " doesn't contain either IP or IPv6 Datagram\n";
00174             }
00175             else
00176             {
00177                 if (dynamic_cast<IPDatagram *>(encapmsg))
00178                     tcpdump.dump(l2r, "", (IPDatagram *)encapmsg);
00179                 else if (dynamic_cast<IPv6Datagram_Base *>(encapmsg))
00180                     tcpdump.dumpIPv6(l2r, "", (IPv6Datagram_Base *)encapmsg);
00181                 else
00182                     ASSERT(0); // cannot get here
00183             }
00184         }
00185     }
00186 
00187     // forward
00188     send(msg, msg->arrivedOn("in1") ? "out2" : "out1");
00189 }


Member Data Documentation

TCPDumper TCPDump::tcpdump [protected]


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:20:24 2007 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.7