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

Error Handling: print out received error for IPv6. More...

#include <IPv6ErrorHandling.h>

Inheritance diagram for inet::IPv6ErrorHandling:

Protected Member Functions

virtual void initialize () override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void displayType1Msg (int code)
 
virtual void displayType2Msg ()
 
virtual void displayType3Msg (int code)
 
virtual void displayType4Msg (int code)
 

Detailed Description

Error Handling: print out received error for IPv6.

Member Function Documentation

void inet::IPv6ErrorHandling::displayType1Msg ( int  code)
protectedvirtual

Referenced by handleMessage().

99 {
100  EV_ERROR << " Destination Unreachable: ";
101  switch (code) {
102  case NO_ROUTE_TO_DEST:
103  EV_ERROR << "no route to destination\n";
104  break;
105 
107  EV_ERROR << "communication with destination administratively prohibited\n";
108  break;
109 
110  case ADDRESS_UNREACHABLE:
111  EV_ERROR << "address unreachable\n";
112  break;
113 
114  case PORT_UNREACHABLE:
115  EV_ERROR << "port unreachable\n";
116  break;
117 
118  default:
119  EV_ERROR << "Unknown Error Code!\n";
120  break;
121  }
122 }
Definition: ICMPv6Message_m.h:109
Definition: ICMPv6Message_m.h:108
Definition: ICMPv6Message_m.h:110
Definition: ICMPv6Message_m.h:107
void inet::IPv6ErrorHandling::displayType2Msg ( )
protectedvirtual

Referenced by handleMessage().

125 {
126  EV_ERROR << " Packet Too Big\n";
127 }
void inet::IPv6ErrorHandling::displayType3Msg ( int  code)
protectedvirtual

Referenced by handleMessage().

130 {
131  EV_ERROR << " Time Exceeded Message: ";
132  switch (code) {
134  EV_ERROR << "hop limit exceeded in transit\n";
135  break;
136 
138  EV_ERROR << "fragment reassembly time exceeded\n";
139  break;
140 
141  default:
142  EV_ERROR << "Unknown Error Code!\n";
143  break;
144  }
145 }
Definition: ICMPv6Message_m.h:129
Definition: ICMPv6Message_m.h:128
void inet::IPv6ErrorHandling::displayType4Msg ( int  code)
protectedvirtual

Referenced by handleMessage().

148 {
149  EV_ERROR << " Parameter Problem Message: ";
150  switch (code) {
151  case ERROREOUS_HDR_FIELD:
152  EV_ERROR << "erroneous header field encountered\n";
153  break;
154 
156  EV_ERROR << "unrecognized Next Header type encountered\n";
157  break;
158 
160  EV_ERROR << "unrecognized IPv6 option encountered\n";
161  break;
162 
163  default:
164  EV_ERROR << "Unknown Error Code!\n";
165  break;
166  }
167 }
Definition: ICMPv6Message_m.h:148
Definition: ICMPv6Message_m.h:149
Definition: ICMPv6Message_m.h:150
void inet::IPv6ErrorHandling::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
37 {
38  ICMPv6Message *icmpv6Msg = check_and_cast<ICMPv6Message *>(msg);
39  IPv6Datagram *d = check_and_cast<IPv6Datagram *>(icmpv6Msg->getEncapsulatedPacket());
40  int type = (int)icmpv6Msg->getType();
41 
42  EV_ERROR << " Type: " << type;
43 
44  switch (type) {
46  ICMPv6DestUnreachableMsg *msg2 = check_and_cast<ICMPv6DestUnreachableMsg *>(icmpv6Msg);
47  int code = msg2->getCode();
48  EV_ERROR << " Code: " << code;
49  displayType1Msg(code);
50  break;
51  }
52 
53  case ICMPv6_PACKET_TOO_BIG: {
54  ICMPv6PacketTooBigMsg *msg2 = check_and_cast<ICMPv6PacketTooBigMsg *>(icmpv6Msg);
55  int code = msg2->getCode();
56  int mtu = msg2->getMTU();
57  EV_ERROR << " Code: " << code << " MTU: " << mtu;
58  //Code is always 0 and ignored by the receiver.
60  break;
61  }
62 
63  case ICMPv6_TIME_EXCEEDED: {
64  ICMPv6TimeExceededMsg *msg2 = check_and_cast<ICMPv6TimeExceededMsg *>(icmpv6Msg);
65  int code = msg2->getCode();
66  EV_ERROR << " Code: " << code;
67  displayType3Msg(code);
68  break;
69  }
70 
72  ICMPv6ParamProblemMsg *msg2 = check_and_cast<ICMPv6ParamProblemMsg *>(icmpv6Msg);
73  int code = msg2->getCode();
74  EV_ERROR << " Code: " << code;
75  displayType4Msg(code);
76  break;
77  }
78 
79  default:
80  cEnum *e = cEnum::get("inet::ICMPv6Type");
81  const char *str = e->getStringFor(type);
82  if (str)
83  EV_ERROR << " " << str << endl;
84  else
85  EV_ERROR << " Unknown Error Type" << endl;
86  break;
87  }
88 
89  EV_DETAIL << "Datagram: Byte length: " << d->getByteLength()
90  << " Src: " << d->getSrcAddress()
91  << " Dest: " << d->getDestAddress()
92  << " Time: " << simTime()
93  << endl;
94 
95  delete icmpv6Msg;
96 }
Definition: ICMPv6Message_m.h:72
Definition: ICMPv6Message_m.h:74
virtual void displayType1Msg(int code)
Definition: IPv6ErrorHandling.cc:98
Definition: ICMPv6Message_m.h:71
virtual void displayType3Msg(int code)
Definition: IPv6ErrorHandling.cc:129
const value< double, units::C > e(1.602176487e-19)
virtual void displayType4Msg(int code)
Definition: IPv6ErrorHandling.cc:147
Definition: ICMPv6Message_m.h:73
virtual void displayType2Msg()
Definition: IPv6ErrorHandling.cc:124
void inet::IPv6ErrorHandling::initialize ( )
overrideprotectedvirtual
33 {
34 }

The documentation for this class was generated from the following files: