sd-lldp-tx: append capabilities before MUD URL

No functional change, but let's append vendor specific informations
after others to sort the TLVs with their type.
This commit is contained in:
Yu Watanabe
2025-06-18 00:53:24 +09:00
parent 27546b769c
commit 0597109ddf
2 changed files with 12 additions and 12 deletions
+11 -11
View File
@@ -238,10 +238,10 @@ static size_t lldp_tx_calculate_maximum_packet_size(sd_lldp_tx *lldp_tx, const c
2 + strlen_ptr(hostname) +
/* System description */
2 + strlen_ptr(pretty_hostname) +
/* MUD URL */
2 + sizeof(SD_LLDP_OUI_IANA_MUD) + strlen_ptr(lldp_tx->mud_url) +
/* System Capabilities */
2 + 4 +
/* MUD URL */
2 + sizeof(SD_LLDP_OUI_IANA_MUD) + strlen_ptr(lldp_tx->mud_url) +
/* End */
2;
}
@@ -428,6 +428,15 @@ static int lldp_tx_create_packet(sd_lldp_tx *lldp_tx, size_t *ret_packet_size, u
if (r < 0)
return r;
r = packet_append_tlv_header(packet, packet_size, &offset, SD_LLDP_TYPE_SYSTEM_CAPABILITIES, 4);
if (r < 0)
return r;
unaligned_write_be16(packet + offset, lldp_tx->supported_capabilities);
offset += 2;
unaligned_write_be16(packet + offset, lldp_tx->enabled_capabilities);
offset += 2;
/* See section 12 of RFC 8520.
* +--------+--------+----------+---------+--------------
* |TLV Type| len | OUI |subtype | MUDString
@@ -448,15 +457,6 @@ static int lldp_tx_create_packet(sd_lldp_tx *lldp_tx, size_t *ret_packet_size, u
if (r < 0)
return r;
r = packet_append_tlv_header(packet, packet_size, &offset, SD_LLDP_TYPE_SYSTEM_CAPABILITIES, 4);
if (r < 0)
return r;
unaligned_write_be16(packet + offset, lldp_tx->supported_capabilities);
offset += 2;
unaligned_write_be16(packet + offset, lldp_tx->enabled_capabilities);
offset += 2;
r = packet_append_tlv_header(packet, packet_size, &offset, SD_LLDP_TYPE_END, 0);
if (r < 0)
return r;
+1 -1
View File
@@ -56,8 +56,8 @@ int sd_lldp_tx_set_hwaddr(sd_lldp_tx *lldp_tx, const struct ether_addr *hwaddr);
int sd_lldp_tx_set_port_description(sd_lldp_tx *lldp_tx, const char *port_description);
int sd_lldp_tx_set_hostname(sd_lldp_tx *lldp_tx, const char *hostname);
int sd_lldp_tx_set_pretty_hostname(sd_lldp_tx *lldp_tx, const char *pretty_hostname);
int sd_lldp_tx_set_mud_url(sd_lldp_tx *lldp_tx, const char *mud_url);
int sd_lldp_tx_set_capabilities(sd_lldp_tx *lldp_tx, uint16_t supported, uint16_t enabled);
int sd_lldp_tx_set_mud_url(sd_lldp_tx *lldp_tx, const char *mud_url);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_lldp_tx, sd_lldp_tx_unref);