Bubble android client. Fork of https://git.zx2c4.com/wireguard-android/
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

wg-quick.c 16 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. /* SPDX-License-Identifier: GPL-2.0
  2. *
  3. * Copyright (C) 2015-2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
  4. *
  5. * This is a shell script written in C. It very intentionally still functions like
  6. * a shell script, calling out to external executables such as ip(8).
  7. */
  8. #define _GNU_SOURCE
  9. #include <stdlib.h>
  10. #include <stdio.h>
  11. #include <stdbool.h>
  12. #include <string.h>
  13. #include <strings.h>
  14. #include <stdarg.h>
  15. #include <ctype.h>
  16. #include <time.h>
  17. #include <unistd.h>
  18. #include <errno.h>
  19. #include <regex.h>
  20. #include <sys/types.h>
  21. #include <sys/stat.h>
  22. #include <sys/wait.h>
  23. #include <sys/param.h>
  24. #ifndef WG_CONFIG_SEARCH_PATHS
  25. #define WG_CONFIG_SEARCH_PATHS "/data/misc/wireguard /data/data/com.wireguard.android/files"
  26. #endif
  27. #define _printf_(x, y) __attribute__((format(printf, x, y)))
  28. #define _cleanup_(x) __attribute__((cleanup(x)))
  29. #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
  30. static bool is_exiting = false;
  31. static void *xmalloc(size_t size)
  32. {
  33. void *ret = malloc(size);
  34. if (ret)
  35. return ret;
  36. perror("Error: malloc");
  37. exit(errno);
  38. }
  39. static void *xstrdup(const char *str)
  40. {
  41. char *ret = strdup(str);
  42. if (ret)
  43. return ret;
  44. perror("Error: strdup");
  45. exit(errno);
  46. }
  47. static void xregcomp(regex_t *preg, const char *regex, int cflags)
  48. {
  49. if (regcomp(preg, regex, cflags)) {
  50. fprintf(stderr, "Error: Regex compilation error\n");
  51. exit(EBADR);
  52. }
  53. }
  54. static char *concat(char *first, ...)
  55. {
  56. va_list args;
  57. size_t len = 0;
  58. char *ret;
  59. va_start(args, first);
  60. for (char *i = first; i; i = va_arg(args, char *))
  61. len += strlen(i);
  62. va_end(args);
  63. ret = xmalloc(len + 1);
  64. ret[0] = '\0';
  65. va_start(args, first);
  66. for (char *i = first; i; i = va_arg(args, char *))
  67. strcat(ret, i);
  68. va_end(args);
  69. return ret;
  70. }
  71. static char *concat_and_free(char *orig, const char *delim, const char *new_line)
  72. {
  73. char *ret;
  74. if (!orig)
  75. ret = xstrdup(new_line);
  76. else
  77. ret = concat(orig, delim, new_line, NULL);
  78. free(orig);
  79. return ret;
  80. }
  81. struct command_buffer {
  82. char *line;
  83. size_t len;
  84. FILE *stream;
  85. };
  86. static void free_command_buffer(struct command_buffer *c)
  87. {
  88. if (!c)
  89. return;
  90. if (c->stream)
  91. pclose(c->stream);
  92. free(c->line);
  93. }
  94. static void freep(void *p)
  95. {
  96. free(*(void **)p);
  97. }
  98. static void fclosep(FILE **f)
  99. {
  100. if (*f)
  101. fclose(*f);
  102. }
  103. #define _cleanup_free_ _cleanup_(freep)
  104. #define _cleanup_fclose_ _cleanup_(fclosep)
  105. #define DEFINE_CMD(name) _cleanup_(free_command_buffer) struct command_buffer name = { 0 };
  106. static char *vcmd_ret(struct command_buffer *c, const char *cmd_fmt, va_list args)
  107. {
  108. _cleanup_free_ char *cmd = NULL;
  109. if (!c->stream && !cmd_fmt)
  110. return NULL;
  111. if (c->stream && cmd_fmt)
  112. pclose(c->stream);
  113. if (cmd_fmt) {
  114. if (vasprintf(&cmd, cmd_fmt, args) < 0) {
  115. perror("Error: vasprintf");
  116. exit(errno);
  117. }
  118. c->stream = popen(cmd, "r");
  119. if (!c->stream) {
  120. perror("Error: popen");
  121. exit(errno);
  122. }
  123. }
  124. errno = 0;
  125. if (getline(&c->line, &c->len, c->stream) < 0) {
  126. if (errno) {
  127. perror("Error: getline");
  128. exit(errno);
  129. }
  130. return NULL;
  131. }
  132. return c->line;
  133. }
  134. _printf_(1, 2) static void cmd(const char *cmd_fmt, ...)
  135. {
  136. _cleanup_free_ char *cmd = NULL;
  137. va_list args;
  138. int ret;
  139. va_start(args, cmd_fmt);
  140. if (vasprintf(&cmd, cmd_fmt, args) < 0) {
  141. perror("Error: vasprintf");
  142. exit(errno);
  143. }
  144. va_end(args);
  145. printf("[#] %s\n", cmd);
  146. ret = system(cmd);
  147. if (ret < 0)
  148. ret = ESRCH;
  149. else if (ret > 0)
  150. ret = WIFEXITED(ret) ? WEXITSTATUS(ret) : EIO;
  151. if (ret && !is_exiting)
  152. exit(ret);
  153. }
  154. _printf_(2, 3) static char *cmd_ret(struct command_buffer *c, const char *cmd_fmt, ...)
  155. {
  156. va_list args;
  157. char *ret;
  158. va_start(args, cmd_fmt);
  159. ret = vcmd_ret(c, cmd_fmt, args);
  160. va_end(args);
  161. return ret;
  162. }
  163. _printf_(1, 2) static void cndc(const char *cmd_fmt, ...)
  164. {
  165. DEFINE_CMD(c);
  166. int error_code;
  167. char *ret;
  168. va_list args;
  169. _cleanup_free_ char *ndc_fmt = concat("ndc ", cmd_fmt, NULL);
  170. va_start(args, cmd_fmt);
  171. printf("[#] ");
  172. vprintf(ndc_fmt, args);
  173. printf("\n");
  174. va_end(args);
  175. va_start(args, cmd_fmt);
  176. ret = vcmd_ret(&c, ndc_fmt, args);
  177. va_end(args);
  178. if (!ret) {
  179. fprintf(stderr, "Error: could not call ndc\n");
  180. exit(ENOSYS);
  181. }
  182. error_code = atoi(ret);
  183. if (error_code >= 400 && error_code < 600) {
  184. fprintf(stderr, "Error: %s\n", ret);
  185. exit(ENONET);
  186. }
  187. }
  188. static void auto_su(int argc, char *argv[])
  189. {
  190. char *args[argc + 4];
  191. if (!getuid())
  192. return;
  193. args[0] = "su";
  194. args[1] = "-p";
  195. args[2] = "-c";
  196. memcpy(&args[3], argv, argc * sizeof(*args));
  197. args[argc + 3] = NULL;
  198. printf("[$] su -p -c ");
  199. for (int i = 0; i < argc; ++i)
  200. printf("%s%c", argv[i], i == argc - 1 ? '\n' : ' ');
  201. execvp("su", args);
  202. exit(errno);
  203. }
  204. static void add_if(const char *iface)
  205. {
  206. cmd("ip link add %s type wireguard", iface);
  207. }
  208. static void del_if(const char *iface)
  209. {
  210. DEFINE_CMD(c);
  211. regex_t reg;
  212. regmatch_t matches[2];
  213. char *netid = NULL;
  214. _cleanup_free_ char *regex = concat("0xc([0-9a-f]+)/0xcffff lookup ", iface, NULL);
  215. xregcomp(&reg, regex, REG_EXTENDED);
  216. cmd("ip link del %s", iface);
  217. for (char *ret = cmd_ret(&c, "ip rule show"); ret; ret = cmd_ret(&c, NULL)) {
  218. if (!regexec(&reg, ret, ARRAY_SIZE(matches), matches, 0)) {
  219. ret[matches[1].rm_eo] = '\0';
  220. netid = &ret[matches[1].rm_so];
  221. break;
  222. }
  223. }
  224. if (netid)
  225. cndc("network destroy %lu", strtoul(netid, NULL, 16));
  226. }
  227. static void up_if(unsigned int *netid, const char *iface)
  228. {
  229. srandom(time(NULL) ^ getpid()); /* Not real randomness. */
  230. while (*netid < 4096)
  231. *netid = random() & 0xfffe;
  232. cmd("wg set %s fwmark 0x20000", iface);
  233. cndc("interface setcfg %s up", iface);
  234. cndc("network create %u vpn 1 1", *netid);
  235. cndc("network interface add %u %s", *netid, iface);
  236. cndc("network users add %u 0-99999", *netid);
  237. }
  238. static void set_dnses(unsigned int netid, const char *dnses)
  239. {
  240. size_t len = strlen(dnses);
  241. if (len > (1<<16))
  242. return;
  243. _cleanup_free_ char *mutable = xstrdup(dnses);
  244. _cleanup_free_ char *arglist = xmalloc(len * 4 + 1);
  245. _cleanup_free_ char *arg = xmalloc(len + 4);
  246. if (!len)
  247. return;
  248. arglist[0] = '\0';
  249. for (char *dns = strtok(mutable, ", \t\n"); dns; dns = strtok(NULL, ", \t\n")) {
  250. if (strchr(dns, '\'') || strchr(dns, '\\'))
  251. continue;
  252. snprintf(arg, len + 3, "'%s' ", dns);
  253. strncat(arglist, arg, len * 4 - 1);
  254. }
  255. if (!strlen(arglist))
  256. return;
  257. cndc("resolver setnetdns %u '' %s", netid, arglist);
  258. }
  259. static void add_addr(const char *iface, const char *addr)
  260. {
  261. if (strchr(addr, ':')) {
  262. cndc("interface ipv6 %s enable", iface);
  263. cmd("ip -6 addr add '%s' dev %s", addr, iface);
  264. } else {
  265. _cleanup_free_ char *mut_addr = strdup(addr);
  266. char *slash = strchr(mut_addr, '/');
  267. unsigned char mask = 32;
  268. if (slash) {
  269. *slash = '\0';
  270. mask = atoi(slash + 1);
  271. }
  272. cndc("interface setcfg %s '%s' %u", iface, mut_addr, mask);
  273. }
  274. }
  275. static void set_addr(const char *iface, const char *addrs)
  276. {
  277. _cleanup_free_ char *mutable = xstrdup(addrs);
  278. for (char *addr = strtok(mutable, ", \t\n"); addr; addr = strtok(NULL, ", \t\n")) {
  279. if (strchr(addr, '\'') || strchr(addr, '\\'))
  280. continue;
  281. add_addr(iface, addr);
  282. }
  283. }
  284. static int get_route_mtu(const char *endpoint)
  285. {
  286. DEFINE_CMD(c_route);
  287. DEFINE_CMD(c_dev);
  288. regmatch_t matches[2];
  289. regex_t regex_mtu, regex_dev;
  290. char *route, *mtu, *dev;
  291. xregcomp(&regex_mtu, "mtu ([0-9]+)", REG_EXTENDED);
  292. xregcomp(&regex_dev, "dev ([^ ]+)", REG_EXTENDED);
  293. if (strcmp(endpoint, "default"))
  294. route = cmd_ret(&c_route, "ip -o route get %s", endpoint);
  295. else
  296. route = cmd_ret(&c_route, "ip -o route show %s", endpoint);
  297. if (!route)
  298. return -1;
  299. if (!regexec(&regex_mtu, route, ARRAY_SIZE(matches), matches, 0)) {
  300. route[matches[1].rm_eo] = '\0';
  301. mtu = &route[matches[1].rm_so];
  302. } else if (!regexec(&regex_dev, route, ARRAY_SIZE(matches), matches, 0)) {
  303. route[matches[1].rm_eo] = '\0';
  304. dev = &route[matches[1].rm_so];
  305. route = cmd_ret(&c_dev, "ip -o link show dev %s", dev);
  306. if (!route)
  307. return -1;
  308. if (regexec(&regex_mtu, route, ARRAY_SIZE(matches), matches, 0))
  309. return -1;
  310. route[matches[1].rm_eo] = '\0';
  311. mtu = &route[matches[1].rm_so];
  312. } else
  313. return -1;
  314. return atoi(mtu);
  315. }
  316. static void set_mtu(const char *iface, unsigned int mtu)
  317. {
  318. DEFINE_CMD(c_endpoints);
  319. regex_t regex_endpoint;
  320. regmatch_t matches[2];
  321. int endpoint_mtu, next_mtu;
  322. if (mtu) {
  323. cndc("interface setmtu %s %u", iface, mtu);
  324. return;
  325. }
  326. xregcomp(&regex_endpoint, "^\\[?([a-z0-9:.]+)\\]?:[0-9]+$", REG_EXTENDED);
  327. endpoint_mtu = get_route_mtu("default");
  328. if (endpoint_mtu == -1)
  329. endpoint_mtu = 1500;
  330. for (char *endpoint = cmd_ret(&c_endpoints, "wg show %s endpoints", iface); endpoint; endpoint = cmd_ret(&c_endpoints, NULL)) {
  331. if (regexec(&regex_endpoint, endpoint, ARRAY_SIZE(matches), matches, 0))
  332. continue;
  333. endpoint[matches[1].rm_eo] = '\0';
  334. endpoint = &endpoint[matches[1].rm_so];
  335. next_mtu = get_route_mtu(endpoint);
  336. if (next_mtu > 0 && next_mtu < endpoint_mtu)
  337. endpoint_mtu = next_mtu;
  338. }
  339. cndc("interface setmtu %s %d", iface, endpoint_mtu - 80);
  340. }
  341. static void add_route(const char *iface, unsigned int netid, const char *route)
  342. {
  343. cndc("network route add %u %s %s", netid, iface, route);
  344. }
  345. static void set_routes(const char *iface, unsigned int netid)
  346. {
  347. DEFINE_CMD(c);
  348. for (char *allowedips = cmd_ret(&c, "wg show %s allowed-ips", iface); allowedips; allowedips = cmd_ret(&c, NULL)) {
  349. char *start = strchr(allowedips, '\t');
  350. if (!start)
  351. continue;
  352. ++start;
  353. for (char *allowedip = strtok(start, " \n"); allowedip; allowedip = strtok(NULL, " \n"))
  354. add_route(iface, netid, allowedip);
  355. }
  356. }
  357. static void set_config(const char *iface, const char *config)
  358. {
  359. FILE *config_writer;
  360. _cleanup_free_ char *cmd = concat("wg setconf ", iface, " /proc/self/fd/0", NULL);
  361. int ret;
  362. printf("[#] %s\n", cmd);
  363. config_writer = popen(cmd, "w");
  364. if (!config_writer) {
  365. perror("Error: popen");
  366. exit(errno);
  367. }
  368. if (fputs(config, config_writer) < 0) {
  369. perror("Error: fputs");
  370. exit(errno);
  371. }
  372. ret = pclose(config_writer);
  373. if (ret)
  374. exit(WIFEXITED(ret) ? WEXITSTATUS(ret) : EIO);
  375. }
  376. static void print_search_paths(FILE *file, const char *prefix)
  377. {
  378. _cleanup_free_ char *paths = strdup(WG_CONFIG_SEARCH_PATHS);
  379. for (char *path = strtok(paths, " "); path; path = strtok(NULL, " "))
  380. fprintf(file, "%s%s\n", prefix, path);
  381. }
  382. static void cmd_usage(const char *program)
  383. {
  384. printf( "Usage: %s [ up | down ] [ CONFIG_FILE | INTERFACE ]\n"
  385. "\n"
  386. " CONFIG_FILE is a configuration file, whose filename is the interface name\n"
  387. " followed by `.conf'. Otherwise, INTERFACE is an interface name, with\n"
  388. " configuration found at:\n\n", program);
  389. print_search_paths(stdout, " - ");
  390. printf( "\n It is to be readable by wg(8)'s `setconf' sub-command, with the exception\n"
  391. " of the following additions to the [Interface] section, which are handled by\n"
  392. " this program:\n\n"
  393. " - Address: may be specified one or more times and contains one or more\n"
  394. " IP addresses (with an optional CIDR mask) to be set for the interface.\n"
  395. " - MTU: an optional MTU for the interface; if unspecified, auto-calculated.\n"
  396. " - DNS: an optional DNS server to use while the device is up.\n\n"
  397. " See wg-quick(8) for more info and examples.\n");
  398. }
  399. static char *cleanup_iface = NULL;
  400. static void cmd_up_cleanup(void)
  401. {
  402. is_exiting = true;
  403. if (cleanup_iface)
  404. del_if(cleanup_iface);
  405. free(cleanup_iface);
  406. }
  407. static void cmd_up(const char *iface, const char *config, unsigned int mtu, const char *addrs, const char *dnses)
  408. {
  409. DEFINE_CMD(c);
  410. unsigned int netid = 0;
  411. if (cmd_ret(&c, "ip link show dev %s 2>/dev/null", iface)) {
  412. fprintf(stderr, "Error: %s already exists\n", iface);
  413. exit(EEXIST);
  414. }
  415. cleanup_iface = xstrdup(iface);
  416. atexit(cmd_up_cleanup);
  417. add_if(iface);
  418. set_config(iface, config);
  419. set_addr(iface, addrs);
  420. up_if(&netid, iface);
  421. set_dnses(netid, dnses);
  422. set_routes(iface, netid);
  423. set_mtu(iface, mtu);
  424. free(cleanup_iface);
  425. cleanup_iface = NULL;
  426. exit(EXIT_SUCCESS);
  427. }
  428. static void cmd_down(const char *iface)
  429. {
  430. DEFINE_CMD(c);
  431. bool found = false;
  432. char *ifaces = cmd_ret(&c, "wg show interfaces");
  433. if (ifaces) {
  434. for (char *eiface = strtok(ifaces, " \n"); eiface; eiface = strtok(NULL, " \n")) {
  435. if (!strcmp(iface, eiface)) {
  436. found = true;
  437. break;
  438. }
  439. }
  440. }
  441. if (!found) {
  442. fprintf(stderr, "Error: %s is not a WireGuard interface\n", iface);
  443. exit(EMEDIUMTYPE);
  444. }
  445. del_if(iface);
  446. exit(EXIT_SUCCESS);
  447. }
  448. static void parse_options(char **iface, char **config, unsigned int *mtu, char **addrs, char **dnses, const char *arg)
  449. {
  450. _cleanup_fclose_ FILE *file = NULL;
  451. _cleanup_free_ char *line = NULL;
  452. _cleanup_free_ char *filename = NULL;
  453. _cleanup_free_ char *paths = strdup(WG_CONFIG_SEARCH_PATHS);
  454. regex_t regex_iface, regex_conf;
  455. regmatch_t matches[2];
  456. struct stat sbuf;
  457. size_t n = 0;
  458. bool in_interface_section = false;
  459. *iface = *config = *addrs = *dnses = NULL;
  460. *mtu = 0;
  461. xregcomp(&regex_iface, "^[a-zA-Z0-9_=+.-]{1,15}$", REG_EXTENDED | REG_NOSUB);
  462. xregcomp(&regex_conf, "/?([a-zA-Z0-9_=+.-]{1,15})\\.conf$", REG_EXTENDED);
  463. if (!regexec(&regex_iface, arg, 0, NULL, 0)) {
  464. for (char *path = strtok(paths, " "); path; path = strtok(NULL, " ")) {
  465. free(filename);
  466. if (asprintf(&filename, "%s/%s.conf", path, arg) < 0) {
  467. perror("Error: asprintf");
  468. exit(errno);
  469. }
  470. file = fopen(filename, "r");
  471. if (file)
  472. break;
  473. }
  474. if (!file) {
  475. fprintf(stderr, "Error: Unable to find configuration file for `%s' in:\n", arg);
  476. print_search_paths(stderr, "- ");
  477. exit(errno);
  478. }
  479. } else {
  480. filename = xstrdup(arg);
  481. file = fopen(filename, "r");
  482. if (!file) {
  483. fprintf(stderr, "Error: Unable to find configuration file at `%s'\n", filename);
  484. exit(errno);
  485. }
  486. }
  487. if (regexec(&regex_conf, filename, ARRAY_SIZE(matches), matches, 0)) {
  488. fprintf(stderr, "Error: The config file must be a valid interface name, followed by .conf\n");
  489. exit(EINVAL);
  490. }
  491. if (fstat(fileno(file), &sbuf) < 0) {
  492. perror("Error: fstat");
  493. exit(errno);
  494. }
  495. if (sbuf.st_mode & 0007)
  496. fprintf(stderr, "Warning: `%s' is world accessible\n", filename);
  497. filename[matches[1].rm_eo] = 0;
  498. *iface = xstrdup(&filename[matches[1].rm_so]);
  499. while (getline(&line, &n, file) >= 0) {
  500. size_t len = strlen(line), j = 0;
  501. if (len > (1<<16))
  502. return;
  503. _cleanup_free_ char *clean = xmalloc(len + 1);
  504. for (size_t i = 0; i < len; ++i) {
  505. if (!isspace(line[i]))
  506. clean[j++] = line[i];
  507. }
  508. clean[j] = '\0';
  509. if (clean[0] == '[')
  510. in_interface_section = false;
  511. if (!strcasecmp(clean, "[Interface]"))
  512. in_interface_section = true;
  513. if (in_interface_section) {
  514. if (!strncasecmp(clean, "Address=", 8) && j > 8) {
  515. *addrs = concat_and_free(*addrs, ",", clean + 8);
  516. continue;
  517. } else if (!strncasecmp(clean, "DNS=", 4) && j > 4) {
  518. *dnses = concat_and_free(*dnses, ",", clean + 4);
  519. continue;
  520. } else if (!strncasecmp(clean, "MTU=", 4) && j > 4) {
  521. *mtu = atoi(clean + 4);
  522. continue;
  523. }
  524. }
  525. *config = concat_and_free(*config, "", line);
  526. }
  527. if (!*iface)
  528. *iface = xstrdup("");
  529. if (!*config)
  530. *config = xstrdup("");
  531. if (!*addrs)
  532. *addrs = xstrdup("");
  533. if (!*dnses)
  534. *dnses = xstrdup("");
  535. }
  536. int main(int argc, char *argv[])
  537. {
  538. _cleanup_free_ char *iface = NULL;
  539. _cleanup_free_ char *config = NULL;
  540. _cleanup_free_ char *addrs = NULL;
  541. _cleanup_free_ char *dnses = NULL;
  542. unsigned int mtu;
  543. if (argc == 2 && (!strcmp(argv[1], "help") || !strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")))
  544. cmd_usage(argv[0]);
  545. else if (argc == 3 && !strcmp(argv[1], "up")) {
  546. auto_su(argc, argv);
  547. parse_options(&iface, &config, &mtu, &addrs, &dnses, argv[2]);
  548. cmd_up(iface, config, mtu, addrs, dnses);
  549. } else if (argc == 3 && !strcmp(argv[1], "down")) {
  550. auto_su(argc, argv);
  551. parse_options(&iface, &config, &mtu, &addrs, &dnses, argv[2]);
  552. cmd_down(iface);
  553. } else {
  554. cmd_usage(argv[0]);
  555. return 1;
  556. }
  557. return 0;
  558. }