Implementing basic LLDP server, should send port_id message

to each port once every 30 seconds.
* Additionally fixes the on-ward passing of LLDP frames through
the switch

The ports on the case are marked 1-8 so this should reflect that
rather than being 0-based

We can send the hostname as well, this can be dynamically allocated

Let's send the model as the system description as well
This commit is contained in:
Rob Emery committed 2026-10-10 09:49:24 +01:00
1 parent ff57084799
commit 1ebee4d6e9
6 files changed
+241

No files matched your search

+12
View File
@@ -16,6 +16,7 @@
#include "rtl837x_leds.h"
#include "rtl837x_bandwidth.h"
#include "rtl837x_init.h"
#include "rtl837x_lldp.h"
#include "dhcp.h"
#include "cmd_parser.h"
#include "cmd_editor.h"
@@ -127,6 +128,7 @@ __xdata uint8_t tx_seq;
__xdata bool stp_enabled;
__xdata uint8_t igmpEnabled;
__xdata uint8_t lldp_enabled;
__xdata char hostname[24]; /* device hostname, default set at boot, see rtl837x_common.h */
__code const uint16_t bit_mask[16] = {
@@ -1066,6 +1068,13 @@ void handle_rx(void)
if (uip_len) {
tcpip_output();
}
} else if (lldp_enabled && uip_buf[0] == 0x01 && uip_buf[1] == 0x80 && uip_buf[2] == 0xc2
&& uip_buf[3] == 0x00 && uip_buf[4] == 0x00 && uip_buf[5] == 0x0e && uip_buf[12] == 0x88
&& uip_buf[13] == 0xcc) { //LLDP Mac + EtherType check
// LLDP packets shouldn't be passed elsewhere
if(uip_len){
print_string("LLDP received\n");
}
} else if (ETH_IN->ether_type == HTONS(0x0806)) { // ARP
uip_arp_arpin();
if (uip_len) {
@@ -1286,6 +1295,8 @@ static void handle_tick(void)
}
}
health_phase(HEALTH_PH_STP);
lldp_tick();
health_phase(HEALTH_LLDP);
}
@@ -1794,6 +1805,7 @@ void main(void)
uip_init();
uip_arp_init();
httpd_init();
lldp_init();
management_vlan = 1; // Default management VLAN is 1