INET Framework for OMNeT++/OMNEST
inet::ospf::MessageHandler Class Reference

#include <MessageHandler.h>

Inheritance diagram for inet::ospf::MessageHandler:
inet::ospf::IMessageHandler

Public Member Functions

 MessageHandler (Router *containingRouter, cSimpleModule *containingModule)
 
void messageReceived (cMessage *message)
 
void handleTimer (cMessage *timer)
 
void processPacket (OSPFPacket *packet, Interface *unused1=nullptr, Neighbor *unused2=nullptr) override
 
void sendPacket (OSPFPacket *packet, IPv4Address destination, int outputIfIndex, short ttl=1)
 
void clearTimer (cMessage *timer)
 
void startTimer (cMessage *timer, simtime_t delay)
 
void printEvent (const char *eventString, const Interface *onInterface=nullptr, const Neighbor *forNeighbor=nullptr) const
 
void printHelloPacket (const OSPFHelloPacket *helloPacket, IPv4Address destination, int outputIfIndex) const
 
void printDatabaseDescriptionPacket (const OSPFDatabaseDescriptionPacket *ddPacket, IPv4Address destination, int outputIfIndex) const
 
void printLinkStateRequestPacket (const OSPFLinkStateRequestPacket *requestPacket, IPv4Address destination, int outputIfIndex) const
 
void printLinkStateUpdatePacket (const OSPFLinkStateUpdatePacket *updatePacket, IPv4Address destination, int outputIfIndex) const
 
void printLinkStateAcknowledgementPacket (const OSPFLinkStateAcknowledgementPacket *ackPacket, IPv4Address destination, int outputIfIndex) const
 
bool authenticatePacket (OSPFPacket *packet)
 
- Public Member Functions inherited from inet::ospf::IMessageHandler
 IMessageHandler (Router *containingRouter)
 
virtual ~IMessageHandler ()
 

Private Attributes

cSimpleModule * ospfModule
 
HelloHandler helloHandler
 
DatabaseDescriptionHandler ddHandler
 
LinkStateRequestHandler lsRequestHandler
 
LinkStateUpdateHandler lsUpdateHandler
 
LinkStateAcknowledgementHandler lsAckHandler
 

Additional Inherited Members

- Protected Attributes inherited from inet::ospf::IMessageHandler
Routerrouter
 

Constructor & Destructor Documentation

inet::ospf::MessageHandler::MessageHandler ( Router containingRouter,
cSimpleModule *  containingModule 
)
27  :
28  IMessageHandler(containingRouter),
29  ospfModule(containingModule),
30  helloHandler(containingRouter),
31  ddHandler(containingRouter),
32  lsRequestHandler(containingRouter),
33  lsUpdateHandler(containingRouter),
34  lsAckHandler(containingRouter)
35 {
36 }
LinkStateAcknowledgementHandler lsAckHandler
Definition: MessageHandler.h:45
IMessageHandler(Router *containingRouter)
Definition: IMessageHandler.h:38
cSimpleModule * ospfModule
Definition: MessageHandler.h:39
HelloHandler helloHandler
Definition: MessageHandler.h:41
LinkStateRequestHandler lsRequestHandler
Definition: MessageHandler.h:43
DatabaseDescriptionHandler ddHandler
Definition: MessageHandler.h:42
LinkStateUpdateHandler lsUpdateHandler
Definition: MessageHandler.h:44

Member Function Documentation

bool inet::ospf::MessageHandler::authenticatePacket ( OSPFPacket packet)
inline

Referenced by processPacket().

67 { return true; }
void inet::ospf::MessageHandler::handleTimer ( cMessage *  timer)

Referenced by messageReceived().

61 {
62  switch (timer->getKind()) {
63  case INTERFACE_HELLO_TIMER: {
64  Interface *intf;
65  if (!(intf = reinterpret_cast<Interface *>(timer->getContextPointer()))) {
66  // should not reach this point
67  EV_INFO << "Discarding invalid InterfaceHelloTimer.\n";
68  delete timer;
69  }
70  else {
71  printEvent("Hello Timer expired", intf);
72  intf->processEvent(Interface::HELLO_TIMER);
73  }
74  }
75  break;
76 
77  case INTERFACE_WAIT_TIMER: {
78  Interface *intf;
79  if (!(intf = reinterpret_cast<Interface *>(timer->getContextPointer()))) {
80  // should not reach this point
81  EV_INFO << "Discarding invalid InterfaceWaitTimer.\n";
82  delete timer;
83  }
84  else {
85  printEvent("Wait Timer expired", intf);
86  intf->processEvent(Interface::WAIT_TIMER);
87  }
88  }
89  break;
90 
92  Interface *intf;
93  if (!(intf = reinterpret_cast<Interface *>(timer->getContextPointer()))) {
94  // should not reach this point
95  EV_INFO << "Discarding invalid InterfaceAcknowledgementTimer.\n";
96  delete timer;
97  }
98  else {
99  printEvent("Acknowledgement Timer expired", intf);
100  intf->processEvent(Interface::ACKNOWLEDGEMENT_TIMER);
101  }
102  }
103  break;
104 
106  Neighbor *neighbor;
107  if (!(neighbor = reinterpret_cast<Neighbor *>(timer->getContextPointer()))) {
108  // should not reach this point
109  EV_INFO << "Discarding invalid NeighborInactivityTimer.\n";
110  delete timer;
111  }
112  else {
113  printEvent("Inactivity Timer expired", neighbor->getInterface(), neighbor);
114  neighbor->processEvent(Neighbor::INACTIVITY_TIMER);
115  }
116  }
117  break;
118 
119  case NEIGHBOR_POLL_TIMER: {
120  Neighbor *neighbor;
121  if (!(neighbor = reinterpret_cast<Neighbor *>(timer->getContextPointer()))) {
122  // should not reach this point
123  EV_INFO << "Discarding invalid NeighborInactivityTimer.\n";
124  delete timer;
125  }
126  else {
127  printEvent("Poll Timer expired", neighbor->getInterface(), neighbor);
128  neighbor->processEvent(Neighbor::POLL_TIMER);
129  }
130  }
131  break;
132 
134  Neighbor *neighbor;
135  if (!(neighbor = reinterpret_cast<Neighbor *>(timer->getContextPointer()))) {
136  // should not reach this point
137  EV_INFO << "Discarding invalid NeighborDDRetransmissionTimer.\n";
138  delete timer;
139  }
140  else {
141  printEvent("Database Description Retransmission Timer expired", neighbor->getInterface(), neighbor);
142  neighbor->processEvent(Neighbor::DD_RETRANSMISSION_TIMER);
143  }
144  }
145  break;
146 
148  Neighbor *neighbor;
149  if (!(neighbor = reinterpret_cast<Neighbor *>(timer->getContextPointer()))) {
150  // should not reach this point
151  EV_INFO << "Discarding invalid NeighborUpdateRetransmissionTimer.\n";
152  delete timer;
153  }
154  else {
155  printEvent("Update Retransmission Timer expired", neighbor->getInterface(), neighbor);
156  neighbor->processEvent(Neighbor::UPDATE_RETRANSMISSION_TIMER);
157  }
158  }
159  break;
160 
162  Neighbor *neighbor;
163  if (!(neighbor = reinterpret_cast<Neighbor *>(timer->getContextPointer()))) {
164  // should not reach this point
165  EV_INFO << "Discarding invalid NeighborRequestRetransmissionTimer.\n";
166  delete timer;
167  }
168  else {
169  printEvent("Request Retransmission Timer expired", neighbor->getInterface(), neighbor);
170  neighbor->processEvent(Neighbor::REQUEST_RETRANSMISSION_TIMER);
171  }
172  }
173  break;
174 
175  case DATABASE_AGE_TIMER: {
176  printEvent("Ageing the database");
177  router->ageDatabase();
178  }
179  break;
180 
181  default:
182  break;
183  }
184 }
void printEvent(const char *eventString, const Interface *onInterface=nullptr, const Neighbor *forNeighbor=nullptr) const
Definition: MessageHandler.cc:377
Router * router
Definition: IMessageHandler.h:35
Definition: OSPFNeighbor.h:53
Definition: OSPFTimer.h:28
Definition: OSPFNeighbor.h:54
Definition: OSPFInterface.h:45
Definition: OSPFInterface.h:46
Definition: OSPFInterface.h:44
Definition: OSPFTimer.h:36
Definition: OSPFTimer.h:32
Definition: OSPFTimer.h:31
Definition: OSPFTimer.h:29
void ageDatabase()
Ages the LSAs in the Router&#39;s database.
Definition: OSPFRouter.cc:292
void inet::ospf::MessageHandler::messageReceived ( cMessage *  message)

Referenced by inet::ospf::OSPFRouting::handleMessage().

39 {
40  if (message->isSelfMessage()) {
41  handleTimer(message);
42  }
43  else if (dynamic_cast<ICMPMessage *>(message)) {
44  EV_ERROR << "ICMP error received -- discarding\n";
45  delete message;
46  }
47  else {
48  OSPFPacket *packet = check_and_cast<OSPFPacket *>(message);
49  EV_INFO << "Received packet: (" << packet->getClassName() << ")" << packet->getName() << "\n";
50  if (packet->getRouterID() == IPv4Address(router->getRouterID())) {
51  EV_INFO << "This packet is from ourselves, discarding.\n";
52  delete message;
53  }
54  else {
55  processPacket(packet);
56  }
57  }
58 }
Router * router
Definition: IMessageHandler.h:35
RouterID getRouterID() const
Definition: OSPFRouter.h:72
void handleTimer(cMessage *timer)
Definition: MessageHandler.cc:60
void processPacket(OSPFPacket *packet, Interface *unused1=nullptr, Neighbor *unused2=nullptr) override
Definition: MessageHandler.cc:186
void inet::ospf::MessageHandler::printDatabaseDescriptionPacket ( const OSPFDatabaseDescriptionPacket ddPacket,
IPv4Address  destination,
int  outputIfIndex 
) const

Referenced by sendPacket().

442 {
443  EV_INFO << "Sending Database Description packet to " << destination << " on interface[" << outputIfIndex << "] with contents:\n";
444 
445  const OSPFDDOptions& ddOptions = ddPacket->getDdOptions();
446  EV_INFO << " ddOptions="
447  << ((ddOptions.I_Init) ? "I " : "_ ")
448  << ((ddOptions.M_More) ? "M " : "_ ")
449  << ((ddOptions.MS_MasterSlave) ? "MS" : "__")
450  << "\n";
451  EV_INFO << " seqNumber=" << ddPacket->getDdSequenceNumber() << "\n";
452  EV_DETAIL << " LSA headers:\n";
453 
454  unsigned int lsaCount = ddPacket->getLsaHeadersArraySize();
455  for (unsigned int i = 0; i < lsaCount; i++) {
456  EV_DETAIL << " " << ddPacket->getLsaHeaders(i) << "\n";
457  }
458 }
void inet::ospf::MessageHandler::printEvent ( const char *  eventString,
const Interface onInterface = nullptr,
const Neighbor forNeighbor = nullptr 
) const

Referenced by handleTimer(), inet::ospf::LinkStateAcknowledgementHandler::processPacket(), inet::ospf::LinkStateRequestHandler::processPacket(), inet::ospf::HelloHandler::processPacket(), inet::ospf::DatabaseDescriptionHandler::processPacket(), and inet::ospf::LinkStateUpdateHandler::processPacket().

378 {
379  EV_DETAIL << eventString;
380  if ((onInterface != nullptr) || (forNeighbor != nullptr)) {
381  EV_DETAIL << ": ";
382  }
383  if (forNeighbor != nullptr) {
384  EV_DETAIL << "neighbor["
385  << forNeighbor->getNeighborID()
386  << "] (state: "
387  << forNeighbor->getStateString(forNeighbor->getState())
388  << "); ";
389  }
390  if (onInterface != nullptr) {
391  EV_DETAIL << "interface["
392  << static_cast<short>(onInterface->getIfIndex())
393  << "] ";
394  switch (onInterface->getType()) {
396  EV_DETAIL << "(PointToPoint)";
397  break;
398 
400  EV_DETAIL << "(Broadcast)";
401  break;
402 
403  case Interface::NBMA:
404  EV_DETAIL << "(NBMA).\n";
405  break;
406 
408  EV_DETAIL << "(PointToMultiPoint)";
409  break;
410 
411  case Interface::VIRTUAL:
412  EV_DETAIL << "(Virtual)";
413  break;
414 
415  default:
416  EV_DETAIL << "(Unknown)";
417  break;
418  }
419  EV_DETAIL << " (state: "
420  << onInterface->getStateString(onInterface->getState())
421  << ")";
422  }
423  EV_DETAIL << ".\n";
424 }
Definition: OSPFInterface.h:60
Definition: OSPFInterface.h:56
Definition: OSPFInterface.h:58
Definition: OSPFInterface.h:57
Definition: OSPFInterface.h:59
void inet::ospf::MessageHandler::printHelloPacket ( const OSPFHelloPacket helloPacket,
IPv4Address  destination,
int  outputIfIndex 
) const

Referenced by sendPacket().

427 {
428  EV_INFO << "Sending Hello packet to " << destination << " on interface[" << outputIfIndex << "] with contents:\n";
429  EV_INFO << " netMask=" << helloPacket->getNetworkMask() << "\n";
430  EV_INFO << " DR=" << helloPacket->getDesignatedRouter() << "\n";
431  EV_INFO << " BDR=" << helloPacket->getBackupDesignatedRouter() << "\n";
432 
433  EV_DETAIL << " neighbors:\n";
434 
435  unsigned int neighborCount = helloPacket->getNeighborArraySize();
436  for (unsigned int i = 0; i < neighborCount; i++) {
437  EV_DETAIL << " " << helloPacket->getNeighbor(i) << "\n";
438  }
439 }
void inet::ospf::MessageHandler::printLinkStateAcknowledgementPacket ( const OSPFLinkStateAcknowledgementPacket ackPacket,
IPv4Address  destination,
int  outputIfIndex 
) const

Referenced by sendPacket().

558 {
559  EV_INFO << "Sending Link State Acknowledgement packet to " << destination << " on interface[" << outputIfIndex << "] with acknowledgements:\n";
560 
561  unsigned int lsaCount = ackPacket->getLsaHeadersArraySize();
562  for (unsigned int i = 0; i < lsaCount; i++) {
563  EV_DETAIL << " " << ackPacket->getLsaHeaders(i) << "\n";
564  }
565 }
void inet::ospf::MessageHandler::printLinkStateRequestPacket ( const OSPFLinkStateRequestPacket requestPacket,
IPv4Address  destination,
int  outputIfIndex 
) const

Referenced by sendPacket().

461 {
462  EV_INFO << "Sending Link State Request packet to " << destination << " on interface[" << outputIfIndex << "] with requests:\n";
463 
464  unsigned int requestCount = requestPacket->getRequestsArraySize();
465  for (unsigned int i = 0; i < requestCount; i++) {
466  const LSARequest& request = requestPacket->getRequests(i);
467  EV_DETAIL << " type=" << request.lsType
468  << ", LSID=" << request.linkStateID
469  << ", advertisingRouter=" << request.advertisingRouter << "\n";
470  }
471 }
void inet::ospf::MessageHandler::printLinkStateUpdatePacket ( const OSPFLinkStateUpdatePacket updatePacket,
IPv4Address  destination,
int  outputIfIndex 
) const

Referenced by sendPacket().

474 {
475  EV_INFO << "Sending Link State Update packet to " << destination << " on interface[" << outputIfIndex << "] with updates:\n";
476 
477  unsigned int i = 0;
478  unsigned int updateCount = updatePacket->getRouterLSAsArraySize();
479 
480  for (i = 0; i < updateCount; i++) {
481  const OSPFRouterLSA& lsa = updatePacket->getRouterLSAs(i);
482  EV_DETAIL << " " << lsa.getHeader() << "\n";
483 
484  EV_DETAIL << " bits="
485  << ((lsa.getV_VirtualLinkEndpoint()) ? "V " : "_ ")
486  << ((lsa.getE_ASBoundaryRouter()) ? "E " : "_ ")
487  << ((lsa.getB_AreaBorderRouter()) ? "B" : "_")
488  << "\n";
489  EV_DETAIL << " links:\n";
490 
491  unsigned int linkCount = lsa.getLinksArraySize();
492  for (unsigned int j = 0; j < linkCount; j++) {
493  const Link& link = lsa.getLinks(j);
494  EV_DETAIL << " ID=" << link.getLinkID();
495  EV_DETAIL << ", data="
496  << link.getLinkData() << " (" << IPv4Address(link.getLinkData()) << ")"
497  << ", type=";
498  switch (link.getType()) {
499  case POINTTOPOINT_LINK:
500  EV_INFO << "PointToPoint";
501  break;
502 
503  case TRANSIT_LINK:
504  EV_INFO << "Transit";
505  break;
506 
507  case STUB_LINK:
508  EV_INFO << "Stub";
509  break;
510 
511  case VIRTUAL_LINK:
512  EV_INFO << "Virtual";
513  break;
514 
515  default:
516  EV_INFO << "Unknown";
517  break;
518  }
519  EV_DETAIL << ", cost=" << link.getLinkCost() << "\n";
520  }
521  }
522 
523  updateCount = updatePacket->getNetworkLSAsArraySize();
524  for (i = 0; i < updateCount; i++) {
525  const OSPFNetworkLSA& lsa = updatePacket->getNetworkLSAs(i);
526  EV_DETAIL << " " << lsa.getHeader() << "\n";
527  EV_DETAIL << " netMask=" << lsa.getNetworkMask() << "\n";
528  EV_DETAIL << " attachedRouters:\n";
529 
530  unsigned int routerCount = lsa.getAttachedRoutersArraySize();
531  for (unsigned int j = 0; j < routerCount; j++) {
532  EV_DETAIL << " " << lsa.getAttachedRouters(j) << "\n";
533  }
534  }
535 
536  updateCount = updatePacket->getSummaryLSAsArraySize();
537  for (i = 0; i < updateCount; i++) {
538  const OSPFSummaryLSA& lsa = updatePacket->getSummaryLSAs(i);
539  EV_DETAIL << " " << lsa.getHeader() << "\n";
540  EV_DETAIL << " netMask=" << lsa.getNetworkMask() << "\n";
541  EV_DETAIL << " cost=" << lsa.getRouteCost() << "\n";
542  }
543 
544  updateCount = updatePacket->getAsExternalLSAsArraySize();
545  for (i = 0; i < updateCount; i++) {
546  const OSPFASExternalLSA& lsa = updatePacket->getAsExternalLSAs(i);
547  EV_DETAIL << " " << lsa.getHeader() << "\n";
548 
549  const OSPFASExternalLSAContents& contents = lsa.getContents();
550  EV_DETAIL << " netMask=" << contents.getNetworkMask() << "\n";
551  EV_DETAIL << " bits=" << ((contents.getE_ExternalMetricType()) ? "E\n" : "_\n");
552  EV_DETAIL << " cost=" << contents.getRouteCost() << "\n";
553  EV_DETAIL << " forward=" << contents.getForwardingAddress() << "\n";
554  }
555 }
Definition: OSPFPacket_m.h:379
Definition: OSPFPacket_m.h:378
Definition: OSPFPacket_m.h:377
Definition: OSPFPacket_m.h:376
void inet::ospf::MessageHandler::processPacket ( OSPFPacket packet,
Interface unused1 = nullptr,
Neighbor unused2 = nullptr 
)
overridevirtual

Implements inet::ospf::IMessageHandler.

Referenced by messageReceived().

187 {
188  // see RFC 2328 8.2
189 
190  // packet version must be OSPF version 2
191  if (packet->getVersion() == 2) {
192  IPv4ControlInfo *controlInfo = check_and_cast<IPv4ControlInfo *>(packet->getControlInfo());
193  int interfaceId = controlInfo->getInterfaceId();
194  AreaID areaID = packet->getAreaID();
195  Area *area = router->getAreaByID(areaID);
196 
197  if (area != nullptr) {
198  // packet Area ID must either match the Area ID of the receiving interface or...
199  Interface *intf = area->getInterface(interfaceId);
200 
201  if (intf == nullptr) {
202  // it must be the backbone area and...
203  if (areaID == BACKBONE_AREAID) {
204  if (router->getAreaCount() > 1) {
205  // it must be a virtual link and the source router's router ID must be the endpoint of this virtual link and...
206  intf = area->findVirtualLink(packet->getRouterID());
207 
208  if (intf != nullptr) {
209  Area *virtualLinkTransitArea = router->getAreaByID(intf->getTransitAreaID());
210 
211  if (virtualLinkTransitArea != nullptr) {
212  // the receiving interface must attach to the virtual link's configured transit area
213  Interface *virtualLinkInterface = virtualLinkTransitArea->getInterface(interfaceId);
214 
215  if (virtualLinkInterface == nullptr) {
216  intf = nullptr;
217  }
218  }
219  else {
220  intf = nullptr;
221  }
222  }
223  }
224  }
225  }
226  if (intf != nullptr) {
227  IPv4Address destinationAddress = controlInfo->getDestAddr();
228  IPv4Address allDRouters = IPv4Address::ALL_OSPF_DESIGNATED_ROUTERS_MCAST;
229  Interface::InterfaceStateType interfaceState = intf->getState();
230 
231  // if destination address is ALL_D_ROUTERS the receiving interface must be in DesignatedRouter or Backup state
232  if (
233  ((destinationAddress == allDRouters) &&
234  (
235  (interfaceState == Interface::DESIGNATED_ROUTER_STATE) ||
236  (interfaceState == Interface::BACKUP_STATE)
237  )
238  ) ||
239  (destinationAddress != allDRouters)
240  )
241  {
242  // packet authentication
243  if (authenticatePacket(packet)) {
244  OSPFPacketType packetType = static_cast<OSPFPacketType>(packet->getType());
245  Neighbor *neighbor = nullptr;
246 
247  // all packets except HelloPackets are sent only along adjacencies, so a Neighbor must exist
248  if (packetType != HELLO_PACKET) {
249  switch (intf->getType()) {
251  case Interface::NBMA:
253  neighbor = intf->getNeighborByAddress(controlInfo->getSrcAddr());
254  break;
255 
257  case Interface::VIRTUAL:
258  neighbor = intf->getNeighborByID(packet->getRouterID());
259  break;
260 
261  default:
262  break;
263  }
264  }
265  switch (packetType) {
266  case HELLO_PACKET:
267  helloHandler.processPacket(packet, intf);
268  break;
269 
271  if (neighbor != nullptr) {
272  ddHandler.processPacket(packet, intf, neighbor);
273  }
274  break;
275 
277  if (neighbor != nullptr) {
278  lsRequestHandler.processPacket(packet, intf, neighbor);
279  }
280  break;
281 
283  if (neighbor != nullptr) {
284  lsUpdateHandler.processPacket(packet, intf, neighbor);
285  }
286  break;
287 
289  if (neighbor != nullptr) {
290  lsAckHandler.processPacket(packet, intf, neighbor);
291  }
292  break;
293 
294  default:
295  break;
296  }
297  }
298  }
299  }
300  }
301  }
302  delete packet;
303 }
LinkStateAcknowledgementHandler lsAckHandler
Definition: MessageHandler.h:45
bool authenticatePacket(OSPFPacket *packet)
Definition: MessageHandler.h:67
Definition: OSPFInterface.h:60
void processPacket(OSPFPacket *packet, Interface *intf, Neighbor *neighbor) override
Definition: DatabaseDescriptionHandler.cc:34
Router * router
Definition: IMessageHandler.h:35
IPv4Address AreaID
Definition: OSPFcommon.h:138
Interface * getInterface(unsigned char ifIndex)
Definition: OSPFArea.cc:205
Definition: OSPFPacket_m.h:54
Definition: OSPFInterface.h:56
const AreaID BACKBONE_AREAID(0, 0, 0, 0)
InterfaceStateType
Definition: OSPFInterface.h:63
Definition: OSPFPacket_m.h:55
Definition: OSPFInterface.h:58
HelloHandler helloHandler
Definition: MessageHandler.h:41
Definition: OSPFInterface.h:57
Definition: OSPFInterface.h:59
unsigned long getAreaCount() const
Definition: OSPFRouter.h:75
Area * getAreaByID(AreaID areaID)
Returns the pointer to the Area identified by the input areaID, if it&#39;s on the Area list...
Definition: OSPFRouter.cc:72
void processPacket(OSPFPacket *packet, Interface *intf, Neighbor *unused=nullptr) override
Definition: HelloHandler.cc:34
LinkStateRequestHandler lsRequestHandler
Definition: MessageHandler.h:43
DatabaseDescriptionHandler ddHandler
Definition: MessageHandler.h:42
Definition: OSPFInterface.h:69
OSPFPacketType
Enum generated from inet/routing/ospfv2/OSPFPacket.msg:27 by nedtool.
Definition: OSPFPacket_m.h:52
Definition: OSPFPacket_m.h:53
Definition: OSPFPacket_m.h:56
static const IPv4Address ALL_OSPF_DESIGNATED_ROUTERS_MCAST
224.0.0.6 All OSPF Designated Routers
Definition: IPv4Address.h:111
LinkStateUpdateHandler lsUpdateHandler
Definition: MessageHandler.h:44
void inet::ospf::MessageHandler::sendPacket ( OSPFPacket packet,
IPv4Address  destination,
int  outputIfIndex,
short  ttl = 1 
)

Referenced by inet::ospf::LinkStateUpdateHandler::acknowledgeLSA(), inet::ospf::Interface::floodLSA(), inet::ospf::LinkStateRequestHandler::processPacket(), inet::ospf::LinkStateUpdateHandler::processPacket(), inet::ospf::Neighbor::retransmitDatabaseDescriptionPacket(), inet::ospf::Neighbor::retransmitUpdatePacket(), inet::ospf::Neighbor::sendDatabaseDescriptionPacket(), inet::ospf::Interface::sendDelayedAcknowledgements(), inet::ospf::Interface::sendHelloPacket(), inet::ospf::Neighbor::sendLinkStateRequestPacket(), and inet::ospf::Interface::sendLSAcknowledgement().

306 {
307  IPv4ControlInfo *ipControlInfo = new IPv4ControlInfo();
308  ipControlInfo->setProtocol(IP_PROT_OSPF);
309  ipControlInfo->setDestAddr(destination);
310  ipControlInfo->setTimeToLive(ttl);
311  ipControlInfo->setInterfaceId(outputIfIndex);
312 
313  packet->setControlInfo(ipControlInfo);
314  switch (packet->getType()) {
315  case HELLO_PACKET: {
316  packet->setKind(HELLO_PACKET);
317  packet->setName("OSPF_HelloPacket");
318 
319  OSPFHelloPacket *helloPacket = check_and_cast<OSPFHelloPacket *>(packet);
320  printHelloPacket(helloPacket, destination, outputIfIndex);
321  }
322  break;
323 
325  packet->setKind(DATABASE_DESCRIPTION_PACKET);
326  packet->setName("OSPF_DDPacket");
327 
328  OSPFDatabaseDescriptionPacket *ddPacket = check_and_cast<OSPFDatabaseDescriptionPacket *>(packet);
329  printDatabaseDescriptionPacket(ddPacket, destination, outputIfIndex);
330  }
331  break;
332 
334  packet->setKind(LINKSTATE_REQUEST_PACKET);
335  packet->setName("OSPF_LSReqPacket");
336 
337  OSPFLinkStateRequestPacket *requestPacket = check_and_cast<OSPFLinkStateRequestPacket *>(packet);
338  printLinkStateRequestPacket(requestPacket, destination, outputIfIndex);
339  }
340  break;
341 
343  packet->setKind(LINKSTATE_UPDATE_PACKET);
344  packet->setName("OSPF_LSUpdPacket");
345 
346  OSPFLinkStateUpdatePacket *updatePacket = check_and_cast<OSPFLinkStateUpdatePacket *>(packet);
347  printLinkStateUpdatePacket(updatePacket, destination, outputIfIndex);
348  }
349  break;
350 
352  packet->setKind(LINKSTATE_ACKNOWLEDGEMENT_PACKET);
353  packet->setName("OSPF_LSAckPacket");
354 
355  OSPFLinkStateAcknowledgementPacket *ackPacket = check_and_cast<OSPFLinkStateAcknowledgementPacket *>(packet);
356  printLinkStateAcknowledgementPacket(ackPacket, destination, outputIfIndex);
357  }
358  break;
359 
360  default:
361  break;
362  }
363 
364  ospfModule->send(packet, "ipOut");
365 }
Definition: OSPFPacket_m.h:54
void printDatabaseDescriptionPacket(const OSPFDatabaseDescriptionPacket *ddPacket, IPv4Address destination, int outputIfIndex) const
Definition: MessageHandler.cc:441
Definition: OSPFPacket_m.h:55
cSimpleModule * ospfModule
Definition: MessageHandler.h:39
Definition: IPProtocolId_m.h:89
void printLinkStateRequestPacket(const OSPFLinkStateRequestPacket *requestPacket, IPv4Address destination, int outputIfIndex) const
Definition: MessageHandler.cc:460
void printLinkStateUpdatePacket(const OSPFLinkStateUpdatePacket *updatePacket, IPv4Address destination, int outputIfIndex) const
Definition: MessageHandler.cc:473
Definition: OSPFPacket_m.h:53
Definition: OSPFPacket_m.h:56
uint8_t ttl
Definition: TCP_NSC.cc:87
void printLinkStateAcknowledgementPacket(const OSPFLinkStateAcknowledgementPacket *ackPacket, IPv4Address destination, int outputIfIndex) const
Definition: MessageHandler.cc:557
void printHelloPacket(const OSPFHelloPacket *helloPacket, IPv4Address destination, int outputIfIndex) const
Definition: MessageHandler.cc:426

Member Data Documentation

DatabaseDescriptionHandler inet::ospf::MessageHandler::ddHandler
private

Referenced by processPacket().

HelloHandler inet::ospf::MessageHandler::helloHandler
private

Referenced by processPacket().

LinkStateAcknowledgementHandler inet::ospf::MessageHandler::lsAckHandler
private

Referenced by processPacket().

LinkStateRequestHandler inet::ospf::MessageHandler::lsRequestHandler
private

Referenced by processPacket().

LinkStateUpdateHandler inet::ospf::MessageHandler::lsUpdateHandler
private

Referenced by processPacket().

cSimpleModule* inet::ospf::MessageHandler::ospfModule
private

Referenced by clearTimer(), sendPacket(), and startTimer().


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