|
|
@@ -1,13 +1,25 @@
|
|
|
#include "link.h"
|
|
|
|
|
|
-#include <libmnl/libmnl.h>
|
|
|
-#include <linux/if_link.h>
|
|
|
-#include <string>
|
|
|
+#include <libmnl/libmnl.h> // mnl_attr_*
|
|
|
+#include <linux/if_link.h> // IFLA_*
|
|
|
+#include <string> // std::string
|
|
|
|
|
|
-// https://netfilter.org/projects/libmnl/doxygen/html/group__attr.html
|
|
|
+Link::Link(const ifinfomsg *msg) {
|
|
|
+ /*
|
|
|
+ struct ifinfomsg {
|
|
|
+ unsigned char ifi_family; // AF_UNSPEC
|
|
|
+ unsigned short ifi_type; // Device type
|
|
|
+ int ifi_index; // Interface index
|
|
|
+ unsigned int ifi_flags; // Device flags
|
|
|
+ unsigned int ifi_change; // change mask
|
|
|
+ };
|
|
|
+ */
|
|
|
+ index = msg->ifi_index;
|
|
|
+}
|
|
|
|
|
|
int Link::mnl_attr_cb(const nlattr *attr, void *data) {
|
|
|
Link *link = (Link *)data;
|
|
|
+ // https://netfilter.org/projects/libmnl/doxygen/html/group__attr.html
|
|
|
// /usr/include/linux/if_link.h
|
|
|
switch (mnl_attr_get_type(attr)) {
|
|
|
case IFLA_ADDRESS:
|
|
|
@@ -35,6 +47,7 @@ void Link::write_yaml(std::ostream &stream,
|
|
|
const yaml_indent_level_t indent_level) const {
|
|
|
const std::string indent(indent_level, ' ');
|
|
|
stream << "ifname: " + ifname + "\n";
|
|
|
+ // stream << indent << "index: " << index << "\n";
|
|
|
stream << indent << "address: ";
|
|
|
address.write_yaml(stream);
|
|
|
stream << "\n";
|