mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 09:21:26 +03:00
sd-lldp: introduce SD_LLDP_OUI_IANA_MUD macro
This commit is contained in:
parent
19b68e9e96
commit
3be1e84fe9
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user