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

📄 ospf_shortest_path_calculation.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 4 页
字号:
        {        sptr_next_hop = ospf_create_next_hop_block ();        if (sptr_next_hop != NULL)            {            sptr_next_hop->next_hop_router = best_neighbor->address;#if defined (__UNNUMBERED_LINK__)            if (best_neighbor->sptr_interface->address == 0x00000000L)                {                sptr_next_hop->outgoing_router_interface = best_neighbor->sptr_interface->port_number;                }            else                {                sptr_next_hop->outgoing_router_interface = best_neighbor->sptr_interface->address;                }#else /* __UNNUMBERED_LINK__ */            sptr_next_hop->outgoing_router_interface = best_neighbor->sptr_interface->address;#endif /* __UNNUMBERED_LINK__ */            return (sptr_next_hop);            }        } 	sptr_next_hop = ospf_inherit_the_set_of_next_hops_from_node_X (sptr_parent->sptr_next_hop);	return (sptr_next_hop);}/**********************************************************************************************************************************/static OSPF_NEXT_HOP_BLOCK *ospf_set_next_hop_when_parent_vertex_is_this_router (OSPF_SHORTEST_PATH_NODE *sptr_destination, OSPF_ROUTER_LINK_PIECE *sptr_link, OSPF_AREA_ENTRY *sptr_area){	OSPF_NEXT_HOP_BLOCK *sptr_next_hop;	OSPF_INTERFACE *sptr_interface = NULL;	OSPF_INTERFACE *sptr_next_interface = NULL;	ULONG router;	ULONG interface_address = 0x00000000;	ULONG next_hop_router = 0x00000000;	ULONG stub_net;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_set_next_hop_when_parent_vertex_is_this_router\r\n");	sptr_next_hop = NULL;	if (sptr_link == NULL)		{		sptr_next_hop = ospf_create_next_hop_block ();		if (sptr_next_hop != NULL)			{			sptr_next_hop->outgoing_router_interface = ospf_find_outgoing_interface_for_router (sptr_destination->vertex, interface_address, &next_hop_router);			}		else			{			return NULL;			}		}	else if (sptr_link->type == OSPF_ROUTER_LINK_TYPE_VIRTUAL)		{		return (NULL);		/* defer the setting of the next hop until the calculation in Section 16.3 */		}	else		{		sptr_next_hop = ospf_create_next_hop_block ();		if (sptr_next_hop != NULL)			{			switch (sptr_link->type)				{				case OSPF_ROUTER_LINK_TYPE_PPP:					{					router = sptr_link->link_id;					router = net_to_host_long (router);					interface_address = sptr_link->link_data;					interface_address = net_to_host_long(interface_address);					sptr_next_hop->outgoing_router_interface = ospf_find_outgoing_interface_for_router (router, interface_address, &next_hop_router);					sptr_next_hop->next_hop_router = next_hop_router;					break;					}				case OSPF_ROUTER_LINK_TYPE_TRANSIT_NETWORK:					{					sptr_next_hop->outgoing_router_interface = sptr_link->link_data;					sptr_next_hop->outgoing_router_interface = net_to_host_long (sptr_next_hop->outgoing_router_interface);					break;					}				case OSPF_ROUTER_LINK_TYPE_STUB_NETWORK:					{					stub_net = net_to_host_long (sptr_link->link_id);					for (sptr_interface = sptr_area->sptr_interfaces; sptr_interface != NULL; sptr_interface = sptr_next_interface)						{						sptr_next_interface = sptr_interface->sptr_forward_link;						if (sptr_interface->area_id == sptr_area->area_id)							{							if (stub_net == (sptr_interface->address & sptr_interface->netmask) )								{#if defined (__UNNUMBERED_LINK__ )								if (sptr_interface->address == 0x00000000) /* unnumbered link */									{									sptr_next_hop->outgoing_router_interface = sptr_interface->port_number;									}								else									{ 									sptr_next_hop->outgoing_router_interface = sptr_interface->address;									}#else /* __UNNUMBERED_LINK__  */					 			sptr_next_hop->outgoing_router_interface = sptr_interface->address;#endif /* __UNNUMBERED_LINK__  */								break;								}                            /* Fix for TSR 297651 (SPR# 83274) */                            else if ((sptr_interface->type == OSPF_POINT_TO_POINT) &&                                      (sptr_interface->sptr_neighbor != NULL) &&                                     (sptr_interface->sptr_neighbor->address == stub_net))                                {#if defined (__UNNUMBERED_LINK__)								if (sptr_interface->address == 0x00000000) /* unnumbered link */									{									sptr_next_hop->outgoing_router_interface = sptr_interface->port_number;									}								else									{ 									sptr_next_hop->outgoing_router_interface = sptr_interface->address;									}#else /* __UNNUMBERED_LINK__  */					 			sptr_next_hop->outgoing_router_interface = sptr_interface->address;#endif /* __UNNUMBERED_LINK__  */                                }							}						}					break;					}				default:					{					table_free (sptr_next_hop);					sptr_next_hop = NULL;					break;					}				}			}		}	return (sptr_next_hop);}/**********************************************************************************************************************************/static OSPF_NEXT_HOP_BLOCK *ospf_set_outgoing_interface_for_a_locally_attached_stub_network (OSPF_ROUTING_TABLE_ENTRY *sptr_routing_table_entry,	OSPF_AREA_ENTRY *sptr_area){	OSPF_INTERFACE *sptr_interface = NULL;	OSPF_INTERFACE *sptr_next_interface = NULL;	OSPF_NEXT_HOP_BLOCK *sptr_next_hop;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_set_outgoing_interface_for_a_locally_attached_stub_network\r\n");	if (sptr_area == NULL)		{		return (NULL);		} 	for (sptr_interface = ospf.sptr_interface_list; sptr_interface != NULL; sptr_interface = sptr_next_interface) 		{		sptr_next_interface = sptr_interface->sptr_forward_link;		if (sptr_interface->area_id == sptr_area->area_id)			{	 		if ( (sptr_interface->address & sptr_interface->netmask) == (sptr_routing_table_entry->destination_id & sptr_routing_table_entry->address_mask) ) 				{ 				sptr_next_hop = (OSPF_NEXT_HOP_BLOCK *) table_malloc (1, sizeof (OSPF_NEXT_HOP_BLOCK));				if (sptr_next_hop != NULL)					{					memset (sptr_next_hop, 0x00, sizeof (OSPF_NEXT_HOP_BLOCK) );					}				else					{					ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *) NULL, "Function: ospf_set_outgoing_interface_for_a_locally_attached_stub_network  OSPF_NEXT_HOP_BLOCK");					return (NULL);					}	 			sptr_next_hop->next_hop_router = 0x00000000L;#if defined (__UNNUMBERED_LINK__ )				if (sptr_interface->address == 0x00000000) /* unnumbered link */					{					sptr_routing_table_entry->sptr_next_hop->outgoing_router_interface = sptr_interface->port_number;					}				else					{ 					sptr_next_hop->outgoing_router_interface = sptr_interface->address;					}#else /* __UNNUMBERED_LINK__  */	 			sptr_next_hop->outgoing_router_interface = sptr_interface->address;#endif /* __UNNUMBERED_LINK__  */				return (sptr_next_hop); 				} 			}		}	return (NULL);}/**********************************************************************************************************************************/static enum TEST ospf_check_if_link_exists_for_ls_header_type_of_ls_router (UNION_OSPF_LINK_STATE_ADVERTISEMENT *sptr_advertisement,ULONG vertex,OSPF_AREA_ENTRY *sptr_area){	OSPF_ROUTER_LINK_PIECE *sptr_router_link;	USHORT number_of_links;	ULONG link_id;	ULONG link_data;	OSPF_LS_DATABASE_ENTRY *sptr_database_entry;	enum TEST test_return_type;	char print_buffer[PRINT_BUFFER_SIZE];	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_check_if_link_exists_for_ls_header_type_of_ls_router\r\n");  	sptr_router_link = &sptr_advertisement->sptr_router->link;  	number_of_links = sptr_advertisement->sptr_router->number_of_links;  	number_of_links = net_to_host_short (number_of_links);  	for (; number_of_links > 0x0000; --number_of_links)  		{  		switch (sptr_router_link->type)  			{  			case OSPF_ROUTER_LINK_TYPE_PPP:  			case OSPF_ROUTER_LINK_TYPE_VIRTUAL:  				{  				link_id = sptr_router_link->link_id;  				link_id = net_to_host_long (link_id);  				if (vertex == link_id)  					{  					return (PASS);  					}  				}				break; /*#$-NOTE:note19-$#*/  			case OSPF_ROUTER_LINK_TYPE_TRANSIT_NETWORK:  				{  				link_data = sptr_router_link->link_data;  				link_data = net_to_host_long (link_data);  				OSPF_CONVERT_IP_ADDRESS_TO_DOT_FORMAT_FOR_DEBUG (print_buffer, link_data); 	  			OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF:    link_data = %s\n", print_buffer);	  			if (link_data == vertex)	  				{	  				return (PASS);	  				}	  			else	  				{	  				link_id = sptr_router_link->link_id;	  				link_id = net_to_host_long (link_id);					/* SPR#76812 -- Begin */					sptr_database_entry = ospf_find_LSA (sptr_area, link_id, 0x00000000L, OSPF_LS_NETWORK);					/* SPR#76812 -- End */					if (sptr_database_entry != NULL)						{						test_return_type = ospf_check_if_link_exists (&sptr_database_entry->advertisement, vertex, sptr_area);						if (test_return_type == PASS)							{							return (PASS);							}						}					}				break;				}			case OSPF_ROUTER_LINK_TYPE_STUB_NETWORK:				{				return (PASS);				break;				}		  	default:		  		{		  		break;		  		}		  	}	  	sptr_router_link = (OSPF_ROUTER_LINK_PIECE *) ((ULONG) sptr_router_link + OSPF_ROUTER_LINK_PIECE_SIZE +	  		((sptr_router_link->number_of_metrics) * OSPF_ROUTER_LINK_METRIC_PIECE_SIZE));	  	}  	return (FAIL);}/********************************************************************************/

⌨️ 快捷键说明

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