]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commitdiff
wg: rename kernel to ipc
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 20 Jul 2016 19:24:27 +0000 (21:24 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Thu, 21 Jul 2016 09:26:52 +0000 (11:26 +0200)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
src/config.c
src/ipc.c [moved from src/kernel.c with 98% similarity]
src/ipc.h [moved from src/kernel.h with 76% similarity]
src/set.c
src/setconf.c
src/show.c
src/showconf.c

index c24aa8706b930eb876bd9f32c3f2d68a4adea25e..611207e1f7863c8b2be839b911035f2af9b8dd76 100644 (file)
@@ -12,7 +12,7 @@
 #include <errno.h>
 
 #include "config.h"
-#include "kernel.h"
+#include "ipc.h"
 #include "base64.h"
 
 #define COMMENT_CHAR '#'
similarity index 98%
rename from src/kernel.c
rename to src/ipc.c
index ad5d1fe618cc14a8970c6ca5aff1bab6fb23214e..3243fcbf8b6e6ffd87e5d18479b70f85eb304fc5 100644 (file)
+++ b/src/ipc.c
@@ -26,7 +26,7 @@
 #include <sys/un.h>
 #include <sys/signal.h>
 
-#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);
similarity index 76%
rename from src/kernel.h
rename to src/ipc.h
index 8aa0f8286d913ac7060f2a63210c88138afcf697..b2312ad4237ac6a998e73778e805966795bd97d2 100644 (file)
+++ b/src/ipc.h
@@ -1,16 +1,16 @@
 /* Copyright 2015-2016 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. */
 
-#ifndef KERNEL_H
-#define KERNEL_H
+#ifndef IPC_H
+#define IPC_H
 
 #include <stdbool.h>
 
 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)); \
index 8278151a1085f845f998bf58c74154d92b7eee01..65f3ff6fb8365ed1dbd0c592c2bd9d69a6d7744f 100644 (file)
--- a/src/set.c
+++ b/src/set.c
@@ -5,7 +5,7 @@
 #include <string.h>
 #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;
        }
index a9787eb7e26883ba6313f82984254df28d9cbb81..a3105e1ed849f175982e98bf8153dbf75cfb1deb 100644 (file)
@@ -6,7 +6,7 @@
 #include <string.h>
 
 #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;
        }
index d606b4ed8c95254f69481c8e5a2e837431b65089..ddda6c3fdf0bc78ced1d2cec3c56f7a049821c6c 100644 (file)
@@ -14,7 +14,7 @@
 #include <time.h>
 #include <netdb.h>
 
-#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;
index 68084c03a509044c2e1c3e0ff73f0ebaf2a0813d..75d78e04359819af50a39cdca39e8f4fcaa020a3 100644 (file)
@@ -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 <interface>\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;
        }