From b318e81cd0849ef7725f6776a680eccc7fcfdc06 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 20 Jul 2016 21:24:27 +0200 Subject: [PATCH] wg: rename kernel to ipc Signed-off-by: Jason A. Donenfeld --- src/config.c | 2 +- src/{kernel.c => ipc.c} | 10 +++++----- src/{kernel.h => ipc.h} | 12 ++++++------ src/set.c | 4 ++-- src/setconf.c | 4 ++-- src/show.c | 12 ++++++------ src/showconf.c | 6 +++--- 7 files changed, 25 insertions(+), 25 deletions(-) rename src/{kernel.c => ipc.c} (98%) rename src/{kernel.h => ipc.h} (76%) diff --git a/src/config.c b/src/config.c index c24aa87..611207e 100644 --- a/src/config.c +++ b/src/config.c @@ -12,7 +12,7 @@ #include #include "config.h" -#include "kernel.h" +#include "ipc.h" #include "base64.h" #define COMMENT_CHAR '#' diff --git a/src/kernel.c b/src/ipc.c similarity index 98% rename from src/kernel.c rename to src/ipc.c index ad5d1fe..3243fcb 100644 --- a/src/kernel.c +++ b/src/ipc.c @@ -26,7 +26,7 @@ #include #include -#include "kernel.h" +#include "ipc.h" #include "../uapi.h" #define SOCK_PATH RUNSTATEDIR "/wireguard/" @@ -455,7 +455,7 @@ out: #endif /* first\0second\0third\0forth\0last\0\0 */ -char *get_wireguard_interfaces(void) +char *ipc_list_devices(void) { struct inflatable_buffer buffer = { .len = 4096 }; int ret; @@ -484,7 +484,7 @@ cleanup: return buffer.buffer; } -int get_device(struct wgdevice **dev, const char *interface) +int ipc_get_device(struct wgdevice **dev, const char *interface) { #ifdef __linux__ if (userspace_has_wireguard_interface(interface)) @@ -495,7 +495,7 @@ int get_device(struct wgdevice **dev, const char *interface) #endif } -int set_device(struct wgdevice *dev) +int ipc_set_device(struct wgdevice *dev) { #ifdef __linux__ if (userspace_has_wireguard_interface(dev->interface)) @@ -506,7 +506,7 @@ int set_device(struct wgdevice *dev) #endif } -bool has_wireguard_interface(const char *interface) +bool ipc_has_device(const char *interface) { #ifdef __linux__ return userspace_has_wireguard_interface(interface) || kernel_has_wireguard_interface(interface); diff --git a/src/kernel.h b/src/ipc.h similarity index 76% rename from src/kernel.h rename to src/ipc.h index 8aa0f82..b2312ad 100644 --- a/src/kernel.h +++ b/src/ipc.h @@ -1,16 +1,16 @@ /* Copyright 2015-2016 Jason A. Donenfeld . All Rights Reserved. */ -#ifndef KERNEL_H -#define KERNEL_H +#ifndef IPC_H +#define IPC_H #include struct wgdevice; -int set_device(struct wgdevice *dev); -int get_device(struct wgdevice **dev, const char *interface); -char *get_wireguard_interfaces(void); -bool has_wireguard_interface(const char *interface); +int ipc_set_device(struct wgdevice *dev); +int ipc_get_device(struct wgdevice **dev, const char *interface); +char *ipc_list_devices(void); +bool ipc_has_device(const char *interface); #define for_each_wgpeer(__dev, __peer, __i) for ((__i) = 0, (__peer) = (typeof(__peer))((uint8_t *)(__dev) + sizeof(struct wgdevice)); \ diff --git a/src/set.c b/src/set.c index 8278151..65f3ff6 100644 --- a/src/set.c +++ b/src/set.c @@ -5,7 +5,7 @@ #include #include "subcommands.h" #include "config.h" -#include "kernel.h" +#include "ipc.h" int set_main(int argc, char *argv[]) { @@ -22,7 +22,7 @@ int set_main(int argc, char *argv[]) strncpy(device->interface, argv[1], IFNAMSIZ - 1); device->interface[IFNAMSIZ - 1] = 0; - if (set_device(device) != 0) { + if (ipc_set_device(device) != 0) { perror("Unable to set device"); goto cleanup; } diff --git a/src/setconf.c b/src/setconf.c index a9787eb..a3105e1 100644 --- a/src/setconf.c +++ b/src/setconf.c @@ -6,7 +6,7 @@ #include #include "config.h" -#include "kernel.h" +#include "ipc.h" #include "subcommands.h" int setconf_main(int argc, char *argv[]) @@ -45,7 +45,7 @@ int setconf_main(int argc, char *argv[]) strncpy(device->interface, argv[1], IFNAMSIZ - 1); device->interface[IFNAMSIZ - 1] = 0; - if (set_device(device) != 0) { + if (ipc_set_device(device) != 0) { perror("Unable to set device"); goto cleanup; } diff --git a/src/show.c b/src/show.c index d606b4e..ddda6c3 100644 --- a/src/show.c +++ b/src/show.c @@ -14,7 +14,7 @@ #include #include -#include "kernel.h" +#include "ipc.h" #include "subcommands.h" #include "terminal.h" #include "base64.h" @@ -326,7 +326,7 @@ int show_main(int argc, char *argv[]) } if (argc == 1 || !strcmp(argv[1], "all")) { - char *interfaces = get_wireguard_interfaces(), *interface; + char *interfaces = ipc_list_devices(), *interface; if (!interfaces) { perror("Unable to get devices"); return 1; @@ -334,7 +334,7 @@ int show_main(int argc, char *argv[]) interface = interfaces; for (size_t len = 0; (len = strlen(interface)); interface += len + 1) { struct wgdevice *device = NULL; - if (get_device(&device, interface) < 0) { + if (ipc_get_device(&device, interface) < 0) { perror("Unable to get device"); continue; } @@ -358,7 +358,7 @@ int show_main(int argc, char *argv[]) show_usage(); return 1; } - interfaces = get_wireguard_interfaces(); + interfaces = ipc_list_devices(); if (!interfaces) { perror("Unable to get devices"); return 1; @@ -371,12 +371,12 @@ int show_main(int argc, char *argv[]) show_usage(); else { struct wgdevice *device = NULL; - if (!has_wireguard_interface(argv[1])) { + if (!ipc_has_device(argv[1])) { fprintf(stderr, "`%s` is not a valid WireGuard interface\n", argv[1]); show_usage(); return 1; } - if (get_device(&device, argv[1]) < 0) { + if (ipc_get_device(&device, argv[1]) < 0) { perror("Unable to get device"); show_usage(); return 1; diff --git a/src/showconf.c b/src/showconf.c index 68084c0..75d78e0 100644 --- a/src/showconf.c +++ b/src/showconf.c @@ -12,7 +12,7 @@ #include "subcommands.h" #include "base64.h" -#include "kernel.h" +#include "ipc.h" #include "../uapi.h" int showconf_main(int argc, char *argv[]) @@ -31,13 +31,13 @@ int showconf_main(int argc, char *argv[]) return 1; } - if (!has_wireguard_interface(argv[1])) { + if (!ipc_has_device(argv[1])) { fprintf(stderr, "`%s` is not a valid WireGuard interface\n", argv[1]); fprintf(stderr, "Usage: %s %s \n", PROG_NAME, argv[0]); return 1; } - if (get_device(&device, argv[1])) { + if (ipc_get_device(&device, argv[1])) { perror("Unable to get device"); goto cleanup; }