summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network/sd-lldp-rx.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
commit78e9bb837c258ac0ec7712b3d612cc2f407e731e (patch)
treef515d16b6efd858a9aeb5b0ef5d6f90bf288283d /src/libsystemd-network/sd-lldp-rx.c
parentAdding debian version 255.5-1. (diff)
downloadsystemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.tar.xz
systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.zip
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libsystemd-network/sd-lldp-rx.c')
-rw-r--r--src/libsystemd-network/sd-lldp-rx.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libsystemd-network/sd-lldp-rx.c b/src/libsystemd-network/sd-lldp-rx.c
index 2fc9a55..74000ff 100644
--- a/src/libsystemd-network/sd-lldp-rx.c
+++ b/src/libsystemd-network/sd-lldp-rx.c
@@ -10,6 +10,7 @@
#include "ether-addr-util.h"
#include "event-util.h"
#include "fd-util.h"
+#include "json.h"
#include "lldp-neighbor.h"
#include "lldp-network.h"
#include "lldp-rx-internal.h"
@@ -490,6 +491,30 @@ int sd_lldp_rx_get_neighbors(sd_lldp_rx *lldp_rx, sd_lldp_neighbor ***ret) {
return k;
}
+int lldp_rx_build_neighbors_json(sd_lldp_rx *lldp_rx, JsonVariant **ret) {
+ _cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
+ int r;
+
+ assert(lldp_rx);
+ assert(ret);
+
+ sd_lldp_neighbor *n;
+ HASHMAP_FOREACH(n, lldp_rx->neighbor_by_id) {
+ _cleanup_(json_variant_unrefp) JsonVariant *w = NULL;
+
+ r = lldp_neighbor_build_json(n, &w);
+ if (r < 0)
+ return r;
+
+ r = json_variant_append_array(&v, w);
+ if (r < 0)
+ return r;
+ }
+
+ *ret = TAKE_PTR(v);
+ return 0;
+}
+
int sd_lldp_rx_set_neighbors_max(sd_lldp_rx *lldp_rx, uint64_t m) {
assert_return(lldp_rx, -EINVAL);
assert_return(m > 0, -EINVAL);