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

📄 ospf_transmit_request.c

📁 vxworks下ospf协议栈
💻 C
字号:
/* ospf_transmit_request.c *//* Copyright 1998 - 2003 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------  01r,17apr03,mwv    SPR 85906, IP fragmentation on LS request. 01r,18jul01,jkw    Added opaque lsa request for ospf_send_ls_request_packet 01q,11may01,aos    Added null pointer checks 01p,26sep00,reshma Added WindRiver CopyRight 01o,25sep00,reshma RFC-1587 implementation for OSPF NSSA Option, also tested against ANVL. 01n,07jul00,reshma Unix compatibility related changes. 01m,04apr00,reshma Added some MIB support (Read only).Passed all important ANVL OSPF tests. 01l,23dec99,reshma Compatibility with VxWorks-IP and VxWorks RTM-interface 01k,28dec98,jack   Compiled and added some comments 01j,11nov98,jack   Config changes, linted and big endian changes 01i,30oct98,jack   Incorporate changes for compilation on Vxworks 01h,23aug98,jack   ANVL tested OSPF with PATRICIA tree route table and no recursion 01g,10aug98,jack   PATRICIA Route Table Based OSPF Code Base 01f,04jun98,jack   Integration with RTM and BGP 01e,24apr98,jack   RTM changes 01d,10jul97,cindy  Pre-release v1.52b   01c,02oct97,cindy  Release Version 1.52 01b,22oct96,cindy  Release Version 1.50 01a,05jun96,cindy  First Beta Release*//* DESCRIPTIONospf_transmit_request.c is used for transmitting link state request packets. This file is used whenever a new OSPF link state request packet needs to be transmitted.*/#include "ospf.h"#if defined (__OSPF_VIRTUAL_STACK__)#include "ospf_vs_lib.h"#endif /* __OSPF_VIRTUAL_STACK__ *//*******************************************************************************************************************************/static void ospf_new_ls_request (OSPF_HEADER **ptr_to_sptr_packet,OSPF_LS_REQUEST_HEADER **ptr_to_sptr_ls_request_header,	OSPF_LS_REQUESTED_ADVERTISEMENT **ptr_to_sptr_requested_advertisement,ULONG interface_mtu);static void ospf_initialize_ls_request_piece (OSPF_LS_REQUESTED_ADVERTISEMENT *sptr_requested_advertisement,OSPF_LS_REQUEST *sptr_ls_request,	enum OSPF_LS_TYPE type);/********************************************************************************//* section 10.9 of OSPF specification (page 94) */void ospf_send_ls_request_packet (OSPF_INTERFACE *sptr_interface,OSPF_NEIGHBOR *sptr_neighbor){	OSPF_LS_REQUEST *sptr_ls_request;	OSPF_HEADER *sptr_packet;	OSPF_LS_REQUEST_HEADER *sptr_ls_request_header;	OSPF_LS_REQUESTED_ADVERTISEMENT *sptr_requested_advertisement;	ULONG interface_mtu;	ULONG length;	ULONG destination_router;	enum OSPF_LS_TYPE type;	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_send_ls_request_packet\r\n");	if (sptr_neighbor->ls_request_queue_count == 0x0000)		{		return;			/* the link state request list is empty, which means no advertisements need to be requested from this neighbor */		}	interface_mtu = ospf_get_interface_mtu (sptr_interface);	ospf_new_ls_request (&sptr_packet, &sptr_ls_request_header, &sptr_requested_advertisement, interface_mtu);	/* Added change as per TMS PR # 1583	   To make sure the sptr_packet will not be referenced if NULL */	if ( sptr_packet == NULL )		return;   /* don't send */	length = OSPF_PACKET_SIZE;#if defined (__OPAQUE_LSA__)	for (type = OSPF_LS_ROUTER; type <= OSPF_LS_TYPE_11; ++type)							/* for each type of advertisement */#else /* __OPAQUE_LSA__ */#if !defined (__NSSA__)	for (type = OSPF_LS_ROUTER; type <= OSPF_LS_AS_EXTERNAL; ++type)							/* for each type of advertisement */#else	for (type = OSPF_LS_ROUTER; type <= (OSPF_LS_TYPE_7); ++type)							/* for each type of advertisement */#endif /*__NSSA__*/#endif /* __OPAQUE_LSA__ */		{#if defined (__NSSA__)		if (type == OSPF_LS_MULTICAST )			continue;#endif /*__NSSA__*/		for (sptr_ls_request = sptr_neighbor->sptr_ls_request[type]; sptr_ls_request != NULL;			sptr_ls_request = sptr_ls_request->sptr_forward_link)			{			ospf_initialize_ls_request_piece (sptr_requested_advertisement, sptr_ls_request, type);			length += OSPF_LS_REQUESTED_ADVERTISEMENT_SIZE;            /* SPR 85906 -- Begin */            if ((length + OSPF_LS_REQUESTED_ADVERTISEMENT_SIZE + OSPF_MAXIMUM_IP_HEADER_SIZE) > interface_mtu)            /* SPR 85906 -- End */				{				destination_router = ospf_determine_destination (sptr_interface, sptr_neighbor);				ospf_tx_packet (sptr_packet, sptr_interface, OSPF_LINK_STATE_REQUEST_PACKET, length, destination_router, TRUE);				return;				}			sptr_requested_advertisement = (OSPF_LS_REQUESTED_ADVERTISEMENT *) ((ULONG) sptr_requested_advertisement + OSPF_LS_REQUESTED_ADVERTISEMENT_SIZE);			}		}	destination_router = ospf_determine_destination (sptr_interface, sptr_neighbor);	ospf_tx_packet (sptr_packet, sptr_interface, OSPF_LINK_STATE_REQUEST_PACKET, length, destination_router, TRUE);	return;}/***********************************************************************************************************************************/static void ospf_new_ls_request (OSPF_HEADER **ptr_to_sptr_packet,OSPF_LS_REQUEST_HEADER **ptr_to_sptr_ls_request_header,	OSPF_LS_REQUESTED_ADVERTISEMENT **ptr_to_sptr_requested_advertisement,ULONG interface_mtu){	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_new_ls_request\r\n");	*ptr_to_sptr_packet = NULL;	*ptr_to_sptr_packet = ospf_get_an_ospf_send_packet (interface_mtu);	/* Added change as per TMS PR # 1583	   To make sure the ptr_to_sptr_packet will not be referenced if       ospf_get_an_ospf_send_packet() failed. */	if (*ptr_to_sptr_packet == NULL)		{		OSPF_PRINTF_DEBUG (OSPF_ALARM_PRINTF, "OSPF: ospf_new_ls_request::ospf_get_an_ospf_send_packet() failed!\r\n");		return;		}	*ptr_to_sptr_ls_request_header = (OSPF_LS_REQUEST_HEADER *) &((*ptr_to_sptr_packet)->rest_of_packet.ls_request);	*ptr_to_sptr_requested_advertisement = (OSPF_LS_REQUESTED_ADVERTISEMENT *) &((*ptr_to_sptr_ls_request_header)->requested_advertisement);	return;}/**********************************************************************************************************************************/static void ospf_initialize_ls_request_piece (OSPF_LS_REQUESTED_ADVERTISEMENT *sptr_requested_advertisement,OSPF_LS_REQUEST *sptr_ls_request,	enum OSPF_LS_TYPE type){	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Entering ospf_initialize_ls_request_piece\r\n");	sptr_requested_advertisement->reserved_bytes[0] = 0x00;	sptr_requested_advertisement->reserved_bytes[1] = 0x00;	sptr_requested_advertisement->reserved_bytes[2] = 0x00;	sptr_requested_advertisement->type = (BYTE) type;	sptr_requested_advertisement->id = sptr_ls_request->id;	sptr_requested_advertisement->advertising_router = sptr_ls_request->advertising_router;	return;}

⌨️ 快捷键说明

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