summaryrefslogtreecommitdiff
path: root/ecp
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2022-02-02 08:14:56 +0100
committerUros Majstorovic <majstor@majstor.org>2022-02-02 08:14:56 +0100
commitd359dd9981f4137e8873a7a571e5c54c5b2449c4 (patch)
treeabfe99bcbce4324c71bd03f68581bdd605d13ec9 /ecp
parente215377e5b1440f8ec0842712f2e559e82de2f03 (diff)
linux and freebsd compatibility
Diffstat (limited to 'ecp')
-rwxr-xr-xecp/build.sh20
-rw-r--r--ecp/src/platform/posix/transport.c1
-rw-r--r--ecp/util/util.c11
3 files changed, 20 insertions, 12 deletions
diff --git a/ecp/build.sh b/ecp/build.sh
index acb1a14..d28c794 100755
--- a/ecp/build.sh
+++ b/ecp/build.sh
@@ -5,24 +5,30 @@ if [ -z $1 ]; then
else
ARG=$1
fi
+
+
+if [ -z $MAKE ]; then
+ MAKE=make
+fi
+
PLATFORM=posix
cd src/ecp
if [ "$ARG" != "clean" ]; then
- make platform=$PLATFORM clean
+ $MAKE platform=$PLATFORM clean
fi
-make platform=$PLATFORM $ARG || exit
+$MAKE platform=$PLATFORM $ARG || exit
if [ "$ARG" == "all" ]; then
- make platform=$PLATFORM install
+ $MAKE platform=$PLATFORM install
fi
cd ../../util
if [ "$ARG" != "clean" ]; then
- make platform=$PLATFORM clean
+ $MAKE platform=$PLATFORM clean
fi
-make platform=$PLATFORM $ARG || exit
+$MAKE platform=$PLATFORM $ARG || exit
cd ../test
if [ "$ARG" != "clean" ]; then
- make platform=$PLATFORM clean
+ $MAKE platform=$PLATFORM clean
fi
-make platform=$PLATFORM $ARG || exit
+$MAKE platform=$PLATFORM $ARG || exit
diff --git a/ecp/src/platform/posix/transport.c b/ecp/src/platform/posix/transport.c
index 2032ce2..c41f0df 100644
--- a/ecp/src/platform/posix/transport.c
+++ b/ecp/src/platform/posix/transport.c
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <unistd.h>
+#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <poll.h>
diff --git a/ecp/util/util.c b/ecp/util/util.c
index 4f4adc2..7ce8da5 100644
--- a/ecp/util/util.c
+++ b/ecp/util/util.c
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
+#include <sys/stat.h>
#include "core.h"
#include "cr.h"
@@ -9,7 +10,7 @@
int ecp_util_key_save(ECPContext *ctx, ECPDHKey *key, char *filename) {
int fd;
ssize_t rv;
-
+
if ((fd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR)) < 0) return ECP_ERR;
rv = write(fd, ecp_cr_dh_pub_get_buf(&key->public), ECP_ECDH_SIZE_KEY);
if (rv != ECP_ECDH_SIZE_KEY) {
@@ -29,7 +30,7 @@ int ecp_util_key_load(ECPContext *ctx, ECPDHKey *key, char *filename) {
int fd;
ssize_t rv;
unsigned char buf[ECP_ECDH_SIZE_KEY];
-
+
if ((fd = open(filename, O_RDONLY)) < 0) return ECP_ERR;
rv = read(fd, buf, ECP_ECDH_SIZE_KEY);
if (rv != ECP_ECDH_SIZE_KEY) {
@@ -44,7 +45,7 @@ int ecp_util_key_load(ECPContext *ctx, ECPDHKey *key, char *filename) {
close(fd);
ecp_cr_dh_pub_from_buf(&key->public, buf);
-
+
key->valid = 1;
return ECP_OK;
}
@@ -52,7 +53,7 @@ int ecp_util_key_load(ECPContext *ctx, ECPDHKey *key, char *filename) {
int ecp_util_node_save(ECPContext *ctx, ECPNode *node, char *filename) {
int fd;
ssize_t rv;
-
+
if ((fd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR)) < 0) return ECP_ERR;
rv = write(fd, ecp_cr_dh_pub_get_buf(&node->public), ECP_ECDH_SIZE_KEY);
if (rv != ECP_ECDH_SIZE_KEY) {
@@ -72,7 +73,7 @@ int ecp_util_node_load(ECPContext *ctx, ECPNode *node, char *filename) {
int fd;
ssize_t rv;
unsigned char buf[ECP_ECDH_SIZE_KEY];
-
+
if ((fd = open(filename, O_RDONLY)) < 0) return ECP_ERR;
rv = read(fd, buf, ECP_ECDH_SIZE_KEY);
if (rv != ECP_ECDH_SIZE_KEY) {