Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
#include <systemd/sd-netlink.h>
#include "daemon.h"
+#include "json.h"
#include "link.h"
#include "links.h"
#include "logging.h"
return r;
}
+
+// JSON
+
+int nw_link_to_json(nw_link* link, struct json_object* o) {
+ int r;
+
+ // Add ifindex
+ r = json_object_add_int64(o, "LinkIndex", link->ifindex);
+ if (r < 0)
+ return r;
+
+ return 0;
+}
typedef struct nw_link nw_link;
#include "daemon.h"
+#include "json.h"
int nw_link_create(nw_link** link, nw_daemon* daemon, int ifindex);
int nw_link_destroy(nw_link* link);
+// JSON
+int nw_link_to_json(nw_link* link, struct json_object* o);
+
#endif /* NETWORKD_LINK_H */
goto ERROR;
}
+ // Add link stuff
+ if (port->link) {
+ r = nw_link_to_json(port->link, o);
+ if (r < 0)
+ goto ERROR;
+ }
+
// Call custom stuff
if (NW_PORT_TYPE(port)->to_json) {
r = NW_PORT_TYPE(port)->to_json(port, o);