+ if (dev->type == &simple_device_type)
+ device_set_present(dev, true);
+
+ device_set_link(dev, true);
+
+ return 0;
+}
+
+int system_if_resolve(struct device *dev)
+{
+ return 1;
+}
+
+struct device *
+system_if_get_parent(struct device *dev)
+{
+ return NULL;
+}
+
+int
+system_if_dump_info(struct device *dev, struct blob_buf *b)
+{
+ blobmsg_add_u8(b, "link", dev->present);
+ return 0;
+}
+
+int
+system_if_dump_stats(struct device *dev, struct blob_buf *b)
+{
+ return 0;
+}
+
+void
+system_if_apply_settings(struct device *dev, struct device_settings *s, uint64_t apply_mask)
+{
+ apply_mask &= s->flags;
+
+ if ((apply_mask & (DEV_OPT_MACADDR | DEV_OPT_DEFAULT_MACADDR)) && !dev->external) {
+ D(SYSTEM, "ifconfig %s hw ether %s",
+ dev->ifname, format_macaddr(s->macaddr));
+ }
+}
+
+static int system_address_msg(struct device *dev, struct device_addr *addr, const char *type)
+{
+ char ipaddr[64];
+ int af = system_get_addr_family(addr->flags);
+
+ D(SYSTEM, "ifconfig %s %s %s/%u",
+ dev->ifname, type, inet_ntop(af, &addr->addr.in, ipaddr, sizeof(ipaddr)),
+ addr->mask);
+
+ return 0;
+}
+
+int system_add_address(struct device *dev, struct device_addr *addr)
+{
+ return system_address_msg(dev, addr, "add");
+}
+
+int system_del_address(struct device *dev, struct device_addr *addr)
+{
+ return system_address_msg(dev, addr, "del");
+}
+
+static int system_route_msg(struct device *dev, struct device_route *route, const char *type)
+{
+ char addr[64], gw[64] = " gw ", devstr[64] = "";
+ int af = system_get_addr_family(route->flags);
+ int alen = system_get_addr_len(route->flags);
+ static uint32_t zero_addr[4];
+
+ if ((route->flags & DEVADDR_FAMILY) != DEVADDR_INET4)
+ return -1;
+
+ if (!route->mask)
+ sprintf(addr, "default");
+ else
+ inet_ntop(af, &route->addr.in, addr, sizeof(addr));
+
+ if (memcmp(&route->nexthop.in, (void *) zero_addr, alen) != 0)
+ inet_ntop(af, &route->nexthop.in, gw + 4, sizeof(gw) - 4);
+ else
+ gw[0] = 0;
+
+ if (dev)
+ sprintf(devstr, " dev %s", dev->ifname);
+
+ if (route->metric > 0)
+ sprintf(devstr, " metric %d", route->metric);
+
+ D(SYSTEM, "route %s %s%s%s", type, addr, gw, devstr);
+ return 0;
+}
+
+static int system_neighbor_msg(struct device *dev, struct device_neighbor *neighbor, const char *type)
+{
+ char addr[64];
+ int af = system_get_addr_family(neighbor->flags);
+ inet_ntop(af, &neighbor->addr.in , addr, sizeof(addr));
+
+ D(SYSTEM, "neigh %s %s%s%s %s", type, addr, neighbor->proxy ? "proxy " : "",
+ (neighbor->flags & DEVNEIGH_MAC) ? format_macaddr(neighbor->macaddr) : "",
+ neighbor->router ? "router": "");
+ return 0;
+}
+
+int system_add_neighbor(struct device *dev, struct device_neighbor *neighbor)
+{
+ return system_neighbor_msg(dev, neighbor, "add");
+}
+
+int system_del_neighbor(struct device *dev, struct device_neighbor *neighbor)
+{
+ return system_neighbor_msg(dev, neighbor, "del");
+}