From 781637bbf4df68e9077b15f22d47a5c87f91bfe1 Mon Sep 17 00:00:00 2001 From: Jon Titor Date: Thu, 28 Sep 2017 13:02:05 -0400 Subject: [PATCH] more boilerplate --- .gitignore | 6 +++++ Makefile | 34 +++++++++++++++++++++++++++++ daemon/main.c | 6 +++++ doc/proto_v0.txt | 51 ++++++++++++++++++++++++++++++++++++++----- include/sarp.h | 4 ++++ include/sarp/router.h | 5 +++++ libsarp/sarp.c | 2 ++ 7 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 Makefile create mode 100644 daemon/main.c create mode 100644 include/sarp.h create mode 100644 include/sarp/router.h create mode 100644 libsarp/sarp.c diff --git a/.gitignore b/.gitignore index 6fca317eb..5e08ea800 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ *~ *\#* + +*.a +*.o +*.plist + +sarpd \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..012292ae6 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +REPO := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) + +EXE = $(REPO)/sarpd +LIB = sarp +STATIC_LIB = $(REPO)/lib$(LIB).a + +STATIC_SRC = $(wildcard $(REPO)/libsarp/*.c) +STATIC_OBJ = $(STATIC_SRC:.c=.o) + +DAEMON_SRC = $(wildcard $(REPO)/daemon/*.c) +DAEMON_OBJ = $(DAEMON_SRC:.c=.o) + +PKG = pkg-config + +PKGS = libsodium + +REQUIRED_CFLAGS = $(CFLAGS) $(shell $(PKG) --cflags $(PKGS)) -I $(REPO)/include -std=c99 +REQUIRED_LDFLAGS = $(LDFLAGS) $(shell $(PKG) --libs $(PKGS)) + +all: build + +build: $(EXE) + +$(EXE): $(DAEMON_OBJ) $(STATIC_LIB) + $(CC) $(REQUIRED_CFLAGS) $(REQUIRED_LDFLAGS) -o $(EXE) $(DAEMON_OBJ) $(STATIC_LIB) + +$(STATIC_LIB): $(STATIC_OBJ) + $(AR) -r $(STATIC_LIB) $(STATIC_OBJ) + +%.o: %.c + $(CC) $(REQUIRED_CFLAGS) -c $^ -o $@ + +clean: + $(RM) $(DAEMON_OBJ) $(EXE) $(STATIC_OBJ) $(STATIC_LIB) diff --git a/daemon/main.c b/daemon/main.c new file mode 100644 index 000000000..70b510c6e --- /dev/null +++ b/daemon/main.c @@ -0,0 +1,6 @@ + + +int main(int argc, char * argv[]) +{ + return 0; +} diff --git a/doc/proto_v0.txt b/doc/proto_v0.txt index e38d6d527..60f7a16aa 100644 --- a/doc/proto_v0.txt +++ b/doc/proto_v0.txt @@ -47,7 +47,13 @@ BD(x) is bittorrent decode x invisible wire protocol version 1: -TODO + +inbound handshake: + + +outbound handshake: + + --- @@ -65,13 +71,20 @@ address info (AI) p: port_uint16 } +Exit Info (XI) + +{ + a: "<16 bytes big endian ipv6 address>", + b: "<16 bytes big endian ipv6 netmask>" +} + router contact (RC) { a: [ one, or, many, AI, here ... ], e: "<32 bytes public encryption key>", k: "<32 bytes public sigining key>", - x: seconds_since_epoch_contact_expiration_uint64, + x: [ Exit, Infos ], z: "<64 bytes signature using signing key>" } @@ -123,7 +136,7 @@ k as symettric key for encryption and decryption. { a: "c", - c: "<32 byte public signing key used for canceling path>" + c: "<32 byte public signing key used for further communication>", i: "<32 byte public kad key of next hop>", k: "<32 byte symmettric key>", p: path_id_uint64, @@ -173,7 +186,7 @@ new_y = y ^ new_z[0:8] a: "u", p: path_id_uint64, y: "", - z: "" + z: "" } link relay downstream message (LRDM) @@ -189,7 +202,7 @@ new_z = SE(k, new_y, z) a: "d", p: path_id_uint64, y: "", - z: "" + z: "" } link relay exit message (LRXM) @@ -229,7 +242,7 @@ replies are sent down the path that messages originate from. { A: "A", I: "<32 bytes signing public key for future communication>", - X: lifetime_of_address_mapping_in_seconds_uint64 + X: lifetime_of_address_mapping_in_seconds_uint64, } grant exit address messsage (GXAM) @@ -254,6 +267,32 @@ reject exit address message (RXAM) Z: "<64 bytes signature signed by exit>" } + + +transfer data fragment message (TDFM) + +variant 1 (with path id): + +transfer data to another path with id P on the local router place Y and X values into +y and z values in LRDM message respectively. + +{ + A: "T", + P: path_id_uint64, + X: "", + Y: "<8 bytes nounce>" +} + +variant 2 (no path id): + +transfer ip traffic for exit + +{ + A: "T", + Y: "", + Z: "<64 bytes signature of previously provided signing key>" +} + find service address message (FSAM) { diff --git a/include/sarp.h b/include/sarp.h new file mode 100644 index 000000000..45811e1b2 --- /dev/null +++ b/include/sarp.h @@ -0,0 +1,4 @@ +#ifndef SARP_H_ +#define SARP_H_ +#include +#endif diff --git a/include/sarp/router.h b/include/sarp/router.h new file mode 100644 index 000000000..cfb577d89 --- /dev/null +++ b/include/sarp/router.h @@ -0,0 +1,5 @@ +#ifndef SARP_ROUTER_H_ +#define SARP_ROUTER_H_ + + +#endif diff --git a/libsarp/sarp.c b/libsarp/sarp.c new file mode 100644 index 000000000..139597f9c --- /dev/null +++ b/libsarp/sarp.c @@ -0,0 +1,2 @@ + +