From 4dcb731d26524d8c69cfdf3643babf31ba6e0a3e Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Fri, 7 Dec 2018 17:36:21 +0100 Subject: [PATCH] Done? (untested) --- net/respondd-module-lldp/README.md | 4 +--- net/respondd-module-lldp/src/respondd.c | 10 ++++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/net/respondd-module-lldp/README.md b/net/respondd-module-lldp/README.md index 0181011..2295156 100644 --- a/net/respondd-module-lldp/README.md +++ b/net/respondd-module-lldp/README.md @@ -5,9 +5,7 @@ The format is the following: { "neighbours": { "lldp": { - "01:00:00:00:00:01": { - "02:00:00:00:00:01" : {"name":"a","descr":"b"} - } + "01:00:00:00:00:01": [ "02:00:00:00:00:01" ] } } } diff --git a/net/respondd-module-lldp/src/respondd.c b/net/respondd-module-lldp/src/respondd.c index dc941c8..6a8ddf0 100644 --- a/net/respondd-module-lldp/src/respondd.c +++ b/net/respondd-module-lldp/src/respondd.c @@ -7,7 +7,7 @@ static struct json_object * respondd_provider_neighbours(void) { lldpctl_conn_t *conn; lldpctl_atom_t *ifaces, *iface, *port, *neighbors, *neighbor; const char *ctlname, *neighmac, *portmac; - struct json_object *ret, *ret_lldp, *neighbors_obj; + struct json_object *ret, *ret_lldp, *neighbors_array; ret_lldp = json_object_new_object(); @@ -24,7 +24,7 @@ static struct json_object * respondd_provider_neighbours(void) { if (!portmac) continue; - neighbors_obj = json_object_new_object(); + neighbors_array = json_object_new_array(); neighbors = lldpctl_atom_get(port, lldpctl_k_port_neighbors); lldpctl_atom_foreach(neighbors, neighbor) { // check if Chassis ID Subtype is MAC address @@ -35,10 +35,12 @@ static struct json_object * respondd_provider_neighbours(void) { if (!neighmac) continue; - json_object_object_add(neighbors_obj, neighmac, json_object_new_object()); + json_object_array_add(neighbors_array, neighmac); } - json_object_object_add(ret_lldp, portmac, neighbors_obj); + lldpctl_atom_dec_ref(neighbors); + json_object_object_add(ret_lldp, portmac, neighbors_array); } + lldpctl_release(conn); ret = json_object_new_object(); json_object_object_add(ret, "lldp", ret_lldp);