mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Merge pull request #332 from DrDoof/fix/igmp-enable-gate
igmp: only hand reports to the CPU while snooping is on
This commit is contained in:
+3
-1
@@ -1540,10 +1540,12 @@ void cmd_parser(void) __banked
|
||||
} else if (cmd_compare(0, "igmp")) {
|
||||
if (cmd_compare(1, "on"))
|
||||
igmp_enable();
|
||||
else if (cmd_compare(1, "off"))
|
||||
igmp_setup();
|
||||
else if (cmd_compare(1, "show"))
|
||||
igmp_show();
|
||||
else
|
||||
igmp_setup(); // Reverts to default with IP-MC being flooded
|
||||
print_string("Error: igmp on|off|show\n");
|
||||
} else if (cmd_compare(0, "hostname")) {
|
||||
/* "hostname" alone reports the current name; "hostname <text>"
|
||||
* sets it, sanitized to JSON-safe printable ASCII. A name with
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "machine.h"
|
||||
|
||||
extern __code struct machine machine;
|
||||
extern __xdata uint8_t igmpEnabled;
|
||||
|
||||
#include "uip.h"
|
||||
|
||||
@@ -85,6 +86,7 @@ void igmp_setup(void) __banked
|
||||
{
|
||||
uint8_t i;
|
||||
print_string("igmp_setup called\n");
|
||||
igmpEnabled = 0;
|
||||
// For now, forward all unkown IP-MC pkts (2 bits per port. 00: flood via floodmask, 01: drop, 10: trap, 11: to rport)
|
||||
REG_SET(RTL837X_IPV4_PORT_MC_LM_ACT, LOOKUP_MISS_FLOOD);
|
||||
REG_SET(RTL837X_IPV6_PORT_MC_LM_ACT, LOOKUP_MISS_FLOOD);
|
||||
@@ -130,6 +132,7 @@ void igmp_setup(void) __banked
|
||||
void igmp_enable(void) __banked
|
||||
{
|
||||
print_string("igmp_enable called\n");
|
||||
igmpEnabled = 1;
|
||||
// Configure trapping of unhandled IGMP protocol packets to CPU
|
||||
REG_SET(RTL837X_IGMP_TRAP_CFG, IGMP_CPU_PORT | IGMP_TRAP_PRIORITY);
|
||||
|
||||
|
||||
+2
-1
@@ -121,6 +121,7 @@ __xdata uint16_t management_vlan;
|
||||
__xdata uint8_t tx_seq;
|
||||
|
||||
__xdata uint8_t stpEnabled;
|
||||
__xdata uint8_t igmpEnabled;
|
||||
__xdata char hostname[24]; /* device hostname, default set at boot, see rtl837x_common.h */
|
||||
|
||||
__code uint16_t bit_mask[16] = {
|
||||
@@ -1152,7 +1153,7 @@ void handle_rx(void)
|
||||
print_string("STP TX\n");
|
||||
tcpip_output();
|
||||
}
|
||||
} else if (uip_buf[0] == 0x01 && uip_buf[1] == 0x00 && uip_buf[2] == 0x5e // IPv4-MC packet?
|
||||
} else if (igmpEnabled && uip_buf[0] == 0x01 && uip_buf[1] == 0x00 && uip_buf[2] == 0x5e // IPv4-MC packet?
|
||||
&& uip_buf[3] == 0x00 && uip_buf[4] == 0x00 && uip_buf[5] == 0x16) {
|
||||
igmp_packet_handler();
|
||||
if (uip_len) {
|
||||
|
||||
Reference in New Issue
Block a user