📄 ospf_dynamic_config.c
字号:
OSPF_AREA_ENTRY *sptr_area = NULL; OSPF_AREA_ENTRY *sptr_next_area = NULL; for (sptr_area = ospf.sptr_area_list; sptr_area != NULL; sptr_area = sptr_next_area ) { sptr_next_area = sptr_area->sptr_forward_link; if ( sptr_area->area_id == area_id ) return TRUE; } return FALSE;}/***************************************************************************************** ospf_dynamic_step_intfSm - dynamically invoke the interface state machine** This routine dynamically invoke the interface state machine for the given event and* inteface state.** <event> OSPF interface event** <state> Current OSPF interface state** <sptr_interface> OSPF interface** RETURNS: N/A** ERRNO:N/A** NOMANUAL*/void ospf_dynamic_step_intfSm( enum OSPF_INTERFACE_EVENT event, enum OSPF_INTERFACE_STATE state, OSPF_INTERFACE *sptr_interface ){ if ( sptr_interface != NULL ) ospf_execute_interface_state_machine( event, state, sptr_interface ); return;}/**************************************************************************************** ospf_dynamic_send_default_summary_lsa - dynamically send default summary* LSA for an stub area.** This routine dynamically calculate the shortest path for the given area* and send a default summary LSA for the stub Area. This routine is invoked* when a stub area is configured to sendAreaSummary (previously configured* as sendNoAreaSummary) or the stub default cost has changed.** <sptr_area> OSPF area** RETURNS: N/A** ERRNO:N/A** NOMANUAL*/void ospf_dynamic_send_default_summary_lsa( OSPF_AREA_ENTRY *sptr_area, enum BOOLEAN send_max_age ){ /* do nothing if router is not configured as Area Border Router */ if ( ospf_check_if_area_border_router() == FALSE ) return; if ( sptr_area != NULL ) { /* stub default cost has changed, reclaculate the shortest path for this area */ ospf_calculate_shortest_path_tree (sptr_area); /* originate a default summary into the stub area */ ospf_originate_default_summary_link_into_the_area( sptr_area, send_max_age ); } return;}/***************************************************************************************** ospf_dynamic_create_area_range - dynamically create an address range for an area** This routine dynamically create an address range for the given area. Shortest path* tree will then be rerun to reevaluate the best paths for this area resulting from* the new address range.** <sptr_area> OSPF area** <addr_ranges> OSPF area address ranges** RETURNS: N/A** ERRNO:N/A** NOMANUAL*/void ospf_dynamic_create_area_range( OSPF_AREA_ENTRY *sptr_area, OSPF_ADDRESS_RANGE_LIST_ENTRY *addr_ranges ){ OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "ospf_dynamic_config: Entering ospf_dynamic_create_area_range\r\n"); if (sptr_area == NULL ) return; /* SPR 88613 - Begin */ /* Withdraw the individual advertisements for nodes now in the address range. * MUST do this before adding the address range, or LSAs are not generated for * links within the new range */ ospf_advertise_lsas_contained_in_address_range (addr_ranges, TRUE); if (sptr_area->sptr_address_ranges == NULL) sptr_area->sptr_address_ranges = addr_ranges; else ospf_add_node_to_end_of_list ((OSPF_GENERIC_NODE *) addr_ranges, (OSPF_GENERIC_NODE *) sptr_area->sptr_address_ranges); /* keep track the number of address range that we got */ sptr_area->number_of_address_ranges++; /* need to set "active" flag to correct value */ addr_ranges->active = ospf_is_address_range_active (addr_ranges); if (addr_ranges->active) { /* set cost of address range, if it's active */ addr_ranges->cost = ospf_get_metric_cost_of_address_range(addr_ranges); /* area address range has been created, advertise it */ ospf_generate_summary_lsa_for_address_range (addr_ranges, FALSE); } /* SPR 88613 - End */ return;}/***************************************************************************************** ospf_dynamic_destroy_area_range - dynamically destory an address range for an area** This routine dynamically destroy an address range for the given area. The shortest* path tree for the area will be reevaluated due to the changes to the address range.** <sptr_area> OSPF area** <addr_ranges> OSPF area address ranges** RETURNS: N/A** ERRNO:N/A** NOMANUAL*/void ospf_dynamic_destroy_area_range( OSPF_AREA_ENTRY *sptr_area, OSPF_ADDRESS_RANGE_LIST_ENTRY *addr_range ){ OSPF_ADDRESS_RANGE_LIST_ENTRY *sptr_addr_range; OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "ospf_dynamic_config: Entering ospf_dynamic_destroy_area_range\r\n"); if ( (sptr_area == NULL) || (addr_range == NULL) ) return; for (sptr_addr_range = sptr_area->sptr_address_ranges; sptr_addr_range != NULL; sptr_addr_range = sptr_addr_range->sptr_forward_link) { if ( (sptr_addr_range->area_id == addr_range->area_id) && (sptr_addr_range->network == addr_range->network) && (sptr_addr_range->mask == addr_range->mask) ) { break; } } /* it is ok to try to delete a non-existence addres range */ if ( sptr_addr_range == NULL ) return; /* SPR 88613 Begin */ /* Only age out address range if it was active */ if (sptr_addr_range->active) { /* area address range has been deleted, age out LSA for that range * Must do this before removing node from list, so that the check in * ospf_flood.c (ospf_flood_advertisement_out_some_subset_of_the_routers_interfaces) * will find the address range and allow the LSA to go through */ ospf_generate_summary_lsa_for_address_range (addr_range, TRUE); } /* SPR 88613 End */ ospf_remove_node_from_list((OSPF_GENERIC_NODE **)&sptr_area->sptr_address_ranges, (OSPF_GENERIC_NODE *)addr_range ); /* if we are here, the adress range has been deleted, decrement the counter */ sptr_area->number_of_address_ranges--; if ( sptr_area->number_of_address_ranges == 0 ) sptr_area->sptr_address_ranges = NULL; /* SPR 88613 Begin */ /* Only advertise links in the address range if it was active (ie, if there * are links to worry about */ if (sptr_addr_range->active) { /* Now advertise all links that used to be summarized */ ospf_advertise_lsas_contained_in_address_range (addr_range, FALSE); } /* SPR 88613 End */ return;}/***************************************************************************************** ospf_dynamic_create_area - dynamically create an OSPF Area** This routine dynamically create an OSPF Area at runtime. It sets up all the necessary* area default values. It also associates an instance of stub area or nssa to the area,* depends on whether the area is defined as stub area or nssa.** <sptr_area> OSPF area** RETURNS: OK or ERROR** ERRNO:N/A** NOMANUAL*/STATUS ospf_dynamic_create_area( OSPF_AREA_ENTRY *sptr_area ){ if ( sptr_area == NULL ) return ERROR; /* initialize the rest of the area parameters */ sptr_area->shortest_path_first_tree.vertex = ospf.router_id; sptr_area->shortest_path_first_tree.vertex_type = OSPF_LS_ROUTER; sptr_area->shortest_path_first_tree.intervening_router = 0x00000000L; sptr_area->run_shortest_path_calculation = FALSE; sptr_area->shortest_path_calculation_time_counter = 0x00000000L; sptr_area->bring_up_virtual_links = FALSE; sptr_area->mib_number_of_link_state_advertisements = 0x00000000L; sptr_area->mib_checksum_sum = 0x00000000L; sptr_area->mib_number_of_type10_lsa = 0x00000000L; sptr_area->mib_type10_checksum_sum = 0x00000000L; /* initialize the hash table list for the area */ ospf_dynamic_init_area_hash_list( sptr_area ); /* determine if this are is defined as stub */ if (sptr_area->flags._bit.stub == TRUE) { OSPF_STUB_AREA_ENTRY *sptr_stub_area; int size; size = sizeof(OSPF_STUB_AREA_ENTRY); sptr_stub_area = (OSPF_STUB_AREA_ENTRY *) table_malloc (1, size); if ( sptr_stub_area == NULL ) { OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "ospf_dynamic_create_area:can't allocate OSPF_STUB_AREA_ENTRY instance!\n"); return ERROR; } memset (sptr_stub_area, 0x00, sizeof (OSPF_STUB_AREA_ENTRY)); sptr_stub_area->sptr_area = sptr_area; if (ospf.sptr_stub_area_list == NULL) ospf.sptr_stub_area_list = sptr_stub_area; else { ospf_add_node_to_end_of_list( (OSPF_GENERIC_NODE *)sptr_stub_area, (OSPF_GENERIC_NODE *)ospf.sptr_stub_area_list ); } /* keep track the number of stub areas that have been configured */ ospf.number_of_stub_areas++; } /* determine if this area is defined for nssa */#if defined(__NSSA__) else if (sptr_area->flags._bit.nssa == TRUE ) { OSPF_NSSA_AREA_ENTRY *sptr_nssa_area; int size; size = sizeof(OSPF_NSSA_AREA_ENTRY); sptr_nssa_area = (OSPF_NSSA_AREA_ENTRY *)table_malloc(1, size); if ( sptr_nssa_area == NULL ) { OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "ospf_dynamic_create_area:can't allocate OSPF_NSSA_AREA_ENTRY instance!\n"); return ERROR; } memset (sptr_nssa_area, 0x00, sizeof (OSPF_NSSA_AREA_ENTRY)); sptr_nssa_area->sptr_area = sptr_area; if (ospf.sptr_nssa_area_list == NULL) ospf.sptr_nssa_area_list = sptr_nssa_area; else { ospf_add_node_to_end_of_list ((OSPF_GENERIC_NODE *)sptr_nssa_area, (OSPF_GENERIC_NODE *)ospf.sptr_nssa_area_list); } /* keep track the number of nssa areas that have been configured */ ospf.number_of_nssa_areas++; }#endif /* __NSSA__ */ if ((ospf.sptr_backbone_area == NULL) && (sptr_area->area_id == OSPF_BACKBONE)) ospf.sptr_backbone_area = sptr_area; if ( ospf.sptr_area_list == NULL ) { /* SPR#76812 */ semTake (ospf_config_mutex, WAIT_FOREVER); ospf.sptr_area_list = sptr_area; semGive (ospf_config_mutex); } else { /* SPR#76812 */ semTake (ospf_config_mutex, WAIT_FOREVER); ospf_add_node_to_end_of_list( (OSPF_GENERIC_NODE *) sptr_area, (OSPF_GENERIC_NODE *) ospf.sptr_area_list ); semGive (ospf_config_mutex); } /* keep track the number of areas that have been configured */ ospf.number_of_areas++; /* force the interfaces list on the area to always point to the head of the overall * interface list in the ospf data structure */ /* SPR#76812 */ semTake (ospf_config_mutex, WAIT_FOREVER); sptr_area->sptr_interfaces = ospf.sptr_interface_list; semGive (ospf_config_mutex); /* check for area border status */ return OK;}/***************************************************************************************** ospf_dynamic_reinit_area - reinitialize the given OSPF Area** This routine reinitialize an existing OSPF Area. All the area-specific parameters* will be reset. Based on the <delete_stub> boolean flag, an existing stub/nssa area* may be destroyed (if the area was previously configured as stub/nssa) or a new* stub/nssa area may be created (if the area is now configured as stub/nssa).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -