NetSim Source Code Help
Loading...
Searching...
No Matches
GarbageCollectionTimer.c
Go to the documentation of this file.
1/************************************************************************************
2* Copyright (C) 2020
3*
4* TETCOS, Bangalore. India *
5
6* Tetcos owns the intellectual property rights in the Product and its content. *
7* The copying, redistribution, reselling or publication of any or all of the *
8* Product or its content without express prior written consent of Tetcos is *
9* prohibited. Ownership and / or any other right relating to the software and all *
10* intellectual property rights therein shall remain at all times with Tetcos. *
11
12* Author: Thangarasu.K *
13* ---------------------------------------------------------------------------------*/
14#ifndef _CRT_SECURE_NO_DEPRECATE
15#define _CRT_SECURE_NO_DEPRECATE
16#endif
17#include "main.h"
18#include "Routing.h"
19/**
20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21
22 Until the garbage-collection timer expires, the route is included in all
23 updates sent by the router. When the garbage collection timer expires, the route is deleted
24 from the routing table
25~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 */
28{
29 RIP_ROUTING_DATABASE *pstruTmpHeadEntry;
30 RIP_ROUTING_DATABASE *pstruTempTableList;
31 RIP_ROUTING_DATABASE *pstruNewTable;
32
33 NETWORK=pstruNETWORK;
35 pstruTempTableList=pstruTmpHeadEntry;
36
37 while(pstruTempTableList)
38 {
39 //check whether the entry is invalid or not if the entry is invalid remove that entry
40 if(pstruTempTableList->nMetric==EXPIRED_ROUTE)
41 {
42 pstruNewTable = pstruTempTableList;
43 pstruTempTableList=pstruTempTableList->pstru_Router_NextEntry;
44 pstruNewTable->pstru_Router_NextEntry = NULL;
45
48
49 if(pstruNewTable->szAddress)
50 IP_FREE(pstruNewTable->szAddress);
51
52 if(pstruNewTable->szRouter)
53 IP_FREE(pstruNewTable->szRouter);
54
55 fnpFreeMemory(pstruNewTable);
56 }
57 else
58 pstruTempTableList=pstruTempTableList->pstru_Router_NextEntry;
59 }
60 return 1;
61}
62
63
int fn_NetSim_RIP_Garbage_Collection_Timer(struct stru_NetSim_Network *pstruNETWORK, NetSim_EVENTDETAILS *pstruEventDetails)
void IP_FREE(NETSIM_IPAddress ip)
#define fnpFreeMemory(p)
Definition: Memory.h:36
#define EXPIRED_ROUTE
Definition: RIP.h:31
EXPORTED struct stru_NetSim_Network * NETWORK
Definition: Stack.h:742
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
struct stru_NetSim_NetworkLayer * pstruNetworkLayer
Definition: Stack.h:721
NETSIM_ID nDeviceId
Definition: Stack.h:750
struct stru_NetSim_Device ** ppstruDeviceList
Definition: Stack.h:737
Routing database structure Reference : RFC 2453, November 1998, Page 8.
Definition: RIP.h:73
unsigned int nMetric
Distance to the destination
Definition: RIP.h:78
NETSIM_IPAddress szRouter
The first router along the route to the destination
Definition: RIP.h:76
struct stru_Router_RIP_Routing_database * pstru_Router_NextEntry
Definition: RIP.h:80
NETSIM_IPAddress szAddress
IP address of the destination host or destination network
Definition: RIP.h:74