summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--code/ecp/Makefile15
-rw-r--r--code/ecp/Makefile.fe3103
-rw-r--r--code/ecp/Makefile.posix3
-rw-r--r--code/ecp/config_fe310.h7
-rw-r--r--code/ecp/config_posix.h7
-rw-r--r--code/ecp/core.c2
-rw-r--r--code/ecp/core.h49
-rw-r--r--code/ecp/crypto/chacha/Makefile5
-rw-r--r--code/ecp/crypto/compat/Makefile5
-rw-r--r--code/ecp/crypto/crypto.c1
-rw-r--r--code/ecp/crypto/crypto.h2
-rw-r--r--code/ecp/crypto/curve25519/Makefile5
-rw-r--r--code/ecp/crypto/poly1305/Makefile5
-rw-r--r--code/ecp/crypto/sha/Makefile5
-rw-r--r--code/ecp/crypto/test/Makefile17
-rw-r--r--code/ecp/fe310/transport.c5
-rw-r--r--code/ecp/htable/htable.c2
-rw-r--r--code/ecp/msgq.h3
-rwxr-xr-xcode/ecp/platform.sh16
-rw-r--r--code/ecp/posix/transport.c2
-rw-r--r--code/ecp/posix/transport.h2
-rw-r--r--code/ecp/rbuf.c2
-rw-r--r--code/ecp/rbuf_recv.c2
-rw-r--r--code/ecp/rbuf_send.c2
-rw-r--r--code/ecp/timer.c2
-rw-r--r--code/ecp/timer.h6
-rw-r--r--code/ecp/vconn/vconn.c5
-rw-r--r--code/fe310/eos/ecp.h1
-rwxr-xr-xcode/platform14
-rw-r--r--code/test/Makefile2
-rw-r--r--code/test/vid/Makefile2
-rw-r--r--code/util/Makefile2
32 files changed, 90 insertions, 111 deletions
diff --git a/code/ecp/Makefile b/code/ecp/Makefile
index 1b16f39..a62e6f0 100644
--- a/code/ecp/Makefile
+++ b/code/ecp/Makefile
@@ -2,7 +2,7 @@ include Makefile.platform
CFLAGS=$(CFLAGS_PL) $(PIC) -I.
obj = core.o timer.o $(obj_rbuf)
-subdirs = crypto $(vconn) $(htable) $(platform)
+subdirs = crypto platform $(htable) $(vconn)
%.o: %.c
$(CC) $(CFLAGS) -c $<
@@ -16,6 +16,19 @@ all: $(obj)
(cd $$i && $(MAKE) && cd ..) || exit; \
done
+install: all
+ mkdir -p build-$(platform)/
+ install libecpcore.a build-$(platform)/
+ install crypto/libecpcr.a build-$(platform)/
+ install platform/libecptm.a build-$(platform)/
+ install platform/libecptr.a build-$(platform)/
+ if [ -f htable/libecpht.a ]; then \
+ install htable/libecpht.a build-$(platform)/; \
+ fi
+ if [ -f vconn/libecpvconn.a ]; then \
+ install vconn/libecpvconn.a build-$(platform)/; \
+ fi
+
clean:
for i in $(subdirs); do \
(cd $$i && $(MAKE) clean && cd ..) || exit; \
diff --git a/code/ecp/Makefile.fe310 b/code/ecp/Makefile.fe310
index 130566b..e753571 100644
--- a/code/ecp/Makefile.fe310
+++ b/code/ecp/Makefile.fe310
@@ -1,6 +1,7 @@
+platform=fe310
+
htable=
vconn=vconn
-platform=fe310
rbuf_obj=
FE310_HOME=/opt/my/freedom-e-sdk
diff --git a/code/ecp/Makefile.posix b/code/ecp/Makefile.posix
index 2680875..c83e050 100644
--- a/code/ecp/Makefile.posix
+++ b/code/ecp/Makefile.posix
@@ -1,6 +1,7 @@
+platform=posix
+
htable=htable
vconn=vconn
-platform=posix
obj_rbuf=rbuf.o rbuf_send.o rbuf_recv.o msgq.o
CFLAGS_PL=-O3
diff --git a/code/ecp/config_fe310.h b/code/ecp/config_fe310.h
index fc95c26..ff61012 100644
--- a/code/ecp/config_fe310.h
+++ b/code/ecp/config_fe310.h
@@ -1 +1,6 @@
-#define ECP_DEBUG 1 \ No newline at end of file
+#ifndef _ECP_CONFIG
+#define _ECP_CONFIG
+
+#define ECP_DEBUG 1
+
+#endif \ No newline at end of file
diff --git a/code/ecp/config_posix.h b/code/ecp/config_posix.h
index ad67d8a..51babef 100644
--- a/code/ecp/config_posix.h
+++ b/code/ecp/config_posix.h
@@ -1,5 +1,10 @@
+#ifndef _ECP_CONFIG
+#define _ECP_CONFIG
+
#define ECP_WITH_PTHREAD 1
#define ECP_WITH_HTABLE 1
#define ECP_WITH_RBUF 1
#define ECP_WITH_MSGQ 1
-#define ECP_DEBUG 1 \ No newline at end of file
+#define ECP_DEBUG 1
+
+#endif \ No newline at end of file
diff --git a/code/ecp/core.c b/code/ecp/core.c
index 3f77c6f..2631f13 100644
--- a/code/ecp/core.c
+++ b/code/ecp/core.c
@@ -1,7 +1,5 @@
#include "core.h"
-#include <string.h>
-
int ecp_dhkey_generate(ECPContext *ctx, ECPDHKey *key) {
int rv;
diff --git a/code/ecp/core.h b/code/ecp/core.h
index 0248814..244df4d 100644
--- a/code/ecp/core.h
+++ b/code/ecp/core.h
@@ -1,3 +1,14 @@
+#include <sys/types.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "config.h"
+
+#ifdef ECP_WITH_PTHREAD
+#include <pthread.h>
+#endif
+
#define ECP_OK 0
#define ECP_ITER_NEXT 1
@@ -84,20 +95,6 @@
#define ecp_conn_is_reg(conn) ((conn->flags) & ECP_CONN_FLAG_REG)
#define ecp_conn_is_open(conn) ((conn->flags) & ECP_CONN_FLAG_OPEN)
-#include "config.h"
-
-#include <sys/types.h>
-#include <stddef.h>
-#include <stdint.h>
-
-struct ECPBuffer;
-struct ECP2Buffer;
-struct ECPContext;
-struct ECPSocket;
-struct ECPConnection;
-struct ECPSeqItem;
-struct ECPFragIter;
-
// typedef long ssize_t;
typedef uint32_t ecp_ack_t;
@@ -134,11 +131,22 @@ typedef uint32_t ecp_seq_t;
#define ECP_SIZE_PLD_RAW_BUF(X,T,P) (ECP_SIZE_PLD(X,T)+((P) ? ((P)->pcount+1)*(ECP_SIZE_PKT_HDR+ECP_SIZE_MSG_BUF(T,P)+ECP_AEAD_SIZE_TAG) : 0))
#define ECP_SIZE_PKT_RAW_BUF(X,T,P) (ECP_SIZE_PLD_RAW_BUF(X,T,P)+ECP_SIZE_PKT_HDR+ECP_AEAD_SIZE_TAG)
-#ifdef ECP_WITH_PTHREAD
-#include <pthread.h>
+#ifdef ECP_DEBUG
+#include <stdio.h>
+#define DPRINT(cnd, format, ...) { if (cnd) { fprintf (stderr, format, __VA_ARGS__); } }
+#else
+#define DPRINT(cnd, format, ...) {}
#endif
-#include "posix/transport.h"
+struct ECPBuffer;
+struct ECP2Buffer;
+struct ECPContext;
+struct ECPSocket;
+struct ECPConnection;
+struct ECPSeqItem;
+struct ECPFragIter;
+
+#include "platform/transport.h"
#include "crypto/crypto.h"
#include "timer.h"
@@ -146,13 +154,6 @@ typedef uint32_t ecp_seq_t;
#include "rbuf.h"
#endif
-#ifdef ECP_DEBUG
-#include <stdio.h>
-#define DPRINT(cnd, format, ...) { if (cnd) { fprintf (stderr, format, __VA_ARGS__); } }
-#else
-#define DPRINT(cnd, format, ...) {}
-#endif
-
typedef int ecp_rng_t (void *, size_t);
typedef int ecp_conn_handler_new_t (struct ECPSocket *s, struct ECPConnection *p, unsigned char *msg, size_t sz, struct ECPConnection **c);
diff --git a/code/ecp/crypto/chacha/Makefile b/code/ecp/crypto/chacha/Makefile
index e64aac3..1bafa7f 100644
--- a/code/ecp/crypto/chacha/Makefile
+++ b/code/ecp/crypto/chacha/Makefile
@@ -4,14 +4,11 @@ CFLAGS=$(CFLAGS_PL) $(PIC) -I../include -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_D
obj = chacha.o
-all: libchacha.a
+all: $(obj)
dep: all
%.o: %.c
$(CC) $(CFLAGS) -c $<
-libchacha.a: $(obj)
- $(AR) rcs $@ $(obj)
-
clean:
rm -f *.o *.a
diff --git a/code/ecp/crypto/compat/Makefile b/code/ecp/crypto/compat/Makefile
index 9e96d9e..fc32fe7 100644
--- a/code/ecp/crypto/compat/Makefile
+++ b/code/ecp/crypto/compat/Makefile
@@ -5,14 +5,11 @@ getentropy = getentropy_osx
obj = explicit_bzero.o timingsafe_memcmp.o timingsafe_bcmp.o # arc4random.o arc4random_uniform.o $(getentropy).o
-all: libcompat.a
+all: $(obj)
dep: all
%.o: %.c
$(CC) $(CFLAGS) -c $<
-libcompat.a: $(obj)
- $(AR) rcs $@ $(obj)
-
clean:
rm -f *.o *.a
diff --git a/code/ecp/crypto/crypto.c b/code/ecp/crypto/crypto.c
index f57e8d8..81bf3cc 100644
--- a/code/ecp/crypto/crypto.c
+++ b/code/ecp/crypto/crypto.c
@@ -1,6 +1,5 @@
#include <core.h>
-#include <string.h>
#include <curve25519.h>
static int dh_mkpair(ecp_dh_public_t *pub, ecp_dh_private_t *priv, ecp_rng_t *rand_buf) {
diff --git a/code/ecp/crypto/crypto.h b/code/ecp/crypto/crypto.h
index 7bd27d5..86b072c 100644
--- a/code/ecp/crypto/crypto.h
+++ b/code/ecp/crypto/crypto.h
@@ -1,5 +1,3 @@
-#include <stddef.h>
-
#define CURVE25519_SIZE_KEY 32
#define CHACHA20_SIZE_KEY 32
#define POLY1305_SIZE_TAG 16
diff --git a/code/ecp/crypto/curve25519/Makefile b/code/ecp/crypto/curve25519/Makefile
index 5799e0e..e9c2c1b 100644
--- a/code/ecp/crypto/curve25519/Makefile
+++ b/code/ecp/crypto/curve25519/Makefile
@@ -4,14 +4,11 @@ CFLAGS=$(CFLAGS_PL) $(PIC) -I../include -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_D
obj = curve25519.o curve25519-generic.o
-all: libcurve25519.a
+all: $(obj)
dep: all
%.o: %.c
$(CC) $(CFLAGS) -c $<
-libcurve25519.a: $(obj)
- $(AR) rcs $@ $(obj)
-
clean:
rm -f *.o *.a
diff --git a/code/ecp/crypto/poly1305/Makefile b/code/ecp/crypto/poly1305/Makefile
index 5751602..418e3a5 100644
--- a/code/ecp/crypto/poly1305/Makefile
+++ b/code/ecp/crypto/poly1305/Makefile
@@ -4,14 +4,11 @@ CFLAGS=$(CFLAGS_PL) $(PIC) -I../include -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_D
obj = poly1305.o
-all: libpoly1305.a
+all: $(obj)
dep: all
%.o: %.c
$(CC) $(CFLAGS) -c $<
-libpoly1305.a: $(obj)
- $(AR) rcs $@ $(obj)
-
clean:
rm -f *.o *.a
diff --git a/code/ecp/crypto/sha/Makefile b/code/ecp/crypto/sha/Makefile
index 4dc3f39..b775c83 100644
--- a/code/ecp/crypto/sha/Makefile
+++ b/code/ecp/crypto/sha/Makefile
@@ -4,14 +4,11 @@ CFLAGS=$(CFLAGS_PL) $(PIC) -I../include -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_D
obj = sha1dgst.o sha1_one.o sha256.o sha512.o
-all: libsha.a
+all: $(obj)
dep: all
%.o: %.c
$(CC) $(CFLAGS) -c $<
-libsha.a: $(obj)
- $(AR) rcs $@ $(obj)
-
clean:
rm -f *.o *.a
diff --git a/code/ecp/crypto/test/Makefile b/code/ecp/crypto/test/Makefile
index 8ea463d..ae19e4b 100644
--- a/code/ecp/crypto/test/Makefile
+++ b/code/ecp/crypto/test/Makefile
@@ -2,10 +2,7 @@ include ../../Makefile.platform
CFLAGS=$(CFLAGS_PL) -I.. -I../include
LDFLAGS=$(LDFLAGS_PL)
-aead_dep=../compat/explicit_bzero.o ../compat/timingsafe_memcmp.o ../compat/timingsafe_bcmp.o \
- ../chacha/chacha.o ../poly1305/poly1305.o ../curve25519/curve25519.o ../curve25519/curve25519-generic.o \
- ../sha/sha512.o ../e_chacha20poly1305.o
-dsa_dep=../*/*.a
+dep=../e_chacha20poly1305.o ../curve25519/*.o ../chacha/*.o ../poly1305/*.o ../sha/*.o ../compat/*.o
%.o: %.c
@@ -14,22 +11,22 @@ dsa_dep=../*/*.a
all: aead aead_enc aead_dec ed25519 ed25519_sign ed25519_open
aead: aead.o
- $(CC) $(LDFLAGS) -o $@ $< $(aead_dep)
+ $(CC) $(LDFLAGS) -o $@ $< $(dep)
aead_enc: aead_enc.o
- $(CC) $(LDFLAGS) -o $@ $< $(aead_dep)
+ $(CC) $(LDFLAGS) -o $@ $< $(dep)
aead_dec: aead_dec.o
- $(CC) $(LDFLAGS) -o $@ $< $(aead_dep)
+ $(CC) $(LDFLAGS) -o $@ $< $(dep)
ed25519: ed25519.o
- $(CC) $(LDFLAGS) -o $@ $< $(dsa_dep)
+ $(CC) $(LDFLAGS) -o $@ $< $(dep)
ed25519_sign: ed25519_sign.o
- $(CC) $(LDFLAGS) -o $@ $< $(dsa_dep)
+ $(CC) $(LDFLAGS) -o $@ $< $(dep)
ed25519_open: ed25519_open.o
- $(CC) $(LDFLAGS) -o $@ $< $(dsa_dep)
+ $(CC) $(LDFLAGS) -o $@ $< $(dep)
clean:
diff --git a/code/ecp/fe310/transport.c b/code/ecp/fe310/transport.c
index 99a1b10..5bffda9 100644
--- a/code/ecp/fe310/transport.c
+++ b/code/ecp/fe310/transport.c
@@ -1,11 +1,8 @@
-#include <stddef.h>
-#include <string.h>
+#include <core.h>
#include <eos/eos.h>
#include <eos/net.h>
-#include <core.h>
-
static int t_addr_eq(ECPNetAddr *addr1, ECPNetAddr *addr2) {
if (addr1->port != addr2->port) return 0;
if (memcmp(addr1->host, addr2->host, sizeof(addr1->host)) != 0) return 0;
diff --git a/code/ecp/htable/htable.c b/code/ecp/htable/htable.c
index 6330ef8..77f5a35 100644
--- a/code/ecp/htable/htable.c
+++ b/code/ecp/htable/htable.c
@@ -1,7 +1,5 @@
#include <core.h>
-#include <string.h>
-
#include "hashtable.h"
static void *h_create(ECPContext *ctx) {
diff --git a/code/ecp/msgq.h b/code/ecp/msgq.h
index 41e819b..a81ff36 100644
--- a/code/ecp/msgq.h
+++ b/code/ecp/msgq.h
@@ -1,8 +1,5 @@
#ifdef ECP_WITH_MSGQ
-#include <pthread.h>
-#include <string.h>
-
#define ECP_MSGQ_MAX_MSG 32
#define ECP_MSGQ_ERR_MAX_MSG -110
diff --git a/code/ecp/platform.sh b/code/ecp/platform.sh
new file mode 100755
index 0000000..b265bd7
--- /dev/null
+++ b/code/ecp/platform.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+
+BASEDIR=$(dirname $0)
+
+if [ -z $1 ]; then
+ echo usage $0 "<platform>"
+ exit 1
+fi
+
+PLATFORM=$1
+
+rm -f $BASEDIR/platform
+ln -sf ./$PLATFORM $BASEDIR/platform
+ln -sf ./config_$PLATFORM.h $BASEDIR/config.h
+ln -sf ./Makefile.$PLATFORM $BASEDIR/Makefile.platform
diff --git a/code/ecp/posix/transport.c b/code/ecp/posix/transport.c
index bdd166a..5415db6 100644
--- a/code/ecp/posix/transport.c
+++ b/code/ecp/posix/transport.c
@@ -1,10 +1,8 @@
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <poll.h>
-#include <stdio.h>
#include <core.h>
diff --git a/code/ecp/posix/transport.h b/code/ecp/posix/transport.h
index c35e13e..6d6d219 100644
--- a/code/ecp/posix/transport.h
+++ b/code/ecp/posix/transport.h
@@ -1,5 +1,3 @@
-#include <stdint.h>
-
#define ECP_IPv4_ADDR_SIZE 4
typedef int ECPNetSock;
diff --git a/code/ecp/rbuf.c b/code/ecp/rbuf.c
index d24ac23..e05aedc 100644
--- a/code/ecp/rbuf.c
+++ b/code/ecp/rbuf.c
@@ -1,7 +1,5 @@
#include "core.h"
-#include <string.h>
-
int ecp_rbuf_init(ECPRBuffer *rbuf, ECPRBMessage *msg, unsigned int msg_size) {
rbuf->msg = msg;
if (msg_size) {
diff --git a/code/ecp/rbuf_recv.c b/code/ecp/rbuf_recv.c
index c262f1d..7a74921 100644
--- a/code/ecp/rbuf_recv.c
+++ b/code/ecp/rbuf_recv.c
@@ -1,7 +1,5 @@
#include "core.h"
-#include <string.h>
-
#define ACK_RATE 8
#define ACK_MASK_FIRST ((ecp_ack_t)1 << (ECP_SIZE_ACKB - 1))
diff --git a/code/ecp/rbuf_send.c b/code/ecp/rbuf_send.c
index 61b29af..e42a85b 100644
--- a/code/ecp/rbuf_send.c
+++ b/code/ecp/rbuf_send.c
@@ -1,7 +1,5 @@
#include "core.h"
-#include <string.h>
-
#define NACK_RATE_UNIT 10000
static ssize_t flush_send(ECPConnection *conn, ECPTimerItem *ti) {
diff --git a/code/ecp/timer.c b/code/ecp/timer.c
index 16a6ad0..f8d710b 100644
--- a/code/ecp/timer.c
+++ b/code/ecp/timer.c
@@ -1,7 +1,5 @@
#include "core.h"
-#include <string.h>
-
int ecp_timer_create(ECPTimer *timer) {
int rv = ECP_OK;
timer->head = -1;
diff --git a/code/ecp/timer.h b/code/ecp/timer.h
index 8863226..9c80007 100644
--- a/code/ecp/timer.h
+++ b/code/ecp/timer.h
@@ -2,12 +2,6 @@
#define ECP_ERR_MAX_TIMER -110
-#include <stddef.h>
-
-#ifdef ECP_WITH_PTHREAD
-#include <pthread.h>
-#endif
-
struct ECPTimerItem;
typedef ssize_t ecp_timer_retry_t (struct ECPConnection *, struct ECPTimerItem *);
diff --git a/code/ecp/vconn/vconn.c b/code/ecp/vconn/vconn.c
index 4023aa9..a11f8fd 100644
--- a/code/ecp/vconn/vconn.c
+++ b/code/ecp/vconn/vconn.c
@@ -1,7 +1,6 @@
-#include "core.h"
-#include "vconn.h"
+#include <core.h>
-#include <string.h>
+#include "vconn.h"
#ifdef ECP_WITH_PTHREAD
static pthread_mutex_t key_perma_mutex;
diff --git a/code/fe310/eos/ecp.h b/code/fe310/eos/ecp.h
index 9cc84db..e4722e8 100644
--- a/code/fe310/eos/ecp.h
+++ b/code/fe310/eos/ecp.h
@@ -1,3 +1,4 @@
+#include <ecp/config_fe310.h>
#include <ecp/core.h>
int ecp_init(ECPContext *ctx);
diff --git a/code/platform b/code/platform
deleted file mode 100755
index 0781395..0000000
--- a/code/platform
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-#
-
-BASEDIR=$(dirname $0)
-
-if [ -z $1 ]; then
- echo usage $0 "<platform>"
- exit 1
-fi
-
-PLATFORM=$1
-
-ln -sf ./Makefile.$PLATFORM $BASEDIR/ecp/Makefile.platform
-ln -sf ./config_$PLATFORM.h $BASEDIR/ecp/config.h \ No newline at end of file
diff --git a/code/test/Makefile b/code/test/Makefile
index 13fa476..0db3126 100644
--- a/code/test/Makefile
+++ b/code/test/Makefile
@@ -2,7 +2,7 @@ include ../ecp/Makefile.platform
CFLAGS=$(CFLAGS_PL) -I../ecp -I../util -Wno-int-to-void-pointer-cast
LDFLAGS=$(LDFLAGS_PL)
-dep=../ecp/libecpcore.a ../ecp/crypto/libecpcr.a ../ecp/htable/libecpht.a ../ecp/posix/libecptr.a ../ecp/posix/libecptm.a ../ecp/vconn/libecpvconn.a ../util/libecputil.a
+dep=../ecp/build-posix/*.a ../util/libecputil.a
%.o: %.c
$(CC) $(CFLAGS) -c $<
diff --git a/code/test/vid/Makefile b/code/test/vid/Makefile
index 0abb572..b3943c0 100644
--- a/code/test/vid/Makefile
+++ b/code/test/vid/Makefile
@@ -2,7 +2,7 @@
LIBVPX_HOME=/Users/majstor/src/libvpx
CFLAGS=-D_V4L2_KERNEL_ -I/usr/src/linux-headers-$(uname -r) -I$(LIBVPX_HOME) -I/opt/local/include/SDL2 -I../../core -I../../vconn -I../../util
LDFLAGS=-L$(LIBVPX_HOME) -L/opt/local/lib
-dep=../../ecp/libecpcore.a ../../ecp/crypto/libecpcr.a ../../ecp/htable/libecpht.a ../../ecp/posix/libecptr.a ../../ecp/posix/libecptm.a ../../vconn/libecpvconn.a ../../util/libecputil.a ../init.o
+dep=../../ecp/build-posix/*.a ../../util/libecputil.a ../init.o
all: client cap
diff --git a/code/util/Makefile b/code/util/Makefile
index a896fc2..6e7227b 100644
--- a/code/util/Makefile
+++ b/code/util/Makefile
@@ -3,7 +3,7 @@ CFLAGS=$(CFLAGS_PL) -I../ecp
LDFLAGS=$(LDFLAGS_PL)
obj=util.o
-dep=../ecp/libecpcore.a ../ecp/crypto/libecpcr.a ../ecp/htable/libecpht.a ../ecp/posix/libecptr.a ../ecp/posix/libecptm.a ./libecputil.a
+dep=../ecp/build-posix/*.a ./libecputil.a
%.o: %.c %.h