📄 ospf_interface_events.c
字号:
/* ospf_interface_events.c - used for executing interface events *//* Copyright 1998 - 2003 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------02e,30jun03,agi Fixed SPR#88879, ospf does not clean up external LSDB when an interface is brought down02d,26may03,agi Changed rwos_get_system_elapsed_time_second() to ospf_get_system_elapsed_time_second()02c,22apr03,ram SPR#76812 Modifications for OSPF performance enhancements02b,29jan03,asr Fix for SPR# 85573. Build, install & flood new router LSA after link down.02a,03dec02,ram SPR#84312 - Change elapsed time to return seconds23,29april02,ark Added in fix for SPR 7578522,10April02,bt modified to not generate Network-LSA for PTMP and POINT-to-POINT21,22march02,kc Fixed SPR74261. When triggering the interface down event to reset the interface variables, it is necessary to flush all lsas associated with the area if there is no more active interface in that area. 20,13october01,kc Dynamic configuration changes.19,06october01,kc Modified ospf_process_interface_backup_seen_event() and ospf_process_interface_wait_timer_event to calculate DR and BDR only if interface type is broadcast or NBMA.18,3may01,jkw change ospf_reset_interface_variables_and_timers_and_destroy_all_associated_neighbor_connections17,21may01,jkw add in new function for point to point16,26september00,reshma Added WindRiver CopyRight15,25september00,reshma RFC-1587 implementation for OSPF NSSA Option, also tested against ANVL.14,07july00,reshma Unix compatibility related changes.13,04april00,reshma Added some MIB support (Read only).Passed all important ANVL OSPF tests.12,23december99,reshma Compatibility with VxWorks-IP and VxWorks RTM-interface11,28december98,jack Compiled and added some comments10,11november98,jack Config changes, linted and big endian changes09,30october98,jack Incorporate changes for compilation on Vxworks08,23august98,jack ANVL tested OSPF with PATRICIA tree route table and no recursion07,10august98,jack PATRICIA Route Table Based OSPF Code Base06,04june98,jack Integration with RTM and BGP05,24april98,jack RTM changes04,10july97,cindy Pre-release v1.52b03,02october97,cindy Release Version 1.5202,22october96,cindy Release Version 1.5001,05june96,cindy First Beta Release*//*DESCRIPTIONospf_interface_events.c is used for processing interface events. Interface events include:OSPF_INTERFACE_UP, OSPF_WAIT_TIMER, OSPF_BACKUP_SEEN, OSPF_NEIGHBOR_CHANGE, OSPF_LOOP_INDICATION,OSPF_UNLOOP_INDICATION, OSPF_INTERFACE_DOWN.This file is used whenever an interface event occurs.*/#include "ospf.h"#if defined (__OSPF_VIRTUAL_STACK__)#include "ospf_vs_lib.h"#endif /* __OSPF_VIRTUAL_STACK__ *//***********************************************************************************************************************************/static char *ospf_interface_types[] ={ "", "Point To Point", "Broadcast", "OSPF_NBMA", "Point To Multipoint", "Virtual"};static char *ospf_interface_states[] ={ "Down", "Loopback", "Waiting", "Point To Point", "DR Other", "BackupDR", "DR "};static char *ospf_interface_events[] ={ "Interface Up", "Wait Timer", "Backup Seen", "Neighbor Change", "Loop Indication", "Unloop Indication", "Interface Down"};/***********************************************************************************************************************************/static void ospf_calculate_backup_designated_router_and_designated_router_for_attached_network (OSPF_INTERFACE *sptr_interface, enum OSPF_INTERFACE_EVENT event);static void ospf_interface_state_transition_printf (OSPF_INTERFACE *sptr_interface,enum OSPF_INTERFACE_EVENT event, enum OSPF_INTERFACE_STATE old_state);static void ospf_calculate_point_to_point_network (OSPF_INTERFACE *sptr_interface);/*************************************************************************** ospf_process_interface_up_event - execute when interface comes up** This routine will initialize the interface variables and bring up* the interface specified.** <sptr_interface> OSPF interface** RETURNS: N/A** ERRNO: N/A** NOMANUAL*//*****************************************************************************************//* section 9.3, State: Down (p. 66-67) */void ospf_process_interface_up_event (OSPF_INTERFACE *sptr_interface){ enum OSPF_INTERFACE_STATE old_state; OSPF_NEIGHBOR *sptr_neighbor = NULL; OSPF_NEIGHBOR *sptr_next_neighbor = NULL; OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_process_interface_up_event\r\n"); old_state = sptr_interface->state; /* SPR 84312 -- Begin */ sptr_interface->potential_neighbor.last_hello = ospf_get_system_elapsed_time_second (); /* SPR 84312 -- End */ sptr_interface->potential_neighbor.periodic_inactivity_time_counter = 0x00000000L; sptr_interface->potential_neighbor.inactivity_timer_enabled = TRUE; ospf_send_hello (sptr_interface, NULL, FALSE); /* begin periodic sending of Hello packets out the interface */ if ((sptr_interface->type == OSPF_POINT_TO_POINT) || (sptr_interface->type == OSPF_POINT_TO_MULTIPOINT) || (sptr_interface->type == OSPF_VIRTUAL_LINK)) { sptr_interface->state = OSPF_INTERFACE_POINT_TO_POINT; sptr_interface->point_timer_enabled = TRUE; } else if (sptr_interface->priority == 0x0000) { sptr_interface->state = OSPF_INTERFACE_DESIGNATED_ROUTER_OTHER; } else { sptr_interface->state = OSPF_INTERFACE_WAITING; sptr_interface->periodic_wait_time_counter = 0x00000000L; sptr_interface->wait_timer_enabled = TRUE; if (sptr_interface->type == OSPF_NBMA) { for (sptr_neighbor = sptr_interface->sptr_neighbor; sptr_neighbor != NULL; sptr_neighbor = sptr_next_neighbor) { sptr_next_neighbor = sptr_neighbor->sptr_forward_link; if (sptr_neighbor->priority > 0x0000) /* check if neighbor is eligible to become designated router */ { ospf_execute_neighbor_state_machine (OSPF_START, sptr_neighbor->state, sptr_interface, sptr_neighbor); } } } } if (sptr_interface->type == OSPF_VIRTUAL_LINK) { sptr_interface->sptr_transit_area->flags._bit.virtual_up = TRUE; ++ospf.number_of_virtual_links_in_Up_state; if (ospf.sptr_backbone_area != NULL) { if (ospf.sptr_backbone_area->lock_time == 0x00000000L) { /* SPR 84312 -- Begin */ ospf.sptr_backbone_area->lock_time = ospf_get_system_elapsed_time_second (); /* SPR 84312 -- End */ } } } else { sptr_interface->sptr_area->build_router = TRUE; /* section 12.4, item (2) (page 115) */ } ++sptr_interface->sptr_area->number_of_interfaces_in_up_state; ospf_interface_state_transition_printf (sptr_interface, OSPF_INTERFACE_UP, old_state); ++sptr_interface->events; /* SPR 84312 -- Begin */ sptr_interface->up_time = ospf_get_system_elapsed_time_second (); /* SPR 84312 -- End */ return;}/*************************************************************************** ospf_process_interface_wait_timer_event - execute when interface wait timer event is received** This routine will either calculate the point to point network if the* interface type is point to point or execute the DR and BDR election* process.** <sptr_interface> OSPF interface** RETURNS: N/A** ERRNO: N/A** NOMANUAL*//*****************************************************************************************//* section 9.3, State: Waiting (p. 67) */void ospf_process_interface_wait_timer_event (OSPF_INTERFACE *sptr_interface){ OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_process_interface_wait_timer_event\r\n"); sptr_interface->wait_timer_enabled = FALSE; if (sptr_interface->state == OSPF_INTERFACE_POINT_TO_POINT) { ospf_calculate_point_to_point_network (sptr_interface); } else { ospf_calculate_backup_designated_router_and_designated_router_for_attached_network (sptr_interface, OSPF_WAIT_TIMER); } return;}/*************************************************************************** ospf_process_interface_backup_seen_event - execute when interface backup seen event is received** This routine will execute the DR and BDR election process.** <sptr_interface> OSPF interface** RETURNS: N/A** ERRNO: N/A** NOMANUAL*//*****************************************************************************************//* section 9.3, State: Waiting (p. 67) */void ospf_process_interface_backup_seen_event (OSPF_INTERFACE *sptr_interface){ OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_process_interface_backup_seen_event\r\n"); sptr_interface->wait_timer_enabled = FALSE; ospf_calculate_backup_designated_router_and_designated_router_for_attached_network (sptr_interface, OSPF_BACKUP_SEEN); return;}/*************************************************************************** ospf_process_interface_neighbor_change_event - execute when interface neighbor change event is received** This routine will execute the DR and BDR election process if* the interface type is either broadcast or nbma.** <sptr_interface> OSPF interface** RETURNS: N/A** ERRNO: N/A** NOMANUAL*//*************************************************************************//* section 9.3, State: DR Other, Backup, or DR (p. 68) */void ospf_process_interface_neighbor_change_event (OSPF_INTERFACE *sptr_interface){ OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_process_interface_neighbor_change_event\r\n"); sptr_interface->flags._bit.neighbor_change = FALSE; sptr_interface->wait_timer_enabled = FALSE; if ((sptr_interface->type == OSPF_BROADCAST) || (sptr_interface->type == OSPF_NBMA)) { ospf_calculate_backup_designated_router_and_designated_router_for_attached_network (sptr_interface, OSPF_NEIGHBOR_CHANGE); } return;}/*************************************************************************** ospf_process_interface_loop_indication_event - execute when interface loop indication event is received** This routine will reset all the interface variables and timers. This* routine will destroy all the associated neighbor connections with* the interface specified.** <sptr_interface> OSPF interface** RETURNS: N/A** ERRNO: N/A** NOMANUAL*//*********************************************************************************************//* section 9.3, State: Any (p. 68) */void ospf_process_interface_loop_indication_event (OSPF_INTERFACE *sptr_interface){ OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_process_interface_loop_indication_event\r\n"); ospf_reset_interface_variables_and_timers_and_destroy_all_associated_neighbor_connections (sptr_interface, OSPF_LOOP_INDICATION, OSPF_INTERFACE_LOOPBACK);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -