📄 igmp_host_receive.c
字号:
/*
$Log:: /OEM Source Code/igmp/igmp_host_receive.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"
/********************************************************************************************/
static void igmp_host_process_membership_query (IGMP_MESSAGE *sptr_igmp_message);
/********************************************************************************************/
void igmp_host_process_received_message (IGMP_MESSAGE *sptr_igmp_message)
{
char ip_address[IP_ADDRESS_PRINT_BUFFER_SIZE];
IGMP_GROUP_CLASS *sptr_group_node;
UINT port;
port = sptr_igmp_message->receiving_port;
switch (sptr_igmp_message->type)
{
case IGMP_MEMBERSHIP_QUERY:
igmp_host_process_membership_query (sptr_igmp_message);
break;
case IGMP_V1_MEMBERSHIP_REPORT:
case IGMP_V2_MEMBERSHIP_REPORT:
sptr_group_node = igmp_get_matching_group_node_on_port (sptr_igmp_message->group_ip_address, port);
if (sptr_group_node == NULL)
{
IGMP_PROTOCOL_ALARM_TRACE (IGMP_ALARM_TRACE, "IGMP Host: Unable to locate node for group %s on port %u for received report.\n",
convert_ip_address_to_dot_format (&ip_address[0], sptr_igmp_message->group_ip_address), port);
return ;
}
sptr_group_node->ip_address_of_last_reporter = sptr_igmp_message->source_ip_address;
sptr_group_node->igmpCacheEntry.igmpCacheLastReporter = sptr_group_node->ip_address_of_last_reporter;
if (sptr_group_node->host_group.state == IGMP_HOST_GROUP_DELAYING_MEMBER_STATE)
{
igmp_process_host_group_state_transition (port, sptr_igmp_message->group_ip_address, IGMP_HOST_GROUP_REPORT_RECEIVED_EVENT);
}
break;
case IGMP_LEAVE_GROUP:
/* IGNORE THE LEAVE GROUP MESSAGE */
break;
default:
IGMP_PROTOCOL_ALARM_TRACE (IGMP_ALARM_TRACE, "IGMP Host: IGMP message received on port %u has INVALID message type.\n",
port);
break;
}
}
/********************************************************************************************/
static void igmp_host_process_membership_query (IGMP_MESSAGE *sptr_igmp_message)
{
char ip_address[IP_ADDRESS_PRINT_BUFFER_SIZE];
IGMP_GROUP_CLASS *sptr_group_node;
UINT port;
ULONG group_ip_address;
UINT max_response_time;
port = sptr_igmp_message->receiving_port;
group_ip_address = sptr_igmp_message->group_ip_address;
max_response_time = sptr_igmp_message->max_response_time;
igmp.port_table[port].ip_address_of_querier = sptr_igmp_message->source_ip_address;
igmp.port_table[port].igmpInterfaceEntry.igmpInterfaceQuerier = igmp.port_table[port].ip_address_of_querier;
/*
NOTE that the check for v1 querier is done before taking appropriate actions for groups for an
important reason. If it was a v1 querier then it would expect a v1 report. and the send routine
would already know of the kind of report to send out.
*/
if (sptr_igmp_message->max_response_time == 0) /* V1 Query */
{
IGMP_PROTOCOL_TRACE (IGMP_TRACE, "IGMP Host: Received Query was generated by V1 router with IP address %s\n",
convert_ip_address_to_dot_format (&ip_address[0], igmp.port_table[port].ip_address_of_querier));
/* start V1 router present timer */
igmp.port_table[port].max_response_time_from_most_recent_query = IGMP_HOST_DEFAULT_V1_MAX_RESPONSE_TIME; /* seconds */
igmp.port_table[port].host_port.v1_router_present = TRUE;
igmp.port_table[port].host_port.v1_router_present_timer = 0;
igmp.port_table[port].igmpInterfaceEntry.igmpInterfaceVersion1QuerierTimer = IGMP_HOST_V1_ROUTER_PRESENT_TIMEOUT;
}
else /* V2 Query */
{
igmp.port_table[port].max_response_time_from_most_recent_query = max_response_time / IGMP_HOST_RESPONSE_TIME_DIVIDER; /* seconds */
}
igmp.port_table[port].igmpInterfaceEntry.igmpInterfaceQueryMaxResponseTime = igmp.port_table[port].max_response_time_from_most_recent_query;
if (group_ip_address == 0x00000000L) /* General Query */
{
for (sptr_group_node = (IGMP_GROUP_CLASS *) get_pointer_to_first_entry_in_list ((LINK *) &igmp.port_table[port].active_group_list);
sptr_group_node != NULL;
sptr_group_node = (IGMP_GROUP_CLASS *) get_pointer_to_next_entry_in_list ((LINK *) &sptr_group_node->links))
{
group_ip_address = sptr_group_node->multicast_group_ip_address;
igmp_process_host_group_state_transition (port, group_ip_address, IGMP_HOST_GROUP_QUERY_RECEIVED_EVENT);
}
}
else /* Group Specific Query */
{
sptr_group_node = igmp_get_matching_group_node_on_port (group_ip_address, port);
if (sptr_group_node == NULL)
{
IGMP_PROTOCOL_ALARM_TRACE (IGMP_ALARM_TRACE, "IGMP Host: Unable to locate node for group %s on port %u for received group specific query.\n",
convert_ip_address_to_dot_format (&ip_address[0], group_ip_address), port);
return ;
}
if ((sptr_group_node->host_group.state == IGMP_HOST_GROUP_DELAYING_MEMBER_STATE) ||
(sptr_group_node->host_group.state == IGMP_HOST_GROUP_IDLE_MEMBER_STATE))
{
igmp_process_host_group_state_transition (port, group_ip_address, IGMP_HOST_GROUP_QUERY_RECEIVED_EVENT);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -