7 static char *
iface =
"ovpn-dummy0";
12 printf(
"CMD: ip link set %s %s\n",
iface, up ?
"up" :
"down");
14 return net_iface_up(NULL,
iface, up);
20 return net_iface_new(NULL, name, type, NULL);
27 int ret = net_iface_type(NULL, name, ret_type);
30 assert(strcmp(type, ret_type) == 0);
39 return net_iface_del(NULL, name);
45 printf(
"CMD: ip link set %s mtu %d\n",
iface, mtu);
47 return net_iface_mtu_set(NULL,
iface, mtu);
56 ret = inet_pton(AF_INET, addr_str, &addr);
64 printf(
"CMD: ip addr add %s/%d dev %s\n", addr_str, prefixlen,
iface);
66 return net_addr_v4_add(NULL,
iface, &addr, prefixlen);
75 ret = inet_pton(AF_INET6, addr_str, &addr);
81 printf(
"CMD: ip -6 addr add %s/%d dev %s\n", addr_str, prefixlen,
iface);
83 return net_addr_v6_add(NULL,
iface, &addr, prefixlen);
97 ret = inet_pton(AF_INET, dst_str, &dst);
105 printf(
"CMD: ip route add %s/%d dev %s", dst_str, prefixlen,
iface);
108 printf(
" metric %d", metric);
112 return net_route_v4_add(NULL, &dst, prefixlen, NULL,
iface, 0, metric);
123 if (!dst_str || !gw_str)
128 ret = inet_pton(AF_INET, dst_str, &dst);
134 ret = inet_pton(AF_INET, gw_str, &gw);
143 printf(
"CMD: ip route add %s/%d dev %s via %s", dst_str, prefixlen,
iface,
147 printf(
" metric %d", metric);
151 return net_route_v4_add(NULL, &dst, prefixlen, &gw,
iface, 0, metric);
165 ret = inet_pton(AF_INET6, dst_str, &dst);
171 printf(
"CMD: ip -6 route add %s/%d dev %s", dst_str, prefixlen,
iface);
174 printf(
" metric %d", metric);
178 return net_route_v6_add(NULL, &dst, prefixlen, NULL,
iface, 0, metric);
186 struct in6_addr dst, gw;
189 if (!dst_str || !gw_str)
194 ret = inet_pton(AF_INET6, dst_str, &dst);
200 ret = inet_pton(AF_INET6, gw_str, &gw);
206 printf(
"CMD: ip -6 route add %s/%d dev %s via %s", dst_str, prefixlen,
210 printf(
" metric %d", metric);
214 return net_route_v6_add(NULL, &dst, prefixlen, &gw,
iface, 0, metric);
220 printf(
"Usage: %s <0-8>\n", name);
235 if (strcmp(
argv[1],
"test") == 0)
245 test = atoi(
argv[1]);
281 printf(
"invalid test: %d\n", test);