📄 macbrmgt.c
字号:
||((filtering_database_type == PERMANENT_DATABASE) && (sptr_matching_fde->type == PERMANENT_TABLE_ENTRY)))
{
delete_entry_from_queue ((LINK *)
&stp_class.sptr_hash_table->entry[sptr_matching_fde->source_address._ushort & stp_class.hash_mask].sptr_forward_link,
&sptr_matching_fde->links);
}
}
}
/****************************************************************************/
FILTERING_DATABASE_ENTRY *find_source_address (LINK *sptr_queue_entry,USHORT source_mac_address_ushort,
ULONG source_mac_address_ulong)
{
while (sptr_queue_entry->sptr_forward_link != NULL)
{
if (((FILTERING_DATABASE_ENTRY *) sptr_queue_entry->sptr_forward_link)->source_address._ushort ==
source_mac_address_ushort
&& ((FILTERING_DATABASE_ENTRY *) sptr_queue_entry->sptr_forward_link)->source_address._ulong ==
source_mac_address_ulong)
{
break;
}
sptr_queue_entry = (LINK *) sptr_queue_entry->sptr_forward_link;
}
return ((FILTERING_DATABASE_ENTRY *) sptr_queue_entry->sptr_forward_link);
}
/****************************************************************************/
void read_filtering_entry (enum FILTERING_DATABASE_TYPE filtering_database_type,
MAC_ADDRESS *sptr_mac_address_to_read,FILTERING_ENTRY_STATUS *sptr_filtering_entry_status)
{
FILTERING_DATABASE_ENTRY *sptr_matching_fde;
sptr_matching_fde =
find_source_address ((LINK *)
&stp_class.sptr_hash_table->entry[sptr_mac_address_to_read->_ushort],
sptr_mac_address_to_read->_ushort,sptr_mac_address_to_read->_ulong);
if (sptr_matching_fde != NULL)
{
if (((filtering_database_type == FILTERING_DATABASE) && (sptr_matching_fde->type == DELETE_ENTRY_ON_TIMEOUT))
||((filtering_database_type == PERMANENT_DATABASE) &&(sptr_matching_fde->type == PERMANENT_TABLE_ENTRY)))
{
sptr_filtering_entry_status->filtering_mac_address = *sptr_mac_address_to_read;
sptr_filtering_entry_status->union_filtering_port.dynamic_port_number = sptr_matching_fde->port_number;
}
}
}
/****************************************************************************/
void read_filtering_entry_range (enum FILTERING_DATABASE_TYPE filtering_database_type,
USHORT database_start_index,USHORT database_stop_index,FILTERING_ENTRY_STATUS *sptr_filtering_entry_status)
{
USHORT database_index;
FILTERING_DATABASE_ENTRY *sptr_matching_fde;
for (database_index = database_start_index; database_index <= database_stop_index; ++database_index)
{
sptr_matching_fde = (FILTERING_DATABASE_ENTRY *) stp_class.sptr_hash_table->entry[database_index].sptr_forward_link;
if ( ((filtering_database_type == FILTERING_DATABASE) && (sptr_matching_fde->type == DELETE_ENTRY_ON_TIMEOUT))
||((filtering_database_type == PERMANENT_DATABASE) && (sptr_matching_fde->type == PERMANENT_TABLE_ENTRY)))
{
sptr_filtering_entry_status->filtering_mac_address = sptr_matching_fde->source_address;
sptr_filtering_entry_status->union_filtering_port.dynamic_port_number = sptr_matching_fde->port_number;
break;
}
}
}
/****************************************************************************/
BRIDGE_PARAMETERS *read_bridge_parameters (void)
{
return ((BRIDGE_PARAMETERS *)&stp_class.this_bridge);
}
/****************************************************************************/
void set_bridge_parameters (USHORT bridge_max_age,USHORT hello_time,USHORT forward_delay,USHORT bridge_priority)
{
stp_class.this_bridge.bridge_id.priority = bridge_priority;
stp_class.this_bridge.bridge_max_age = bridge_max_age;
stp_class.this_bridge.bridge_hello_time = hello_time;
stp_class.this_bridge.bridge_forward_delay = forward_delay;
}
/****************************************************************************/
UNION_FILTERING_STP_PORT_CLASS *read_port_parameters (USHORT port_number)
{
return ((UNION_FILTERING_STP_PORT_CLASS *)&stp_class.port[port_number]);
}
/****************************************************************************/
void force_port_state (USHORT port_number,enum PORT_STATE state)
{
stp_class.port[port_number].state = state;
}
/****************************************************************************/
void set_port_parameters (USHORT port_number,USHORT path_cost,BYTE port_priority)
{
stp_class.port[port_number].path_cost = path_cost;
stp_class.port[port_number].port_id.priority = port_priority;
}
/****************************************************************************/
enum BOOLEAN stp_forwarding_enabled (USHORT port_number)
{
if (stp_class.port[port_number + 1].state == FORWARDING)
return (TRUE);
else
return (FALSE);
}
/*************************************************************************/
void enable_or_disable_stp_printing (enum BOOLEAN enable_or_disable)
{
stp_class.stp_printing_enabled = enable_or_disable;
}
/*************************************************************************/
void enable_or_disable_stp_group_printing (enum BOOLEAN enable_or_disable,enum STP_PRINTF_GROUPS printf_group)
{
switch (printf_group)
{
case STP_MEMORY_PRINTF:
stp_class.memory_printing_enabled = enable_or_disable;
break;
case STP_ALARM_PRINTF:
stp_class.alarm_printing_enabled = enable_or_disable;
break;
case STP_SNMP_PRINTF:
stp_class.snmp_printing_enabled = enable_or_disable;
break;
case STP_DATA_PRINTF:
stp_class.data_printing_enabled = enable_or_disable;
break;
case STP_ALGORITHM_PRINTF:
stp_class.stp_algorithm_printing_enabled = enable_or_disable;
break;
}
}
/*************************************************************************/
void stp_printf (enum STP_PRINTF_GROUPS printf_group,const char *cptr_format, ...)
{
enum BOOLEAN print_string;
va_list argptr;
va_start (argptr,cptr_format);
if (stp_class.stp_printing_enabled == FALSE)
{
va_end (argptr);
return;
}
print_string = FALSE;
switch (printf_group)
{
case STP_MEMORY_PRINTF:
print_string = stp_class.memory_printing_enabled;
break;
case STP_ALARM_PRINTF:
print_string = stp_class.alarm_printing_enabled;
break;
case STP_SNMP_PRINTF:
print_string = stp_class.snmp_printing_enabled;
break;
case STP_DATA_PRINTF:
print_string = stp_class.data_printing_enabled;
break;
case STP_ALGORITHM_PRINTF:
print_string = stp_class.stp_algorithm_printing_enabled;
break;
}
if (print_string == TRUE)
vprintf (cptr_format,argptr);
va_end (argptr);
}
#if defined (DEBUG)
/****************************************************************************/
ULONG counter_t;
/****************************************************************************/
void display_spanning_tree_packet (USHORT port_number,ETHERNET_BUFFER *sptr_rx_packet,USHORT size_of_packet)
{
stp_printf (STP_DATA_PRINTF,"STP: Port Number %04x ",port_number);
if (stp_class.port[port_number].token_ring == TRUE)
{
sptr_rx_packet = (ETHERNET_BUFFER *) ((ULONG) sptr_rx_packet + 2);
}
stp_printf (STP_DATA_PRINTF,"STP :Dest %08lx%04x", swap_long (sptr_rx_packet->mac_header.destination_address._ulong),
swap (sptr_rx_packet->mac_header.destination_address._ushort));
stp_printf (STP_DATA_PRINTF,"STP: Src %08lx%04x ",swap_long (sptr_rx_packet->mac_header.source_address._ulong),
swap (sptr_rx_packet->mac_header.source_address._ushort));
if (sptr_rx_packet->mac_header.destination_address._ushort == 0x0000)
++counter_t;
stp_printf (STP_DATA_PRINTF,"STP: Size %04x\r\n",size_of_packet);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -