Done? (untested)

This commit is contained in:
Martin/Geno 2018-12-07 17:36:21 +01:00 committed by genofire
parent fc12743119
commit 4dcb731d26
2 changed files with 7 additions and 7 deletions

View File

@ -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" ]
}
}
}

View File

@ -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);