📄 ospf_dynamic_config.c
字号:
/* ospf_dynamic_config.c - API for dynamic reconfiguration *//* Copyright 1998-2003 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------02t,30jun03,agi Fixed SPR#88879, ospf does not clean up external LSDB when an interface is brought down02s,06jun03,htm Fixed SPR#86153 - Inside ospf_dynamic_create_interface() Set area_id of virtual interface to backbone/pseudo area_id not to the transit area id. 02r,02jun03,asr Renamed route_proto to route_protocol02q,09may03,kc Fixed SPR#88389 - Added route_proto and is_default_route arguments to ospf_dynamic_flush_external_routes().02p,12may03,asr Changes to make OSPF virtual stack compatible02o,27apr03,kc Fixed SPR#86625 - added ospf_dynamic_send_default_summary_lsa(). Modified ospf_dynamic_create_interface() and ospf_dynamic_reinit_interface() to originate a default summary lsa if the interface is attached to a stub area that is configured to send area summary.02n,15may03,kkz SPR 88613 - Area Address range rewrite: - correct use of "active" flag for address ranges, to track active links - when area address range changes status, correctly age out old LSAs and advertise appropriate new one(s) - fix a logic error in ospf_dynamic_reinit_interface()02m,23may03,agi Changed RWOS semaphores to vxWorks semaphores02l,22apr03,ram SPR#76812 Modifications for OSPF performance enhancements02k,18mar03,kkz SPR 86531 - Fixed ospf_dynamic_reinit_interface() to check ABR status AFTER calling ospf_dynamic_reset_interface()02j,05mar03,mwv SPR 86274 fix a logic error in ospf_dynamic_reinit_interface()02i,19nov02,kc Fixed ospf_dynamic_reset_interface() and ospf_dynamic_reinit_interface() to send router lsa to all other connected areas if the area border router status has changed. Fixed ospf_dynamic_reset_interface() to flush self-originated network lsa if ncessary. Also modified ospf_dynamic_create_interface() and ospf_dynamic_destroy_interface() to send the router lsa using the ospf_notify_areas_for_abr_change(). Flush self-originated network lsa using ospf_flush_network_link_advertisement() in the ospf_dynamic_destroy_interface(). SPR 84478, 84485, 8448602h,03oct02,hme Fixed TSR# 291665 (SPR 83674) ospf_dynamic_create_interface() and ospf_dynamic_destroy_interface() needs to send out router lsa to all areas if the ABR status for the router is changed when interface is added or deleted.02g,08oct02,agi Fixed compiler warnings02f,22jun02,kc Do not saved low-level interface handler when dynamically create an interface.02e,05jun02,kc Modified ospf_dynamic_config_overflow() to correctly set the force_out_of_overflow_state to TRUE when bringing the router out of the overflow state.02d,31may02,kc Fixed MIPS32 compiler warnings.02c,24may02,kc Modified ospf_dynamic_create_interface() to save a local copy of the if_flags and if_index (retrieved from ifnet_structure) to the OSPF_INTERFACE data structure.02b,23apr02,kc Properly keep track the number of areas, stub areas, nssa, virtual interfaces, interfaces and area aggregations that have been configured. Explicitly reset the linked list head pointer for area, stub area, nssa, virtual interface, interfaces and area aggregations to NULL if the counter for such data structure is zero.02a,23apr02,kc Fixed ospf_dynamic_create_interface() - don't join multicast group and don't attempt to obtain the low-level interface handler if interface type is virtual link.01z,23apr02,kc Modified ospf_dynamic_destroy_interface() to also remove the virtual link instance from the virtual interface linked list.01x,19apr02,kc Force routing table to rebuild when an interface is removed in ospf_dynamic_destroy_interface().01w,18apr02,kc Fixed SPR #74432 - Added ospf_dynamic_export_external_routes() and ospf_dynamic_flush_external_routes() routines.01v,19apr02,jkw Fix memory leak for external lsas.01u,10apr02,kc Remerged changed to ospf_dynamic_init_unnumbered_interface() - added net_to_host_long(inet_addr(theAddr)) and ifunit().01t,10apr02,kc Remerged changes for unnumbered interface support. Added new ospf_dynamic_init_unnumbered_interface() function.01s,04apr02,kc Changed ospf_dynamic_create_virtIntf() to complete all the necessary virtual link setup before invoking ospf_dynamic_create_interface(). link setup has been completed.01r,01apr02,kc Modified ospf_dynamic_destroy_interface() to fix crashes when deleting the first interface on the interface list. The pointer to the interface list needs to be adjusted for all areas configured.01q,01apr02,kc Fixed ospf_dynamic_destroy_area() to remove the stub/nssa entry and to free memory allocated for the area entry.01p,25mar02,kc Fixed ospf_dynamic_cleanup_area() again - set the forward pointer for the shortest_path_first_tree to NULL after freeing the memory pointed to by the given pointer.01o,22mar02,kc Fixed ospf_dynamic_cleanup_area() - explictly set the pointer pointed to by sptr_candidate and sptr_summary_advertisement_list_head to NULL after freeing the memory pointed to by the given pointer.01n,22mar02,kc Fixed SPR74261. Added ospf_dynamic_init_area_hash_list() function. Fixed ospf_dynamic_reinit_interface() to correctly put the interface onto the newly configured area.01m,07feb02,kc Modified ospf_dynamic_create_interface() to group all calls to ospf_multicast_group_request() together.01l,22jan02,kc Modified ospf_dynamic_destroy_interface() to fix crashes when deleting an interface. Also modified ospf_dynamic_create_area() to initialize the interface list for the area correctly.01k,17jan02,kc Fixed ospf_dynamic_create_interface() - get low level interface handler from os.01j,21dec01,kc Fixed ospf_dynamic_destroy_interface() routine.01i,20dec01,jkw Removed sptr_area->sptr_interfaces structure.01h,13dec01,kc Added ospf_dynamic_calculate_spf() routine.01g,07dec01,kc Added ospf_dynamic_reset_interface() and ospf_dynamic_reinit_interface() routines.01f,23oct01,kc Fixed type error - renamed ospf_dynamic_destory_neighbor() to ospf_dynamic_destroy_neighbor01e,21oct01,kc Added ospf_dynamic_config_overflow() and ospf_dynamic_flush_opaque_lsa() routines.01d,20oct01,kc Added ospf_dynamic_create_area_range() and ospf_dynamic_destroy_area_range() routines.01c,20oct01,kc Added ospf_dynamic_destory_neighbor() routine.01b,17oct01,kc Modified ospf_dynamic_reinit_area to only create a new instance of stub/nssa if it is not already exist.01a,24sep01,kc Initial file creation.*//*DESCRIPTIONThis module contains various helper functions used by the OSPF ManagmentInterface to configure the OSPF. The intention of this module is to encapsulateall the OSPF specific implementation detail from the MIB API. Notice that thismodule does not acquire any locking mechanism to ensure mutual exclusion whenaccessing the global OSPF data structure. It is the caller responsibility toensure such locking mechanism takes place before calling functions in thismodule.*//* VxWorks standard includes */#include <stdio.h>#include <stdlib.h>#include <vxWorks.h>/* OSPF includes */#include "ospf.h"#if defined (__OSPF_VIRTUAL_STACK__)#include "ospf_vs_lib.h"#endif /* __OSPF_VIRTUAL_STACK__ *//********************************************************************************* ospf_dynamic_cleanup_area - dynamically clean up a given area** This routine dynamically clean up all summary advertisements, link state database* and shortest path information associated with an area. This routine is identical to* the ospf_free_all_the_associated_area_pointers() except that this routine does not* free the allocated memory for the area range.** <sptr_area> OSPF area** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/LOCAL void ospf_dynamic_cleanup_area(OSPF_AREA_ENTRY* sptr_area){ OSPF_ADVERTISEMENT_NODE *sptr_summary_lsa_list; OSPF_ADVERTISEMENT_NODE *sptr_summary_head; OSPF_ADVERTISEMENT_NODE *sptr_next_summary_lsa_list; /* Free area's summary_advertisements */ sptr_summary_head = sptr_area->sptr_summary_advertisement_list_head; for (sptr_summary_lsa_list = sptr_summary_head; sptr_summary_lsa_list != NULL; sptr_summary_lsa_list = sptr_next_summary_lsa_list ) { sptr_next_summary_lsa_list = sptr_summary_lsa_list->sptr_forward_link; ospf_remove_node_from_list((OSPF_GENERIC_NODE **)&sptr_summary_head, (OSPF_GENERIC_NODE*) sptr_summary_lsa_list); table_free ((void*) sptr_summary_lsa_list ); sptr_summary_lsa_list = NULL; } /* Free area's shortest_path tree */ if ( sptr_area->shortest_path_first_tree.sptr_next_hop != NULL ) { ospf_free_entire_list( (OSPF_GENERIC_NODE*)sptr_area->shortest_path_first_tree.sptr_next_hop ); } ospf_free_areas_shortest_path_tree_nodes (sptr_area->sptr_candidate); ospf_free_areas_link_state_database (sptr_area); /* explicitly reset all the area pointers */ sptr_area->shortest_path_first_tree.sptr_forward_link = NULL; sptr_area->shortest_path_first_tree.sptr_backward_link = NULL; sptr_area->shortest_path_first_tree.sptr_next_hop = NULL; sptr_area->sptr_summary_advertisement_list_head = NULL; sptr_area->sptr_candidate = NULL; return;}/***************************************************************************************** ospf_dynamic_init_area_hash_list - dynamically reinitialize hash table for an area** This routine dynamically reinitialize the hash table for an OSPF Area.** <sptr_area> OSPF area** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/LOCAL void ospf_dynamic_init_area_hash_list( OSPF_AREA_ENTRY *sptr_area ){ enum OSPF_LS_TYPE ls_type; ULONG index; OSPF_LS_DATABASE_HEAD *sptr_ls_database_head;#if !defined (__NSSA__) for (ls_type = OSPF_LS_ROUTER; ls_type <= OSPF_LS_AS_EXTERNAL; ++ls_type)#else for (ls_type = OSPF_LS_ROUTER; ls_type <= OSPF_LS_TYPE_7; ++ls_type)#endif /*__NSSA__*/ {#if defined (__NSSA__) if (ls_type == OSPF_LS_MULTICAST ) continue;#endif /*__NSSA__*/ for (index = 0x00000000L, sptr_ls_database_head = &(sptr_area->ls_database_hash_table[ls_type][index]); /* for each hash list */ index < OSPF_HASH_TABLE_SIZE; ++index, sptr_ls_database_head = &(sptr_area->ls_database_hash_table[ls_type][index])) { sptr_ls_database_head->sptr_linear_database_entry = NULL; sptr_ls_database_head->sptr_avl_database_entry = NULL; sptr_ls_database_head->rerun = FALSE; } }#if defined (__OPAQUE_LSA__) for (ls_type = TYPE_9_LSA; ls_type <= TYPE_11_LSA; ++ls_type) { for (index = 0x00000000L, sptr_ls_database_head = &(sptr_area->opaque_ls_database_hash_table[ls_type][index]); /* for each hash list */ index < OSPF_HASH_TABLE_SIZE; ++index, sptr_ls_database_head = &(sptr_area->opaque_ls_database_hash_table[ls_type][index])) { sptr_ls_database_head->sptr_linear_database_entry = NULL; sptr_ls_database_head->sptr_avl_database_entry = NULL; sptr_ls_database_head->rerun = FALSE; } }#endif /* __OPAQUE_LSA__ */ return;}/********************************************************************************* ospf_dynamic_destroy_neighbor - dynamically destory an OSPF Neighbor** This routine dynamically destory an OSPF Neighbor. The adjancies with the* neighbor will be destroyed. Neighbor will be removed from the interface list* and all link-state database associated with this neighbor will be removed from* OSPF** <sptr_interface> OSPF interface** <sptr_neighbor> OSPF neighbor associated with interface** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/void ospf_dynamic_destroy_neighbor( OSPF_INTERFACE *sptr_interface, OSPF_NEIGHBOR *sptr_neighbor ) { if ( (sptr_interface == NULL) || (sptr_neighbor == NULL) ) return; /* SPR#76812 */ semTake (ospf_config_mutex, WAIT_FOREVER); /* remove this neighbor from the interface's neighbor list */ ospf_remove_node_from_list((OSPF_GENERIC_NODE **)&(sptr_interface->sptr_neighbor), (OSPF_GENERIC_NODE *)sptr_neighbor); semGive (ospf_config_mutex); /* free all memory occupied by this neighbor instance */ ospf_free_neighbor(sptr_neighbor); }/**************************************************************************************** ospf_dynamic_tear_down_neighbors - tear down the neighbor's adjacency** This routine tear down the neighbr's adjacency. It removes all the link state* advertisements associates with this neighbor.** <sptr_interface> OSPF interface** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/void ospf_dynamic_tear_down_neighbors(OSPF_INTERFACE *sptr_interface){ OSPF_NEIGHBOR *sptr_neighbor; OSPF_NEIGHBOR *sptr_next_neighbor; enum BOOLEAN down; if ( sptr_interface == NULL ) return; down = TRUE; /* tell 'em we are going down */ for (sptr_neighbor = sptr_interface->sptr_neighbor; sptr_neighbor != NULL; sptr_neighbor = sptr_next_neighbor ) { sptr_next_neighbor = sptr_neighbor->sptr_forward_link;; ospf_clear_advertisements_from_lists(sptr_interface, sptr_neighbor); /* send empty hello to tell this neighbor that this interface is going away */ ospf_send_hello(sptr_interface, NULL, down); /* destory the neighbor */ ospf_dynamic_destroy_neighbor( sptr_interface, sptr_neighbor ); } return;}/***************************************************************************************** ospf_dynamic_validate_area - validate if an OSPF Area exists** This routine validates if the given OSPF Area ID is valid.** <area_id> OSPF area identifier** RETURNS: TRUE or FALSE** ERRNO: N/A** NOMANUAL*/enum BOOLEAN ospf_dynamic_validate_area( ULONG area_id ){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -