5aa51c035510e73f41f3b6a1eac18a36f7390563
14 int system_bridge_addbr(struct device
*bridge
)
16 DPRINTF("brctl addbr %s\n", bridge
->ifname
);
20 int system_bridge_delbr(struct device
*bridge
)
22 DPRINTF("brctl delbr %s\n", bridge
->ifname
);
26 int system_bridge_addif(struct device
*bridge
, struct device
*dev
)
28 DPRINTF("brctl addif %s %s\n", bridge
->ifname
, dev
->ifname
);
32 int system_bridge_delif(struct device
*bridge
, struct device
*dev
)
34 DPRINTF("brctl delif %s %s\n", bridge
->ifname
, dev
->ifname
);
38 int system_vlan_add(struct device
*dev
, int id
)
40 DPRINTF("vconfig add %s %d\n", dev
->ifname
, id
);
44 int system_vlan_del(struct device
*dev
)
46 DPRINTF("vconfig rem %s\n", dev
->ifname
);
50 int system_if_up(struct device
*dev
)
52 DPRINTF("ifconfig %s up\n", dev
->ifname
);
56 int system_if_down(struct device
*dev
)
58 DPRINTF("ifconfig %s down\n", dev
->ifname
);
62 int system_if_check(struct device
*dev
)
66 if (!strcmp(dev
->ifname
, "eth0"))
67 device_set_present(dev
, true);
72 int system_add_address(struct device
*dev
, struct device_addr
*addr
)
74 uint8_t *a
= (uint8_t *) &addr
->addr
.in
;
77 if ((addr
->flags
& DEVADDR_FAMILY
) == DEVADDR_INET4
) {
78 DPRINTF("ifconfig %s add %d.%d.%d.%d/%d\n",
79 dev
->ifname
, a
[0], a
[1], a
[2], a
[3], addr
->mask
);
81 inet_ntop(AF_INET6
, &addr
->addr
.in6
, ipaddr
, sizeof(struct in6_addr
));
82 DPRINTF("ifconfig %s add %s/%d\n",
83 dev
->ifname
, ipaddr
, addr
->mask
);
90 int system_del_address(struct device
*dev
, struct device_addr
*addr
)
92 uint8_t *a
= (uint8_t *) &addr
->addr
.in
;
95 if ((addr
->flags
& DEVADDR_FAMILY
) == DEVADDR_INET4
) {
96 DPRINTF("ifconfig %s del %d.%d.%d.%d\n",
97 dev
->ifname
, a
[0], a
[1], a
[2], a
[3]);
99 inet_ntop(AF_INET6
, &addr
->addr
.in6
, ipaddr
, sizeof(struct in6_addr
));
100 DPRINTF("ifconfig %s del %s/%d\n",
101 dev
->ifname
, ipaddr
, addr
->mask
);
108 int system_add_route(struct device
*dev
, struct device_route
*route
)
110 uint8_t *a1
= (uint8_t *) &route
->addr
.in
;
111 uint8_t *a2
= (uint8_t *) &route
->nexthop
.in
;
112 char addr
[40], gw
[40] = "", devstr
[64] = "";
114 if ((route
->flags
& DEVADDR_FAMILY
) != DEVADDR_INET4
)
118 sprintf(addr
, "default");
120 sprintf(addr
, "%d.%d.%d.%d/%d",
121 a1
[0], a1
[1], a1
[2], a1
[3], route
->mask
);
123 if (memcmp(a2
, "\x00\x00\x00\x00", 4) != 0)
124 sprintf(gw
, " gw %d.%d.%d.%d",
125 a2
[0], a2
[1], a2
[2], a2
[3]);
127 if (route
->flags
& DEVADDR_DEVICE
)
128 sprintf(devstr
, " dev %s", dev
->ifname
);
130 DPRINTF("route add %s%s%s\n", addr
, gw
, devstr
);
134 int system_del_route(struct device
*dev
, struct device_route
*route
)
136 uint8_t *a1
= (uint8_t *) &route
->addr
.in
;
137 uint8_t *a2
= (uint8_t *) &route
->nexthop
.in
;
138 char addr
[40], gw
[40] = "", devstr
[64] = "";
140 if ((route
->flags
& DEVADDR_FAMILY
) != DEVADDR_INET4
)
144 sprintf(addr
, "default");
146 sprintf(addr
, "%d.%d.%d.%d/%d",
147 a1
[0], a1
[1], a1
[2], a1
[3], route
->mask
);
149 if (memcmp(a2
, "\x00\x00\x00\x00", 4) != 0)
150 sprintf(gw
, " gw %d.%d.%d.%d",
151 a2
[0], a2
[1], a2
[2], a2
[3]);
153 if (route
->flags
& DEVADDR_DEVICE
)
154 sprintf(devstr
, " dev %s", dev
->ifname
);
156 DPRINTF("route del %s%s%s\n", addr
, gw
, devstr
);