]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-lldp-tx: append capabilities before MUD URL
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 15 Jun 2025 01:20:12 +0000 (10:20 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 17 Jun 2025 15:53:24 +0000 (00:53 +0900)
No functional change, but let's append vendor specific informations
after others to sort the TLVs with their type.

src/libsystemd-network/sd-lldp-tx.c
src/systemd/sd-lldp-tx.h

index 3f73d881d4dfd57d3c6665018e1f7d692d6eafe0..92b8ac516129b8f74ebbd05e2d6db5adcbe15077 100644 (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;
index 107292027da35ca1c191dc3cb4de4d491da7fd5f..520f5a20831feb0805787b9092f581d5f426c6da 100644 (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);