19 int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg)
21 D(SYSTEM, "brctl addbr %s\n", bridge->ifname);
25 int system_bridge_delbr(struct device *bridge)
27 D(SYSTEM, "brctl delbr %s\n", bridge->ifname);
31 int system_bridge_addif(struct device *bridge, struct device *dev)
33 D(SYSTEM, "brctl addif %s %s\n", bridge->ifname, dev->ifname);
37 int system_bridge_delif(struct device *bridge, struct device *dev)
39 D(SYSTEM, "brctl delif %s %s\n", bridge->ifname, dev->ifname);
43 int system_vlan_add(struct device *dev, int id)
45 D(SYSTEM, "vconfig add %s %d\n", dev->ifname, id);
49 int system_vlan_del(struct device *dev)
51 D(SYSTEM, "vconfig rem %s\n", dev->ifname);
55 int system_if_up(struct device *dev)
57 D(SYSTEM, "ifconfig %s up\n", dev->ifname);
61 int system_if_down(struct device *dev)
63 D(SYSTEM, "ifconfig %s down\n", dev->ifname);
67 void system_if_clear_state(struct device *dev)
71 int system_if_check(struct device *dev)
75 if (!strcmp(dev->ifname, "eth0"))
76 device_set_present(dev, true);
81 int system_add_address(struct device *dev, struct device_addr *addr)
83 uint8_t *a = (uint8_t *) &addr->addr.in;
86 if ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET4) {
87 D(SYSTEM, "ifconfig %s add %d.%d.%d.%d/%d\n",
88 dev->ifname, a[0], a[1], a[2], a[3], addr->mask);
90 inet_ntop(AF_INET6, &addr->addr.in6, ipaddr, sizeof(struct in6_addr));
91 D(SYSTEM, "ifconfig %s add %s/%d\n",
92 dev->ifname, ipaddr, addr->mask);
99 int system_del_address(struct device *dev, struct device_addr *addr)
101 uint8_t *a = (uint8_t *) &addr->addr.in;
104 if ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET4) {
105 D(SYSTEM, "ifconfig %s del %d.%d.%d.%d\n",
106 dev->ifname, a[0], a[1], a[2], a[3]);
108 inet_ntop(AF_INET6, &addr->addr.in6, ipaddr, sizeof(struct in6_addr));
109 D(SYSTEM, "ifconfig %s del %s/%d\n",
110 dev->ifname, ipaddr, addr->mask);
117 int system_add_route(struct device *dev, struct device_route *route)
119 uint8_t *a1 = (uint8_t *) &route->addr.in;
120 uint8_t *a2 = (uint8_t *) &route->nexthop.in;
121 char addr[40], gw[40] = "", devstr[64] = "";
123 if ((route->flags & DEVADDR_FAMILY) != DEVADDR_INET4)
127 sprintf(addr, "default");
129 sprintf(addr, "%d.%d.%d.%d/%d",
130 a1[0], a1[1], a1[2], a1[3], route->mask);
132 if (memcmp(a2, "\x00\x00\x00\x00", 4) != 0)
133 sprintf(gw, " gw %d.%d.%d.%d",
134 a2[0], a2[1], a2[2], a2[3]);
136 if (route->flags & DEVADDR_DEVICE)
137 sprintf(devstr, " dev %s", dev->ifname);
139 D(SYSTEM, "route add %s%s%s\n", addr, gw, devstr);
143 int system_del_route(struct device *dev, struct device_route *route)
145 uint8_t *a1 = (uint8_t *) &route->addr.in;
146 uint8_t *a2 = (uint8_t *) &route->nexthop.in;
147 char addr[40], gw[40] = "", devstr[64] = "";
149 if ((route->flags & DEVADDR_FAMILY) != DEVADDR_INET4)
153 sprintf(addr, "default");
155 sprintf(addr, "%d.%d.%d.%d/%d",
156 a1[0], a1[1], a1[2], a1[3], route->mask);
158 if (memcmp(a2, "\x00\x00\x00\x00", 4) != 0)
159 sprintf(gw, " gw %d.%d.%d.%d",
160 a2[0], a2[1], a2[2], a2[3]);
162 if (route->flags & DEVADDR_DEVICE)
163 sprintf(devstr, " dev %s", dev->ifname);
165 D(SYSTEM, "route del %s%s%s\n", addr, gw, devstr);