?? ospf_neighbor_events.c
字號:
/* SPR 84312 -- End */ sptr_neighbor->periodic_slave_hold_time_counter = 0x00000000L; sptr_neighbor->mode = OSPF_SLAVE_HOLD; /* wait RouterDeadInterval seconds before freeing the last Database Description packet */ } else if (sptr_neighbor->sptr_database_summary != NULL) { ospf_free_neighbor_database_summary_list (sptr_neighbor); } return;}/*************************************************************************************//* section 10.3, State: Loading (p. 84) */void ospf_process_neighbor_loading_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_loading_done_event\r\n"); old_state = sptr_neighbor->state; sptr_neighbor->state = OSPF_NEIGHBOR_FULL; ospf_update_designated_router_state_if_necessary (old_state, sptr_interface, sptr_neighbor); 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 to TRUE , ospf_process_neighbor_loading_done_event\r\n",sptr_interface->address); sptr_interface->flags._bit.build_network = TRUE; /* section 12.4, item (4) (page 115) */ } ospf_neighbor_state_transition_printf (sptr_neighbor, OSPF_LOADING_DONE, old_state); ++sptr_neighbor->events; /* Virtual link updates */#if !defined (__OSPF_VIRTUAL_LINK__) if (sptr_neighbor->sptr_interface->type == OSPF_VIRTUAL_LINK) { ospf_schedule_routing_table_build(); }#else /*__OSPF_VIRTUAL_LINK__*/ if (sptr_neighbor->sptr_interface->type == OSPF_VIRTUAL_LINK) { 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 */ } } if(sptr_interface->sptr_transit_area != NULL) { if (sptr_interface->sptr_transit_area->lock_time == 0x00000000L) { /* SPR 84312 -- Begin */ sptr_interface->sptr_transit_area->lock_time = ospf_get_system_elapsed_time_second (); /* SPR 84312 -- End */ } } ospf_schedule_routing_table_build(); }#endif /* __OSPF_VIRTUAL_LINK__ */}/***************************************************************************************//* section 10.3, State: 2-Way (p. 84) */void ospf_start_forming_an_adjacency_with_the_neighbor (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_start_forming_an_adjacency_with_the_neighbor\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 { return; } } else { return; } ospf_neighbor_state_transition_printf (sptr_neighbor, OSPF_ADJACENCY_OK, old_state); ++sptr_neighbor->events; return;}/**************************************************************************//* section 10.3, State: ExStart or greater (p. 84) */void ospf_maintain_or_destroy_existing_adjacency (OSPF_INTERFACE *sptr_interface,OSPF_NEIGHBOR *sptr_neighbor,enum OSPF_NEIGHBOR_EVENT event){ enum OSPF_NEIGHBOR_STATE old_state; PARAMETER_NOT_USED (event); /* * 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. */ OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_maintain_or_destroy_existing_adjacency\r\n"); if ((sptr_interface->type == OSPF_POINT_TO_POINT) || (sptr_interface->type == OSPF_VIRTUAL_LINK) || (sptr_interface->type == OSPF_POINT_TO_MULTIPOINT)) { return; /* yes, we should still be adjacent, so there is no state change and no further action is necessary */ } 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)) { return; /* yes, we should still be adjacent, so there is no state change and no further action is necessary */ } } /* otherwise, destroy existing adjacency */ old_state = sptr_neighbor->state; sptr_neighbor->state = OSPF_NEIGHBOR_2_WAY; sptr_neighbor->mode = OSPF_CLEAR_MODE; sptr_neighbor->last_exchange = 0x00000000L; sptr_neighbor->database_description_sequence_number = 0x00000000L; ospf_clear_advertisements_from_lists (sptr_interface, sptr_neighbor); ospf_decrement_appropriate_neighbor_state_counters (sptr_interface, old_state, sptr_neighbor->state); if (old_state == OSPF_NEIGHBOR_FULL) { ospf_update_flags_due_to_adjacency_tear_down (sptr_interface); } ospf_neighbor_state_transition_printf (sptr_neighbor, OSPF_ADJACENCY_OK, old_state); ++sptr_neighbor->events;}/*************************************************************************//* section 10.3, State: Exchange or greater (p. 85) */void ospf_tear_down_and_reestablish_adjacency (OSPF_INTERFACE *sptr_interface,OSPF_NEIGHBOR *sptr_neighbor,enum OSPF_NEIGHBOR_EVENT event){ enum OSPF_NEIGHBOR_STATE old_state; OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_tear_down_and_reestablish_adjacency\r\n"); old_state = sptr_neighbor->state; sptr_neighbor->state = OSPF_NEIGHBOR_EXCHANGE_START; ospf_update_designated_router_state_if_necessary (old_state, sptr_interface, sptr_neighbor); ospf_clear_advertisements_from_lists (sptr_interface, sptr_neighbor); ospf_decrement_appropriate_neighbor_state_counters (sptr_interface, old_state, sptr_neighbor->state); if (old_state == OSPF_NEIGHBOR_FULL) { ospf_update_flags_due_to_adjacency_tear_down (sptr_interface); } ospf_establish_adjacency (sptr_interface, sptr_neighbor); ospf_neighbor_state_transition_printf (sptr_neighbor, event, old_state); ++sptr_neighbor->events; return;}/****************************************************************************//* section 10.3, State: 2-Way or greater (p. 86) */void ospf_process_neighbor_1_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_1_way_received_event\r\n"); old_state = sptr_neighbor->state; sptr_neighbor->state = OSPF_NEIGHBOR_INITIALIZING; sptr_neighbor->mode = OSPF_CLEAR_MODE; sptr_neighbor->last_exchange = 0x00000000L; sptr_neighbor->database_description_sequence_number = 0x00000000L; sptr_neighbor->designated_router = 0x00000000L; sptr_neighbor->backup_designated_router = 0x00000000L; ospf_clear_advertisements_from_lists (sptr_interface, sptr_neighbor); ospf_decrement_appropriate_neighbor_state_counters (sptr_interface, old_state, sptr_neighbor->state); if (old_state == OSPF_NEIGHBOR_FULL) { ospf_update_flags_due_to_adjacency_tear_down (sptr_interface); } /* Section 10.3 (Introduction): When a neighbor's state change, it may be * necessary to rerun the designated router election algorithm. This is determined * whether the interface NeighborChange event is generated. * Section 9.2: NeighborChange event should be executed if (item number 2) there * is no longer bidirection communication with a neighbor. Here we have tear * down the adjacency with the neighbor. So the interface state machine needs to * be executed. Otherwise, WindNet OSPF will never detect the scenario where the * neighbor has shutdown and restart again (before the router dead interval expires). */ if ( (sptr_interface->state == OSPF_INTERFACE_DESIGNATED_ROUTER_OTHER) || (sptr_interface->state == OSPF_INTERFACE_BACKUP_DESIGNATED_ROUTER) || (sptr_interface->state == OSPF_INTERFACE_DESIGNATED_ROUTER) ) { ospf_execute_interface_state_machine( OSPF_NEIGHBOR_CHANGE, sptr_interface->state, sptr_interface); } ospf_neighbor_state_transition_printf (sptr_neighbor, OSPF_ONE_WAY, old_state); ++sptr_neighbor->events; return;}/**************************************************************************************//* section 10.3, State: Any (p. 85-86) */void ospf_process_neighbor_down_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_down_event\r\n"); old_state = sptr_neighbor->state; sptr_neighbor->state = OSPF_NEIGHBOR_DOWN; sptr_neighbor->last_exchange = 0x00000000L; sptr_neighbor->last_hello = 0x00000000L; sptr_neighbor->inactivity_timer_enabled = FALSE; sptr_neighbor->cryptographic_sequence_number = 0x00000000L; if (sptr_interface->designated_router.address == sptr_neighbor->address) { sptr_interface->designated_router.state = OSPF_NEIGHBOR_DOWN; } else if (sptr_interface->backup_designated_router.address == sptr_neighbor->address ) { sptr_interface->backup_designated_router.state = OSPF_NEIGHBOR_DOWN; } ospf_clear_advertisements_from_lists (sptr_interface, sptr_neighbor); ospf_decrement_appropriate_neighbor_state_counters (sptr_interface, old_state, sptr_neighbor->state); ospf_update_flags_due_to_adjacency_tear_down (sptr_interface); if (old_state > OSPF_NEIGHBOR_INITIALIZING) { ospf_execute_interface_state_machine (OSPF_NEIGHBOR_CHANGE, sptr_interface->state, sptr_interface); } ospf_neighbor_state_transition_printf (sptr_neighbor, OSPF_INACTIVITY_TIMER, old_state);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -