This repository has been archived on 2024-01-23. You can view files and clone it, but cannot push or open issues or pull requests.
2015-06-05 15:58:00 +02:00
|
|
|
/* Copyright 2015-2016 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "subcommands.h"
|
|
|
|
#include "config.h"
|
2016-07-20 21:24:27 +02:00
|
|
|
#include "ipc.h"
|
2015-06-05 15:58:00 +02:00
|
|
|
|
|
|
|
int set_main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
struct wgdevice *device = NULL;
|
|
|
|
int ret = 1;
|
|
|
|
|
|
|
|
if (argc < 3) {
|
2016-07-08 02:30:03 +02:00
|
|
|
fprintf(stderr, "Usage: %s %s <interface> [listen-port <port>] [private-key <file path>] [peer <base64 public key> [remove] [endpoint <ip>:<port>] [persistent-keepalive <interval seconds>] [allowed-ips <ip1>/<cidr1>[,<ip2>/<cidr2>]...] ]...\n", PROG_NAME, argv[0]);
|
2015-06-05 15:58:00 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!config_read_cmd(&device, argv + 2, argc - 2))
|
|
|
|
goto cleanup;
|
|
|
|
strncpy(device->interface, argv[1], IFNAMSIZ - 1);
|
|
|
|
device->interface[IFNAMSIZ - 1] = 0;
|
|
|
|
|
2016-07-20 21:24:27 +02:00
|
|
|
if (ipc_set_device(device) != 0) {
|
2015-06-05 15:58:00 +02:00
|
|
|
perror("Unable to set device");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
free(device);
|
|
|
|
return ret;
|
|
|
|
}
|