diff --git a/src/libsystemd-network/lldp-neighbor.c b/src/libsystemd-network/lldp-neighbor.c index 7eae998a608..342e490603c 100644 --- a/src/libsystemd-network/lldp-neighbor.c +++ b/src/libsystemd-network/lldp-neighbor.c @@ -289,10 +289,9 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) { "Found private TLV that is too short, ignoring."); /* RFC 8520: MUD URL */ - if (memcmp(p, SD_LLDP_OUI_MUD, sizeof(SD_LLDP_OUI_MUD)) == 0 && - p[sizeof(SD_LLDP_OUI_MUD)] == SD_LLDP_OUI_SUBTYPE_MUD_USAGE_DESCRIPTION) { - r = parse_string(n->lldp_rx, &n->mud_url, p + sizeof(SD_LLDP_OUI_MUD) + 1, - length - 1 - sizeof(SD_LLDP_OUI_MUD)); + if (memcmp(p, SD_LLDP_OUI_IANA_MUD, sizeof(SD_LLDP_OUI_IANA_MUD)) == 0) { + r = parse_string(n->lldp_rx, &n->mud_url, p + sizeof(SD_LLDP_OUI_IANA_MUD), + length - sizeof(SD_LLDP_OUI_IANA_MUD)); if (r < 0) return r; } diff --git a/src/network/networkd-lldp-tx.c b/src/network/networkd-lldp-tx.c index c1cbe60d73b..1a4128600ff 100644 --- a/src/network/networkd-lldp-tx.c +++ b/src/network/networkd-lldp-tx.c @@ -146,7 +146,7 @@ static int lldp_make_packet( /* MUD URL */ if (mud) - l += 2 + sizeof(SD_LLDP_OUI_MUD) + 1 + mud_length; + l += 2 + sizeof(SD_LLDP_OUI_IANA_MUD) + mud_length; packet = malloc(l); if (!packet) @@ -199,7 +199,6 @@ static int lldp_make_packet( } if (mud) { - uint8_t oui_mud[sizeof(SD_LLDP_OUI_MUD)] = {0x00, 0x00, 0x5E}; /* * +--------+--------+----------+---------+-------------- * |TLV Type| len | OUI |subtype | MUDString @@ -215,12 +214,11 @@ static int lldp_make_packet( * o MUDstring = the length MUST NOT exceed 255 octets */ - r = lldp_write_tlv_header(&p, SD_LLDP_TYPE_PRIVATE, sizeof(SD_LLDP_OUI_MUD) + 1 + mud_length); + r = lldp_write_tlv_header(&p, SD_LLDP_TYPE_PRIVATE, sizeof(SD_LLDP_OUI_IANA_MUD) + mud_length); if (r < 0) return r; - p = mempcpy(p, &oui_mud, sizeof(SD_LLDP_OUI_MUD)); - *(p++) = SD_LLDP_OUI_SUBTYPE_MUD_USAGE_DESCRIPTION; + p = mempcpy(p, SD_LLDP_OUI_IANA_MUD, sizeof(SD_LLDP_OUI_IANA_MUD)); p = mempcpy(p, mud, mud_length); } diff --git a/src/systemd/sd-lldp.h b/src/systemd/sd-lldp.h index d615d404602..c32d7894764 100644 --- a/src/systemd/sd-lldp.h +++ b/src/systemd/sd-lldp.h @@ -92,8 +92,12 @@ enum { #define SD_LLDP_OUI_802_1 (const uint8_t[]) { 0x00, 0x80, 0xc2 } #define SD_LLDP_OUI_802_3 (const uint8_t[]) { 0x00, 0x12, 0x0f } -#define SD_LLDP_OUI_MUD (const uint8_t[]) { 0x00, 0x00, 0x5E } -#define SD_LLDP_OUI_SUBTYPE_MUD_USAGE_DESCRIPTION 0x01 +#define _SD_LLDP_OUI_IANA 0x00, 0x00, 0x5E +#define SD_LLDP_OUI_IANA (const uint8_t[]) { _SD_LLDP_OUI_IANA } + +#define SD_LLDP_OUI_IANA_SUBTYPE_MUD 0x01 +#define SD_LLDP_OUI_IANA_MUD \ + (const uint8_t[]) { _SD_LLDP_OUI_IANA, SD_LLDP_OUI_IANA_SUBTYPE_MUD } /* IEEE 802.1AB-2009 Annex E */ enum {