7static 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);
121 if (!dst_str || !gw_str)
126 ret = inet_pton(AF_INET, dst_str, &dst);
132 ret = inet_pton(AF_INET, gw_str, &gw);
141 printf(
"CMD: ip route add %s/%d dev %s via %s", dst_str, prefixlen,
iface, gw_str);
144 printf(
" metric %d", metric);
148 return net_route_v4_add(NULL, &dst, prefixlen, &gw,
iface, 0, metric);
162 ret = inet_pton(AF_INET6, dst_str, &dst);
168 printf(
"CMD: ip -6 route add %s/%d dev %s", dst_str, prefixlen,
iface);
171 printf(
" metric %d", metric);
175 return net_route_v6_add(NULL, &dst, prefixlen, NULL,
iface, 0, metric);
181 struct in6_addr dst, gw;
184 if (!dst_str || !gw_str)
189 ret = inet_pton(AF_INET6, dst_str, &dst);
195 ret = inet_pton(AF_INET6, gw_str, &gw);
201 printf(
"CMD: ip -6 route add %s/%d dev %s via %s", dst_str, prefixlen,
iface, gw_str);
204 printf(
" metric %d", metric);
208 return net_route_v6_add(NULL, &dst, prefixlen, &gw,
iface, 0, metric);
214 printf(
"Usage: %s <0-8>\n", name);
229 if (strcmp(
argv[1],
"test") == 0)
239 test = atoi(
argv[1]);
275 printf(
"invalid test: %d\n", test);
#define IFACE_TYPE_LEN_MAX
static int net__route_v6_add_gw(const char *dst_str, int prefixlen, const char *gw_str, int metric)
static int net__addr_v6_add(const char *addr_str, int prefixlen)
static int net__iface_mtu_set(int mtu)
static int net__route_v4_add(const char *dst_str, int prefixlen, int metric)
static int net__iface_del(const char *name)
static int net__iface_new(const char *name, const char *type)
static int net__route_v4_add_gw(const char *dst_str, int prefixlen, const char *gw_str, int metric)
static int net__route_v6_add(const char *dst_str, int prefixlen, int metric)
static int net__addr_v4_add(const char *addr_str, int prefixlen)
static int net__iface_type(const char *name, const char *type)
static int net__iface_up(bool up)