71 L3Address srcAddr, destAddr;
73 for (cPacket *pk = dynamic_cast<cPacket *>(msg); pk; pk = pk->getEncapsulatedPacket()) {
74 INetworkDatagram *dgram =
dynamic_cast<INetworkDatagram *
>(pk);
76 srcAddr = dgram->getSourceAddress();
77 destAddr = dgram->getDestinationAddress();
79 if (dynamic_cast<IPv4Datagram *>(pk)) {
80 IPv4Datagram *ipv4dgram =
static_cast<IPv4Datagram *
>(pk);
81 if (ipv4dgram->getMoreFragments() || ipv4dgram->getFragmentOffset() > 0)
82 os << (ipv4dgram->getMoreFragments() ?
"" :
"last ")
83 <<
"fragment with offset=" << ipv4dgram->getFragmentOffset() <<
" of ";
85 #endif // ifdef WITH_IPv4 87 #ifdef WITH_TCP_COMMON 88 else if (dynamic_cast<tcp::TCPSegment *>(pk)) {
89 printTCPPacket(os, srcAddr, destAddr, static_cast<tcp::TCPSegment *>(pk));
92 #endif // ifdef WITH_TCP_COMMON 94 else if (dynamic_cast<UDPPacket *>(pk)) {
95 printUDPPacket(os, srcAddr, destAddr, static_cast<UDPPacket *>(pk));
98 #endif // ifdef WITH_UDP 100 else if (dynamic_cast<ICMPMessage *>(pk)) {
101 printICMPPacket(os, srcAddr, destAddr, static_cast<ICMPMessage *>(pk));
104 #endif // ifdef WITH_IPv4 106 os <<
"(" << msg->getClassName() <<
")" <<
" id=" << msg->getId() <<
" kind=" << msg->getKind();
void printICMPPacket(std::ostream &os, L3Address srcAddr, L3Address destAddr, ICMPMessage *packet) const
Definition: InetPacketPrinter.cc:174
void printTCPPacket(std::ostream &os, L3Address srcAddr, L3Address destAddr, tcp::TCPSegment *tcpSeg) const
Definition: InetPacketPrinter.cc:109
void printUDPPacket(std::ostream &os, L3Address srcAddr, L3Address destAddr, UDPPacket *udpPacket) const
Definition: InetPacketPrinter.cc:164