diff --git a/cmd_parser.c b/cmd_parser.c index a1e187e..996e743 100644 --- a/cmd_parser.c +++ b/cmd_parser.c @@ -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 " * sets it, sanitized to JSON-safe printable ASCII. A name with diff --git a/rtl837x_igmp.c b/rtl837x_igmp.c index 3b267af..feddf9a 100644 --- a/rtl837x_igmp.c +++ b/rtl837x_igmp.c @@ -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); diff --git a/rtlplayground.c b/rtlplayground.c index bdb8ab3..b9cc05d 100644 --- a/rtlplayground.c +++ b/rtlplayground.c @@ -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) {