mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-09-03 21:45:02 +03:00
lldp: rename TLV accessor pseudo-macros
Let's make sure the inline functions for retrieving TLV data actually carry TLV in the name, so that we don#t assume they retrieve the whole, raw packet data.
This commit is contained in:
@@ -700,7 +700,7 @@ _public_ int sd_lldp_neighbor_tlv_next(sd_lldp_neighbor *n) {
|
|||||||
if (n->rindex + 2 > n->raw_size) /* Truncated message */
|
if (n->rindex + 2 > n->raw_size) /* Truncated message */
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
|
|
||||||
length = LLDP_NEIGHBOR_LENGTH(n);
|
length = LLDP_NEIGHBOR_TLV_LENGTH(n);
|
||||||
if (n->rindex + 2 + length > n->raw_size)
|
if (n->rindex + 2 + length > n->raw_size)
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
|
|
||||||
@@ -718,7 +718,7 @@ _public_ int sd_lldp_neighbor_tlv_get_type(sd_lldp_neighbor *n, uint8_t *type) {
|
|||||||
if (n->rindex + 2 > n->raw_size)
|
if (n->rindex + 2 > n->raw_size)
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
|
|
||||||
*type = LLDP_NEIGHBOR_TYPE(n);
|
*type = LLDP_NEIGHBOR_TLV_TYPE(n);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -750,14 +750,14 @@ _public_ int sd_lldp_neighbor_tlv_get_oui(sd_lldp_neighbor *n, uint8_t oui[3], u
|
|||||||
if (r == 0)
|
if (r == 0)
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
||||||
length = LLDP_NEIGHBOR_LENGTH(n);
|
length = LLDP_NEIGHBOR_TLV_LENGTH(n);
|
||||||
if (length < 4)
|
if (length < 4)
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
|
|
||||||
if (n->rindex + 2 + length > n->raw_size)
|
if (n->rindex + 2 + length > n->raw_size)
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
|
|
||||||
d = LLDP_NEIGHBOR_DATA(n);
|
d = LLDP_NEIGHBOR_TLV_DATA(n);
|
||||||
memcpy(oui, d, 3);
|
memcpy(oui, d, 3);
|
||||||
*subtype = d[3];
|
*subtype = d[3];
|
||||||
|
|
||||||
@@ -789,8 +789,7 @@ _public_ int sd_lldp_neighbor_tlv_get_raw(sd_lldp_neighbor *n, const void **ret,
|
|||||||
if (n->rindex + 2 > n->raw_size)
|
if (n->rindex + 2 > n->raw_size)
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
|
|
||||||
length = LLDP_NEIGHBOR_LENGTH(n);
|
length = LLDP_NEIGHBOR_TLV_LENGTH(n);
|
||||||
|
|
||||||
if (n->rindex + 2 + length > n->raw_size)
|
if (n->rindex + 2 + length > n->raw_size)
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
|
|
||||||
|
@@ -83,18 +83,18 @@ static inline void *LLDP_NEIGHBOR_RAW(const sd_lldp_neighbor *n) {
|
|||||||
return (uint8_t*) n + ALIGN(sizeof(sd_lldp_neighbor));
|
return (uint8_t*) n + ALIGN(sizeof(sd_lldp_neighbor));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint8_t LLDP_NEIGHBOR_TYPE(const sd_lldp_neighbor *n) {
|
static inline uint8_t LLDP_NEIGHBOR_TLV_TYPE(const sd_lldp_neighbor *n) {
|
||||||
return ((uint8_t*) LLDP_NEIGHBOR_RAW(n))[n->rindex] >> 1;
|
return ((uint8_t*) LLDP_NEIGHBOR_RAW(n))[n->rindex] >> 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t LLDP_NEIGHBOR_LENGTH(const sd_lldp_neighbor *n) {
|
static inline size_t LLDP_NEIGHBOR_TLV_LENGTH(const sd_lldp_neighbor *n) {
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
|
|
||||||
p = (uint8_t*) LLDP_NEIGHBOR_RAW(n) + n->rindex;
|
p = (uint8_t*) LLDP_NEIGHBOR_RAW(n) + n->rindex;
|
||||||
return p[1] + (((size_t) (p[0] & 1)) << 8);
|
return p[1] + (((size_t) (p[0] & 1)) << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void* LLDP_NEIGHBOR_DATA(const sd_lldp_neighbor *n) {
|
static inline void* LLDP_NEIGHBOR_TLV_DATA(const sd_lldp_neighbor *n) {
|
||||||
return ((uint8_t*) LLDP_NEIGHBOR_RAW(n)) + n->rindex + 2;
|
return ((uint8_t*) LLDP_NEIGHBOR_RAW(n)) + n->rindex + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user