09d1806dba459463c811e5643b3a2bcdfd4343e3
20 int system_bridge_addbr(struct device
*bridge
, struct bridge_config
*cfg
)
22 D(SYSTEM
, "brctl addbr %s\n", bridge
->ifname
);
26 int system_bridge_delbr(struct device
*bridge
)
28 D(SYSTEM
, "brctl delbr %s\n", bridge
->ifname
);
32 int system_bridge_addif(struct device
*bridge
, struct device
*dev
)
34 D(SYSTEM
, "brctl addif %s %s\n", bridge
->ifname
, dev
->ifname
);
38 int system_bridge_delif(struct device
*bridge
, struct device
*dev
)
40 D(SYSTEM
, "brctl delif %s %s\n", bridge
->ifname
, dev
->ifname
);
44 int system_vlan_add(struct device
*dev
, int id
)
46 D(SYSTEM
, "vconfig add %s %d\n", dev
->ifname
, id
);
50 int system_vlan_del(struct device
*dev
)
52 D(SYSTEM
, "vconfig rem %s\n", dev
->ifname
);
56 int system_if_up(struct device
*dev
)
58 D(SYSTEM
, "ifconfig %s up\n", dev
->ifname
);
62 int system_if_down(struct device
*dev
)
64 D(SYSTEM
, "ifconfig %s down\n", dev
->ifname
);
68 void system_if_clear_state(struct device
*dev
)
72 int system_if_check(struct device
*dev
)
76 if (!strcmp(dev
->ifname
, "eth0"))
77 device_set_present(dev
, true);
83 system_if_get_parent(struct device
*dev
)
85 if (!strcmp(dev
->ifname
, "eth0"))
86 return device_get("eth1", true);
91 int system_if_dump_stats(struct device
*dev
, struct blob_buf
*b
)
96 int system_add_address(struct device
*dev
, struct device_addr
*addr
)
98 uint8_t *a
= (uint8_t *) &addr
->addr
.in
;
101 if ((addr
->flags
& DEVADDR_FAMILY
) == DEVADDR_INET4
) {
102 D(SYSTEM
, "ifconfig %s add %d.%d.%d.%d/%d\n",
103 dev
->ifname
, a
[0], a
[1], a
[2], a
[3], addr
->mask
);
105 inet_ntop(AF_INET6
, &addr
->addr
.in6
, ipaddr
, sizeof(struct in6_addr
));
106 D(SYSTEM
, "ifconfig %s add %s/%d\n",
107 dev
->ifname
, ipaddr
, addr
->mask
);
114 int system_del_address(struct device
*dev
, struct device_addr
*addr
)
116 uint8_t *a
= (uint8_t *) &addr
->addr
.in
;
119 if ((addr
->flags
& DEVADDR_FAMILY
) == DEVADDR_INET4
) {
120 D(SYSTEM
, "ifconfig %s del %d.%d.%d.%d\n",
121 dev
->ifname
, a
[0], a
[1], a
[2], a
[3]);
123 inet_ntop(AF_INET6
, &addr
->addr
.in6
, ipaddr
, sizeof(struct in6_addr
));
124 D(SYSTEM
, "ifconfig %s del %s/%d\n",
125 dev
->ifname
, ipaddr
, addr
->mask
);
132 int system_add_route(struct device
*dev
, struct device_route
*route
)
134 uint8_t *a1
= (uint8_t *) &route
->addr
.in
;
135 uint8_t *a2
= (uint8_t *) &route
->nexthop
.in
;
136 char addr
[40], gw
[40] = "", devstr
[64] = "";
138 if ((route
->flags
& DEVADDR_FAMILY
) != DEVADDR_INET4
)
142 sprintf(addr
, "default");
144 sprintf(addr
, "%d.%d.%d.%d/%d",
145 a1
[0], a1
[1], a1
[2], a1
[3], route
->mask
);
147 if (memcmp(a2
, "\x00\x00\x00\x00", 4) != 0)
148 sprintf(gw
, " gw %d.%d.%d.%d",
149 a2
[0], a2
[1], a2
[2], a2
[3]);
151 if (route
->flags
& DEVADDR_DEVICE
)
152 sprintf(devstr
, " dev %s", dev
->ifname
);
154 D(SYSTEM
, "route add %s%s%s\n", addr
, gw
, devstr
);
158 int system_del_route(struct device
*dev
, struct device_route
*route
)
160 uint8_t *a1
= (uint8_t *) &route
->addr
.in
;
161 uint8_t *a2
= (uint8_t *) &route
->nexthop
.in
;
162 char addr
[40], gw
[40] = "", devstr
[64] = "";
164 if ((route
->flags
& DEVADDR_FAMILY
) != DEVADDR_INET4
)
168 sprintf(addr
, "default");
170 sprintf(addr
, "%d.%d.%d.%d/%d",
171 a1
[0], a1
[1], a1
[2], a1
[3], route
->mask
);
173 if (memcmp(a2
, "\x00\x00\x00\x00", 4) != 0)
174 sprintf(gw
, " gw %d.%d.%d.%d",
175 a2
[0], a2
[1], a2
[2], a2
[3]);
177 if (route
->flags
& DEVADDR_DEVICE
)
178 sprintf(devstr
, " dev %s", dev
->ifname
);
180 D(SYSTEM
, "route del %s%s%s\n", addr
, gw
, devstr
);
184 int system_flush_routes(void)
189 time_t system_get_rtime(void)
193 if (gettimeofday(&tv
, NULL
) == 0)