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

📄 ospf_transmit_utilities.c

📁 vxworks下ospf协议栈
💻 C
字号:
/* ospf_transmit_utilities.c *//* Copyright 2000 Wind River Systems, Inc. *//*modification history___________________ 21,10April02,bt			Modified ospf_determine_packet_destination() for NBMA	   20,3may01,jkw				Added checks for NULL pointers and alarm messages 19,26september00,reshma	Added WindRiver CopyRight 18,25september00,reshma	RFC-1587 implementation for OSPF NSSA Option, also tested against ANVL. 17,07july00,reshma			Unix compatibility related changes. 16,04april00,reshma		Added some MIB support (Read only).Passed all important ANVL OSPF tests. 15,23december99,reshma		Compatibility with VxWorks-IP and VxWorks RTM-interface 14,07january99,jack		Change in function ospf_determine_destination to set destination for							virtual links and point to point links 13,06janauary99,jack		Change in function ospf_determine_destination 12,28december98,jack		Compiled and added some comments 11,23november98,jack		Changed %p in printing to %lx 10,11november98,jack		Config changes, linted and big endian changes 09,30october98,jack		Incorporate changes for compilation on Vxworks 08,23august98,jack			ANVL tested OSPF with PATRICIA tree route table and no recursion 07,10august98,jack			PATRICIA Route Table Based OSPF Code Base 06,04june98,jack			Integration with RTM and BGP 05,24april98,jack			RTM changes 04,10july97,cindy			Pre-release v1.52b   03,02october97,cindy		Release Version 1.52 02,22october96,cindy		Release Version 1.50 01,05june96,cindy			First Beta Release*/ /* DESCRIPTIONospf_transmit_utilities.c is used for creating and deleting OSPF packets that need to be transmitted.  This file will find out the correct destination for each OSPF packet.This file is used whenever a new OSPF packet needs to be transmitted.*/#include "ospf.h"#if defined (__OSPF_VIRTUAL_STACK__)#include "ospf_vs_lib.h"#endif /* __OSPF_VIRTUAL_STACK__ *//*******************************************************************************************************************************//******************************************************************************************************************************/OSPF_HEADER *ospf_get_an_ospf_send_packet (ULONG size_of_packet){	OSPF_HEADER *sptr_return;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_get_an_ospf_send_packet\r\n");	sptr_return = (OSPF_HEADER *) buffer_malloc (size_of_packet);	if (sptr_return == NULL)		{		OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: buffer_malloc () failed\n");		OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: error allocating packet of size:%u \r\n", size_of_packet);		ospf_print_memory_error_message_and_free_buffer_if_necessary ((void *) NULL, "OSPF_HEADER");        }	else		{		memset (sptr_return, 0x00, size_of_packet);		OSPF_PRINTF_MEMORY (OSPF_MEMORY_PRINTF, "OSPF: pointer to send packet, %lx\r\n", sptr_return);		}	return (sptr_return);}/**************************************************************************************************************************************/void ospf_free_an_ospf_send_packet (OSPF_HEADER *sptr_tx_packet){/*	OSPF_PRINTF_MEMORY (OSPF_MEMORY_PRINTF,"OSPF: Free of %08lx\r\n",(ULONG) sptr_tx_packet);*/	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_free_an_ospf_send_packet\r\n");	buffer_free ((void *) sptr_tx_packet);	sptr_tx_packet = NULL;	return;}/**********************************************************************************************************************************/ULONG ospf_determine_packet_destination (OSPF_INTERFACE *sptr_interface,OSPF_NEIGHBOR *sptr_neighbor){	ULONG destination;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_determine_packet_destination\r\n");	if (sptr_neighbor != NULL)		{		destination = ospf_determine_destination (sptr_interface, sptr_neighbor);		}	else		{		switch (sptr_interface->type)			{			case OSPF_BROADCAST:				{				if (ospf.ip_multicast == TRUE)					{					switch (sptr_interface->state)						{						case OSPF_INTERFACE_DESIGNATED_ROUTER:						case OSPF_INTERFACE_BACKUP_DESIGNATED_ROUTER:							{							destination = OSPF_ADDR_ALLSPF;							break;							}						default:							{							destination = OSPF_ADDR_ALLDR;							break;							}						}					}				else					{					destination = 0x00000000L;					break;					}				break;				}			case OSPF_NBMA:				{				/*destination = OSPF_ALL_EXCHANGE_NEIGHBORS;*/				/*__NBMA_PTMP__*/				destination = ospf_determine_destination (sptr_interface, sptr_interface->sptr_neighbor);				break;				}#if defined (__RFC_2328__)			/* RFC 2178 G.2 */			case OSPF_POINT_TO_MULTIPOINT:				{				destination = OSPF_ALL_EXCHANGE_NEIGHBORS;				break;				}#endif /*__RFC_2328__*/			case OSPF_POINT_TO_POINT:			case OSPF_VIRTUAL_LINK:				{				destination = ospf_determine_destination (sptr_interface, sptr_interface->sptr_neighbor);				break;				}			default:				{				destination = 0x00000000L;				break;				}			}		}	return (destination);}/******************************************************************************************************************************/ULONG ospf_determine_destination (OSPF_INTERFACE *sptr_interface,OSPF_NEIGHBOR *sptr_neighbor){	ULONG destination;	PARAMETER_NOT_USED (sptr_interface);	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_determine_destination\r\n");#if defined (__UNNUMBERED_LINK__)	/* -bt- */	if((sptr_interface->type == OSPF_POINT_TO_POINT) && (sptr_interface->address == 0))	{		/* set the unnumbered destination ip */		destination = sptr_interface->unnumbered_dest_ip;	}	else#endif	/* __UNNUMBERED_LINK__ -bt- */	if ( (ospf.ip_multicast == TRUE)  && (sptr_interface->type == OSPF_POINT_TO_POINT) /* && (sptr_interface->flags._bit.multicast == TRUE) */)		{		destination = OSPF_ADDR_ALLSPF;		}	else if ( (sptr_interface->type == OSPF_VIRTUAL_LINK) && (sptr_neighbor != NULL) )		{		destination = sptr_neighbor->address;		}	else		{		if (sptr_neighbor != NULL)			{			destination = sptr_neighbor->address;			}		else			{			destination = 0x00000000L;      /*#$-NOTE:note18-$#*/			}		}	return (destination);}

⌨️ 快捷键说明

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