+ switch (operstate) {
+ case IF_OPER_UNKNOWN:
+ return "UNKNOWN";
+ case IF_OPER_NOTPRESENT:
+ return "NOT-PRESENT";
+ case IF_OPER_DOWN:
+ return "DOWN";
+ case IF_OPER_LOWERLAYERDOWN:
+ return "LOWER-LAYER-DOWN";
+ case IF_OPER_TESTING:
+ return "TESTING";
+ case IF_OPER_DORMANT:
+ return "DORMANT";
+ case IF_OPER_UP:
+ return "UP";
+ }
+
+ return "";
+}
+
+static void extract_link(struct ifinfomsg *msg, int bytes,
+ const char **ifname, unsigned char *operstate)
+{
+ struct rtattr *attr;
+
+ for (attr = IFLA_RTA(msg); RTA_OK(attr, bytes);
+ attr = RTA_NEXT(attr, bytes)) {
+ switch (attr->rta_type) {
+ case IFLA_IFNAME:
+ if (ifname != NULL)
+ *ifname = RTA_DATA(attr);
+ break;
+ case IFLA_OPERSTATE:
+ if (operstate != NULL)
+ *operstate = *((unsigned char *) RTA_DATA(attr));
+ break;
+ case IFLA_LINKMODE:
+ break;
+ }
+ }
+}
+
+static void process_newlink(unsigned short type, int index, unsigned flags,
+ unsigned change, struct ifinfomsg *msg, int bytes)
+{
+ unsigned char operstate = 0xff;
+ const char *ifname = NULL;