summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/lldp-internal.c
diff options
context:
space:
mode:
authorSusant Sahani <susant@redhat.com>2014-12-11 09:59:55 +0530
committerSusant Sahani <susant@redhat.com>2014-12-19 08:15:05 +0530
commit49699bac94d24b444274f91f85c82e6fad04d029 (patch)
tree617cd733775e4b23bcabc37de590f4f6ff8ef916 /src/libsystemd-network/lldp-internal.c
parentce43e484465050c619ea9a1991d49b3d6215028b (diff)
downloadsystemd-49699bac94d24b444274f91f85c82e6fad04d029.tar.gz
LLDP: Add support for networkctl
Diffstat (limited to 'src/libsystemd-network/lldp-internal.c')
-rw-r--r--src/libsystemd-network/lldp-internal.c97
1 files changed, 96 insertions, 1 deletions
diff --git a/src/libsystemd-network/lldp-internal.c b/src/libsystemd-network/lldp-internal.c
index 7085a02491..f86c11e6ca 100644
--- a/src/libsystemd-network/lldp-internal.c
+++ b/src/libsystemd-network/lldp-internal.c
@@ -86,6 +86,8 @@ int lldp_read_port_id(tlv_packet *tlv,
goto out1;
switch (subtype) {
+ case LLDP_PORT_SUBTYPE_PORT_COMPONENT:
+ case LLDP_PORT_SUBTYPE_INTERFACE_ALIAS:
case LLDP_PORT_SUBTYPE_INTERFACE_NAME:
r = tlv_packet_read_string(tlv, &s, length);
@@ -127,12 +129,105 @@ int lldp_read_ttl(tlv_packet *tlv, uint16_t *ttl) {
r = tlv_packet_read_u16(tlv, ttl);
- (void) lldp_tlv_packet_exit_container(tlv);
+ (void)lldp_tlv_packet_exit_container(tlv);
out:
return r;
}
+int lldp_read_system_name(tlv_packet *tlv,
+ uint16_t *length,
+ char **data) {
+ char *s;
+ int r;
+
+ assert_return(tlv, -EINVAL);
+
+ r = lldp_tlv_packet_enter_container(tlv, LLDP_TYPE_SYSTEM_NAME);
+ if (r < 0)
+ return r;
+
+ r = tlv_packet_read_string(tlv, &s, length);
+ if (r < 0)
+ goto out;
+
+ *data = (char *) s;
+
+ out:
+ (void)lldp_tlv_packet_exit_container(tlv);
+
+ return r;
+}
+
+int lldp_read_system_description(tlv_packet *tlv,
+ uint16_t *length,
+ char **data) {
+ char *s;
+ int r;
+
+ assert_return(tlv, -EINVAL);
+
+ r = lldp_tlv_packet_enter_container(tlv, LLDP_TYPE_SYSTEM_DESCRIPTION);
+ if (r < 0)
+ return r;
+
+ r = tlv_packet_read_string(tlv, &s, length);
+ if (r < 0)
+ goto out;
+
+ *data = (char *) s;
+
+ out:
+ (void)lldp_tlv_packet_exit_container(tlv);
+
+ return r;
+}
+
+int lldp_read_port_description(tlv_packet *tlv,
+ uint16_t *length,
+ char **data) {
+ char *s;
+ int r;
+
+ assert_return(tlv, -EINVAL);
+
+ r = lldp_tlv_packet_enter_container(tlv, LLDP_TYPE_PORT_DESCRIPTION);
+ if (r < 0)
+ return r;
+
+ r = tlv_packet_read_string(tlv, &s, length);
+ if (r < 0)
+ goto out;
+
+ *data = (char *) s;
+
+ out:
+ (void)lldp_tlv_packet_exit_container(tlv);
+
+ return r;
+}
+
+int lldp_read_system_capability(tlv_packet *tlv, uint16_t *data) {
+ int r;
+
+ assert_return(tlv, -EINVAL);
+
+ r = lldp_tlv_packet_enter_container(tlv, LLDP_TYPE_SYSTEM_CAPABILITIES);
+ if (r < 0)
+ return r;
+
+ r = tlv_packet_read_u16(tlv, data);
+ if (r < 0)
+ goto out;
+
+ return 0;
+ out:
+
+ (void)lldp_tlv_packet_exit_container(tlv);
+
+ return r;
+}
+
/* 10.5.5.2.2 mibUpdateObjects ()
* The mibUpdateObjects () procedure updates the MIB objects corresponding to
* the TLVs contained in the received LLDPDU for the LLDP remote system