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

#include <RipProtocolPrinter.h>

Inheritance diagram for inet::RipProtocolPrinter:
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::RipProtocolPrinter::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 packet = dynamicPtrCast<const RipPacket>(chunk)) {
21  context.infoColumn << "RIP: ";
22  switch (packet->getCommand()) {
23  case RIP_REQUEST:
24  context.infoColumn << "req ";
25  break;
26 
27  case RIP_RESPONSE:
28  context.infoColumn << "resp ";
29  break;
30 
31  default:
32  context.infoColumn << "unknown ";
33  break;
34  }
35  unsigned int size = packet->getEntryArraySize();
36  for (unsigned int i = 0; i < size; ++i) {
37  const RipEntry& entry = packet->getEntry(i);
38  if (i > 0)
39  context.infoColumn << "; ";
40  if (i > 2) {
41  context.infoColumn << "...(" << size << " entries)";
42  break;
43  }
44  context.infoColumn << entry.address << "/" << entry.prefixLength;
45  if (!entry.nextHop.isUnspecified())
46  context.infoColumn << "->" << entry.nextHop;
47  if (entry.metric == 16)
48  context.infoColumn << " unroutable";
49  else
50  context.infoColumn << " m=" << entry.metric;
51  }
52  }
53  else
54  context.infoColumn << "(RIP) " << chunk;
55 }

The documentation for this class was generated from the following files:
inet::RIP_REQUEST
@ RIP_REQUEST
Definition: RipPacket_m.h:68
inet::RIP_RESPONSE
@ RIP_RESPONSE
Definition: RipPacket_m.h:69