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

📄 ospf_external_route_calculation.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 4 页
字号:
        sptr_routing_table_entry_for_N->path_type = OSPF_ROUTE_PATH_TYPE_1_EXTERNAL;        sptr_routing_table_entry_for_N->path_cost = distance_X + cost_Y;        sptr_routing_table_entry_for_N->type2_cost = 0x00;        }    return;}/*************************************************************************** ospf_install_new_external_path_based_on_cost - install new external path based on cost** This routine will install a new external path based on cost of* external link state advertisements.** <destination_N> External advertisement destination** <sptr_routing_table_entry_for_N> Routing table entry for destination** <distance_X> Distance of path** <cost_Y> Cost of link** <advertisement> Advertisement to be installed** <sptr_routing_table_entry_for_forwarding_address> Routing table entry for forwarding address** <sptr_routing_table_entry_for_ASBR> Routing table entry for ASBR** RETURNS: TRUE or FALSE** ERRNO: N/A** NOMANUAL*//**************************************************************************************//* section 16.4, item (6) OSPF Specification + section 3.5, item (5) RFC-1587 NSSA Option */static enum BOOLEAN ospf_install_new_external_path_based_on_cost (ULONG destination_N,    OSPF_ROUTING_TABLE_NODE *sptr_routing_table_node_for_N, ULONG distance_X,ULONG cost_Y,    UNION_OSPF_LINK_STATE_ADVERTISEMENT *advertisement, OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_forwarding_address,    OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_ASBR){    ULONG tos0_metric =0;    enum OSPF_ROUTING_TABLE_UPDATE_ACTION action;    OSPF_ROUTING_TABLE_ENTRY  *sptr_routing_table_entry_for_N =NULL;    enum BOOLEAN return_value;    OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_install_new_external_path_based_on_cost\r\n");#if !defined (__NSSA__)    tos0_metric = net_to_host_long (advertisement->sptr_external->tos0_metric);#else    tos0_metric = net_to_host_long (advertisement->sptr_type_7->tos0_metric);#endif /*__NSSA__*/    sptr_routing_table_entry_for_N = sptr_routing_table_node_for_N->sptr_routing_table_entry;    action = ospf_compare_costs_of_external_paths (sptr_routing_table_entry_for_N, distance_X, cost_Y, tos0_metric);    switch (action)        {        case OSPF_REPLACE_PATH:            {            return_value = TRUE;            OSPF_PRINTF_ROUTING_TABLE (OSPF_ROUTING_TABLE_PRINTF, "OSPF: Replacing External Path\r\n");            ospf_install_the_external_area_path_to_N_and_replace_rtm_route (destination_N, sptr_routing_table_node_for_N, advertisement,                sptr_routing_table_entry_for_forwarding_address, sptr_routing_table_entry_for_ASBR, distance_X, cost_Y); /* delete followed by an add */            break;            }        case OSPF_ADD_PATH:            {            OSPF_PRINTF_ROUTING_TABLE (OSPF_ROUTING_TABLE_PRINTF, "OSPF: Adding External Path\r\n");#if !defined (__NSSA__)            if ((advertisement->sptr_external->tos0_forwarding_address != 0x00000000L) &&                (sptr_routing_table_entry_for_forwarding_address != NULL))#else            if ((advertisement->sptr_type_7->tos0_forwarding_address != 0x00000000L) &&                (sptr_routing_table_entry_for_forwarding_address != NULL))#endif /*__NSSA__*/                {                return_value = ospf_add_new_path_to_routing_table_entry_and_update_rtm (sptr_routing_table_node_for_N,                    sptr_routing_table_entry_for_forwarding_address->destination_id, sptr_routing_table_entry_for_forwarding_address);                }            else                {                return_value = ospf_add_new_path_to_routing_table_entry_and_update_rtm (sptr_routing_table_node_for_N,                    sptr_routing_table_entry_for_ASBR->destination_id, sptr_routing_table_entry_for_ASBR);                }            break;            }        case OSPF_NO_ACTION:            {            return_value = FALSE;            break;            }        default:            {            return_value = FALSE;            break;            }        }    return (return_value);}/*************************************************************************** ospf_compare_costs_of_external_paths - compares the costs of external paths** This routine will compare the costs of external paths** <sptr_routing_table_entry_for_N> Routing table entry for destination** <distance_X> Distance of path** <cost_Y> Cost of link** <tos0_metric> Metric of external link** RETURNS: OSPF_NO_ACTION or OSPF_ADD_PATH or OSPF_DELETE_PATH or OSPF_REPLACE_PATH** ERRNO: N/A** NOMANUAL*/static enum OSPF_ROUTING_TABLE_UPDATE_ACTION ospf_compare_costs_of_external_paths (OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_N,    ULONG distance_X,ULONG cost_Y,ULONG tos0_metric){    enum OSPF_ROUTING_TABLE_UPDATE_ACTION action;    OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_compare_costs_of_external_paths\r\n");    action = OSPF_NO_ACTION;    if ((tos0_metric & OSPF_ASE_bit_E) != OSPF_ASE_bit_E)        {        if (sptr_routing_table_entry_for_N->path_type == OSPF_ROUTE_PATH_TYPE_1_EXTERNAL)            {            if (sptr_routing_table_entry_for_N->path_cost > distance_X + cost_Y)                {                action = OSPF_REPLACE_PATH;                }            else if (sptr_routing_table_entry_for_N->path_cost == distance_X + cost_Y)                {#if defined (__NSSA__)                                                                  /* Any type 5 LSA*/                if ( sptr_routing_table_entry_for_N->link_type == OSPF_LS_AS_EXTERNAL)                    {                    action = OSPF_REPLACE_PATH;                    }                else if ((sptr_routing_table_entry_for_N->link_type == OSPF_LS_TYPE_7) && (sptr_routing_table_entry_for_N->optional_capabilities._bit.dont_propagate == FALSE) &&                            (sptr_routing_table_entry_for_N->sptr_link_state_origin->sptr_type_7->tos0_forwarding_address != 0x00000000L))                    {                    action = OSPF_REPLACE_PATH;                    }#else                action = OSPF_ADD_PATH;#endif /*__NSSA__*/                }            }        else            {            action = OSPF_REPLACE_PATH;            }        }    else if (sptr_routing_table_entry_for_N->path_type == OSPF_ROUTE_PATH_TYPE_2_EXTERNAL)        {        if (sptr_routing_table_entry_for_N->type2_cost > cost_Y)            {            action = OSPF_REPLACE_PATH;            }        else if (sptr_routing_table_entry_for_N->type2_cost == cost_Y)            {            if (sptr_routing_table_entry_for_N->path_cost > distance_X)                {                action = OSPF_REPLACE_PATH;                }            else if (sptr_routing_table_entry_for_N->path_cost == distance_X)                {                action = OSPF_ADD_PATH;                }            }        }    return (action);}/*************************************************************************** ospf_invalidate_type_7_route_entry - invalidate type 7 routing table entry** This routine will invalidate a type 7 routing table entry.** <sptr_type_7> Type 7 link state advertisement** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/#if defined (__NSSA__)void ospf_invalidate_type_7_route_entry (OSPF_TYPE_7_LINK_ADVERTISEMENT_HEADER *sptr_type_7){    ULONG destination_N =0;    ULONG   tos0_metric =0;    OSPF_ROUTING_TABLE_NODE *sptr_routing_table_node =NULL;    ULONG advertising_router_from_rxed_advertisement =0;    OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_invalidate_type_7_route_entry\r\n");    destination_N = net_to_host_long (sptr_type_7->ls_header.id);    tos0_metric = net_to_host_long (sptr_type_7->tos0_metric);    advertising_router_from_rxed_advertisement = net_to_host_long (sptr_type_7->ls_header.advertising_router);    if ( (tos0_metric & OSPF_ASE_bit_E) == OSPF_ASE_bit_E)        {        sptr_routing_table_node = ospf_find_routing_table_node  (destination_N, (enum OSPF_LS_TYPE) sptr_type_7->ls_header.type,            OSPF_ROUTE_PATH_TYPE_2_EXTERNAL, NULL);  /* NEWRT LOOKUP */        }    else        {        sptr_routing_table_node = ospf_find_routing_table_node (destination_N, (enum OSPF_LS_TYPE) sptr_type_7->ls_header.type,            OSPF_ROUTE_PATH_TYPE_1_EXTERNAL, NULL); /* NEWRT LOOKUP */        }    if ( (sptr_routing_table_node != NULL) &&        (advertising_router_from_rxed_advertisement == sptr_routing_table_node->sptr_routing_table_entry->advertising_router) )        {        ospf_invalidate_routing_table_entry (sptr_routing_table_node, sptr_type_7->network_mask, destination_N, NULL);        /* code removed on 8/2/1998 - No longer needed - this is done in the above function ospf_invalidate_routing_table_entry */        /*#$-NOTE:note40-$#*/        }}#endif /*__NSSA__*//*************************************************************************** ospf_install_the_external_area_path_to_N_and_replace_rtm_route - install external path and update rtm** This routine will install the external area path and replace the rtm route.** <destination_N> External advertisement destination** <sptr_routing_table_node_for_N> Routing table node for destination** <advertisement> Advertisement to be installed** <sptr_routing_table_entry_for_forwarding_address> Routing table entry for forwarding address** <sptr_routing_table_entry_for_ASBR> Routing table entry for ASBR** <distance_X> Distance of path** <cost_Y> Cost of link** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/static void ospf_install_the_external_area_path_to_N_and_replace_rtm_route (ULONG destination_N,    OSPF_ROUTING_TABLE_NODE *sptr_routing_table_node_for_N, UNION_OSPF_LINK_STATE_ADVERTISEMENT *advertisement,    OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_forwarding_address,    OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry_for_ASBR, ULONG distance_X,ULONG cost_Y){    OSPF_ROUTING_TABLE_ENTRY  *sptr_routing_table_entry_for_N =NULL;    OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_install_the_external_area_path_to_N_and_replace_rtm_route\r\n");    sptr_routing_table_entry_for_N = sptr_routing_table_node_for_N->sptr_routing_table_entry;#if defined (__RTM__)    ospf_export_route_to_other_protocols (OSPF_DELETE_PATH, sptr_routing_table_entry_for_N); /* Replace- so delete first */#endif    ospf_install_the_external_area_path_to_N (destination_N, sptr_routing_table_entry_for_N, advertisement,        sptr_routing_table_entry_for_forwarding_address, sptr_routing_table_entry_for_ASBR, distance_X, cost_Y);#if defined (__RTM__)    ospf_export_route_to_other_protocols (OSPF_ADD_PATH, sptr_routing_table_entry_for_N);#endif}/* SPR 85050 -- Begin *//*************************************************************************** ospf_compare_costs_of_external_lsdb_entries** This routine is called to compare the costs of two external lsdb entries* it similar to ospf_compare_costs_of_external_paths however the comparison* is between two tos0_metric values.*** RETURNS: TRUE if new_metric is better than metric, FALSE otherwise** ERRNO: N/A** NOMANUAL*/enum BOOLEAN ospf_compare_costs_of_external_lsdb_entries (ULONG new_metric, ULONG metric){    OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_compare_costs_of_external_lsdb_entries\r\n");    if ((new_metric & OSPF_ASE_bit_E) == OSPF_ASE_bit_E)    {		/* new_metric is type 2 */        if ((metric & OSPF_ASE_bit_E) == OSPF_ASE_bit_E)        {			if((new_metric & 0x00ffffff) < (metric & 0x00ffffff))			{				return(TRUE);			}		}		/* metric is either better or type 1 */		return(FALSE);	}	else	{		/* new_metric is type 1 */		if((metric & OSPF_ASE_bit_E) != OSPF_ASE_bit_E)		{			if((new_metric & 0x00ffffff) >= (metric & 0x00ffffff))			{				return(FALSE);			}		}		/* metric is either worse or type 2 */		return(TRUE);	}}/* SPR 85050 -- End *//**************************************************************************************/

⌨️ 快捷键说明

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