// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2015-2020 Jason A. Donenfeld . All Rights Reserved. */ #include #include #include #include "containers.h" #include "config.h" #include "ipc.h" #include "subcommands.h" int set_main(int argc, char *argv[]) { struct wgdevice *device = NULL; int ret = 1; if (argc < 3) { fprintf(stderr, "Usage: %s %s [listen-port ] [fwmark ] [private-key ] [peer [remove] [preshared-key ] [endpoint :] [persistent-keepalive ] [allowed-ips /[,/]...] ]...\n", PROG_NAME, argv[0]); return 1; } device = config_read_cmd(argv + 2, argc - 2); if (!device) goto cleanup; strncpy(device->name, argv[1], IFNAMSIZ - 1); device->name[IFNAMSIZ - 1] = '\0'; if (ipc_set_device(device) != 0) { perror("Unable to modify interface"); goto cleanup; } ret = 0; cleanup: free_wgdevice(device); return ret; }