Skip to content

Commit

Permalink
Done? (untested)
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire committed Mar 8, 2019
1 parent efc5648 commit c14a457
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions net/respondd-module-lldp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions net/respondd-module-lldp/src/respondd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit c14a457

Please sign in to comment.