summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/lldp-tlv.c
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2015-07-27 18:04:46 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2015-10-02 17:39:22 +0200
commit4fc6de5df31c81ae35e82ed91d0a2ee515edad41 (patch)
tree28eafab32619e68f35a179b196a7f3813687a9f5 /src/libsystemd-network/lldp-tlv.c
parent7434883c40f3623372044f88cdde3eda49ba9758 (diff)
lldp: add sd_lldp_tlv_packet_get_destination_type()
It can be useful to know the destination address of a LLDP frame because it determines the scope of propagation of the frame and thus this information be used to know whether the neighbor is connected to the same physical link. See clause 7.1 of IEEE Std 802.1AB-2009.
Diffstat (limited to 'src/libsystemd-network/lldp-tlv.c')
-rw-r--r--src/libsystemd-network/lldp-tlv.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libsystemd-network/lldp-tlv.c b/src/libsystemd-network/lldp-tlv.c
index 24f2606f31..996c5b8881 100644
--- a/src/libsystemd-network/lldp-tlv.c
+++ b/src/libsystemd-network/lldp-tlv.c
@@ -539,3 +539,20 @@ int sd_lldp_packet_read_system_capability(tlv_packet *tlv, uint16_t *data) {
return r;
}
+
+int sd_lldp_packet_get_destination_type(tlv_packet *tlv, int *dest) {
+ assert_return(tlv, -EINVAL);
+ assert_return(dest, -EINVAL);
+
+ /* 802.1AB-2009, Table 7-1 */
+ if (!memcmp(&tlv->mac, LLDP_MAC_NEAREST_BRIDGE, ETH_ALEN))
+ *dest = SD_LLDP_DESTINATION_TYPE_NEAREST_BRIDGE;
+ else if (!memcmp(&tlv->mac, LLDP_MAC_NEAREST_NON_TPMR_BRIDGE, ETH_ALEN))
+ *dest = SD_LLDP_DESTINATION_TYPE_NEAREST_NON_TPMR_BRIDGE;
+ else if (!memcmp(&tlv->mac, LLDP_MAC_NEAREST_CUSTOMER_BRIDGE, ETH_ALEN))
+ *dest = SD_LLDP_DESTINATION_TYPE_NEAREST_CUSTOMER_BRIDGE;
+ else
+ return -EINVAL;
+
+ return 0;
+}