aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTushar Pankaj <tushar.s.pankaj@gmail.com>2018-11-07 10:59:13 -0600
committerTushar Pankaj <tushar.s.pankaj@gmail.com>2018-11-07 10:59:13 -0600
commit1f73168641d92917dc942c3d6cc200fb7f557674 (patch)
tree6d3116a873b4b9d6cd06cc3cb4781204133950c8
parentAdd Makefile library includes for capnp (diff)
parentWrite basic mains so project compiles (diff)
downloadwg-dynamic-1f73168641d92917dc942c3d6cc200fb7f557674.tar.xz
wg-dynamic-1f73168641d92917dc942c3d6cc200fb7f557674.zip
Merge branch 'master' into tp/protocol_draft
-rw-r--r--.gitignore4
-rw-r--r--Makefile11
-rw-r--r--TODO10
-rw-r--r--client.c (renamed from wg-dynamic-server.c)6
-rw-r--r--client.h11
-rw-r--r--server.c (renamed from wg-dynamic-client.c)6
-rw-r--r--server.h11
-rw-r--r--wg_dynamic_client.c33
-rw-r--r--wg_dynamic_server.c33
9 files changed, 121 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 9755cc7..841b8d5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,3 +53,7 @@ dkms.conf
# Editor temporaries
*~
+
+# Binaries
+wg-dynamic-client
+wg-dynamic-server
diff --git a/Makefile b/Makefile
index bab97c6..34e9c8e 100644
--- a/Makefile
+++ b/Makefile
@@ -10,16 +10,19 @@ CFLAGS ?= ${CFLAGS_DEBUG} ${LIBRARY_INCLUDES}
LDFLAGS ?= ${LDFLAGS_DEBUG} ${LIBRARY_LDFLAGS}
.PHONY: clean style
PROGS = wg-dynamic-client wg-dynamic-server
-CLIENT_OBJS = wg-dynamic-client.o protocol.capnp.o
-SERVER_OBJS = wg-dynamic-server.o protocol.capnp.o
+CLIENT_OBJS = wg_dynamic_client.o client.o protocol.capnp.o
+SERVER_OBJS = wg_dynamic_server.o server.o protocol.capnp.o
all: ${PROGS}
wg-dynamic-client: ${CLIENT_OBJS}
${CC} ${LDFLAGS} ${CLIENT_OBJS} -o $@
wg-dynamic-server: ${SERVER_OBJS}
${CC} ${LDFLAGS} ${SERVER_OBJS} -o $@
-wg-dynamic-client.o: wg-dynamic-client.c
-wg-dynamic-server.o: wg-dynamic-server.c
+
+wg_dynamic_client.o: wg_dynamic_client.c client.h
+client.o: client.c client.h
+wg_dynamic_server.o: wg_dynamic_server.c server.h
+server.o: server.c server.h
protocol.capnp.o: protocol.capnp.c
# capnproto
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..d0f91e6
--- /dev/null
+++ b/TODO
@@ -0,0 +1,10 @@
+Here are some of the TODO in loosely step-by-step order:
+* Design a Cap'n Proto protocol (no compression, no packing allowed!)
+* Write server side to create TCP connection
+* Write client side to connect to TCP connection
+* Get client side to properly configure the dynamic IP from the server (using dummy data sent by server)
+ - Will need to use libmnl to configure the device
+ - Will need to use mini wireguard library (https://git.zx2c4.com/WireGuard/tree/contrib/examples/embeddable-wg-library) to configure wireguard
+* Get server side to give real dynamic IP info to client
+* Get client side to handle events (up/down/etc)
+ - libevent
diff --git a/wg-dynamic-server.c b/client.c
index 87e3946..2c2f091 100644
--- a/wg-dynamic-server.c
+++ b/client.c
@@ -2,3 +2,9 @@
/*
* Copyright (C) 2018 Wireguard LLC
*/
+
+int connect_to_server(const char interface[])
+{
+ /* TODO */
+ return -1;
+}
diff --git a/client.h b/client.h
new file mode 100644
index 0000000..996cb58
--- /dev/null
+++ b/client.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright (C) 2018 Wireguard LLC
+ */
+
+#ifndef CLIENT_H
+#define CLIENT_H
+
+int connect_to_server(const char interface[]);
+
+#endif
diff --git a/wg-dynamic-client.c b/server.c
index 87e3946..0315ccb 100644
--- a/wg-dynamic-client.c
+++ b/server.c
@@ -2,3 +2,9 @@
/*
* Copyright (C) 2018 Wireguard LLC
*/
+
+int setup_server(const char interface[])
+{
+ /* TODO */
+ return -1;
+}
diff --git a/server.h b/server.h
new file mode 100644
index 0000000..3ffa9c5
--- /dev/null
+++ b/server.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright (C) 2018 Wireguard LLC
+ */
+
+#ifndef SERVER_H
+#define SERVER_H
+
+int setup_server(const char interface[]);
+
+#endif
diff --git a/wg_dynamic_client.c b/wg_dynamic_client.c
new file mode 100644
index 0000000..318714d
--- /dev/null
+++ b/wg_dynamic_client.c
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright (C) 2018 Wireguard LLC
+ */
+
+#include "client.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+const char *PROG_NAME;
+
+static void show_usage()
+{
+ fprintf(stderr, "Usage: %s <interface>\n\n", PROG_NAME);
+}
+
+int main(int argc, char *argv[])
+{
+ PROG_NAME = argv[0];
+
+ if (argc == 1) {
+ show_usage();
+ return EXIT_FAILURE;
+ }
+
+ if (connect_to_server(argv[1]) < 0) {
+ perror("error connecting to server");
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/wg_dynamic_server.c b/wg_dynamic_server.c
new file mode 100644
index 0000000..191da67
--- /dev/null
+++ b/wg_dynamic_server.c
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright (C) 2018 Wireguard LLC
+ */
+
+#include "server.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+const char *PROG_NAME;
+
+static void show_usage()
+{
+ fprintf(stderr, "Usage: %s <interface>\n\n", PROG_NAME);
+}
+
+int main(int argc, char *argv[])
+{
+ PROG_NAME = argv[0];
+
+ if (argc == 1) {
+ show_usage();
+ return EXIT_FAILURE;
+ }
+
+ if (setup_server(argv[1]) < 0) {
+ perror("error setting up server");
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}