15#ifndef _NETSIM_OSPF_H_
16#define _NETSIM_OSPF_H_
21#pragma comment(lib,"NetworkStack.lib")
22#pragma comment(lib,"Metrics.lib")
36#define GET_LOWER_IP(ip1,ip2) ((ip1) ? ((ip2) ? ((ip1)->int_ip[0] < (ip2)->int_ip[0] ? (ip1) : (ip2)) : (ip1)) : (ip2));
37#define DEVICE_CURR_IP (DEVICE_NWADDRESS(pstruEventDetails->nDeviceId,pstruEventDetails->nInterfaceId))
38#define DEVICE_CURR_MASK (DEVICE_SUBNETMASK(pstruEventDetails->nDeviceId,pstruEventDetails->nInterfaceId))
40#define OSPF_CURR_TIME() (pstruEventDetails->dEventTime)
42#define strAllSPFRouters "224.0.0.5"
43#define strAllDRouters "224.0.0.6"
44#define strNULLIP "0.0.0.0"
45#define strInvalidAreaId "255.255.255.254"
46#define strSingleAreaId "255.255.255.255"
47#define strBackboneAreaId "0.0.0.0"
54#define ANY_DEST (GET_BROADCAST_IP(4))
56#define OSPF_BROADCAST_JITTER (0*MILLISECOND)
57#define OSPF_DO_NOT_AGE (0x8000)
58#define OSPF_LSA_MAX_AGE_DIFF (15 * MINUTE)
105#define OSPF_AREA_GET_IN(ospf,in) (OSPF_AREA_GET((ospf),(in),NULL,NULL))
106#define OSPF_AREA_GET_ID(ospf,id) (OSPF_AREA_GET((ospf),0,(id),NULL))
107#define OSPF_AREA_GET_IP(ospf,ip) (OSPF_AREA_GET((ospf),0,NULL,(ip)))
149#define OSPF_PDS_SET(d,ospf) (fn_NetSim_Stack_SetAppProtocolData(d,APP_PROTOCOL_OSPF,ospf))
150#define OSPF_PDS_GET(d) ((ptrOSPF_PDS)(DEVICE_APPVAR(d,APP_PROTOCOL_OSPF)))
151#define OSPF_PDS_CURRENT() (OSPF_PDS_GET(pstruEventDetails->nDeviceId))
179#define OSPF_IF_CURRENT() (OSPF_IF_GET(OSPF_PDS_CURRENT(), pstruEventDetails->nInterfaceId))
400#define ospf_event_add(time,d,in,subevent,packet,eventdata) ospf_event_add_dbg(time,d,in,subevent,packet,eventdata,__LINE__,__FILE__)
412#pragma message(__LOC__"Remove after link failure bug")
void ospf_lsreq_retransmit(ptrOSPF_PDS ospf, ptrOSPF_IF thisInterface, ptrOSPF_NEIGHBOR neigh, UINT seqNum)
void ospf_lsupdate_send()
NETSIM_IPAddress AllDRouters
bool ospf_lsreq_isRequestedLSAReceived(ptrOSPF_NEIGHBOR neigh)
struct stru_event_details_lsdb EVENTLSDB
bool ospf_rlsa_hasLink(ptrOSPF_PDS ospf, ptrOSPFLSAHDR wlsa, ptrOSPFLSAHDR vlsa)
void start_interval_hello_timer()
ptrOSPFLSAHDR ospf_lsa_find_old_lsa(ptrOSPFLIST list, OSPFID rid, OSPFID lid)
UINT64 ospf_event_add_dbg(double time, NETSIM_ID d, NETSIM_ID in, int subevent, NetSim_PACKET *packet, void *eventData, int line, char *file)
int ospf_lsa_compare(ptrOSPF_PDS ospf, ptrOSPFLSAHDR oldLS, ptrOSPFLSAHDR newLS)
bool ospf_lsa_flood(ptrOSPF_PDS pds, OSPFID area, ptrOSPFLSAHDR lsa, NETSIM_IPAddress srcAddr, NETSIM_ID in)
void ospf_neighbor_handle_KillNbrEvent()
void ospf_lsdb_removeLSA(ptrOSPF_PDS ospf, ptrOSPFAREA_DS area, ptrOSPFLSAHDR lsa)
void ospf_neighbor_handle_1way_event()
bool ospf_is_dr_router_fulladjacentwithAnother(ptrOSPF_IF ospf)
void ospf_neighbor_handle_exchangeDone_event()
ptrOSPFLSAHDR ospf_lsdb_lookup_lsaListByID(ptrOSPFLIST list, OSPFID linkStateId)
void ospf_process_hello()
struct stru_event_details_lsdb * ptrEVENTLSDB
ptrOSPF_IF OSPF_IF_GET(ptrOSPF_PDS ospf, NETSIM_ID ifId)
bool ospf_lsdb_update(ptrOSPF_PDS ospf, ptrOSPF_IF thisInterface, ptrOSPFLSAHDR lsa, ptrOSPFAREA_DS thisArea, NETSIM_IPAddress srcAddr)
void ospf_event_set_and_call(int subevent, void *otherDetails)
bool ospf_lsa_hasLink(ptrOSPF_PDS ospf, ptrOSPFLSAHDR wlsa, ptrOSPFLSAHDR vlsa)
void ospf_lsa_scheduleSummaryLSA(ptrOSPF_PDS ospf, ptrOSPF_IF thisInterface, ptrOSPFAREA_DS area, NETSIM_IPAddress destAddr, NETSIM_IPAddress destMask, OSPFDESTTYPE destType, bool isFlush)
ptrOSPFLSAHDR ospf_lsReq_searchFromList(ptrOSPF_NEIGHBOR neigh, ptrOSPFLSAHDR lsa)
ptrOSPF_NEIGHBOR OSPF_NEIGHBOR_FIND_BY_IP(ptrOSPF_IF thisInterface, NETSIM_IPAddress ip)
struct stru_OSPF_COST_LIST OSPF_COST_LIST
void ospf_spf_scheduleCalculation(ptrOSPF_PDS ospf)
NETSIM_ID ospf_getInterfaceIdForNextHop(NETSIM_ID d, NETSIM_IPAddress addr)
void ospf_neighbor_handle_inactivityTimer_event()
struct stru_OSPF_PATH OSPF_PATH
void ospf_lsaAck_sendDelayedAck(ptrOSPF_PDS ospf, ptrOSPF_IF thisInterface, ptrOSPFLSAHDR lsa)
void ospf_neighbor_handle_helloReceived_event()
OSPFIFSTATE ospf_DR_election(ptrOSPF_PDS ospf, ptrOSPF_IF thisInterface)
void ospf_lsa_printRLSA(char *logid, ptrOSPFRLSA rlsa)
void ospf_neighbor_handle_start_event()
void ospf_lsu_sendLSUpdateToNeighbor(ptrOSPF_PDS ospf, ptrOSPF_IF thisInterface)
bool ospf_lsa_isSelfOriginated(ptrOSPF_PDS ospf, ptrOSPFLSAHDR lsa)
void ospf_neighbor_add(ptrOSPF_IF ospf, ptrOSPF_NEIGHBOR neigh)
enum_address_range_status
@ ADDRRNSTATUS_DONOTADVERTISE
void ospf_handle_interfaceDown_event()
bool ospf_lsa_is_content_changed(ptrOSPF_PDS ospf, ptrOSPFLSAHDR newLSA, ptrOSPFLSAHDR oldLSA)
bool ospf_dlog_isEnable(char *id)
void ospf_lsdb_scheduleMaxAgeRemovalTimer(ptrOSPF_PDS ospf)
ptrOSPF_NEIGHBOR ospf_neighbor_new(NETSIM_IPAddress ip, OSPFID rid)
static bool isOSPFSPFDebug
void ospf_area_handleABRTask(ptrOSPF_PDS ospf)
struct stru_address_range * ptrADDR_RN
bool Ospf_rlsa_getASBRouter(UINT8 VEB)
void ospf_lsdb_handleMaxAgeRemovalTimer()
void start_sending_dd_msg()
void print_ospf_log(OSPFLOGFLAG logFlag, char *format,...)
void ospf_lsa_printList(char *logid, ptrOSPFLIST list, char *name)
void ospf_lsreq_send(ptrOSPF_PDS ospf, NETSIM_ID interfaceId, NETSIM_IPAddress nbrAddr, bool retx)
void ospf_lsreq_insertToList(ptrOSPF_NEIGHBOR neigh, ptrOSPFLSAHDR lsHdr, double time)
void ospf_neighbor_handle_negotiationDone_event()
bool ospf_lsa_compareToListMem(ptrOSPF_PDS ospf, ptrOSPFLSAHDR oldLS, ptrOSPFLSAHDR newLS)
bool ospf_isMyAddr(NETSIM_ID d, NETSIM_IPAddress addr)
ptrOSPF_COST_LIST fn_NetSim_App_Routing_Init(NETSIM_ID d, ptrOSPF_COST_LIST list)
bool ospf_neighbor_isAnyNeighborInExchangeOrLoadingState(ptrOSPF_PDS ospf)
UINT16 ospf_lsa_maskDoNotAge(ptrOSPF_PDS ospf, UINT16 routerLSAAge)
ptrOSPFLSAHDR ospf_neighbor_searchSendList(ptrOSPFLIST list, ptrOSPFLSAHDR lsa)
bool ospf_lsa_update_lsahdr(ptrOSPF_PDS ospf, ptrOSPFAREA_DS area, ptrOSPFLSAHDR lsa, ptrOSPFLSAHDR old, LSTYPE lstype)
NETSIM_IPAddress AllSPFRouters
void ospf_handle_LSRequest()
void ospf_lsa_assignNewLSAIntoLSOrigin(ptrOSPF_PDS pds, ptrOSPFLSAHDR LSA, ptrOSPFLSAHDR newLSA)
enum enum_ospf_router_type OSPFRTYPE
struct stru_OSPF_COST_LIST * ptrOSPF_COST_LIST
ptrOSPFLSAHDR ospf_lsdb_lookup(ptrOSPF_PDS ospf, ptrOSPFAREA_DS area, LSTYPE lsType, OSPFID adveRouter, OSPFID linkStateID)
ptrOSPFLIST ospf_lsreq_initList()
void ospf_lsa_flush(ptrOSPF_PDS ospf, ptrOSPFAREA_DS area, ptrOSPFLSAHDR lsa)
void ospf_lsa_schedule(ptrOSPF_PDS ospf, ptrOSPF_IF thisInterface, ptrOSPFAREA_DS area, ptrOSPFLSAHDR lsa)
void init_ospf_dlog(char *id, char *fileName)
struct stru_address_range ADDR_RN
void ospf_lsa_print(char *logid, ptrOSPFLSAHDR LSHeader, char *msg)
struct stru_area_ds * ptrOSPFAREA_DS
void ospf_lsa_schedule_routerLSA(ptrOSPF_PDS ospf, ptrOSPFAREA_DS area, bool isFlush)
void ospf_lsa_ScheduleLSDB()
bool ospf_lsdb_install(ptrOSPF_PDS ospf, OSPFID areaId, ptrOSPFLSAHDR lsa, ptrOSPFLIST list)
bool ospf_lsa_checkForDoNotAge(ptrOSPF_PDS ospf, UINT16 routerLSAAge)
void ospf_handle_helloTimer_event()
void ospf_lsa_handle_floodTimer_event()
void ospf_lsack_handleDelayedAckTimer()
void ospf_lsa_queueToFlood(ptrOSPF_PDS pds, ptrOSPF_IF ospf, ptrOSPFLSAHDR lsa)
int ospf_lsa_isMoreRecent(ptrOSPF_PDS ospf, ptrOSPFLSAHDR newLSA, ptrOSPFLSAHDR oldLSA)
struct stru_area_ds OSPFAREA_DS
bool ospf_is_router_fullAdjacentWithDR(ptrOSPF_IF ospf)
char * form_dlogId(char *name, NETSIM_ID d)
NETSIM_ID ospf_neighbor_getInterfaceIdforThisNeighbor(ptrOSPF_PDS ospf, NETSIM_IPAddress neighIPaddr)
void ospf_lsaAck_sendDirectAck(ptrOSPF_PDS ospf, NETSIM_ID interfaceId, ptrARRAYLIST ackList, NETSIM_IPAddress nbrAddr)
void ospf_lsreq_removeFromReqList(ptrOSPFLIST list, ptrOSPFLSAHDR lsa)
void ospf_event_set(int subevent)
void ospf_handle_LSUPDATE()
bool Ospf_rlsa_getABRouter(UINT8 VEB)
void ospf_LSDB_handle_IncrementAge_event()
void ospf_lsupdate_handleRxmtTimer()
void ospf_rlsa_originateRouterLSA(ptrOSPFAREA_DS area, bool isFlush)
bool isOSPFConfigured(NETSIM_ID d)
void ospf_spf_handleCalculateSPFEvent()
void ospf_neighbor_insertToSendList(ptrOSPFLIST list, ptrOSPFLSAHDR lsa, double time)
void ospf_lsahdr_add_lsa(ptrOSPFLSAHDR lhdr, void *lsa, UINT16 len)
bool get_ospf_log_status()
bool ospf_lsa_hasMaxAge(ptrOSPF_PDS ospf, ptrOSPFLSAHDR lsa)
struct stru_OSPF_PATH * ptrOSPF_PATH
void ospf_area_init(NETSIM_ID d, NETSIM_ID in)
void ospf_lsa_scheduleNWLSA(ptrOSPF_PDS ospf, ptrOSPF_IF thisInterface, ptrOSPFAREA_DS area, bool isFlush)
void ospf_neighbor_handle_2wayReceived_event()
void print_ospf_Dlog(char *id, char *format,...)
static bool isOSPFHelloDebug
void ospf_lsa_addToMaxAgeLSAList(ptrOSPF_PDS ospf, OSPFID areaId, ptrOSPFLSAHDR lsa)
void ospf_lsa_assignNewLSAge(ptrOSPF_PDS ospf, UINT16 *routerLSAAge, UINT16 newLSAAge)
void OSPF_AREA_SET(ptrOSPF_PDS ospf, ptrOSPFAREA_DS area)
void ospf_handle_interfaceUp_event()
void ospf_neighbor_handle_LoadingDoneEvent()
ptrOSPFAREA_DS OSPF_AREA_GET(ptrOSPF_PDS ospf, NETSIM_ID in, OSPFID areaId, NETSIM_IPAddress interfaceIP)
ptrOSPFLSAHDR ospf_lsdb_lookup_lsaList(ptrOSPFLIST list, OSPFID adverRouter, OSPFID linkStateId)
enum enum_address_range_status ADDR_RN_STATUS
bool ospf_rlsa_isBodyChanged(ptrOSPFLSAHDR newLSA, ptrOSPFLSAHDR oldLSA)
ptrOSPF_NEIGHBOR OSPF_NEIGHBOR_FIND(ptrOSPF_IF ospf, OSPFID id)
void ospf_interface_handleMultipleInterfaceEvent()
enum enum_if_state OSPFIFSTATE
enum enum_ospf_dest_type OSPFDESTTYPE
struct stru_OSPF_COST_LIST * next
struct stru_OSPF_PATH * next
NETSIM_ID * assocRouterInterfaceId
ptrOSPFLIST shortestPathList
double lastLSAOriginateTime
bool extRoutingCapability
ptrOSPFLIST addressRangeList
ptrOSPFLIST routerLSAList
ptrOSPFLIST routerSummaryLSAList
ptrOSPFLIST nwSummaryLSAList
NETSIM_IPAddress * assocRouterInterface
NETSIM_IPAddress destMask
NETSIM_IPAddress destAddr
bool isPartitionedIntoArea
ptrOSPFROUTINGTABLE routingTable
bool isMaxAgeRemovalTimerSet