diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-12-16 03:47:05 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-12-16 03:51:43 +0100 |
commit | ae339a000e8f25e7aa98d3db3d8d576072802188 (patch) | |
tree | d5de68ad597a73ee7d240977a987b03618df03d3 /wireguard-go-bridge/example.c | |
parent | Bump the go runtime (diff) | |
download | wireguard-apple-ae339a000e8f25e7aa98d3db3d8d576072802188.tar.xz wireguard-apple-ae339a000e8f25e7aa98d3db3d8d576072802188.zip |
Further generalize makefile
This should allow us to eventually build on macOS
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | wireguard-go-bridge/example.c | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/wireguard-go-bridge/example.c b/wireguard-go-bridge/example.c deleted file mode 100644 index 7ba0c42..0000000 --- a/wireguard-go-bridge/example.c +++ /dev/null @@ -1,46 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 - * - * Copyright (C) 2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. - */ - -#include "wireguard.h" -#include <stdio.h> -#include <stdbool.h> -#include <unistd.h> - -static struct { - int something; -} ctx; - -static bool is_closed = false; - -ssize_t do_read(void *ctx, unsigned char *buf, size_t len) -{ - printf("Reading from instance with ctx %p into buffer %p of length %zu\n", ctx, buf, len); - sleep(1); - return is_closed ? -1 : 0; -} - -ssize_t do_write(void *ctx, unsigned char *buf, size_t len) -{ - printf("Writing from instance with ctx %p into buffer %p of length %zu\n", ctx, buf, len); - return len; -} - -void do_log(int level, const char *msg) -{ - printf("Log level %d: %s", level, msg); -} - -int main(int argc, char *argv[]) -{ - int handle; - - printf("WireGuard Go Version %s\n", wgVersion()); - wgSetLogger(do_log); - handle = wgTurnOn((gostring_t){ .p = "test", .n = 4 }, (gostring_t){ .p = "", .n = 0 }, 0, do_read, do_write, &ctx); - sleep(5); - is_closed = true; - wgTurnOff(handle); - return 0; -} |