INET Framework for OMNeT++/OMNEST
inet::IcmpProtocolPrinter Class Reference

#include <IcmpProtocolPrinter.h>

Inheritance diagram for inet::IcmpProtocolPrinter:
inet::ProtocolPrinter

Public Member Functions

virtual void print (const Ptr< const Chunk > &chunk, const Protocol *protocol, const cMessagePrinter::Options *options, Context &context) const override
 Prints the given chunk of protocol according to options into context. More...
 

Member Function Documentation

◆ print()

void inet::IcmpProtocolPrinter::print ( const Ptr< const Chunk > &  chunk,
const Protocol protocol,
const cMessagePrinter::Options *  options,
Context context 
) const
overridevirtual

Prints the given chunk of protocol according to options into context.

Implements inet::ProtocolPrinter.

19 {
20  if (auto header = dynamicPtrCast<const IcmpHeader>(chunk)) {
21  switch (header->getType()) {
23  context.typeColumn << "DEST-UN";
24  // TODO packet contains a complete Ipv4Header and the first 8 bytes of transport header (or icmp). (protocol specified in Ipv4Header.)
25  context.infoColumn << "code=" << header->getCode();
26  break;
27  case ICMP_TIME_EXCEEDED:
28  context.typeColumn << "TIME-EX";
29  // TODO packet contains a complete Ipv4Header and the first 8 bytes of transport header (or icmp). (protocol specified in Ipv4Header.)
30  context.infoColumn << "code=" << header->getCode();
31  break;
33  context.typeColumn << "PAR-PROB";
34  // TODO packet contains a complete Ipv4Header and the first 8 bytes of transport header (or icmp). (protocol specified in Ipv4Header.)
35  context.infoColumn << "code=" << header->getCode();
36  break;
37  case ICMP_ECHO_REQUEST:
38  context.typeColumn << "ECHO-REQ";
39  context.infoColumn << "code=" << header->getCode();
40  if (auto echoHeader = dynamicPtrCast<const IcmpEchoRequest>(header))
41  context.infoColumn << " id=" << echoHeader->getIdentifier() << " seq=" << echoHeader->getSeqNumber();
42  break;
43  case ICMP_ECHO_REPLY:
44  context.typeColumn << "ECHO-REPLY";
45  context.infoColumn << "code=" << header->getCode();
46  if (auto echoHeader = dynamicPtrCast<const IcmpEchoReply>(header))
47  context.infoColumn << " id=" << echoHeader->getIdentifier() << " seq=" << echoHeader->getSeqNumber();
48  break;
49  default:
50  context.infoColumn << "ICMP-" << header->getType() << "-" << header->getCode();
51  break;
52  }
53  }
54  else
55  context.infoColumn << "(ICMP) " << chunk;
56 }

The documentation for this class was generated from the following files:
inet::ICMP_DESTINATION_UNREACHABLE
@ ICMP_DESTINATION_UNREACHABLE
Definition: IcmpHeader_m.h:77
inet::ICMP_PARAMETER_PROBLEM
@ ICMP_PARAMETER_PROBLEM
Definition: IcmpHeader_m.h:84
inet::ICMP_ECHO_REQUEST
@ ICMP_ECHO_REQUEST
Definition: IcmpHeader_m.h:80
inet::ICMP_TIME_EXCEEDED
@ ICMP_TIME_EXCEEDED
Definition: IcmpHeader_m.h:83
inet::ICMP_ECHO_REPLY
@ ICMP_ECHO_REPLY
Definition: IcmpHeader_m.h:85