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

📄 ospf_routing_table_lookups.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 3 页
字号:
						{							if (sptr_routing_table_node->sptr_routing_table_entry->path_cost < best_sptr_routing_table_node->sptr_routing_table_entry->path_cost)							{								best_sptr_routing_table_node = sptr_routing_table_node;							}							else if (sptr_routing_table_node->sptr_routing_table_entry->path_cost == best_sptr_routing_table_node->sptr_routing_table_entry->path_cost)							{								if (sptr_routing_table_node->sptr_routing_table_entry->sptr_area->area_id > best_sptr_routing_table_node->sptr_routing_table_entry->sptr_area->area_id)								{									best_sptr_routing_table_node = sptr_routing_table_node;								}							}						}						else if(((sptr_routing_table_node->sptr_routing_table_entry->path_type == OSPF_ROUTE_PATH_TYPE_INTRA) &&						   		(sptr_routing_table_node->sptr_routing_table_entry->sptr_area->area_id != OSPF_BACKBONE)) &&						   		((best_sptr_routing_table_node->sptr_routing_table_entry->path_type != OSPF_ROUTE_PATH_TYPE_INTRA) ||						   		(best_sptr_routing_table_node->sptr_routing_table_entry->sptr_area->area_id == OSPF_BACKBONE)))						{							best_sptr_routing_table_node = sptr_routing_table_node;						}						else if (((sptr_routing_table_node->sptr_routing_table_entry->path_type != OSPF_ROUTE_PATH_TYPE_INTRA) ||								(sptr_routing_table_node->sptr_routing_table_entry->sptr_area->area_id == OSPF_BACKBONE)) &&								((best_sptr_routing_table_node->sptr_routing_table_entry->path_type != OSPF_ROUTE_PATH_TYPE_INTRA) ||								(best_sptr_routing_table_node->sptr_routing_table_entry->sptr_area->area_id == OSPF_BACKBONE)))						{							if (sptr_routing_table_node->sptr_routing_table_entry->path_cost < best_sptr_routing_table_node->sptr_routing_table_entry->path_cost)							{								best_sptr_routing_table_node = sptr_routing_table_node;							}							else if (sptr_routing_table_node->sptr_routing_table_entry->path_cost == best_sptr_routing_table_node->sptr_routing_table_entry->path_cost)							{								if (sptr_routing_table_node->sptr_routing_table_entry->sptr_area->area_id > best_sptr_routing_table_node->sptr_routing_table_entry->sptr_area->area_id)								{									best_sptr_routing_table_node = sptr_routing_table_node;								}							}						}					}					else					{						/* rfc 1583 compliant search */						if (sptr_routing_table_node->sptr_routing_table_entry->path_cost < best_sptr_routing_table_node->sptr_routing_table_entry->path_cost)						{							best_sptr_routing_table_node = sptr_routing_table_node;						}						else if (sptr_routing_table_node->sptr_routing_table_entry->path_cost == best_sptr_routing_table_node->sptr_routing_table_entry->path_cost)						{							if (sptr_routing_table_node->sptr_routing_table_entry->sptr_area->area_id > best_sptr_routing_table_node->sptr_routing_table_entry->sptr_area->area_id)							{								best_sptr_routing_table_node = sptr_routing_table_node;							}						}					}				}			}		}	}	if (best_sptr_routing_table_node != NULL)	{		return (best_sptr_routing_table_node->sptr_routing_table_entry);	}	return (NULL);}/*******************************************************************************//* section 16.3 of OSPF specification (page 158) *//* UNH 4.2 start *//******************************************************************************** ospf_find_routing_table_entry_for_ABR** DESCRIPTION:* This function searches the routing table to find an entry for* the given area border router and for the given area (first fit)* NOTE: For an ABR, there are several ABR routing table entries, one ABR routing table*    entry for each area the router is attached to.* PARAMETERS:*   destination_id_to_look = the router ID of the area border router*   area_id = area id for which to locate a routing table entry.** RETURNS: pointer to the routing table entry*/OSPF_ROUTING_TABLE_ENTRY* ospf_find_routing_table_entry_for_ABR(ULONG destination_id_to_look, ULONG area_id){    OSPF_ROUTING_TABLE_NODE *sptr_routing_table_node = NULL;    OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry = NULL;	ULONG hash_id;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_find_routing_table_entry_for_ABR\r\n");	hash_id = destination_id_to_look;	hash_id = hash_id & OSPF_RT_HASH_MASK;    for (sptr_routing_table_node = ospf.sptr_routing_table_head[OSPF_ROUTE_TABLE_ROUTER][hash_id];         sptr_routing_table_node != NULL;		 sptr_routing_table_node = sptr_routing_table_node->sptr_forward_link)		{		if ((sptr_routing_table_node->sptr_routing_table_entry->destination_type == OSPF_DESTINATION_TYPE_ABR) &&			(sptr_routing_table_node->sptr_routing_table_entry->destination_id == destination_id_to_look) &&			(sptr_routing_table_node->sptr_routing_table_entry->sptr_area->area_id == area_id))	    {            sptr_routing_table_entry = sptr_routing_table_node->sptr_routing_table_entry;        }    }    return sptr_routing_table_entry;}/* UNH 4.2 end *//*******************************************************************************************************************************/OSPF_ROUTING_TABLE_NODE *ospf_find_routing_table_node (ULONG destination_id_to_look, enum OSPF_LS_TYPE lsa_header_type,                                                       enum OSPF_ROUTE_PATH_TYPE path_type,OSPF_AREA_ENTRY *sptr_area)          /* NEWRT LOOKUP */{    OSPF_ROUTING_TABLE_NODE *sptr_routing_table_node;    enum OSPF_ROUTE_DESTINATION_TYPE destination_type;    OSPF_ROUTING_TABLE_NODE *best_sptr_routing_table_node = NULL;    enum BOOLEAN first_pass = TRUE;    ULONG hash_id;	enum OSPF_ROUTE_TABLE_TYPE table_type = OSPF_ROUTE_TABLE_NETWORK;    OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_find_routing_table_node\r\n");    switch(lsa_header_type)    {		case OSPF_LS_SUMMARY_NETWORK:		case OSPF_LS_NETWORK:			destination_type = OSPF_DESTINATION_TYPE_NETWORK;			table_type = OSPF_ROUTE_TABLE_NETWORK;			break;		case OSPF_LS_AS_EXTERNAL:#if defined (__NSSA__)		case OSPF_LS_TYPE_7:#endif /* __NSSA__	*/			destination_type = OSPF_DESTINATION_TYPE_ASE;			break;		case OSPF_LS_SUMMARY_AS_BOUNDARY_ROUTER:		case OSPF_DESTINATION_TYPE_ASBR:			destination_type = OSPF_DESTINATION_TYPE_ASBR;			table_type = OSPF_ROUTE_TABLE_ROUTER;			break;		case OSPF_LS_ROUTER_ABR:			destination_type = OSPF_DESTINATION_TYPE_ABR;			table_type = OSPF_ROUTE_TABLE_ROUTER;			break;		default:			destination_type = OSPF_DESTINATION_TYPE_WILDCARD;			break;	}	hash_id = destination_id_to_look;	hash_id = hash_id & OSPF_RT_HASH_MASK;	/* Look in both router and network tables for destination type wild*/	if(destination_type == OSPF_DESTINATION_TYPE_WILDCARD)	{		for(table_type = OSPF_ROUTE_TABLE_NETWORK; table_type < OSPF_ROUTE_TABLE_MAX; table_type++)		{			for(sptr_routing_table_node = ospf.sptr_routing_table_head[table_type][hash_id];				sptr_routing_table_node != NULL;				sptr_routing_table_node = sptr_routing_table_node->sptr_forward_link)			{        		if ((sptr_routing_table_node->sptr_routing_table_entry->destination_id == destination_id_to_look) &&            	   ((sptr_routing_table_node->sptr_routing_table_entry->path_type == path_type) || (path_type == OSPF_ROUTE_PATH_TYPE_WILDCARD)) &&            	   ((sptr_routing_table_node->sptr_routing_table_entry->sptr_area == sptr_area) || (sptr_area == NULL)))            	{            		if (first_pass)            		{            	    	best_sptr_routing_table_node = sptr_routing_table_node;            	    	first_pass = FALSE;            	    }            		else            	    {#if defined (__RFC_2328__)            		    if (sptr_routing_table_node->sptr_routing_table_entry->path_cost > best_sptr_routing_table_node->sptr_routing_table_entry->path_cost)#else            		    if (sptr_routing_table_node->sptr_routing_table_entry->path_cost < best_sptr_routing_table_node->sptr_routing_table_entry->path_cost)#endif            	        {            		        best_sptr_routing_table_node = sptr_routing_table_node;            	        }            	    }            	}        	}		}	}	else	{		/* Destination type is not wild*/		for(sptr_routing_table_node = ospf.sptr_routing_table_head[table_type][hash_id];			sptr_routing_table_node != NULL;			sptr_routing_table_node = sptr_routing_table_node->sptr_forward_link)		{        	if ((sptr_routing_table_node->sptr_routing_table_entry->destination_type == destination_type) &&               (sptr_routing_table_node->sptr_routing_table_entry->destination_id == destination_id_to_look) &&               ((sptr_routing_table_node->sptr_routing_table_entry->path_type == path_type) || (path_type == OSPF_ROUTE_PATH_TYPE_WILDCARD)) &&               ((sptr_routing_table_node->sptr_routing_table_entry->sptr_area == sptr_area) || (sptr_area == NULL)))            {            	if (first_pass)            	{            	   	best_sptr_routing_table_node = sptr_routing_table_node;            	   	first_pass = FALSE;            	}            	else            	{#if defined (__RFC_2328__)            	    if (sptr_routing_table_node->sptr_routing_table_entry->path_cost > best_sptr_routing_table_node->sptr_routing_table_entry->path_cost)#else            	    if (sptr_routing_table_node->sptr_routing_table_entry->path_cost < best_sptr_routing_table_node->sptr_routing_table_entry->path_cost)#endif                    {            	        best_sptr_routing_table_node = sptr_routing_table_node;                    }                }            }        }	}	return(best_sptr_routing_table_node);}/* Fix for SPR# 297651 (SPR#83274) *//*******************************************************************************************************************************/OSPF_ROUTING_TABLE_NODE *ospf_find_router_or_network_routing_table_node (ULONG destination_id_to_look, enum OSPF_LS_TYPE lsa_header_type,                                                                         enum OSPF_ROUTE_PATH_TYPE path_type,OSPF_AREA_ENTRY *sptr_area){    OSPF_ROUTING_TABLE_NODE *sptr_routing_table_node;    OSPF_ROUTING_TABLE_NODE *best_sptr_routing_table_node = NULL;    enum BOOLEAN first_pass = TRUE;    ULONG hash_id;	enum OSPF_ROUTE_TABLE_TYPE table_type;    OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_find_router_or_network_routing_table_node\r\n");    switch(lsa_header_type)    {        case OSPF_LS_SUMMARY_AS_BOUNDARY_ROUTER:        case OSPF_LS_ROUTER:        case OSPF_LS_ROUTER_ABR:        case OSPF_LS_ROUTER_ASBR:  			table_type = OSPF_ROUTE_TABLE_ROUTER;			break;		default:			table_type = OSPF_ROUTE_TABLE_NETWORK;			break;	}	hash_id = destination_id_to_look;	hash_id = hash_id & OSPF_RT_HASH_MASK;	for(sptr_routing_table_node = ospf.sptr_routing_table_head[table_type][hash_id];		sptr_routing_table_node != NULL;		sptr_routing_table_node = sptr_routing_table_node->sptr_forward_link)	{       	if ((sptr_routing_table_node->sptr_routing_table_entry->destination_id == destination_id_to_look) &&            ((sptr_routing_table_node->sptr_routing_table_entry->path_type == path_type) || (path_type == OSPF_ROUTE_PATH_TYPE_WILDCARD)) &&            ((sptr_routing_table_node->sptr_routing_table_entry->sptr_area == sptr_area) || (sptr_area == NULL)))        {           	if (first_pass)           	{           	   	best_sptr_routing_table_node = sptr_routing_table_node;           	   	first_pass = FALSE;           	}           	else           	{#if defined (__RFC_2328__)           	    if (sptr_routing_table_node->sptr_routing_table_entry->path_cost > best_sptr_routing_table_node->sptr_routing_table_entry->path_cost)#else           	    if (sptr_routing_table_node->sptr_routing_table_entry->path_cost < best_sptr_routing_table_node->sptr_routing_table_entry->path_cost)#endif                {           	        best_sptr_routing_table_node = sptr_routing_table_node;                }            }        }    }    return(best_sptr_routing_table_node);}/* SPR#76812 -- End */

⌨️ 快捷键说明

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