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

📄 ospf_receive_update.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 4 页
字号:
/* ospf_receive_update.c  - OSPF receive update *//* Copyright 2000-2002 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------02r,03jul03,ram Changed surogate hello to reset counter regardless of neighbor                 state02q,26may03,agi Changed rwos_get_system_elapsed_time_second() to                ospf_get_system_elapsed_time_second()02p,22apr03,ram SPR#76812 Modifications for OSPF performance enhancements02o,28jan03,ram SPR 85050 Added support for external route redistribution based                on OSPF external metric values02n,16dec01,mwv Remove static void                 ospf_install_a_received_external_lsa_in_rest_of_the_areas ()                It was not used and it was causing compile warning.02m,09dec02,hme Fixed SPR#75796, ANVL 37.102l,03dec02,ram SPR 84312 - Change elapsed time to return seconds02k,27nov02,fli Fixed memory leaking when adding/deleting external route                 (SPR#83981).02j,19nov02,mwv     Merge TMS code SPR 8428402i,04nov02,fli     Fixed external route does not get deleted (SPR# 83819).02h,24oct02,hme     Fixed memory leak for external lsas (SPR# 83420).                    Everytime an external LSA is received, we were leaking 60 bytes.02g,12oct02,hme     Fixed TSR#294348.                    Changed ospf_process_more_recent_link_state_advertisement() to:                    (1) first install the new LSA into the LSDB                    (2) then invoke ospf_flood_advertisement_out_some_subset_of_the_routers_interfaces()                    with the parameter advertisement_installed set to TRUE.02f,13may02,ark	    Added in fix for SPR 75793. Changed ospf_find_LSA to                    ospf_find_network_LSA if LSA type is OSPF_LS_NETWORK02e,19apr02,jkw     Fix memory leak for external lsas.02d,18apr02,jkw     Fix SPR 74428 and SPR 73041.  Routes being exported to RTM more than                    once.02c,16apr02,jkw     One copy of external and type 11 lsa02b,05feb02,jkw     Fix invalid routes not being deleted.02a,30jan02,jkw     Fix routes not being propagated.01z,19jan02,jkw     Fix SPR 72111 and 72127. Invalid routes.01y,20dec01,jkw		Removed sptr_area->sptr_interfaces structure.01x,28nov01,jkw		Virtual link updates.01w,23aug01,jkw		Fixed compiler warnings.01v,22aug01,jkw     Added opaque lsa updates.01u,13aug01,kc      Fixed compiler warnings.01t,9may01,aos      Added __RFC2328_FLOODING_MODIFICATIONS__ compiler directive to                    support RFC 2328 flooding modifications01s,3may01,jkw      Added checks for NULL pointers and alarm messages01r,26sep00,reshma	Added WindRiver CopyRight01q,25sep00,reshma  RFC-1587 implementation for OSPF NSSA Option, also tested against                    ANVL.01p,07jul00,reshma  Unix compatibility related changes.01o,04apr00,reshma  Added some MIB support (Read only).Passed all important ANVL OSPF                    tests.01n,23dec99,reshma  Compatibility with VxWorks-IP and VxWorks RTM-interface01m,13aug99,jack    ifdefed lsl control calls01l,17jun99,jack    ospf_process_more_recent_link_state_advertisement  to process received                    update which are self originated - Change is not ANVL tested If                    things break rollback01k,28dec98,jack    Compiled and added some comments01j,11nov98,jack    Config changes, linted and big endian changes01i,30oct98,jack    Incorporate changes for compilation on Vxworks01h,23aug98,jack    ANVL tested OSPF with PATRICIA tree route table and no recursion01g,10aug98,jack    PATRICIA Route Table Based OSPF Code Base01f,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_receive_update.c is used for processing received link state update packets.  This filewill process the link state update and check if the link state advertisements already exist inthe link state database.  If the link state advertisement does not exist then the link stateadvertisement will be installed in the link state database.This file is used whenever a new OSPF link state update is received.*/#include "ospf.h"#if defined (__OSPF_VIRTUAL_STACK__)#include "ospf_vs_lib.h"#endif /* __OSPF_VIRTUAL_STACK__ *//********************************************************************************************************************************/static enum OSPF_PACKET_STATE ospf_process_all_advertisements_in_the_link_state_update_packet (OSPF_LS_UPDATE_HEADER *sptr_ls_update_header,	OSPF_INTERFACE *sptr_interface,ULONG source_address,ULONG destination_address,OSPF_NEIGHBOR *sptr_neighbor);static enum OSPF_PACKET_STATE ospf_process_link_state_advertisement (OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *sptr_advertisement,	USHORT length_of_new_advertisement /* in network order */,OSPF_INTERFACE *sptr_interface, ULONG source_address,	ULONG destination_address,OSPF_NEIGHBOR *sptr_neighbor);static void ospf_process_more_recent_link_state_advertisement (OSPF_DATABASE_INFORMATION_STRUCTURE *sptr_database_information,	OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *sptr_advertisement,OSPF_INTERFACE *sptr_interface,OSPF_NEIGHBOR *sptr_neighbor,	ULONG source_address,ULONG destination_address);#if defined (__RFC_2328__)static void	send_database_copy_back_to_sending_neighbor (OSPF_LS_DATABASE_ENTRY *sptr_database_entry,OSPF_NEIGHBOR *sptr_neighbor,	OSPF_INTERFACE *sptr_interface);#endif /* __RFC_2328__ */static enum TEST ospf_validate_LS_checksum (OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *sptr_advertisement,	USHORT length_of_advertisement /* in network order */);static void ospf_remove_request_from_neighbor_request_list (OSPF_NEIGHBOR *sptr_neighbor,UNION_OSPF_LINK_STATE_ADVERTISEMENT *sptr_advertisement);static void ospf_receive_self_originated_link_state (OSPF_DATABASE_INFORMATION_STRUCTURE *sptr_database_information, OSPF_INTERFACE *sptr_interface);static void ospf_send_direct_acknowledgement (OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *sptr_advertisement,OSPF_INTERFACE *sptr_interface,	OSPF_NEIGHBOR *sptr_neighbor);static enum TEST ospf_make_a_copy_of_new_advertisement_from_rx_update (	UNION_OSPF_LINK_STATE_ADVERTISEMENT **ptr_sptr_union_advertisement,	OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER **ptr_sptr_advertisement_to_be_installed_in_lsdb,	OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *sptr_advertisement_in_rxed_packet, OSPF_INTERFACE *sptr_interface);/*opaque lsa opaque prototype jkw*/#if defined (__OPAQUE_LSA__)static void ospf_install_a_received_type_11_lsa_in_rest_of_the_areas (UNION_OSPF_LINK_STATE_ADVERTISEMENT *sptr_union_new_advertisement, OSPF_AREA_ENTRY* sptr_area_received_in, OSPF_INTERFACE* sptr_interface);#endif /* __OPAQUE_LSA__ */#if defined (__RFC_2328__)static bool ospf_is_lsa_self_originated (OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *sptr_advertisement);static bool ospf_check_if_neighbor_exchange_or_loading(OSPF_NEIGHBOR *sptr_neighbor);#endif /*__RFC_2328__*//**************************************************************************//* section 13 of OSPF specification (page 133-136) */enum OSPF_PACKET_STATE ospf_ls_update_packet_received  (OSPF_LS_UPDATE_HEADER *sptr_ls_update_header,OSPF_NEIGHBOR *sptr_neighbor,	OSPF_INTERFACE *sptr_interface_packet_received_on,ULONG source_address,ULONG destination_address){	enum OSPF_PACKET_STATE packet_state;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_ls_update_packet_received\r\n");	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: ##### LS Update packet received ############################################\r\n");	if (sptr_neighbor->state < OSPF_NEIGHBOR_EXCHANGE)				/* section 13 (page 133) */		{		OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF:  Dropped LS Update packet because neighbor's state is less than Exchange\r\n");		return (OSPF_ERROR_UPDATE_STATE);		}	/* SPR#76812 -- Begin */	/* If neighbor is in full state and an update is received from it, then update	 * the neighbors hello parameters */    sptr_neighbor->periodic_inactivity_time_counter = 0x00000000L;			/* reset inactivity timer */	sptr_neighbor->inactivity_timer_enabled = TRUE;		 /* SPR#76812 -- End */	sptr_neighbor->ls_request_list_has_changed = FALSE;	packet_state = ospf_process_all_advertisements_in_the_link_state_update_packet (sptr_ls_update_header,		sptr_interface_packet_received_on, source_address, destination_address, sptr_neighbor);	if (packet_state != GOOD_RECEIVE)		{		return (packet_state);		}	ospf_generate_network_and_router_link_state_advertisements (sptr_interface_packet_received_on);	/* if any requests were acknowledged, send new request packet */	if ((sptr_neighbor->state > OSPF_NEIGHBOR_EXCHANGE_START) && (sptr_neighbor->ls_request_list_has_changed == TRUE))		{		ospf_send_ls_request_packet (sptr_interface_packet_received_on, sptr_neighbor);		}	return (GOOD_RECEIVE);}/**************************************************************************//* section 13 of OSPF specification (page 133-136) */static enum OSPF_PACKET_STATE ospf_process_all_advertisements_in_the_link_state_update_packet (OSPF_LS_UPDATE_HEADER *sptr_ls_update_header,	OSPF_INTERFACE *sptr_interface,ULONG source_address,ULONG destination_address,OSPF_NEIGHBOR *sptr_neighbor){	OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *sptr_advertisement;	USHORT length_of_new_advertisement;	ULONG number_of_advertisements_left_to_examine;	enum OSPF_PACKET_STATE packet_state;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_process_all_advertisements_in_the_link_state_update_packet\r\n");	sptr_advertisement = &(sptr_ls_update_header->advertisement_header.router);	number_of_advertisements_left_to_examine = sptr_ls_update_header->number_of_advertisements;	number_of_advertisements_left_to_examine = net_to_host_long (number_of_advertisements_left_to_examine);	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: ##### LS Update packet number of LSAs = %d\r\n",number_of_advertisements_left_to_examine);	for (; number_of_advertisements_left_to_examine > 0x00000000L; --number_of_advertisements_left_to_examine)		{		length_of_new_advertisement = sptr_advertisement->ls_header.length;		OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF," ****************>>>> Received Link id in LINK DATA (HEX): %lx LSAlength = %d - %d<<<<<----- \r\n", sptr_advertisement->link.link_id, length_of_new_advertisement, net_to_host_short (length_of_new_advertisement) );		packet_state = ospf_process_link_state_advertisement (sptr_advertisement, length_of_new_advertisement, sptr_interface, source_address,			destination_address, sptr_neighbor);		if (packet_state != GOOD_RECEIVE)			{			return (packet_state);			}		length_of_new_advertisement = net_to_host_short (length_of_new_advertisement);		sptr_advertisement = (OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *) ((ULONG) sptr_advertisement + length_of_new_advertisement);		}	return (GOOD_RECEIVE);}/**************************************************************************//* section 13 of OSPF specification (page 133-136) */static enum OSPF_PACKET_STATE ospf_process_link_state_advertisement (OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *sptr_advertisement,	USHORT length_of_new_advertisement /* in network order */,OSPF_INTERFACE *sptr_interface, ULONG source_address,	ULONG destination_address,OSPF_NEIGHBOR *sptr_neighbor){	OSPF_DATABASE_INFORMATION_STRUCTURE database_information;	OSPF_LS_DATABASE_NODE *sptr_retransmission_node;	OSPF_LS_REQUEST *sptr_ls_request;	OSPF_LS_DATABASE_ENTRY database_entry;	enum TEST test_return_type;	enum TEST request_is_more_recent;	ULONG current_time;	seq_t sequence_number;	USHORT age;	ULONG link_state_id;	ULONG advertising_router;	ULONG current_difference;	ULONG system_elapsed_time;#if defined (__OPAQUE_LSA__)	OSPF_OPAQUE_CALLBACK *sptr_opaque_callback = NULL;	BYTE lsa_type = sptr_advertisement->ls_header.type;	BYTE opaque_type = 0;	UNION_OSPF_LS_ID id;#endif /* __OPAQUE_LSA__ */	OSPF_LS_DATABASE_ENTRY *sptr_database_entry;#if !defined (__RFC_2328__)	OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *sptr_advertisement_to_be_installed_in_lsdb = NULL;	UNION_OSPF_LINK_STATE_ADVERTISEMENT *sptr_union_new_advertisement = NULL;	enum TEST different_lsa;#endif /* !__RFC_2328__*/	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_process_link_state_advertisement\r\n");	current_difference = 0x0000000L;	system_elapsed_time = 0x0000000L;	memset(&database_information, 0, sizeof (OSPF_DATABASE_INFORMATION_STRUCTURE));	/* section 13, item (1) - (page 133) */	test_return_type = ospf_validate_LS_checksum (sptr_advertisement, length_of_new_advertisement);	if (test_return_type == FAIL)		{		OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Discarding advertisement because the checksum is invalid\r\n");		return (GOOD_RECEIVE);		/* checksum is invalid, so discard this advertisement and get the next one from the Link State Update packet */		}	/* section 13, item (2) - (page 133) */#if defined (__OPAQUE_LSA__)	if ((sptr_advertisement->ls_header.type < OSPF_LS_ROUTER) || (sptr_advertisement->ls_header.type > OSPF_LS_TYPE_11))#else /* __OPAQUE_LSA__ */#if !defined (__NSSA__)	if ((sptr_advertisement->ls_header.type < OSPF_LS_ROUTER) || (sptr_advertisement->ls_header.type > OSPF_LS_AS_EXTERNAL))#else	if ((sptr_advertisement->ls_header.type < OSPF_LS_ROUTER) || (sptr_advertisement->ls_header.type > OSPF_LS_TYPE_7))#endif /*__NSSA__*/#endif /* __OPAQUE_LSA__ */		{		OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Discarding advertisement because the LS Type is bad\r\n");		return (GOOD_RECEIVE);		/* unknown LS type, so discard this advertisement and get the next one from the Link State Update packet */		}#if defined (__OPAQUE_LSA__)	if (ospf.opaque_capability == FALSE)		{		if ((sptr_advertisement->ls_header.type == OSPF_LS_TYPE_9) ||			(sptr_advertisement->ls_header.type == OSPF_LS_TYPE_10) ||			(sptr_advertisement->ls_header.type == OSPF_LS_TYPE_11))			{			return (GOOD_RECEIVE);			}		}#endif /* __OPAQUE_LSA__ */	/* section 13, item (3) - (page 133) */	if ((sptr_advertisement->ls_header.type == OSPF_LS_AS_EXTERNAL) && (sptr_interface->sptr_area->flags._bit.stub == TRUE))		{		OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: AS External Link advertisements are not flooded into/throughout stub areas\r\n");		return (GOOD_RECEIVE);		/* AS external link advertisements are not flooded into/throughout stub areas - see section 3.6, (pages 35-36) */		}    /*opaque lsa support type 11 not flooded into stub areas jkw*/#if defined (__OPAQUE_LSA__)

⌨️ 快捷键说明

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