diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 2ad59f8cb14..e60cc82fd3d 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -98,6 +98,21 @@ get_interface_csv() { export -n "${1}=$_ifnames" } +add_custom_tlv_callback() +{ + # syntax: configure [ports ethX[,…]] lldp custom-tlv [add|replace] oui XX,XX,XX subtype XX oui-info XX[,XX,...] + # ex: configure ports br-lan,eth0 lldp custom-tlv replace oui 33,44,55 subtype 254 oui-info 55,55,55,55,55 + # ex: configure lldp custom-tlv oui 33,44,44 subtype 232 + + local _ports + local _tlv + # CSV of device ports + get_interface_csv _ports "$1" 'ports' + config_get _tlv "$1" 'tlv' + + echo "configure ${_ports:+ports $_ports }lldp custom-tlv $_tlv" >> "$LLDPD_CONF" +} + write_lldpd_conf() { local lldp_description @@ -197,6 +212,9 @@ write_lldpd_conf() [ "$lldp_mgmt_addr_advertisements" -gt 0 ] && echo "configure lldp management-addresses-advertisements" >> "$LLDPD_CONF" ||\ echo "unconfigure lldp management-addresses-advertisements" >> "$LLDPD_CONF" + # Custom TLV handling + config_foreach add_custom_tlv_callback 'custom-tlv' + # Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR [ -e "$LLDPD_CONFS_DIR" ] || ln -s /etc/lldpd.d "$LLDPD_CONFS_DIR" }