?? ospf_neighbor_events.c
字號(hào):
/* ospf_neighbor_events.c - OSPF neighbor events *//* Copyright 2000-2003 Wind River Systems, Inc. */ /*modification history--------------------02e,24jun03,asr Backed out the fix for SPR8737502d,26may03,agi Changed rwos_get_system_elapsed_time_second() to ospf_get_system_elapsed_time_second()02b,29may03,kkz SPR 87375 - On event AdjacencyOK, do not reset adjacency if we are DR or BDR02c,23may03,agi Changed RWOS semaphores to vxWorks semaphores02b,22apr03,ram SPR#76812 Modifications for OSPF performance enhancements02a,03dec02,ram SPR 84312 - Change elapsed time to return seconds28,22april02,ark Added in fixes for Virtual links27,05febuary02,kc Fixed ospf_process_neighbor_1_way_received_event() to execute interface state machine if necessary (TMS PR#1866).26,11january02,jkw Fix TSR 72091, neighbors not being added.25,09january02,kc Added ospf mib support to ospf_remove_neighbor_from_interface_neighbor_list().24,03december01,jkw Fix establishing adjacency with neighbor section 10.4 in the RFC. We were not checking to see if the router itself was either the DR or BDR.23,15november01,jkw Virtual link updates22,13october01,kc Dynamic configuration changes.21,26september01,kc Made ospf_clear_advertisements_from_lists() public.20,19june01,aos Calling to ospf_clean_up_retransmit_lists_affiliated_with_this_advertisement () function before freeing the LS database entry.19,3may01,jkw Added checks for NULL pointers and alarm messages18,26september00,reshma Added WindRiver CopyRight17,25september00,reshma RFC-1587 implementation for OSPF NSSA Option, also tested against ANVL. Also added ospf_mib_delete_xxx_entry functions.16,07july00,reshma Unix compatibility related changes.15,04april00,reshma Added some MIB support (Read only).Passed all important ANVL OSPF tests.14,23december99,reshma Compatibility with VxWorks-IP and VxWorks RTM-interface13,13august99,jack ifdefed lsl control calls12,12may99,jack Removed call ospf_clear_advertisements_from_database in ospf_process_neighbor_down_event. Refer OSPF FAQ John Moy Pg#16111,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_neighbor_events.c is used for processing neighbor events. Neighbor events include:OSPF_HELLO_RECEIVED, OSPF_START, OSPF_TWO_WAY_RECEIVED, OSPF_NEGOTIATION_DONE, OSPF_EXCHANGE_DONE,OSPF_BAD_LINK_STATE_REQUEST, OSPF_LOADING_DONE, OSPF_ADJACENCY_OK, OSPF_SEQUENCE_NUMBER_MISMATCH,OSPF_ONE_WAY, OSPF_KILL_NEIGHBOR, OSPF_INACTIVITY_TIMER,OSPF_DOWN_INDICATION_FROM_LOWER_LEVEL_PROTOCOLS_RECEIVED.This file is used whenever a neighbor event occurs.*/#include "ospf.h"#if defined (__OSPF_VIRTUAL_STACK__)#include "ospf_vs_lib.h"#endif /* __OSPF_VIRTUAL_STACK__ *//********************************************************************************************************************************/static char *ospf_neighbor_events[] ={ "Hello Received", "Start", "Two Way Received", "Negotiation Done", "Exchange Done", "Bad LS Request", "Loading Done", "Adjacency OK", "Sequence # Mismatch", "One way", "Kill Neighbor", "Inactivity Timer", "Lower Level Down"};static char *ospf_neighbor_states[] ={ "Down", "Attempt", "Initializing", "Two Way", "Exchange Start", "Exchange", "Loading", "Full", "SCVirtual"};/********************************************************************************************************************************/static void ospf_establish_adjacency (OSPF_INTERFACE *sptr_interface,OSPF_NEIGHBOR *sptr_neighbor);static OSPF_NEIGHBOR *ospf_remove_neighbor_from_interface_neighbor_list (OSPF_INTERFACE *sptr_interface,OSPF_NEIGHBOR *sptr_neighbor_to_remove);static void ospf_update_flags_due_to_adjacency_tear_down (OSPF_INTERFACE *sptr_interface);static void ospf_decrement_appropriate_neighbor_state_counters (OSPF_INTERFACE *sptr_interface,enum OSPF_NEIGHBOR_STATE old_state, enum OSPF_NEIGHBOR_STATE new_state);static void ospf_update_designated_router_state_if_necessary (enum OSPF_NEIGHBOR_STATE old_state,OSPF_INTERFACE *sptr_interface, OSPF_NEIGHBOR *sptr_neighbor);static void ospf_update_neighbor_state_counters (OSPF_INTERFACE *sptr_interface,enum OSPF_NEIGHBOR_STATE state, enum OSPF_COUNTER_ACTION_TYPE increment);static void ospf_neighbor_state_transition_printf (OSPF_NEIGHBOR *sptr_neighbor,enum OSPF_NEIGHBOR_EVENT event, enum OSPF_NEIGHBOR_STATE old_state);/**************************************************************************************//* section 10.3, State: Any (p. 81-82) */void ospf_process_neighbor_hello_received_event (OSPF_INTERFACE *sptr_interface,OSPF_NEIGHBOR *sptr_neighbor,enum OSPF_NEIGHBOR_EVENT event){ enum OSPF_NEIGHBOR_STATE old_state; PARAMETER_NOT_USED (event); OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_process_neighbor_hello_received_event\r\n"); /* SPR 84312 -- Begin */ sptr_neighbor->last_hello = ospf_get_system_elapsed_time_second (); /* SPR 84312 -- End */ sptr_neighbor->periodic_inactivity_time_counter = 0x00000000L; /* reset inactivity timer */ sptr_neighbor->inactivity_timer_enabled = TRUE; if ((sptr_neighbor->state == OSPF_NEIGHBOR_ATTEMPT) || (sptr_neighbor->state == OSPF_NEIGHBOR_DOWN)) { old_state = sptr_neighbor->state; sptr_neighbor->state = OSPF_NEIGHBOR_INITIALIZING; ospf_update_neighbor_state_counters (sptr_interface, OSPF_NEIGHBOR_INITIALIZING, OSPF_INCREMENT_COUNTERS); ospf_neighbor_state_transition_printf (sptr_neighbor, OSPF_HELLO_RECEIVED, old_state); ++sptr_neighbor->events; } return;}/****************************************************************************************//* section 10.3, State: Down (p. 81) */void ospf_process_neighbor_start_event (OSPF_INTERFACE *sptr_interface,OSPF_NEIGHBOR *sptr_neighbor,enum OSPF_NEIGHBOR_EVENT event)/* this routine is called for OSPF_NBMA networks only - section 10.2, Event: Start (p. 79) */{ enum OSPF_NEIGHBOR_STATE old_state; PARAMETER_NOT_USED (event); OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_process_neighbor_start_event\r\n"); if (sptr_interface->priority > 0x0000) /* check if router is eligible to become Designated Router - section 9.5.1 (p. 72) */ { ospf_send_hello (sptr_interface, sptr_neighbor, FALSE); } /* SPR 84312 -- Begin */ sptr_neighbor->last_hello = ospf_get_system_elapsed_time_second (); /* SPR 84312 -- End */ sptr_neighbor->periodic_inactivity_time_counter = 0x00000000L; /* reset inactivity timer */ sptr_neighbor->inactivity_timer_enabled = TRUE; old_state = sptr_neighbor->state; sptr_neighbor->state = OSPF_NEIGHBOR_ATTEMPT; ospf_neighbor_state_transition_printf (sptr_neighbor, OSPF_START, old_state); ++sptr_neighbor->events;}/****************************************************************************************//* section 10.3, State: Init (p. 82) */void ospf_process_neighbor_2_way_received_event (OSPF_INTERFACE *sptr_interface,OSPF_NEIGHBOR *sptr_neighbor,enum OSPF_NEIGHBOR_EVENT event){ enum OSPF_NEIGHBOR_STATE old_state; PARAMETER_NOT_USED (event); OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_process_neighbor_2_way_received_event\r\n"); old_state = sptr_neighbor->state; /* * section 10.4 (p. 87) - Routers connected by point-to-point networks, Point-to-MultiPoint networks and virtual links always become * adjacent. On broadcast and OSPF_NBMA networks, all routers become adjacent to both the Designated Router and the Backup Designated * Router. */ if ((sptr_interface->type == OSPF_POINT_TO_POINT) || (sptr_interface->type == OSPF_VIRTUAL_LINK) || (sptr_interface->type == OSPF_POINT_TO_MULTIPOINT)) { ospf_establish_adjacency (sptr_interface, sptr_neighbor); } else if ((sptr_interface->type == OSPF_BROADCAST) || (sptr_interface->type == OSPF_NBMA)) { if ((sptr_interface->designated_router.address == sptr_neighbor->address) || (sptr_interface->backup_designated_router.address == sptr_neighbor->address) || (sptr_interface->designated_router.address == sptr_interface->address) || (sptr_interface->backup_designated_router.address == sptr_interface->address)) { ospf_establish_adjacency (sptr_interface, sptr_neighbor); } else { sptr_neighbor->state = OSPF_NEIGHBOR_2_WAY; } } else { sptr_neighbor->state = OSPF_NEIGHBOR_2_WAY; } ospf_neighbor_state_transition_printf (sptr_neighbor, OSPF_TWO_WAY_RECEIVED, old_state); ++sptr_neighbor->events; return;}/*************************************************************************************//* section 10.3, State: ExStart (p. 83) */void ospf_process_neighbor_negotiation_done_event (OSPF_INTERFACE *sptr_interface,OSPF_NEIGHBOR *sptr_neighbor,enum OSPF_NEIGHBOR_EVENT event){ enum OSPF_NEIGHBOR_STATE old_state; enum OSPF_RETURN_FLAGS return_flag; PARAMETER_NOT_USED (event); OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_process_neighbor_negotiation_done_event\r\n"); return_flag = ospf_build_ls_database_summary (sptr_interface, sptr_neighbor); if (return_flag == OSPF_NO_BUFFERS) { return; } old_state = sptr_neighbor->state; sptr_neighbor->state = OSPF_NEIGHBOR_EXCHANGE; ospf_update_designated_router_state_if_necessary (old_state, sptr_interface, sptr_neighbor); ospf_update_neighbor_state_counters (sptr_interface, OSPF_NEIGHBOR_EXCHANGE, OSPF_INCREMENT_COUNTERS); ospf_neighbor_state_transition_printf (sptr_neighbor, OSPF_NEGOTIATION_DONE, old_state); ++sptr_neighbor->events; return;}/************************************************************************************//* section 10.3, State: Exchange (p. 83) */void ospf_process_neighbor_exchange_done_event (OSPF_INTERFACE *sptr_interface,OSPF_NEIGHBOR *sptr_neighbor,enum OSPF_NEIGHBOR_EVENT event){ enum OSPF_NEIGHBOR_STATE old_state; PARAMETER_NOT_USED (event); OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_process_neighbor_exchange_done_event\r\n"); old_state = sptr_neighbor->state; if (sptr_neighbor->ls_request_queue_count == 0x0000) { sptr_neighbor->state = OSPF_NEIGHBOR_FULL; ospf_update_neighbor_state_counters (sptr_interface, OSPF_NEIGHBOR_FULL, OSPF_INCREMENT_COUNTERS); sptr_interface->sptr_area->build_router = TRUE; /* section 12.4, item (4) (page 115) */ if (sptr_interface->state == OSPF_INTERFACE_DESIGNATED_ROUTER) { OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Set build_network on interface with address (HEX) %lx TRUE , ospf_process_neighbor_exchange_done_event\r\n",sptr_interface->address); sptr_interface->flags._bit.build_network = TRUE; /* section 12.4, item (4) (page 115) */ } /* Virtual link updates */ if (sptr_neighbor->sptr_interface->type == OSPF_VIRTUAL_LINK) { ospf_schedule_routing_table_build(); } } else { sptr_neighbor->state = OSPF_NEIGHBOR_LOADING; } ospf_update_designated_router_state_if_necessary (old_state, sptr_interface, sptr_neighbor); ospf_neighbor_state_transition_printf (sptr_neighbor, OSPF_EXCHANGE_DONE, old_state); ++sptr_neighbor->events; if (sptr_neighbor->mode == OSPF_SLAVE) /* section 10.8, (page 94) */ { /* SPR 84312 -- Begin */ sptr_neighbor->last_exchange = ospf_get_system_elapsed_time_second ();
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -