aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/setconf.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-09-25 04:22:09 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-02 02:45:53 +0200
commitf129bdab552d21ae3cd77412342b94b5f23587b2 (patch)
tree4cb9ebc3ed181a9fd463ac00dbca0274c647a79c /src/tools/setconf.c
parenttools: uapi: only make sure socket file is socket (diff)
downloadwireguard-monolithic-historical-f129bdab552d21ae3cd77412342b94b5f23587b2.tar.xz
wireguard-monolithic-historical-f129bdab552d21ae3cd77412342b94b5f23587b2.zip
netlink: switch from ioctl to netlink for configuration
Diffstat (limited to 'src/tools/setconf.c')
-rw-r--r--src/tools/setconf.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/tools/setconf.c b/src/tools/setconf.c
index c70edab..1857ff6 100644
--- a/src/tools/setconf.c
+++ b/src/tools/setconf.c
@@ -5,6 +5,7 @@
#include <stdlib.h>
#include <string.h>
+#include "containers.h"
#include "config.h"
#include "ipc.h"
#include "subcommands.h"
@@ -28,7 +29,7 @@ int setconf_main(int argc, char *argv[])
perror("fopen");
return 1;
}
- if (!config_read_init(&ctx, &device, !strcmp(argv[0], "addconf"))) {
+ if (!config_read_init(&ctx, !strcmp(argv[0], "addconf"))) {
fclose(config_input);
return 1;
}
@@ -38,12 +39,13 @@ int setconf_main(int argc, char *argv[])
goto cleanup;
}
}
- if (!config_read_finish(&ctx) || !device) {
+ device = config_read_finish(&ctx);
+ if (!device) {
fprintf(stderr, "Invalid configuration\n");
goto cleanup;
}
- strncpy(device->interface, argv[1], IFNAMSIZ - 1);
- device->interface[IFNAMSIZ - 1] = 0;
+ strncpy(device->name, argv[1], IFNAMSIZ - 1);
+ device->name[IFNAMSIZ - 1] = 0;
if (ipc_set_device(device) != 0) {
perror("Unable to set device");
@@ -56,6 +58,6 @@ cleanup:
if (config_input)
fclose(config_input);
free(config_buffer);
- free(device);
+ free_wgdevice(device);
return ret;
}