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

📄 ospf_utilities.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 4 页
字号:
	if (cptr_current_token != NULL)		{		port_number = (USHORT) atoi (cptr_current_token);		cptr_current_token = strtok ((char *) '\0', " ,\t\n;");		if (cptr_current_token != NULL)			{			memset ( ((BYTE *) ospf.port[port_number].config.simple_plain_text_or_md5_password), 0x00, OSPF_AUTHENTICATION_SIZE	);			password_length = (USHORT) strlen (cptr_current_token);			if (password_length <= OSPF_AUTHENTICATION_SIZE)				{																			/* Changes from the previous version regarding processing of authentication_type=1 */				if ( ospf.port[port_number].config.authentication_type == 1)					{					if ( password_length > OSPF_AUTHENTICATION_SIMPLE_SIZE)						{						OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: oversize plain text password at port %u : truncated to 8 bytes\n", port_number);						memcpy ((void *) ospf.port[port_number].config.simple_plain_text_or_md5_password, (void *) cptr_current_token, OSPF_AUTHENTICATION_SIMPLE_SIZE);						}					else						{						memcpy ((void *) ospf.port[port_number].config.simple_plain_text_or_md5_password, (void *) cptr_current_token, password_length);						}					}				else					{						/* MD5 authentication type */					memcpy ((void *) ospf.port[port_number].config.simple_plain_text_or_md5_password, (void *) cptr_current_token, password_length);					}				if (password_length < OSPF_AUTHENTICATION_SIZE)					{					memset ((void *) ((BYTE *) ospf.port[port_number].config.simple_plain_text_or_md5_password + (ULONG) password_length), 0x00, (OSPF_AUTHENTICATION_SIZE - password_length));					}				}			else				{				OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: oversize plain text password at port %u : truncated to 16 bytes\n", port_number);				memcpy ((void *) ospf.port[port_number].config.simple_plain_text_or_md5_password, (void *) cptr_current_token, OSPF_AUTHENTICATION_SIZE);				}			}		/* Reshma:		 * If the authentication type is "Simple Password", we are done and		 * should return immediately. If it is MD5 Authentication Type,		 * continue on to try to get the key ID.		 */		if ( ospf.port[port_number].config.authentication_type == 1)		/* Changes from the previous version regarding processing of authentication_type=1 */			{			return( PASS );			}		cptr_current_token = strtok ((char *) '\0', ",\t\n;");		if (cptr_current_token != NULL)        	{			key_ID = (BYTE) atoi (cptr_current_token);			ospf.port[port_number].config.md5_authentication_key_ID = key_ID;			sptr_authentication_key = (OSPF_AUTHENTICATION_KEY *) table_malloc (1, sizeof (OSPF_AUTHENTICATION_KEY));			if ( sptr_authentication_key != NULL)				{				memset (sptr_authentication_key, 0x0, sizeof (OSPF_AUTHENTICATION_KEY));				}			else				{				OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: Initialization - Function ospf_parse_port_plain_text_or_md5_password: table_malloc failed \r\n");				ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *) NULL, "OSPF_AUTHENTICATION_KEY");				return (FAIL);				}			sptr_authentication_key->key_ID = (BYTE) ospf.port[port_number].config.md5_authentication_key_ID;			memcpy (sptr_authentication_key->md5_16byte_password, ospf.port[port_number].config.simple_plain_text_or_md5_password, OSPF_AUTHENTICATION_SIZE);			if (ospf.port[port_number].config.sptr_authentication_key == NULL)				{				ospf.port[port_number].config.sptr_authentication_key = sptr_authentication_key;				}			else				{				ospf_add_node_to_end_of_list ((OSPF_GENERIC_NODE *) sptr_authentication_key, (OSPF_GENERIC_NODE *) ospf.port[port_number].config.sptr_authentication_key);				}			return (PASS);           	}		}	return (FAIL);}/******************************************************************************/#if (_BYTE_ORDER == _BIG_ENDIAN )ULONG ospf_min (ULONG arg1, ULONG arg2)	  /*#$-NOTE:note36-$#*/{	if (arg1 < arg2)		return (arg1);	else		return (arg2);}#endif /* _BYTE_ORDER == _BIG_ENDIAN *//******************************************************************************/enum TEST ospf_export_route_to_other_protocols (enum OSPF_ROUTING_TABLE_UPDATE_ACTION action,	OSPF_ROUTING_TABLE_ENTRY *sptr_ospf_route_entry_to_export){	OSPF_NEXT_HOP_BLOCK	*sptr_next_hop_block;	OSPF_ROUTE_QUEUE_ENTRY *sptr_ospf_route_queue_entry;	enum TEST return_code;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_export_route_to_other_protocols\r\n");	if (sptr_ospf_route_entry_to_export->destination_type == OSPF_DESTINATION_TYPE_ASBR  ||		sptr_ospf_route_entry_to_export->destination_type == OSPF_DESTINATION_TYPE_ABR  ||		sptr_ospf_route_entry_to_export->destination_type == OSPF_DESTINATION_TYPE_WILDCARD )		{		return (FAIL);		}	OSPF_PRINTF_RTM (OSPF_RTM_PRINTF, "OSPF_RTM_PRINTF: In function ospf_export_route_to_other_protocols  \r\n");	for (sptr_next_hop_block = sptr_ospf_route_entry_to_export->sptr_next_hop; sptr_next_hop_block != NULL;		sptr_next_hop_block = sptr_next_hop_block->sptr_forward_link)		{		sptr_ospf_route_queue_entry = table_malloc (1, sizeof (OSPF_ROUTE_QUEUE_ENTRY));		if (sptr_ospf_route_queue_entry == NULL)			{			ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *) NULL, "OSPF_ROUTE_QUEUE_ENTRY");			return (FAIL);			}		memset (sptr_ospf_route_queue_entry, 0x00, sizeof (OSPF_ROUTE_QUEUE_ENTRY));		return_code = ospf_convert_ospf_route_table_entry_into_ip_route ((IP_ROUTE_ENTRY*) &(sptr_ospf_route_queue_entry->ip_route_entry),			sptr_ospf_route_entry_to_export, sptr_next_hop_block);		if (return_code == FAIL)			{			table_free (sptr_ospf_route_queue_entry);			sptr_ospf_route_queue_entry = NULL;			continue;			}		sptr_ospf_route_queue_entry->action = action;		if (ospf.sptr_ospf_export_route_queue == NULL)			{			ospf.sptr_ospf_export_route_queue = sptr_ospf_route_queue_entry;			sptr_ospf_route_queue_entry->sptr_forward_link = NULL;			sptr_ospf_route_queue_entry->sptr_backward_link = NULL;			}		else			{			ospf_add_node_to_end_of_list ((OSPF_GENERIC_NODE *) sptr_ospf_route_queue_entry,				(OSPF_GENERIC_NODE *) ospf.sptr_ospf_export_route_queue);			}		}	return (PASS);}/******************************************************************************/void ospf_process_export_route_queue (){	OSPF_ROUTE_QUEUE_ENTRY *sptr_ospf_route_queue_entry;	OSPF_ROUTE_QUEUE_ENTRY *sptr_next_ospf_route_queue_entry;	ULONG routes_dequeued;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_process_export_route_queue\r\n");	routes_dequeued = 0x00000000L;	for (sptr_ospf_route_queue_entry = ospf.sptr_ospf_export_route_queue;		(sptr_ospf_route_queue_entry != NULL && routes_dequeued < ospf.ospf_routes_dequeued_per_run); sptr_ospf_route_queue_entry = sptr_next_ospf_route_queue_entry)		{		sptr_next_ospf_route_queue_entry = sptr_ospf_route_queue_entry->sptr_forward_link;		ospf_redistribute_route (sptr_ospf_route_queue_entry->action, &sptr_ospf_route_queue_entry->ip_route_entry);		ospf_remove_node_from_list ( (OSPF_GENERIC_NODE **) &(ospf.sptr_ospf_export_route_queue),			(OSPF_GENERIC_NODE*) sptr_ospf_route_queue_entry);		table_free (sptr_ospf_route_queue_entry);		sptr_ospf_route_queue_entry = NULL;		++routes_dequeued;		}	return;}/********************************************************************************* ospf_process_export_route_queue_all - process the export route queue** This routine will process the entire export route queue.  It is * meant to be called when time sensitivity is not an issue, for example* during shutdown.** RETURNS:*/void ospf_process_export_route_queue_all (){	OSPF_ROUTE_QUEUE_ENTRY *sptr_ospf_route_queue_entry;	OSPF_ROUTE_QUEUE_ENTRY *sptr_next_ospf_route_queue_entry;	OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_process_export_route_queue_all\r\n");	for (sptr_ospf_route_queue_entry = ospf.sptr_ospf_export_route_queue;		  sptr_ospf_route_queue_entry != NULL; 		  sptr_ospf_route_queue_entry = sptr_next_ospf_route_queue_entry)		{		sptr_next_ospf_route_queue_entry = sptr_ospf_route_queue_entry->sptr_forward_link;		ospf_redistribute_route (sptr_ospf_route_queue_entry->action, &sptr_ospf_route_queue_entry->ip_route_entry);		ospf_remove_node_from_list ( (OSPF_GENERIC_NODE **) &(ospf.sptr_ospf_export_route_queue),									 (OSPF_GENERIC_NODE*) sptr_ospf_route_queue_entry);				table_free (sptr_ospf_route_queue_entry);				sptr_ospf_route_queue_entry = NULL;		}		return;}/******************************************************************************/static enum TEST ospf_redistribute_route (enum OSPF_ROUTING_TABLE_UPDATE_ACTION action, IP_ROUTE_ENTRY *sptr_ip_route_entry){	OSPF_ROUTING_TABLE_ENTRY *sptr_ospf_routing_table_entry;	IP_ROUTE_ENTRY ip_route_entry_to_substitute_deleted;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_redistribute_route\r\n");		switch (action)			{			case OSPF_ADD_PATH:				OSPF_PRINTF_RTM (OSPF_RTM_PRINTF, "OSPF_RTM_PRINTF: calling rtm_add_route  \r\n");#if defined (__RTM__)				sptr_ip_route_entry->ipRouteType = INDIRECT_ROUTE_TYPE;	/* Reshma: RTM does not add this Gateway to Routing table unless this routetype is INDIRECT_ROUTE_TYPE */#if defined (__OSPF_ROUTER_STACK__)					rtm_add_route (    #if defined (VIRTUAL_STACK)					ospf.ospf_vsid,    #endif /* VIRTUAL_STACK */					ospf.ospf_rtm_handle,					(void *) sptr_ip_route_entry,					0xffff,					0x00000000L ,					NULL,					NULL					);#else /* __OSPF_ROUTER_STACK__ */				rtm_add_route (ospf.ospf_rtm_handle, (void *) sptr_ip_route_entry, 0xffff,					0x00000000L/* RTM_ADD_ROUTE */, NULL, NULL);#endif /* __OSPF_ROUTER_STACK__ */#endif /* __RTM__ */				break;			/* hme 291001 begin                              */			/* revert the OSPF_REPACE_PATH to pre-TSR291001 */			case OSPF_REPLACE_PATH:				OSPF_PRINTF_RTM (OSPF_RTM_PRINTF, "OSPF_RTM_PRINTF: calling rtm_delete_route  \r\n");#if defined (__RTM__)				sptr_ospf_routing_table_entry = ospf_routing_table_lookup(sptr_ip_route_entry->target,                                                                                          0x00000000L,                                                                                          NULL);				if ( (sptr_ospf_routing_table_entry == NULL) ||                                     (sptr_ospf_routing_table_entry->sptr_next_hop->route_status ==                                     	OSPF_ROUTE_IS_NOT_AVAILABLE_NOW) ) /* ### JACK July */					{					/*rtm_delete_route (ospf.ospf_rtm_handle,                                                            (void *) sptr_ip_route_entry,                                                            0x00000000L  RTM_DELETE_ROUTE  ,                                                            NULL);*/#if defined (__OSPF_ROUTER_STACK__)					rtm_delete_route (    #if defined (VIRTUAL_STACK)							  ospf.ospf_vsid,    #endif /* VIRTUAL_STACK */							  ospf.ospf_rtm_handle,							  (void *) sptr_ip_route_entry,							  0x00000000L,							  NULL);#else /* __OSPF_ROUTER_STACK__ */					rtm_delete_route (ospf.ospf_rtm_handle,					                  (void *) sptr_ip_route_entry,					                  0x00000000L /* RTM_DELETE_ROUTE */ ,                                                          NULL);#endif /* __OSPF_ROUTER_STACK__ */					}				else					{					memset ((void*) &ip_route_entry_to_substitute_deleted, 0x00, sizeof (IP_ROUTE_ENTRY));					ospf_convert_ospf_route_table_entry_into_ip_route (&ip_route_entry_to_substitute_deleted,                                                                                           sptr_ospf_routing_table_entry,                                                                                           sptr_ospf_routing_table_entry->sptr_next_hop);					/*rtm_delete_route (ospf.ospf_rtm_handle,                                                            (void *) sptr_ip_route_entry,                                                            0x00000000L  RTM_DELETE_ROUTE,                                                            &ip_route_entry_to_substitute_deleted);*/#if defined (__OSPF_ROUTER_STACK__)					rtm_delete_route (    #if defined (VIRTUAL_STACK)							  ospf.ospf_vsid,    #endif /* VIRTUAL_STACK */							  ospf.ospf_rtm_handle,							  (void *) sptr_ip_route_entry,							  0x00000000L,							  NULL);#else /* __OSPF_ROUTER_STACK__ */					rtm_delete_route (ospf.ospf_rtm_handle,                                                          (void *) sptr_ip_route_entry,                                                          0x00000000L /* RTM_DELETE_ROUTE */ ,                                                          &ip_route_entry_to_substitute_deleted);#endif /* __OSPF_ROUTER_STACK__ */					}#endif /* __RTM__ */			/* hme 291001 end                                */				break;			case OSPF_DELETE_PATH:#if defined (__RTM__)#if defined (__OSPF_ROUTER_STACK__)				rtm_delete_route (    #if defined (VIRTUAL_STACK)								ospf.ospf_vsid,    #endif /* VIRTUAL_STACK */								ospf.ospf_rtm_handle,								(void *) sptr_ip_route_entry,								0x00000000L,								NULL								);#else /* __OSPF_ROUTER_STACK__ */				rtm_delete_route (ospf.ospf_rtm_handle, (void *) sptr_ip_route_entry,					0x00000000L /* RTM_DELETE_ROUTE */ , NULL /* &ip_route_entry_to_substitute_deleted - No specific route to substitute Jack ### July 7/31 */);#endif /* __OSPF_ROUTER_STACK__ */#endif /* __RTM__ */				break;			default:				OSPF_PRINTF_RTM (OSPF_RTM_PRINTF, "OSPF_RTM_PRINTF: Fn, ospf_export_route_to_other_protocols, Illegal parameters to function ospf_export_route_to_other_protocols: action: %d  \r\n",action);				break;			}	return (PASS);}/******************************************************************************/static enum TEST ospf_convert_ospf_route_table_entry_into_ip_route (IP_ROUTE_ENTRY *sptr_ip_route_entry,	OSPF_ROUTING_TABLE_ENTRY *sptr_ospf_route_entry_to_export, OSPF_NEXT_HOP_BLOCK	*sptr_next_hop_block){	OSPF_AREA_ENTRY *sptr_area;	OSPF_INTERFACE *sptr_interface;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_convert_ospf_route_table_entry_into_ip_route\r\n");	if (sptr_ospf_route_entry_to_export == NULL)		{		return (FAIL);		}	sptr_ip_route_entry->target = sptr_ospf_route_entry_to_export->destination_id;	sptr_ip_route_entry->mask = sptr_ospf_route_entry_to_export->address_mask;	sptr_ip_route_entry->gateway = sptr_next_hop_block->next_hop_router;	/* SPR 74616 - change to get routing table to accept the route		This covers the case of locally attached stub networks	 */	/* SPR 74616 */	/* SPR 81145 */

⌨️ 快捷键说明

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