NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
OSPF_LSDB.c
1/************************************************************************************
2* Copyright (C) 2023 *
3* TETCOS, Bangalore. India *
4* *
5* Tetcos owns the intellectual property rights in the Product and its content. *
6* The copying, redistribution, reselling or publication of any or all of the *
7* Product or its content without express prior written consent of Tetcos is *
8* prohibited. Ownership and / or any other right relating to the software and all *
9* intellectual property rights therein shall remain at all times with Tetcos. *
10* *
11* Author: Shashi Kant Suman *
12* *
13* ---------------------------------------------------------------------------------*/
14#include "main.h"
15#include "NetSim_utility.h"
16#include "OSPF.h"
17#include "OSPF_enum.h"
18#include "OSPF_Msg.h"
19#include "OSPF_Neighbor.h"
20#include "OSPF_Interface.h"
21#include "OSPF_List.h"
22
23ptrOSPFLSAHDR ospf_lsdb_lookup_lsaList(ptrOSPFLIST list,
24 OSPFID adverRouter,
25 OSPFID linkStateId)
26{
27 ptrOSPFLSAHDR lsa;
28 void* pass = ospf_list_newIterator();
29 while ((lsa = ospf_list_iterate_mem(list, pass)) != NULL)
30 {
31 if (!OSPFID_COMPARE(lsa->AdvertisingRouter, adverRouter) &&
32 !OSPFID_COMPARE(lsa->LinkStateID, linkStateId))
33 {
34 ospf_list_deleteIterator(pass);
35 return lsa;
36 }
37 }
38 ospf_list_deleteIterator(pass);
39 return NULL;
40}
41
42ptrOSPFLSAHDR ospf_lsdb_lookup_lsaListByID(ptrOSPFLIST list,
43 OSPFID linkStateId)
44{
45 ptrOSPFLSAHDR lsa;
46 void* pass = ospf_list_newIterator();
47 while ((lsa = ospf_list_iterate_mem(list, &pass)) != NULL)
48 {
49 if (!OSPFID_COMPARE(lsa->LinkStateID, linkStateId))
50 {
51 ospf_list_deleteIterator(pass);
52 return lsa;
53 }
54 }
55 ospf_list_deleteIterator(pass);
56 return NULL;
57}
58
59ptrOSPFLSAHDR ospf_lsdb_lookup(ptrOSPF_PDS ospf,
60 ptrOSPFAREA_DS area,
61 LSTYPE lsType,
62 OSPFID adveRouter,
63 OSPFID linkStateID)
64{
65 ospf;
66 switch (lsType)
67 {
68 case LSTYPE_ROUTERLSA:
69 return ospf_lsdb_lookup_lsaList(area->routerLSAList,
70 adveRouter,
71 linkStateID);
72 break;
73 case LSTYPE_NETWORKLSA:
74 return ospf_lsdb_lookup_lsaList(area->nwLSAList,
75 adveRouter,
76 linkStateID);
77 break;
78 case LSTYPE_SUMMARYLSA_ROUTER:
79 return ospf_lsdb_lookup_lsaList(area->routerSummaryLSAList,
80 adveRouter,
81 linkStateID);
82 break;
83 case LSTYPE_SUMMARYLSA_NETWORK:
84 return ospf_lsdb_lookup_lsaList(area->nwSummaryLSAList,
85 adveRouter,
86 linkStateID);
87 break;
88 default:
89 fnNetSimError("Unknown LSType %d in %s\n",
90 lsType,
91 __FUNCTION__);
92 break;
93 }
94 return NULL;
95}
96
97bool ospf_lsdb_install(ptrOSPF_PDS ospf,
98 OSPFID areaId,
99 ptrOSPFLSAHDR lsa,
100 ptrOSPFLIST list)
101{
102 //RFC 2328 -- section 13.2
103 bool ret = false;
104 void* pass = ospf_list_newIterator();
105 ptrOSPFLSAHDR hdr = NULL;
106 ptrOSPFLSAHDR newLSA;
107 while ((hdr = ospf_list_iterate_mem(list, pass)) != NULL)
108 {
109 if (!OSPFID_COMPARE(lsa->AdvertisingRouter, hdr->AdvertisingRouter) &&
110 !OSPFID_COMPARE(lsa->LinkStateID, hdr->LinkStateID))
111 break;
112 }
113 ospf_list_deleteIterator(pass);
114
115 // LSA found in list
116 if (hdr)
117 {
118 ret = ospf_lsa_is_content_changed(ospf, lsa, hdr);
119
120 if (ret)
121 {
122 newLSA = OSPF_LSA_MSG_COPY(lsa);
123 newLSA->time = OSPF_CURR_TIME();
124 ospf_list_replace_mem(list, hdr, newLSA);
125
126 if (lsa->LSType == LSTYPE_ROUTERLSA ||
127 lsa->LSType == LSTYPE_NETWORKLSA)
128 ospf_lsa_assignNewLSAIntoLSOrigin(ospf, lsa, newLSA);
129
130 OSPF_LSA_MSG_FREE(hdr);
131 }
132 }
133 else
134 {
135 newLSA = OSPF_LSA_MSG_COPY(lsa);
136 newLSA->time = OSPF_CURR_TIME();
137 ospf_list_add_mem(list, newLSA);
138 ret = true;
139 }
140
141 ospf_lsa_printList(form_dlogId("LSDB", ospf->myId), list, "LSDB install");
142
143 if (ospf_lsa_hasMaxAge(ospf, lsa))
144 ospf_lsa_addToMaxAgeLSAList(ospf, areaId, lsa);
145 return ret;
146}
147
148static int ospf_lsdb_updateLSAList(ptrOSPF_PDS ospf,
149 ptrOSPF_IF thisInterface,
150 ptrOSPFAREA_DS area,
151 ptrOSPFLIST list,
152 ptrOSPFLSAHDR lsa,
153 NETSIM_IPAddress srcAddr)
154{
155 bool isFloodBack;
156 ptrOSPFLSAHDR hdr = NULL;
157 void* pass = ospf_list_newIterator();
158 while ((hdr = ospf_list_iterate_mem(list, pass)) != NULL)
159 {
160 if (!OSPFID_COMPARE(lsa->AdvertisingRouter, hdr->AdvertisingRouter) &&
161 !OSPFID_COMPARE(lsa->LinkStateID, hdr->LinkStateID))
162 {
163 assert(hdr->time); // Time is not updated. Somewhere forgot to update. Check!!
164 print_ospf_Dlog(form_dlogId("LSDB", ospf->myId), "\tLSA found in LSDB\n"
165 " advertisingRouter %s linkStateID %s",
166 lsa->AdvertisingRouter->str_ip,
167 lsa->LinkStateID->str_ip);
168
169 // RFC2328, Sec-13 (5.a)
170 if(!ospf_lsa_isSelfOriginated(ospf,lsa) &&
171 OSPF_CURR_TIME()-hdr->time < ospf->minLSInterval)
172
173 {
174 print_ospf_Dlog(form_dlogId("LSDB", ospf->myId), "Received LSA is more recent, but arrives "
175 "before minLSInterval. So don't update LSDB");
176 ospf_list_deleteIterator(pass);
177 return -1;
178 }
179 break;
180 }
181 }
182 ospf_list_deleteIterator(pass);
183
184 isFloodBack = ospf_lsa_flood(ospf,
185 area->areaId,
186 lsa,
187 srcAddr,
188 thisInterface->id);
189
190 if (!isFloodBack)
191 {
192 if (thisInterface->State == OSPFIFSTATE_BACKUP)
193 {
194 if (!IP_COMPARE(thisInterface->designaterRouter, srcAddr))
195 ospf_lsaAck_sendDelayedAck(ospf,
196 thisInterface,
197 lsa);
198 }
199 else
200 {
201 ospf_lsaAck_sendDelayedAck(ospf,
202 thisInterface,
203 lsa);
204 }
205 }
206
207 return (int)ospf_lsdb_install(ospf, area->areaId, lsa, list);
208}
209
210bool ospf_lsdb_update(ptrOSPF_PDS ospf,
211 ptrOSPF_IF thisInterface,
212 ptrOSPFLSAHDR lsa,
213 ptrOSPFAREA_DS thisArea,
214 NETSIM_IPAddress srcAddr)
215{
216 int ret = false;
217
218 switch (lsa->LSType)
219 {
220 case LSTYPE_ROUTERLSA:
221 ret = ospf_lsdb_updateLSAList(ospf,
222 thisInterface,
223 thisArea,
224 thisArea->routerLSAList,
225 lsa,
226 srcAddr);
227 break;
228 case LSTYPE_NETWORKLSA:
229 ret = ospf_lsdb_updateLSAList(ospf,
230 thisInterface,
231 thisArea,
232 thisArea->nwLSAList,
233 lsa,
234 srcAddr);
235 break;
236 case LSTYPE_SUMMARYLSA_NETWORK:
237 ret = ospf_lsdb_updateLSAList(ospf,
238 thisInterface,
239 thisArea,
240 thisArea->nwSummaryLSAList,
241 lsa,
242 srcAddr);
243 break;
244 case LSTYPE_SUMMARYLSA_ROUTER:
245 ret = ospf_lsdb_updateLSAList(ospf,
246 thisInterface,
247 thisArea,
248 thisArea->routerSummaryLSAList,
249 lsa,
250 srcAddr);
251 break;
252 default:
253 fnNetSimError("Unknown LS hdr of type %s in %s",
254 strLSTYPE[lsa->LSType],
255 __FUNCTION__);
256 break;
257 }
258
259 if (ret < 0)
260 return false;
261
262 if (ospf_lsa_isSelfOriginated(ospf, lsa))
263 {
264 bool isFlush = false;
265 switch (lsa->LSType)
266 {
267 case LSTYPE_NETWORKLSA:
268 {
269 NETSIM_ID in = fn_NetSim_Stack_GetInterfaceIdFromIP(ospf->myId,
270 lsa->LinkStateID);
271
272 ptrOSPF_IF myInterface;
273 if (in)
274 {
275 myInterface = OSPF_IF_GET(ospf, in);
276 if (myInterface->State != OSPFIFSTATE_DR &&
277 OSPFID_COMPARE(lsa->AdvertisingRouter, ospf->routerId))
278 isFlush = true;
279 }
280 }
281 break;
282 case LSTYPE_SUMMARYLSA_NETWORK:
283 {
284#pragma message(__LOC__"Implement after routing table implementation")
285 }
286 break;
287 case LSTYPE_SUMMARYLSA_ROUTER:
288 {
289#pragma message(__LOC__"Implement after routing table implementation")
290 }
291 break;
292 }
293 if (isFlush)
294 {
295 ospf_lsa_flush(ospf, thisArea, lsa);
296 }
297 else
298 {
299 ptrOSPFLSAHDR oldLSA = ospf_lsdb_lookup(ospf,
300 thisArea,
301 lsa->LSType,
302 lsa->AdvertisingRouter,
303 lsa->LinkStateID);
304
305 oldLSA->LSSequenceNumber = lsa->LSSequenceNumber + 1;
306 /*ptrEVENTLSDB elsdb = calloc(1,sizeof* elsdb);
307 elsdb->area = thisArea;
308 elsdb->lsType = LSTYPE_ROUTERLSA;
309 elsdb->isFlush = false;
310 pstruEventDetails->szOtherDetails = elsdb;
311 ospf_lsa_ScheduleLSDB();
312 pstruEventDetails->szOtherDetails = NULL;*/
313 ospf_lsa_schedule(ospf,
314 thisInterface,
315 thisArea,
316 lsa);
317 }
318 }
319
320 return ret;
321}
322
323void ospf_lsdb_scheduleMaxAgeRemovalTimer(ptrOSPF_PDS ospf)
324{
325 ospf_event_add(OSPF_CURR_TIME() + ospf->maxAgeRemovalTime,
326 ospf->myId,
327 0,
328 OSPF_MAXAGEREMOVALTIMER,
329 NULL,
330 NULL);
331 ospf->isMaxAgeRemovalTimerSet = true;
332}
333
334static bool ospf_lsdb_isLSAInNeighborRxtList(ptrOSPF_PDS ospf,
335 OSPFID areaId,
336 ptrOSPFLSAHDR lsa)
337{
338 UINT i;
339 for (i = 0; i < ospf->ifCount; i++)
340 {
341 ptrOSPF_IF thisInterface = ospf->ospfIf[i];
342 if (OSPFID_COMPARE(areaId,invalidAreaId) &&
343 OSPFID_COMPARE(areaId,thisInterface->areaId))
344 continue;
345
346 UINT n;
347 for (n = 0; n < thisInterface->neighborRouterCount; n++)
348 {
349 ptrOSPF_NEIGHBOR neigh = thisInterface->neighborRouterList[n];
350
351 ptrOSPFLSAHDR l;
352 void* pass = ospf_list_newIterator();
353
354 while ((l=ospf_list_iterate_mem(neigh->neighLSRxtList,pass))!=NULL)
355 {
356 // If LSA exists in retransmission list
357 if (ospf_lsa_compareToListMem(ospf, l, lsa))
358 {
359 ospf_list_deleteIterator(pass);
360 return true;
361 }
362 }
363 ospf_list_deleteIterator(pass);
364 }
365 }
366 return false;
367}
368
369static void ospf_lsdb_removeLSAFromList(ptrOSPFLIST list,
370 ptrOSPFLSAHDR lsa)
371{
372 if (ospf_list_is_empty(list))
373 return;
374
375 ptrOSPFLSAHDR l;
376 void* pass = ospf_list_newIterator();
377 while ((l = ospf_list_iterate_mem(list, pass)) != NULL)
378 {
379 if (!OSPFID_COMPARE(l->AdvertisingRouter, lsa->AdvertisingRouter) &&
380 !OSPFID_COMPARE(l->LinkStateID, lsa->LinkStateID))
381 ospf_list_delete_mem(list, l, pass);
382 }
383 ospf_list_deleteIterator(pass);
384}
385
386static void ospf_lsdb_removeFromSendList(ptrOSPF_PDS ospf,
387 ptrOSPFLSAHDR lsa,
388 OSPFID areaId)
389{
390 UINT i;
391 for (i = 0; i < ospf->ifCount; i++)
392 {
393 ptrOSPF_IF thisInterface = ospf->ospfIf[i];
394
395 // Skip the interface if it doesn't belong to specified area
396 if (OSPFID_COMPARE(thisInterface->areaId, areaId) &&
397 OSPFID_COMPARE(areaId, invalidAreaId))
398 continue;
399
400 UINT n;
401 for (n = 0; n < thisInterface->neighborRouterCount; n++)
402 {
403 ptrOSPF_NEIGHBOR neigh = thisInterface->neighborRouterList[n];
404
405 ptrOSPFLSAHDR s;
406 void* pass = ospf_list_newIterator();
407 while ((s = ospf_list_iterate_mem(neigh->linkStateSendList, pass)) != NULL)
408 {
409 if (s->LSType == lsa->LSType &&
410 !OSPFID_COMPARE(s->AdvertisingRouter, lsa->AdvertisingRouter) &&
411 !OSPFID_COMPARE(s->LinkStateID, lsa->LinkStateID))
412 {
413 ospf_list_delete_mem(neigh->linkStateSendList, s, pass);
414 }
415 }
416 ospf_list_deleteIterator(pass);
417 }
418 }
419}
420
421void ospf_lsdb_removeLSA(ptrOSPF_PDS ospf,
422 ptrOSPFAREA_DS area,
423 ptrOSPFLSAHDR lsa)
424{
425 bool removeFromSend = true;
426 switch (lsa->LSType)
427 {
428 case LSTYPE_ROUTERLSA:
429 ospf_lsdb_removeLSAFromList(area->routerLSAList, lsa);
430 break;
431 case LSTYPE_NETWORKLSA:
432 ospf_lsdb_removeLSAFromList(area->nwLSAList, lsa);
433 break;
434 case LSTYPE_SUMMARYLSA_NETWORK:
435 ospf_lsdb_removeLSAFromList(area->nwSummaryLSAList, lsa);
436 break;
437 case LSTYPE_SUMMARYLSA_ROUTER:
438 ospf_lsdb_removeLSAFromList(area->routerSummaryLSAList, lsa);
439 break;
440 default:
441 removeFromSend = false;
442 fnNetSimError("Unknown LSTYPE %d in %s.",
443 lsa->LSType, __FUNCTION__);
444 break;
445 }
446
447 if (removeFromSend)
448 {
449 ospf_lsdb_removeFromSendList(ospf,
450 lsa,
451 area->areaId);
452 }
453}
454
455void ospf_lsdb_handleMaxAgeRemovalTimer()
456{
457 ptrOSPF_PDS ospf = OSPF_PDS_CURRENT();
458 bool scheduledTimer = false;
459
460 if (ospf_neighbor_isAnyNeighborInExchangeOrLoadingState(ospf))
461 {
462 ospf_lsdb_scheduleMaxAgeRemovalTimer(ospf);
463 return;
464 }
465 else
466 {
467 ospf->isMaxAgeRemovalTimerSet = false;
468
469 for (UINT i = 0; i < ospf->ifCount; i++)
470 {
471 ptrOSPF_IF thisInterface = ospf->ospfIf[i];
472 ptrOSPFAREA_DS area = OSPF_AREA_GET_ID(ospf, thisInterface->areaId);
473
474 if (!area)
475 continue;
476
477 ptrOSPFLSAHDR lsa;
478 void* pass = ospf_list_newIterator();
479 while ((lsa = ospf_list_iterate_mem(area->maxAgeList, pass)) != NULL)
480 {
481 OSPFID areaId;
482 areaId = thisInterface->areaId;
483 if (ospf_lsdb_isLSAInNeighborRxtList(ospf, areaId, lsa))
484 {
485 if (!scheduledTimer)
486 {
487 ospf_lsdb_scheduleMaxAgeRemovalTimer(ospf);
488 scheduledTimer = true;
489 }
490 continue;
491 }
492
493 ospf_lsdb_removeLSA(ospf, area, lsa);
494 ospf_list_delete_mem(area->maxAgeList, lsa, pass);
495 }
496 ospf_list_deleteIterator(pass);
497
498 if (!ospf_list_is_empty(area->maxAgeList) &&
499 !ospf->isMaxAgeRemovalTimerSet &&
500 !scheduledTimer)
501 {
502 ospf_lsdb_scheduleMaxAgeRemovalTimer(ospf);
503 scheduledTimer = true;
504 }
505 }
506 }
507}
508
509static void ospf_lsdb_refreshLSA(ptrOSPF_PDS ospf,
510 ptrOSPFLSAHDR LSHeader,
511 OSPFID areaId)
512{
513 ptrOSPFAREA_DS thisArea = OSPF_AREA_GET_ID(ospf, areaId);
514 if (LSHeader->LSSequenceNumber == OSPF_MAX_SEQUENCE_NUMBER)
515 {
516 // Sequence number reaches the maximum value. We need to
517 // flush this instance first before originating any instance.
518 ospf_lsa_flush(ospf, thisArea, LSHeader);
519 ospf_lsa_schedule(ospf, 0, thisArea, LSHeader);
520 }
521 else
522 {
523 LSHeader->LSSequenceNumber += 1;
524 LSHeader->LSAge = 0;
525 LSHeader->time = OSPF_CURR_TIME();
526
527 ospf_lsa_flood(ospf, areaId, LSHeader, NULL, 0);
528 }
529}
530
531static void ospf_LSDB_IncrementLSAgeInLSAList(ptrOSPF_PDS ospf,
532 ptrOSPFLIST list,
533 OSPFID areaId)
534{
535 ptrOSPFLSAHDR LSHeader = NULL;
536 void* pass = ospf_list_newIterator();
537
538 while ((LSHeader = ospf_list_iterate_mem(list, pass)) != NULL)
539 {
540 UINT16 tempAge;
541 if (ospf_lsa_checkForDoNotAge(ospf, LSHeader->LSAge))
542 tempAge = ospf_lsa_maskDoNotAge(ospf, LSHeader->LSAge);
543 else
544 tempAge = ospf_lsa_maskDoNotAge(ospf, LSHeader->LSAge) +
545 ((UINT16)(ospf->incrementTime / SECOND));
546
547 if (tempAge > ospf->LSAMaxAge)
548 tempAge = ospf->LSAMaxAge;
549
550 if (ospf_lsa_maskDoNotAge(ospf, LSHeader->LSAge) ==
551 ospf->LSAMaxAge)
552 continue;
553
554 // Increment LS age.
555 ospf_lsa_assignNewLSAge(ospf,
556 &LSHeader->LSAge,
557 tempAge);
558
559 // LS Age field of Self originated LSA reaches LSRefreshTime
560 if (!OSPFID_COMPARE(LSHeader->AdvertisingRouter, ospf->routerId) &&
561 ospf_lsa_maskDoNotAge(ospf, tempAge) == ospf->LSRefreshTime / SECOND)
562 {
563 ospf_lsdb_refreshLSA(ospf, LSHeader, areaId);
564 }
565 // Expired, so remove from LSDB and flood.
566 else if (ospf_lsa_maskDoNotAge(ospf, tempAge) == ospf->LSAMaxAge)
567 {
568 ospf_lsa_flood(ospf,
569 areaId,
570 LSHeader,
571 ANY_DEST,
572 0);
573 ospf_lsa_addToMaxAgeLSAList(ospf, areaId, LSHeader);
574 ospf_spf_scheduleCalculation(ospf);
575 }
576 }
577 ospf_list_deleteIterator(pass);
578}
579
580static void ospf_LSDB_removeStaleDoNotAgeLSA(ptrOSPF_PDS ospf)
581{
582 ptrOSPFAREA_DS thisArea = NULL;
583 ptrOSPFLSAHDR LSHeader = NULL;
584 void* pass = NULL;
585
586 UINT i;
587 for (i = 0; i < ospf->areaCount; i++)
588 {
589 thisArea = ospf->areaDS[i];
590 pass = ospf_list_newIterator();
591 while ((LSHeader = ospf_list_iterate_mem(thisArea->nwLSAList, pass)) != NULL)
592 {
593 //Check for DoNotAge LSA
594 if (ospf_lsa_checkForDoNotAge(ospf, LSHeader->LSAge))
595 {
596 //Check for at least MaxAge Seconds
597 if ((OSPF_CURR_TIME() - LSHeader->time) >= ospf->LSAMaxAge)
598 {
599 //Flush this LSA
600 ospf_lsa_flush(ospf, thisArea, LSHeader);
601 ospf_lsdb_removeLSA(ospf, thisArea, LSHeader);
602 }
603 }
604 }
605 ospf_list_deleteIterator(pass);
606 pass = ospf_list_newIterator();
607 while ((LSHeader = ospf_list_iterate_mem(thisArea->routerLSAList, pass)) != NULL)
608 {
609 //Check for DoNotAge LSA
610 if (ospf_lsa_checkForDoNotAge(ospf, LSHeader->LSAge))
611 {
612 //Check for at least MaxAge Seconds
613 if ((OSPF_CURR_TIME() - LSHeader->time) >= ospf->LSAMaxAge)
614 {
615 //Flush this LSA
616 ospf_lsa_flush(ospf, thisArea, LSHeader);
617 ospf_lsdb_removeLSA(ospf, thisArea, LSHeader);
618 }
619 }
620 }
621 ospf_list_deleteIterator(pass);
622 pass = ospf_list_newIterator();
623 while ((LSHeader = ospf_list_iterate_mem(thisArea->nwSummaryLSAList, pass)) != NULL)
624 {
625 //Check for DoNotAge LSA
626 if (ospf_lsa_checkForDoNotAge(ospf, LSHeader->LSAge))
627 {
628 //Check for at least MaxAge Seconds
629 if ((OSPF_CURR_TIME() - LSHeader->time) >= ospf->LSAMaxAge)
630 {
631 //Flush this LSA
632 ospf_lsa_flush(ospf, thisArea, LSHeader);
633 ospf_lsdb_removeLSA(ospf, thisArea, LSHeader);
634 }
635 }
636 }
637 ospf_list_deleteIterator(pass);
638 pass = ospf_list_newIterator();
639 while ((LSHeader = ospf_list_iterate_mem(thisArea->routerSummaryLSAList, pass)) != NULL)
640 {
641 //Check for DoNotAge LSA
642 if (ospf_lsa_checkForDoNotAge(ospf, LSHeader->LSAge))
643 {
644 //Check for at least MaxAge Seconds
645 if ((OSPF_CURR_TIME() - LSHeader->time) >= ospf->LSAMaxAge)
646 {
647 //Flush this LSA
648 ospf_lsa_flush(ospf, thisArea, LSHeader);
649 ospf_lsdb_removeLSA(ospf, thisArea, LSHeader);
650 }
651 }
652 }
653 ospf_list_deleteIterator(pass);
654 }
655}
656
657static void ospf_lsdb_incrementLSAge(ptrOSPF_PDS ospf)
658{
659 UINT i;
660 for (i = 0; i < ospf->areaCount; i++)
661 {
662 ptrOSPFAREA_DS thisArea = ospf->areaDS[i];
663 ospf_LSDB_IncrementLSAgeInLSAList(ospf,
664 thisArea->nwLSAList,
665 thisArea->areaId);
666 ospf_LSDB_IncrementLSAgeInLSAList(ospf,
667 thisArea->routerLSAList,
668 thisArea->areaId);
669 ospf_LSDB_IncrementLSAgeInLSAList(ospf,
670 thisArea->nwSummaryLSAList,
671 thisArea->areaId);
672 ospf_LSDB_IncrementLSAgeInLSAList(ospf,
673 thisArea->routerSummaryLSAList,
674 thisArea->areaId);
675 }
676
677 //RFC:1793::Section 2.3
678 //As increment LSA is called after periodic intervals so
679 //removal of stale DoNotAge LSAs can be done here
680 //(1) The LSA has been in the router’s database
681 //for at least MaxAge seconds.
682 //(2) The originator of the LSA has been unreachable (according to
683 //the routing calculations specified by Section 16 of [1]) for
684 //at least MaxAge seconds
685 if (ospf->supportDC)
686 ospf_LSDB_removeStaleDoNotAgeLSA(ospf);
687}
688
689void ospf_LSDB_handle_IncrementAge_event()
690{
691 print_ospf_log(OSPF_LOG, "Router %d, Increment Age event is triggered at time %0.3lf",
692 pstruEventDetails->nDeviceId,
693 pstruEventDetails->dEventTime / MILLISECOND);
694
695 ptrOSPF_PDS ospf = OSPF_PDS_CURRENT();
696
697 ospf_event_add(OSPF_CURR_TIME() + ospf->incrementTime,
698 ospf->myId,
699 pstruEventDetails->nInterfaceId,
700 pstruEventDetails->nSubEventType,
701 NULL,
702 NULL);
703
704 // Increment age of each LSA.
705 ospf_lsdb_incrementLSAge(ospf);
706}