wg: rename kernel to ipc

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2016-07-20 21:24:27 +02:00
parent 9889b42788
commit b318e81cd0
7 changed files with 25 additions and 25 deletions

View File

@ -12,7 +12,7 @@
#include <errno.h>
#include "config.h"
#include "kernel.h"
#include "ipc.h"
#include "base64.h"
#define COMMENT_CHAR '#'

View File

@ -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);

View File

@ -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)); \

View File

@ -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;
}

View 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;
}

View 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;

View 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;
}