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

📄 ospf_receive_update.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 4 页
字号:
		advertising_router = net_to_host_long (advertising_router);		if ((advertising_router == ospf.router_id) || ((sptr_advertisement->ls_header.type == OSPF_LS_NETWORK) &&			(test_return_type == PASS)))			{			sptr_database_information->new_advertisement.sptr_router = sptr_advertisement;			sptr_database_information->sptr_interface = sptr_interface;			sptr_database_information->sptr_neighbor = sptr_neighbor;			sptr_database_information->source_address = source_address;			sptr_database_information->destination_address = destination_address;			ospf_receive_self_originated_link_state (sptr_database_information, sptr_interface);			ospf_schedule_routing_table_build();			return;			}		/* section 13, item (5c) - (page 143) */		if (sptr_database_information->sptr_database_entry != NULL)			{			ospf_remove_current_database_copy_from_all_neighbors_retransmission_lists (sptr_database_information->sptr_database_entry,				sptr_interface);			}		/* section 13, item (5d) - (page 143) */		sptr_advertisement_to_be_installed_in_lsdb = NULL;		sptr_union_new_advertisement = NULL;		status_of_advertisements_copy_for_installation_in_lsdb = ospf_make_a_copy_of_new_advertisement_from_rx_update (			&sptr_union_new_advertisement, &sptr_advertisement_to_be_installed_in_lsdb, sptr_advertisement, sptr_interface);		if (status_of_advertisements_copy_for_installation_in_lsdb == FAIL )			{			OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "Did not install LSA from link_state_id (HEX):%lx - copy of received LSUPDATE Failed\r\n",				sptr_advertisement->link.link_id);			}		sptr_database_information->new_advertisement.sptr_router = sptr_advertisement_to_be_installed_in_lsdb; /* Fix SPR# 83420 Starts. */        /* section 13, item (5d) - (page 134) */        if (status_of_advertisements_copy_for_installation_in_lsdb == PASS )	        {            /* SPR 83981 --- Begin */            /* For external route the areas has no significant meaning and we don't need to             * intall the route for different area.             */            /* SPR 83981 --- End */            /*opaque lsa add support for flooding type 11 lsa jkw*/#if defined (__OPAQUE_LSA__)            if ( sptr_advertisement->ls_header.type == OSPF_LS_TYPE_11 )                {                ospf_install_a_received_type_11_lsa_in_rest_of_the_areas (sptr_union_new_advertisement, sptr_interface->sptr_area, sptr_interface);                }#endif /* __OPAQUE_LSA__ */            /* SPR 83819 -- Begin             *             *  Moved the call             *      ospf_install_a_new_advertisement_in_the_link_state_database()             *  after             *      ospf_install_a_received_external_lsa_in_rest_of_the_areas();             *  Otherwise the LSA will not get installed in LSDB.             */			/* SPR 85050 */            sptr_database_information->sptr_database_entry =                ospf_install_a_new_advertisement_in_the_link_state_database (                    sptr_database_information->sptr_database_entry,                    sptr_union_new_advertisement,                    sptr_interface->sptr_area,                    &different_lsa, 0);            /* SPR 83819 -- End */            /* SPR 83981 --- Begin */            /* We should release the copy that we made if the installed the LSA is not             * our copy.             */            if (   sptr_database_information->sptr_database_entry->advertisement.sptr_router                != sptr_union_new_advertisement->sptr_router )            {                table_free(sptr_union_new_advertisement->sptr_router);            }            /* SPR 83981 --- End */        }        /* Fix SPR# 83420 Ends.*/        /* HME Fix SPR#75796 ANVL 37.1  Begin*/        sptr_database_information->sptr_database_entry->lock_time_MinLSInterval = sptr_database_information->time_difference;  /*rwos_get_system_elapsed_time_second () - sptr_database_information->sptr_database_entry->ls_database_time_stamp; */        /* HME Fix SPR#75796 ANVL 37.1  End*/        /* section 13, item (5b) - (page 143) */		advertisement_was_flooded_back_out_receiving_interface = ospf_flood_advertisement_out_some_subset_of_the_routers_interfaces (			sptr_advertisement, sptr_interface->sptr_area, sptr_interface, sptr_neighbor, TRUE);		if (advertisement_was_flooded_back_out_receiving_interface)			{			if ((sptr_interface->state == OSPF_INTERFACE_BACKUP_DESIGNATED_ROUTER) && (sptr_interface->designated_router.address == sptr_neighbor->address))				{			  	/*				 * The folowing is decremented in function ospf_send_direct_acknowledgement when neighbor is passed as NULL (MULTICASTED)				 */				ospf_add_entry_to_interfaces_delayed_acknowledgement_list (sptr_interface,sptr_database_information->sptr_database_entry);				}			else if ((sptr_interface->state == OSPF_INTERFACE_BACKUP_DESIGNATED_ROUTER) && (sptr_interface->designated_router.address != sptr_neighbor->address));			else				{			  	/*				 * The folowing is decremented in function ospf_send_direct_acknowledgement when neighbor is passed as NULL (MULTICASTED)				 */				ospf_add_entry_to_interfaces_delayed_acknowledgement_list (sptr_interface,sptr_database_information->sptr_database_entry);				}        }		/* section 13, item (5e) - (page 135) */		if ((advertisement_was_flooded_back_out_receiving_interface == FALSE) && ((sptr_interface->state != OSPF_INTERFACE_BACKUP_DESIGNATED_ROUTER) ||			((sptr_interface->state == OSPF_INTERFACE_BACKUP_DESIGNATED_ROUTER) &&	(sptr_interface->designated_router.address == sptr_neighbor->address))))			{			/* This gets decremented in ospf_send_acknowledgement */			++(sptr_interface->number_of_acknowledgements_on_delayed_acknowledgement_list); /* The following routine decrements this by one */			ospf_send_direct_acknowledgement ( (OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *) sptr_advertisement_to_be_installed_in_lsdb , sptr_interface, NULL);			}		table_free ((void*) sptr_union_new_advertisement);		sptr_union_new_advertisement = NULL;		}	return;}/****************************************************************************************//* section 13, item (1) - (page 133) */static enum TEST ospf_validate_LS_checksum (OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *sptr_advertisement,	USHORT length_of_advertisement /* in network order */){	USHORT age;	enum TEST test_return_type;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_validate_LS_checksum\r\n");	age = sptr_advertisement->ls_header.age;	sptr_advertisement->ls_header.age = 0x0000;		/* temporarily throw out age for checksumming purposes - see section 12.1.7, (page 110) */	test_return_type = ospf_verify_LS_checksum ((void *) sptr_advertisement, length_of_advertisement,		sptr_advertisement->ls_header.checksum);	if (test_return_type == FAIL)		{		OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: BAD CHECKSUM\r\n");		}	sptr_advertisement->ls_header.age = age;		/* restore age to its previous value except keep it in host order */	return (test_return_type);}/*******************************************************************************************************************************/static void ospf_remove_request_from_neighbor_request_list (OSPF_NEIGHBOR *sptr_neighbor,UNION_OSPF_LINK_STATE_ADVERTISEMENT *sptr_advertisement){	OSPF_LS_REQUEST *sptr_ls_request;	OSPF_LS_REQUEST *sptr_next_ls_request;	OSPF_LS_HEADER ls_header;	enum TEST request_is_more_recent;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_remove_request_from_neighbor_request_list\r\n");	for (sptr_ls_request = sptr_neighbor->sptr_ls_request[sptr_advertisement->sptr_router->ls_header.type]; sptr_ls_request != NULL;		sptr_ls_request = sptr_next_ls_request)		{		sptr_next_ls_request = sptr_ls_request->sptr_forward_link;		if ((sptr_advertisement->sptr_router->ls_header.id == sptr_ls_request->id) &&			(sptr_advertisement->sptr_router->ls_header.advertising_router == sptr_ls_request->advertising_router))			{			/*			 * ospf_check_if_more_recent () requires two variables of type OSPF_LS_HEADER as input.  So transfer the necessary fields from			 * the OSPF_LS_REQUEST structure to a temporary OSPF_LS_HEADER structure so we can call the routine properly.			 */			ospf_transfer_fields_from_ls_request_structure_to_ls_header_structure (sptr_ls_request, &ls_header);			request_is_more_recent = ospf_check_if_more_recent (&ls_header, &sptr_advertisement->sptr_router->ls_header, 0x00000000L);			if (request_is_more_recent == PASS)				{				return;				}			else				{				ospf_remove_node_from_list ((OSPF_GENERIC_NODE **) &sptr_neighbor->sptr_ls_request[sptr_advertisement->sptr_router->ls_header.type],					(OSPF_GENERIC_NODE *) sptr_ls_request);				table_free ((void *) sptr_ls_request);				sptr_ls_request = NULL;				--sptr_neighbor->ls_request_queue_count;				if ((sptr_neighbor->ls_request_queue_count == 0x0000) && (sptr_neighbor->state == OSPF_NEIGHBOR_LOADING))					{					ospf_execute_neighbor_state_machine (OSPF_LOADING_DONE, sptr_neighbor->state, sptr_neighbor->sptr_interface, sptr_neighbor);					}				sptr_neighbor->ls_request_list_has_changed = TRUE;				return;				}			}		}	return;}/************************************************************************//* section 13.4 of OSPF specification */static void ospf_receive_self_originated_link_state (OSPF_DATABASE_INFORMATION_STRUCTURE *sptr_database_information, OSPF_INTERFACE *sptr_interface){    OSPF_AREA_ENTRY *sptr_area = sptr_interface->sptr_area;    enum OSPF_LS_TYPE ls_type;	USHORT age = 0x0000;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_receive_self_originated_link_state\r\n");	if (sptr_database_information->found_link_state_advertisement_in_database == FALSE)		{		/* We have received an advertisement that this router is no longer originating.  So flush it from the routing domain. */		age = OSPF_MAXIMUM_AGE;		age = host_to_net_short(age);		ls_type = sptr_database_information->new_advertisement.sptr_router->ls_header.type;		sptr_database_information->new_advertisement.sptr_router->ls_header.age = age;		ospf_flood_advertisement_out_some_subset_of_the_routers_interfaces (sptr_database_information->new_advertisement.sptr_router,			sptr_area, NULL, NULL, FALSE);		}	else		{		ospf_clean_up_retransmit_lists_affiliated_with_this_advertisement (sptr_database_information->sptr_database_entry);		sptr_database_information->sptr_database_entry->advertisement.sptr_router->ls_header.sequence_number =			sptr_database_information->new_advertisement.sptr_router->ls_header.sequence_number;		ospf_originate_new_instance_of_the_link_state_advertisement (sptr_database_information->sptr_database_entry,			sptr_database_information->sptr_interface->sptr_area, TRUE);		}	return;}/*******************************************************************************************************************************/#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){	OSPF_LS_DATABASE_NODE	ls_database_node;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering send_database_copy_back_to_sending_neighbor\r\n");	ls_database_node.sptr_forward_link = NULL;	ls_database_node.sptr_backward_link = NULL;	ls_database_node.sptr_ls_database_entry = sptr_database_entry;	ls_database_node.flood = TRUE;	ls_database_node.periodic_retransmit_time_counter = 0x00000000L;	ospf_send_ls_update (&ls_database_node, sptr_neighbor, sptr_interface, FALSE, TRUE);	return;}#endif /* __RFC_2328__ *//*******************************************************************************************************************************/static void ospf_send_direct_acknowledgement (OSPF_ROUTER_LINK_ADVERTISEMENT_HEADER *sptr_advertisement,OSPF_INTERFACE *sptr_interface,	OSPF_NEIGHBOR *sptr_neighbor){	OSPF_LS_HEADER_QUEUE *sptr_direct_acknowledgement;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_send_direct_acknowledgement\r\n");    if ( sptr_advertisement == NULL )        return;	/*	 * Freed in ospf_transmit_acknowledgement.c line+91. Fn ospf_send_acknowledgement.c	 */	sptr_direct_acknowledgement = (OSPF_LS_HEADER_QUEUE *) table_malloc (1, sizeof (OSPF_LS_HEADER_QUEUE));

⌨️ 快捷键说明

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