diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-02-25 06:16:47 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-03-01 01:40:26 +0100 |
commit | c48ca17aa82a9e2435c181ca56aca3dfb42fe47d (patch) | |
tree | 1656c6caef73c69a299df8182943a12cb775b160 /src/shared/varlink-io.systemd.Network.c | |
parent | sd-lldp-rx: serialize LLDP neighbors to JSON format (diff) | |
download | systemd-c48ca17aa82a9e2435c181ca56aca3dfb42fe47d.tar.xz systemd-c48ca17aa82a9e2435c181ca56aca3dfb42fe47d.zip |
network/varlink: add varlink method to get LLDP neighbors
The method provides the list of LLDP neighbors.
Co-authored-by: Tomáš Pecka <tomas.pecka@cesnet.cz>
Diffstat (limited to '')
-rw-r--r-- | src/shared/varlink-io.systemd.Network.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/shared/varlink-io.systemd.Network.c b/src/shared/varlink-io.systemd.Network.c index feb1e52feb..986f2cfc69 100644 --- a/src/shared/varlink-io.systemd.Network.c +++ b/src/shared/varlink-io.systemd.Network.c @@ -16,8 +16,35 @@ static VARLINK_DEFINE_METHOD( VARLINK_DEFINE_OUTPUT(NamespaceId, VARLINK_INT, 0), VARLINK_DEFINE_OUTPUT(NamespaceNSID, VARLINK_INT, VARLINK_NULLABLE)); +static VARLINK_DEFINE_STRUCT_TYPE( + LLDPNeighbor, + VARLINK_DEFINE_FIELD(ChassisID, VARLINK_STRING, VARLINK_NULLABLE), + VARLINK_DEFINE_FIELD(RawChassisID, VARLINK_INT, VARLINK_ARRAY), + VARLINK_DEFINE_FIELD(PortID, VARLINK_STRING, VARLINK_NULLABLE), + VARLINK_DEFINE_FIELD(RawPortID, VARLINK_INT, VARLINK_ARRAY), + VARLINK_DEFINE_FIELD(PortDescription, VARLINK_STRING, VARLINK_NULLABLE), + VARLINK_DEFINE_FIELD(SystemName, VARLINK_STRING, VARLINK_NULLABLE), + VARLINK_DEFINE_FIELD(SystemDescription, VARLINK_STRING, VARLINK_NULLABLE), + VARLINK_DEFINE_FIELD(EnabledCapabilities, VARLINK_INT, VARLINK_NULLABLE)); + +static VARLINK_DEFINE_STRUCT_TYPE( + LLDPNeighborsByInterface, + VARLINK_DEFINE_FIELD(InterfaceIndex, VARLINK_INT, 0), + VARLINK_DEFINE_FIELD(InterfaceName, VARLINK_STRING, 0), + VARLINK_DEFINE_FIELD(InterfaceAlternativeNames, VARLINK_STRING, VARLINK_ARRAY|VARLINK_NULLABLE), + VARLINK_DEFINE_FIELD_BY_TYPE(Neighbors, LLDPNeighbor, VARLINK_ARRAY)); + +static VARLINK_DEFINE_METHOD( + GetLLDPNeighbors, + VARLINK_DEFINE_INPUT(InterfaceIndex, VARLINK_INT, VARLINK_NULLABLE), + VARLINK_DEFINE_INPUT(InterfaceName, VARLINK_STRING, VARLINK_NULLABLE), + VARLINK_DEFINE_OUTPUT_BY_TYPE(Neighbors, LLDPNeighborsByInterface, VARLINK_ARRAY)); + VARLINK_DEFINE_INTERFACE( io_systemd_Network, "io.systemd.Network", &vl_method_GetStates, - &vl_method_GetNamespaceId); + &vl_method_GetNamespaceId, + &vl_method_GetLLDPNeighbors, + &vl_type_LLDPNeighbor, + &vl_type_LLDPNeighborsByInterface); |