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

📄 ospf_inter_area_route_calculation.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 2 页
字号:
/* ospf_inter_area_route_calculation.c - used for calcuating inter area routes for the routing table *//* Copyright 1998 - 2003 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01w,22jul03,agi    Fixed compiler warning01v,09june03,htm   SPR 87382, ANVL 4.201u,26may03,kkz    SPR 88330, ANVL 27.1502a,22apr03,ram	   SPR#76812 Modifications for OSPF performance enhancements01t,24dec02,dsk    Fixed SPR#75194, ANVL 27.1501s,22nov02,htm    Fix for TSR# 297651 (SPR#83274).01r,13nov01,jkw    Change number of address ranges to ULONG01q,03may01,jkw    Added checks for NULL pointers and alarm messages01p,26sep00,reshma	Added WindRiver CopyRight01o,25sep00,reshma	RFC-1587 implementation for OSPF NSSA Option, also tested against ANVL.01n,07jul00,reshma Unix compatibility related changes.01m,04apr00,reshma Added some MIB support (Read only).Passed all important ANVL OSPF tests.01l,23dec99,reshma Compatibility with VxWorks-IP and VxWorks RTM-interface01k,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_inter_area_route_calculation.c is used for calculating the inter-area routes to a destination.The inter-area routes are calculated using the summary lsas.This file is used whenever the routing table is calculated and there are summary lsas presentin the link state database.*/#include "ospf.h"#if defined (__OSPF_VIRTUAL_STACK__)#include "ospf_vs_lib.h"#endif /* __OSPF_VIRTUAL_STACK__ *//***********************************************************************************************************************************/static enum BOOLEAN ospf_check_configured_area_address_ranges (OSPF_ADVERTISEMENT_NODE *sptr_advertisement_node,OSPF_AREA_ENTRY *sptr_area);static void ospf_create_and_install_a_new_inter_area_entry_for_N (ULONG destination_N,OSPF_ADVERTISEMENT_NODE *sptr_advertisement_node,	OSPF_AREA_ENTRY *sptr_area,ULONG area_border_router_BR,OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_BR,	ULONG cost_IAC, enum BOOLEAN on_new_summary_lsa_received_path);static void ospf_install_the_inter_area_path_to_N (ULONG destination_N,OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_N,	OSPF_ADVERTISEMENT_NODE *sptr_advertisement_node,OSPF_AREA_ENTRY *sptr_area,ULONG area_border_router_BR,	OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_BR,ULONG cost_IAC);static void ospf_install_the_inter_area_path_to_N_and_replace_rtm_route (ULONG destination_N,	OSPF_ROUTING_TABLE_NODE *sptr_routing_table_node_for_N /* ### 7/31 */, OSPF_ADVERTISEMENT_NODE *sptr_advertisement_node,	OSPF_AREA_ENTRY *sptr_area,ULONG area_border_router_BR, OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_BR,	ULONG cost_IAC);/*************************************************************************** ospf_calculate_inter_area_routes - calculate inter area routes** This routine will call the routines to calculate the inter* area routes using summary link state advertisements.** <sptr_area> OSPF area** RETURNS: N/A** ERRNO: N/A** NOMANUAL*//*******************************************************************************//* section 16.2 of OSPF specification (page 156) */void ospf_calculate_inter_area_routes (OSPF_AREA_ENTRY *sptr_area){	OSPF_ADVERTISEMENT_NODE *sptr_advertisement_node =NULL;	OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_calculate_inter_area_routes\r\n");	for (sptr_advertisement_node = sptr_area->sptr_summary_advertisement_list_head; sptr_advertisement_node != NULL;		sptr_advertisement_node = sptr_advertisement_node->sptr_forward_link)		{		ospf_calculate_inter_area_routes_for_a_single_summary_advertisement (sptr_advertisement_node, sptr_area, FALSE);		}	return;}/*************************************************************************** ospf_calculate_inter_area_routes_for_a_single_summary_advertisement - calculate inter area routes for a single summary LSA** This routine will calculate inter area routes using a* single summary link state advertisement.** <sptr_advertisement_node> Advertisement node ** <sptr_area> OSPF area** <on_new_summary_lsa_received_path> Boolean to check if new summary path ** RETURNS: TRUE or FALSE** ERRNO: N/A** NOMANUAL*//*******************************************************************************//* section 16.2 of OSPF specification (page 156) */enum BOOLEAN ospf_calculate_inter_area_routes_for_a_single_summary_advertisement (OSPF_ADVERTISEMENT_NODE *sptr_advertisement_node,	OSPF_AREA_ENTRY *sptr_area, enum BOOLEAN on_new_summary_lsa_received_path){	ULONG tos0_metric =0;	USHORT age =0;	ULONG area_border_router_BR =0;	enum BOOLEAN ignore_advertisement;	ULONG destination_N =0;	OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_BR =NULL;	ULONG cost_IAC =0;	OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_N =NULL;	OSPF_ROUTING_TABLE_NODE *sptr_routing_table_node_for_N =NULL;	enum BOOLEAN return_value;	OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_calculate_inter_area_routes_for_a_single_summary_advertisement\r\n");	tos0_metric = net_to_host_long (sptr_advertisement_node->advertisement.sptr_summary->tos0_metric);	tos0_metric = tos0_metric & OSPF_LSInfinity;	age = net_to_host_short (sptr_advertisement_node->advertisement.sptr_summary->ls_header.age);	area_border_router_BR = net_to_host_long (sptr_advertisement_node->advertisement.sptr_summary->ls_header.advertising_router);	if ((tos0_metric == OSPF_LSInfinity) || (age == OSPF_MAXIMUM_AGE) || (area_border_router_BR == ospf.router_id))	 /*#$-NOTE:note39-$#*/		{		if ( (tos0_metric == OSPF_LSInfinity) || (age == OSPF_MAXIMUM_AGE) )			{            /*ANVL 27.15 start */             /* deleted inter area route by MAXAGE, recompute Routing Table for alternate path */            ospf_schedule_routing_table_build();            /* ANVL27.15 end */			ospf_display_routing_table ();			}		return (FALSE);													/* section 16.2, items (1 & 2) (page 157) */		}	if (sptr_advertisement_node->advertisement.sptr_summary->ls_header.type == OSPF_LS_SUMMARY_NETWORK)		{		if (sptr_area != NULL )			{			ignore_advertisement = ospf_check_configured_area_address_ranges (sptr_advertisement_node, sptr_area);			if (ignore_advertisement == TRUE)				{				return (FALSE);										/* section 16.2, item (3) (page 157) */				}			}		}	sptr_routing_table_entry_for_BR = ospf_find_routing_table_entry (area_border_router_BR, OSPF_DESTINATION_TYPE_ABR,		OSPF_ROUTE_PATH_TYPE_WILDCARD, sptr_area);	/* NEWRT LOOKUP */	if (sptr_routing_table_entry_for_BR == NULL)		{		return (FALSE);											/* section 16.2, item (4) (page 157) */		}	destination_N = net_to_host_long (sptr_advertisement_node->advertisement.sptr_summary->ls_header.id);	/* Mistral Added Change on June 1st */    /* Fix for SPR# 297651 (SPR#83274). Mainly search for any network route with the desired path type which matches       the specified path type. This execludes searching for any network or router route to avoid       the bug that a network/host IP address matches a router ID which causes the new network/host       route not to be installed in ospf routing table*/    sptr_routing_table_node_for_N = ospf_find_router_or_network_routing_table_node (destination_N, sptr_advertisement_node->advertisement.sptr_summary->ls_header.type, 			OSPF_ROUTE_PATH_TYPE_WILDCARD, NULL);	if (sptr_routing_table_node_for_N != NULL)		{		sptr_routing_table_entry_for_N = sptr_routing_table_node_for_N->sptr_routing_table_entry;		}	else		{		sptr_routing_table_entry_for_N = NULL;		}	if (sptr_routing_table_entry_for_N != NULL)		{		if ( (sptr_routing_table_entry_for_N->destination_id == 0x00000000L /* default route */ ) && (destination_N != 0x00000000L) )			{			sptr_routing_table_entry_for_N = NULL; /* Always install a more specific route than default; if available */			}		}	cost_IAC = sptr_routing_table_entry_for_BR->path_cost + tos0_metric;	/*mistral Added Change on June 1st*/	if(sptr_routing_table_entry_for_N == NULL)		{		if ( (sptr_routing_table_entry_for_N != NULL) && (sptr_routing_table_entry_for_N->path_type == OSPF_ROUTE_PATH_TYPE_INTRA)			&& (sptr_routing_table_entry_for_N->destination_id == destination_N) )			{			return (FALSE);													/* section 16.2, item (6) (page 157) */			}		ospf_create_and_install_a_new_inter_area_entry_for_N (destination_N, sptr_advertisement_node, sptr_area, area_border_router_BR,			sptr_routing_table_entry_for_BR, cost_IAC, on_new_summary_lsa_received_path);		return (TRUE);		}	else if ((sptr_routing_table_entry_for_N->path_type == OSPF_ROUTE_PATH_TYPE_1_EXTERNAL) ||		(sptr_routing_table_entry_for_N->path_type == OSPF_ROUTE_PATH_TYPE_2_EXTERNAL))		{		ospf_install_the_inter_area_path_to_N_and_replace_rtm_route (destination_N, sptr_routing_table_node_for_N,			sptr_advertisement_node, sptr_area, area_border_router_BR, sptr_routing_table_entry_for_BR, cost_IAC);		return (TRUE);		}	else if (sptr_routing_table_entry_for_N->path_type == OSPF_ROUTE_PATH_TYPE_INTRA)		{		return (FALSE);													/* section 16.2, item (6) (page 157) */		}	else if (sptr_routing_table_entry_for_N->path_cost > cost_IAC)		/* section 16.2, item (7) (page 158) */		{		ospf_install_the_inter_area_path_to_N_and_replace_rtm_route (destination_N, sptr_routing_table_node_for_N,			sptr_advertisement_node, sptr_area, area_border_router_BR, sptr_routing_table_entry_for_BR, cost_IAC);		return (TRUE);		}	else if (sptr_routing_table_entry_for_N->path_cost == cost_IAC)	/* section 16.2, item (7) (page 158) */		{		return_value = ospf_add_new_path_to_routing_table_entry_and_update_rtm (sptr_routing_table_node_for_N, area_border_router_BR,			sptr_routing_table_entry_for_BR);		return (return_value);		}	return (FALSE);}/*************************************************************************** ospf_check_configured_area_address_ranges - check configured area address range** This routine will check if an area address range is configured* for an area.** <sptr_advertisement_node> Advertisement node ** <sptr_area> OSPF area** RETURNS: TRUE or FALSE** ERRNO: N/A** NOMANUAL*/static enum BOOLEAN ospf_check_configured_area_address_ranges (OSPF_ADVERTISEMENT_NODE *sptr_advertisement_node,OSPF_AREA_ENTRY *sptr_area){	enum BOOLEAN ignore_advertisement;	OSPF_ADDRESS_RANGE_LIST_ENTRY *sptr_address_range =NULL;	ULONG number_of_address_ranges =0;	ULONG link_state_id =0;	ULONG network_mask =0;	OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_check_configured_area_address_ranges\r\n");	ignore_advertisement = FALSE;	sptr_address_range = sptr_area->sptr_address_ranges;	if (sptr_address_range != NULL)		{		for (number_of_address_ranges = sptr_area->number_of_address_ranges; number_of_address_ranges > 0x0000;			--number_of_address_ranges)			{			link_state_id = net_to_host_long (sptr_advertisement_node->advertisement.sptr_summary->ls_header.id);			network_mask = net_to_host_long (sptr_advertisement_node->advertisement.sptr_summary->network_mask);			if ((sptr_address_range->network == link_state_id) && (sptr_address_range->mask == network_mask) &&				(sptr_address_range->active == TRUE))				{				ignore_advertisement = TRUE;				break;				}			sptr_address_range = sptr_address_range->sptr_forward_link;			}

⌨️ 快捷键说明

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