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

📄 igmp_transmit.c

📁 路由器协议平台igmp协议设计实现源码。
💻 C
字号:
/*
 $Log:: /OEM Source Code/igmp/igmp_transmit.c                                                      $
 * 
 * 1     4/23/98 9:53p Release Engineer
 * Initial release
 * IGMP v4.1.0
 */
/************************************************************************/
/*  Copyright (C) 1997-1998 RouterWare, Inc.                            */
/*  Unpublished - rights reserved under the Copyright Laws of the       */
/*  United States.  Use, duplication, or disclosure by the              */
/*  Government is subject to restrictions as set forth in               */
/*  subparagraph (c)(1)(ii) of the Rights in Technical Data and         */
/*  Computer Software clause at 252.227-7013.                           */
/*  RouterWare, Inc., 3961 MacArthur Blvd. Suite 212, Newport Beach, CA */
/************************************************************************/
#include "igmp.h"
/********************************************************************************************/
void igmp_transmit_message (UINT port, ULONG group_ip_address, enum IGMP_MESSAGE_TYPE message_type,
	enum BOOLEAN copy_to_router, enum BOOLEAN copy_to_host)
{
	char ip_address[IP_ADDRESS_PRINT_BUFFER_SIZE];
	IGMP_MESSAGE *sptr_igmp_message;
	IGMP_GROUP_CLASS *sptr_matching_group_node;

	sptr_igmp_message = igmp_create_message ();

	if (sptr_igmp_message == NULL)
		{
		IGMP_PROTOCOL_ALARM_TRACE (IGMP_ALARM_TRACE, "IGMP: Failed to create IGMP message to transmit Query for group %s on port %u\n",
				convert_ip_address_to_dot_format (&ip_address[0], group_ip_address), port);

		return;
		}

	sptr_igmp_message->type = message_type;
	
	sptr_igmp_message->group_ip_address = group_ip_address;

	if (message_type == IGMP_MEMBERSHIP_QUERY)
		{
		if (igmp.port_table[port].version == IGMP_VERSION_1)
			{
			sptr_igmp_message->max_response_time = 0;
			}
		else 
			{
			if (group_ip_address == 0x00000000L)
				{
				sptr_igmp_message->max_response_time = igmp.port_table[port].router_port.general_query_max_response_time;
				}
			else
				{
				/* get the matching group node ONLY if group is already present on the port */
				sptr_matching_group_node = igmp_get_matching_group_node_on_port (group_ip_address, port);

				if (sptr_matching_group_node == NULL)
					{
					IGMP_PROTOCOL_ALARM_TRACE (IGMP_ALARM_TRACE, "IGMP: Unable to locate group %s on port %u for sending group specific query.\n",
							convert_ip_address_to_dot_format (&ip_address[0], group_ip_address), port);

					igmp_free_message (sptr_igmp_message);

					return /*(FAIL)*/;
					}
					
				sptr_igmp_message->max_response_time = sptr_matching_group_node->router_group.group_specific_query_interval;
				}		
			}		
		}
	else
		{
		sptr_igmp_message->max_response_time = 0;
		}

	/* the following two lines are for the loopback. Basically, when the host/router receives this message, it should
		have complete info */

	sptr_igmp_message->receiving_port = port;

	sptr_igmp_message->source_ip_address = igmp.port_table[port].ip_address_of_port;

 	igmp_serialize_message (port, sptr_igmp_message);

	if ((copy_to_router == TRUE) && (igmp.port_table[port].router_enabled == TRUE))
		{
		igmp_router_process_received_message (sptr_igmp_message);
		}

	if ((copy_to_host == TRUE) && (igmp.port_table[port].host_enabled == TRUE))
		{
		igmp_host_process_received_message (sptr_igmp_message);
		}

	igmp_free_message (sptr_igmp_message);
}

⌨️ 快捷键说明

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