⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ospf_control.c

📁 vxworks下ospf协议栈
💻 C
字号:
/* ospf_control.c - used for shutting down OSPF router *//* Copyright 1998-2003 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------02u,17jul03,kc      Fixed SPR#88975 - added call to ospf2Mapi_shutdown() in                    ospf_halt_ospf_router().02t,30jun03,agi     closed raw ip socket on shutdown (again)02s,17jun03,agi     reverted closing raw ip socket on shutdown02r,13jun03,agi     SPR#88974, close raw socket on shutdown02q,11jun03,ram     SPR#88965 Separate route table and LSDB hash parameters02p,11jun03,agi     Added deletion of the watch dog02o,30may03,agi     Fixed SPR#88958 halt_ospf_router() is not to close ipSock02n,30may03,agi     fixed halt_ospf_router()02m,27may03,agi     Changed rw_container to ospf_container02l,14may03,asr	    Changes to make OSPF virtual stack compatible02k,27may03,mwv     SPR 87784 ospf_shut_down_router () will call                     ospf_process_export_route_queue_all () to process ALL                     messages in the export route queue 02l,26may03,kc      Fixed SPR#87790 - removed the ospf2Mapi_request() shutdown                     request in ospf_shut_down_ospf_router().02k,14may03,agi     Changed RWOS semaphores to vxWorks semaphores02j,22apr03,ram	    SPR#76812 Modifications for OSPF performance enhancements02i,19nov02,mwv     merge TMS code SPR 8428402h,30aug02,agi     Fixed compiler warnings02g,16apr02,jkw     One copy of external and type 11 lsa02f,01apr02,kc      Change the printf to OSPF_ALARM_PRINTF.02e,13oct01,kc      Dynamic Configuration changes.02d,11oct01,jkw     Set pointer to NULL after table_free.02c,24sep01,kc      Cleaned up receive task related globals after raw socket fixes.02b,21sep01,kc      Removed unused raw socket close() calls.02a,13aug01,kc      Fixed compiler warnings.01z,14aug01,aos     Fixed OSPF shutdown routine01y,20jun01,jkw     Added unnumbered link support01x,3may01,jkw      Added checks for NULL pointers and alarm messages01w,3may01,jkw      Added printf messages for NULL pointers01v 30sep00,reshma  Added raw_sockets to replace direct call to IP.01u,26sep00,reshma  Added WindRiver CopyRight01t,25sep00,reshma  RFC-1587 implementation for OSPF NSSA Option, also tested against ANVL.01s,07jul00,reshma  Unix compatibility related changes.01r,04apr00,reshma  Added some MIB support (Read only).Passed all important ANVL                    OSPF tests.01q,23dec99,reshma  Compatibility with VxWorks-IP and VxWorks RTM-interface01p,13aug99,jack    Compilation fixes no IP case01o,28dec98,jack    Compiled and added some comments01n,02dec98,jack    Changes to remove Vx warnings01m,11nov98,jack    Config changes, linted and big endian changes01l,30oct98,jack    Incorporate changes for compilation on Vxworks01k,27aug98,jack	Added ospf_free_entire_list on,ospf.sptr_external_advertisement_list_head01j,23aug98,jack    ANVL tested OSPF with PATRICIA tree route table and no recursion01i,10aug98,jack    PATRICIA Route Table Based OSPF Code Base01h,07jul98,jack    Patricia RT table related changes - need to be tested01g,19jun98,jack    List routine changes. OSPF add and delete list routines, eventually                     call the rwutils list routines.01f,04jun98,jack    Integration with RTM and BGP01e,24apr98,jack    RTM changes01d,10jul97,cindy   Pre-release v1.52b01c,02oct97,cindy   Release Version 1.5201b,22oct96,cindy   Release Version 1.5001a,05jun96,cindy   First Beta Release*//*DESCRIPTIONospf_control.c is used for shutting down OSPF.This file is used when a user issues a command to shutdown OSPF.*/#include "ospf.h"#if defined (__OSPF_VIRTUAL_STACK__)#include "ospf_vs_lib.h"#endif /* __OSPF_VIRTUAL_STACK__ */#include <ioLib.h>#if defined(__OSPF_ROUTER_STACK__)/* asr: new function prototype */IMPORT RTM_HANDLE protocol_rtm_terminate (    RTM_HANDLE protoRtmHandle#if defined (VIRTUAL_STACK)     , int vsNum#endif /* VIRTUAL_STACK */    );#endif /*__OSPF_ROUTER_STACK__*//******************************************************************************** ospf_kill_all_tasks - kill all OSPF tasks ** This function kills all OSPF tasks.  It does not kill the OSPF RTM task.  * This task is killed by RTM.** RETURNS: N/A** NOMANUAL*/void ospf_kill_all_tasks ()    {    OSPF_TASKS  task;    for (task = OSPF_TASK_TIMER; task < OSPF_NUM_TASKS; task++)        {        if (task == OSPF_TASK_RTM)            {            continue;            }        if (taskDelete (ospf.ospf_tasks[task].task_id) == ERROR)            {            printf (                "Unable to delete OSPF task %s",                ospf.ospf_tasks[task].task_name);            }        }    }/******************************************************************************** ospf_halt_ospf_router - calls the utility functions to clean up OSPF for deletion.** This routine clean up all the data structures and tasks in OSPF.* This is done by acquiring the OSPF mutex and then calling utility* functions to clean up the lists and tasks in OSPF.** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/void  ospf_halt_ospf_router (void)    {	OSPF_PRINTF_PROLOGUE (        OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_halt_ospf_router\r\n");    ospf.protocol_enabled = FALSE;    ospf_shut_down_ospf_router ();#if defined(__OSPF_MIB__)    /* SPR#88975 - force tOspfMapi task to shutdown as well */    ospf2Mapi_shutdown();#endif /* __OSPF_MIB__ */    /* close the raw socket */    close (ipSock);#if defined (__OSPF_ROUTER_STACK__)    /* asr: protocol_rtm_terminate now takes virtual stack ID as well */	#if defined (VIRTUAL_STACK)		protocol_rtm_terminate (ospf.ospf_rtm_handle, ospf.ospf_vsid);	#else 		protocol_rtm_terminate (ospf.ospf_rtm_handle);	#endif /* VIRTUAL_STACK */#else  /*__OSPF_ROUTER_STACK__*/	rtm_deregister_protocol(ospf.ospf_rtm_handle);#endif /*__OSPF_ROUTER_STACK__*/    ospf_deregister_with_ip (NULL,NULL);    ospf_kill_all_tasks ();    }/******************************************************************************* ospf_shut_down_ospf_router - cleans up data structures in OSPF** This routine clean up all the data structures in OSPF.* This is done by flushing out all the link state databases, interfaces,* areas, and external route queue.** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/void ospf_shut_down_ospf_router ()    {	OSPF_CONTAINER_ITERATOR iterator;	OSPF_EXTERNAL_ROUTE *sptr_external_route =NULL;	OSPF_ROUTING_TABLE_NODE *sptr_routing_table_node = NULL;	OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry = NULL;    enum BOOLEAN  goingdown;	OSPF_INTERFACE *sptr_interface = NULL;	OSPF_INTERFACE *sptr_next_interface = NULL;    ULONG index;	enum OSPF_ROUTE_TABLE_TYPE table_type;	OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_shut_down_ospf_router\r\n");	iterator = (OSPF_CONTAINER_ITERATOR)NULL;	sptr_external_route = NULL;	/* Flush out all the self originated LSAs */	ospf_flush_the_link_state_database_of_router_lsa ();	ospf_flush_the_link_state_database_of_network_summary_lsa ();	ospf_flush_the_link_state_database_of_asbr_summary_lsa ();	ospf_flush_the_link_state_database_of_external_lsa ();#if defined (__NSSA__)	ospf_flush_the_link_state_database_of_type_7_lsa ();#endif /* __NSSA__ */	ospf_flush_the_link_state_database_of_network_lsa ();#if defined (__OPAQUE_LSA__)	ospfRemoveAllTypes();#endif /* __OPAQUE_LSA__ */	/* Send empty hello to relinquish DR control */    goingdown = TRUE;	for (sptr_interface = ospf.sptr_interface_list; sptr_interface != NULL; sptr_interface = sptr_next_interface)		{		sptr_next_interface = sptr_interface->sptr_forward_link;		ospf_send_hello (sptr_interface, NULL, goingdown);		}		/*opaque lsa free up lsa 9 and lsa 11 list jkw */#if defined (__OPAQUE_LSA__)	if (ospf.sptr_type_9_callback_list_head != NULL)		{		ospf_free_entire_list ((OSPF_GENERIC_NODE*) ospf.sptr_type_9_callback_list_head);		}	ospf.sptr_type_9_callback_list_head = NULL;	if (ospf.sptr_type_10_callback_list_head != NULL)		{		ospf_free_entire_list ((OSPF_GENERIC_NODE*) ospf.sptr_type_10_callback_list_head);		}	ospf.sptr_type_10_callback_list_head = NULL;	if (ospf.sptr_type_11_callback_list_head != NULL)		{		ospf_free_entire_list ((OSPF_GENERIC_NODE*) ospf.sptr_type_11_callback_list_head);		}	ospf.sptr_type_11_callback_list_head = NULL;#endif /* __OPAQUE_LSA__ */	ospf_free_ospf_classes_area_lists ();	ospf_free_interfaces ();	ospf.sptr_interface_list = NULL;	ospf.sptr_area_list = NULL;	ospf.sptr_backbone_area = NULL;	ospf.sptr_stub_area_list = NULL;	ospf.sptr_nssa_area_list = NULL;	if (ospf.sptr_configured_virtual_links != NULL)    	{		ospf_free_entire_list ((OSPF_GENERIC_NODE*) ospf.sptr_configured_virtual_links);    	}	ospf.sptr_configured_virtual_links = NULL;	if (ospf.sptr_configured_external_routes != NULL)		{		ospf_free_entire_list ((OSPF_GENERIC_NODE*) ospf.sptr_configured_external_routes);		}	ospf.sptr_configured_external_routes = NULL;	if (ospf.sptr_originated_external_routes != NULL)		{		ospf_free_entire_list ((OSPF_GENERIC_NODE*) ospf.sptr_originated_external_routes);		}	ospf.sptr_originated_external_routes = NULL;	/* Remove routes from RTM */	/* SPR#76812 -- Begin */    for(table_type = OSPF_ROUTE_TABLE_NETWORK; table_type < OSPF_ROUTE_TABLE_MAX; table_type++)        {        for(index = 0x00000000L; index < OSPF_RT_HASH_TABLE_SIZE; index++)            {            if(ospf.sptr_routing_table_head[table_type][index] != NULL)			    {                for (sptr_routing_table_node = ospf.sptr_routing_table_head[table_type][index];                     sptr_routing_table_node != NULL;                     sptr_routing_table_node = sptr_routing_table_node->sptr_forward_link)                    {                    if(sptr_routing_table_entry != NULL)                        {                        ospf_export_route_to_other_protocols (                            OSPF_DELETE_PATH,                             sptr_routing_table_entry);                        }                    }                }            }        }    /* SPR#76812 -- End */	/* SPR 87784         *	 * process the queue */	ospf_process_export_route_queue_all();    /* SPR#76812 -- Begin */    for(table_type = OSPF_ROUTE_TABLE_NETWORK; table_type < OSPF_ROUTE_TABLE_MAX; table_type++)        {        for(index = 0x00000000L; index < OSPF_RT_HASH_TABLE_SIZE; index++)            {            if(ospf.sptr_routing_table_head[table_type][index] != NULL)                {                ospf_free_routing_table_nodes (                    ospf.sptr_routing_table_head[table_type][index]);                }            }        }	/* SPR#76812 -- End */    if (ospf.sptr_host_list != NULL)        {        ospf_free_entire_list ((OSPF_GENERIC_NODE*) ospf.sptr_host_list);        }    ospf.sptr_host_list = NULL;    if ((iterator = ospf_container_create_iterator (ospf.sptr_external_route_queue)) == 0)        {        return;        } 	ospf_container_goto_front (iterator);	while (ospf_container_is_at_end (iterator) == false)		{		sptr_external_route = (OSPF_EXTERNAL_ROUTE*) ospf_container_at (iterator);		if (sptr_external_route  != NULL)			{			table_free (sptr_external_route);			sptr_external_route = NULL;			}		ospf_container_next (iterator);		}	ospf_container_free_iterator (iterator);	iterator = 0;	ospf_container_free (ospf.sptr_external_route_queue);	ospf.sptr_external_route_queue = NULL;	if (ospf.sptr_ospf_export_route_queue != NULL)		{		ospf_free_entire_list ((OSPF_GENERIC_NODE*) ospf.sptr_ospf_export_route_queue);		}    /* delete the watchdog timer */    if (ospf.watchdog  != INVALID_HANDLE)        {        wdDelete (ospf.watchdog);        }    } /* ospf_shut_down_ospf_router() */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -