summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ouroboros/CMakeLists.txt11
-rw-r--r--include/ouroboros/bitmap.h12
-rw-r--r--include/ouroboros/btree.h6
-rw-r--r--include/ouroboros/cdefs.h6
-rw-r--r--include/ouroboros/cep.h (renamed from include/ouroboros/cacep.h)29
-rw-r--r--include/ouroboros/crc32.h12
-rw-r--r--include/ouroboros/crypt.h56
-rw-r--r--include/ouroboros/dev.h11
-rw-r--r--include/ouroboros/endian.h16
-rw-r--r--include/ouroboros/errno.h17
-rw-r--r--include/ouroboros/fccntl.h35
-rw-r--r--include/ouroboros/flow.h54
-rw-r--r--include/ouroboros/fqueue.h47
-rw-r--r--include/ouroboros/hash.h79
-rw-r--r--include/ouroboros/hashtable.h55
-rw-r--r--include/ouroboros/ipcp-dev.h62
-rw-r--r--include/ouroboros/ipcp.h167
-rw-r--r--include/ouroboros/irm.h42
-rw-r--r--include/ouroboros/list.h8
-rw-r--r--include/ouroboros/local-dev.h12
-rw-r--r--include/ouroboros/lockfile.h12
-rw-r--r--include/ouroboros/logs.h87
-rw-r--r--include/ouroboros/md5.h6
-rw-r--r--include/ouroboros/name.h40
-rw-r--r--include/ouroboros/notifier.h6
-rw-r--r--include/ouroboros/np1_flow.h36
-rw-r--r--include/ouroboros/proc.h44
-rw-r--r--include/ouroboros/proto.h6
-rw-r--r--include/ouroboros/protobuf.h117
-rw-r--r--include/ouroboros/pthread.h51
-rw-r--r--include/ouroboros/qos.h153
-rw-r--r--include/ouroboros/qoscube.h12
-rw-r--r--include/ouroboros/random.h12
-rw-r--r--include/ouroboros/rib.h21
-rw-r--r--include/ouroboros/serdes-irm.h79
-rw-r--r--include/ouroboros/serdes-oep.h70
-rw-r--r--include/ouroboros/sha3.h6
-rw-r--r--include/ouroboros/shm_du_buff.h18
-rw-r--r--include/ouroboros/shm_flow_set.h30
-rw-r--r--include/ouroboros/shm_rbuff.h23
-rw-r--r--include/ouroboros/shm_rdrbuff.h40
-rw-r--r--include/ouroboros/sockets.h.in (renamed from include/ouroboros/sockets.h)41
-rw-r--r--include/ouroboros/test.h82
-rw-r--r--include/ouroboros/time.h130
-rw-r--r--include/ouroboros/time_utils.h81
-rw-r--r--include/ouroboros/timerwheel.h47
-rw-r--r--include/ouroboros/tpm.h6
-rw-r--r--include/ouroboros/utils.h25
-rw-r--r--include/ouroboros/version.h.in6
-rw-r--r--include/ouroboros/wrap/CMakeLists.txt71
-rw-r--r--include/ouroboros/wrap/ouroboros.i48
51 files changed, 1450 insertions, 693 deletions
diff --git a/include/ouroboros/CMakeLists.txt b/include/ouroboros/CMakeLists.txt
index c0a83030..4e90bc59 100644
--- a/include/ouroboros/CMakeLists.txt
+++ b/include/ouroboros/CMakeLists.txt
@@ -1,8 +1,14 @@
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/version.h" @ONLY)
+set(SOCK_BUF_SIZE 10240 CACHE STRING
+ "Size of the buffer used by the UNIX sockets for local IPC")
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sockets.h.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/sockets.h" @ONLY)
+
set(HEADER_FILES
- cacep.h
+ cep.h
cdefs.h
dev.h
errno.h
@@ -10,11 +16,10 @@ set(HEADER_FILES
fqueue.h
ipcp.h
irm.h
+ name.h
proto.h
qos.h
${CMAKE_CURRENT_BINARY_DIR}/version.h
)
install(FILES ${HEADER_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ouroboros)
-
-add_subdirectory(wrap)
diff --git a/include/ouroboros/bitmap.h b/include/ouroboros/bitmap.h
index 02e4de4b..04467a8a 100644
--- a/include/ouroboros/bitmap.h
+++ b/include/ouroboros/bitmap.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Bitmap implementation
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,8 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_BITMAP_H
-#define OUROBOROS_BITMAP_H
+#ifndef OUROBOROS_LIB_BITMAP_H
+#define OUROBOROS_LIB_BITMAP_H
#include <stddef.h>
#include <unistd.h>
@@ -45,4 +45,4 @@ bool bmp_is_id_valid(struct bmp * bmp,
bool bmp_is_id_used(struct bmp * bmp,
ssize_t id);
-#endif /* OUROBOROS_BITMAP_H */
+#endif /* OUROBOROS_LIB_BITMAP_H */
diff --git a/include/ouroboros/btree.h b/include/ouroboros/btree.h
index a9f7526e..cf982856 100644
--- a/include/ouroboros/btree.h
+++ b/include/ouroboros/btree.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* B-trees
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
diff --git a/include/ouroboros/cdefs.h b/include/ouroboros/cdefs.h
index 5cb42982..f4a5dc65 100644
--- a/include/ouroboros/cdefs.h
+++ b/include/ouroboros/cdefs.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* C Definitions
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
diff --git a/include/ouroboros/cacep.h b/include/ouroboros/cep.h
index b9fd0efb..4c1737f0 100644
--- a/include/ouroboros/cacep.h
+++ b/include/ouroboros/cep.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
- * The Common Application Connection Establishment Protocol
+ * The Ouroboros Connection Establishment Protocol
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,20 +20,19 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_CACEP_H
-#define OUROBOROS_CACEP_H
+#ifndef OUROBOROS_CEP_H
+#define OUROBOROS_CEP_H
#include <ouroboros/cdefs.h>
#include <ouroboros/proto.h>
#include <stdint.h>
-#include <sys/types.h>
-#define CACEP_BUF_STRLEN 64
+#define OCEP_BUF_STRLEN 128
struct conn_info {
- char comp_name[CACEP_BUF_STRLEN + 1];
- char protocol[CACEP_BUF_STRLEN + 1];
+ char comp_name[OCEP_BUF_STRLEN + 1];
+ char protocol[OCEP_BUF_STRLEN + 1];
uint32_t pref_version;
enum proto_concrete_syntax pref_syntax;
struct proto_field fixed_conc_syntax[PROTO_MAX_FIELDS];
@@ -43,12 +42,12 @@ struct conn_info {
__BEGIN_DECLS
-int cacep_snd(int fd,
- const struct conn_info * in);
+int cep_snd(int fd,
+ const struct conn_info * in);
-int cacep_rcv(int fd,
- struct conn_info * out);
+int cep_rcv(int fd,
+ struct conn_info * out);
__END_DECLS
-#endif /* OUROBOROS_CACEP_H */
+#endif /* OUROBOROS_CEP_H */
diff --git a/include/ouroboros/crc32.h b/include/ouroboros/crc32.h
index 6bcd1694..eb610797 100644
--- a/include/ouroboros/crc32.h
+++ b/include/ouroboros/crc32.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* 32-bit Cyclic Redundancy Check
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,8 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_CRC32_H
-#define OUROBOROS_CRC32_H
+#ifndef OUROBOROS_LIB_CRC32_H
+#define OUROBOROS_LIB_CRC32_H
#include <stdint.h>
#include <stddef.h>
@@ -32,4 +32,4 @@ void crc32(uint32_t * crc,
const void * buf,
size_t len);
-#endif /* OUROBOROS_CRC32_H */
+#endif /* OUROBOROS_LIB_CRC32_H */
diff --git a/include/ouroboros/crypt.h b/include/ouroboros/crypt.h
new file mode 100644
index 00000000..28fe63b2
--- /dev/null
+++ b/include/ouroboros/crypt.h
@@ -0,0 +1,56 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2024
+ *
+ * Cryptography
+ *
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., http://www.fsf.org/about/contact/.
+ */
+
+#ifndef OUROBOROS_LIB_CRYPT_H
+#define OUROBOROS_LIB_CRYPT_H
+
+#include <ouroboros/shm_du_buff.h>
+#include <ouroboros/utils.h>
+
+#define SYMMKEYSZ 32
+
+struct crypt_info {
+ uint16_t flags;
+ void * ctx;
+ uint8_t key[SYMMKEYSZ];
+};
+
+int crypt_dh_pkp_create(void ** pkp,
+ uint8_t * pk);
+
+void crypt_dh_pkp_destroy(void * pkp);
+
+int crypt_dh_derive(void * pkp,
+ buffer_t pk,
+ uint8_t * s);
+
+int crypt_encrypt(struct crypt_info * info,
+ struct shm_du_buff * sdb);
+
+int crypt_decrypt(struct crypt_info * info,
+ struct shm_du_buff * sdb);
+
+int crypt_init(struct crypt_info * info);
+
+void crypt_fini(struct crypt_info * info);
+
+#endif /* OUROBOROS_LIB_CRYPT_H */
diff --git a/include/ouroboros/dev.h b/include/ouroboros/dev.h
index 7c5ab460..6e643a2c 100644
--- a/include/ouroboros/dev.h
+++ b/include/ouroboros/dev.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* API for applications
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -40,6 +40,11 @@ int flow_alloc(const char * dst_name,
int flow_accept(qosspec_t * qs,
const struct timespec * timeo);
+/* Returns flow descriptor, qs updates to supplied QoS. */
+int flow_join(const char * bc,
+ qosspec_t * qs,
+ const struct timespec * timeo);
+
int flow_dealloc(int fd);
ssize_t flow_write(int fd,
diff --git a/include/ouroboros/endian.h b/include/ouroboros/endian.h
index f29b6749..addb2ed3 100644
--- a/include/ouroboros/endian.h
+++ b/include/ouroboros/endian.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Endianness
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,12 +20,14 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_ENDIAN_H
-#define OUROBOROS_ENDIAN_H
+#ifndef OUROBOROS_LIB_ENDIAN_H
+#define OUROBOROS_LIB_ENDIAN_H
#if defined(__linux__) || defined(__CYGWIN__) || \
(defined(__MACH__) && !defined(__APPLE__))
-#define _DEFAULT_SOURCE
+#ifndef _DEFAULT_SOURCE
+#error You must define _DEFAULT_SOURCE before including this file
+#endif
#include <endian.h>
#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <sys/endian.h>
@@ -70,4 +72,4 @@
#define hton16(x) htobe16(x)
#define ntoh16(x) betoh16(x)
-#endif /* OUROBOROS_ENDIAN_H */
+#endif /* OUROBOROS_LIB_ENDIAN_H */
diff --git a/include/ouroboros/errno.h b/include/ouroboros/errno.h
index e2029888..25e776df 100644
--- a/include/ouroboros/errno.h
+++ b/include/ouroboros/errno.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Ouroboros specific error numbers
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -25,11 +25,14 @@
#include <errno.h>
-#define ENOTALLOC 1000 /* Flow is not allocated */
-#define EIPCPTYPE 1001 /* Unknown IPCP type */
+#define ENOTALLOC 1000 /* Flow is not allocated */
+#define EIPCPTYPE 1001 /* Unknown IPCP type */
#define EIRMD 1002 /* Failed to communicate with IRMD */
#define EIPCP 1003 /* Failed to communicate with IPCP */
-#define EIPCPSTATE 1004 /* Target in wrong state */
-#define EFLOWDOWN 1005 /* Flow is down */
+#define EIPCPSTATE 1004 /* Target in wrong state */
+#define EFLOWDOWN 1005 /* Flow is down */
+#define EFLOWPEER 1006 /* Flow is down (peer timed out) */
+#define ECRYPT 1007 /* Encryption error */
+#define ENAME 1008 /* Naming error */
#endif /* OUROBOROS_ERRNO_H */
diff --git a/include/ouroboros/fccntl.h b/include/ouroboros/fccntl.h
index 5c3fc064..aa2b0d14 100644
--- a/include/ouroboros/fccntl.h
+++ b/include/ouroboros/fccntl.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Flow and FRCT connection control
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -28,28 +28,27 @@
#include <sys/time.h>
/* Flow flags, same values as fcntl.h */
-#define FLOWFRDONLY 00000000 /* Read-only flow */
-#define FLOWFWRONLY 00000001 /* Write-only flow */
-#define FLOWFRDWR 00000002 /* Read-write flow */
-#define FLOWFACCMODE 00000003 /* Access mask */
+#define FLOWFRDONLY 00000000 /* Read-only flow */
+#define FLOWFWRONLY 00000001 /* Write-only flow */
+#define FLOWFRDWR 00000002 /* Read-write flow */
+#define FLOWFACCMODE 00000003 /* Access mask */
-#define FLOWFDOWN 00000004 /* Flow is down */
+#define FLOWFDOWN 00000004 /* Flow is down */
-#define FLOWFRNOBLOCK 00001000 /* Non-blocking read */
-#define FLOWFWNOBLOCK 00002000 /* Non-blocking write */
+#define FLOWFRNOBLOCK 00001000 /* Non-blocking read */
+#define FLOWFWNOBLOCK 00002000 /* Non-blocking write */
#define FLOWFNONBLOCK (FLOWFRNOBLOCK | FLOWFWNOBLOCK)
-#define FLOWFRNOPART 00004000 /* Disable partial reads */
+#define FLOWFRNOPART 00010000 /* Disable partial reads */
+#define FLOWFWNOPART 00020000 /* Disable partial writes */
-#define FLOWFDEFAULT FLOWFRDWR
+#define FLOWFDEFAULT (FLOWFRDWR | FLOWFWNOPART)
#define FLOWFINVALID (FLOWFWRONLY | FLOWFRDWR)
/* FRCT flags */
-#define FRCTFRESCNTRL 00000001 /* Feedback from receiver */
-#define FRCTFRTX 00000002 /* Reliable flow */
-#define FRCTFERRCHCK 00000004 /* Check for errors */
-#define FRCTFORDERING 00000010 /* Ordered delivery */
-#define FRCTFPARTIAL 00000020 /* Allow partial delivery */
+#define FRCTFRTX 00000001 /* Reliable flow */
+#define FRCTFRESCNTL 00000002 /* Feedback from receiver */
+#define FRCTFLINGER 00000004 /* Send unsent data */
/* Flow operations */
#define FLOWSRCVTIMEO 00000001 /* Set read timeout */
@@ -64,7 +63,7 @@
/* FRCT operations */
#define FRCTSFLAGS 00001000 /* Set flags for FRCT */
-#define FRCTGFLAGS 00001001 /* Get flags for FRCT */
+#define FRCTGFLAGS 00002000 /* Get flags for FRCT */
__BEGIN_DECLS
diff --git a/include/ouroboros/flow.h b/include/ouroboros/flow.h
new file mode 100644
index 00000000..e6bf8886
--- /dev/null
+++ b/include/ouroboros/flow.h
@@ -0,0 +1,54 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2024
+ *
+ * Flows
+ *
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., http://www.fsf.org/about/contact/.
+ */
+
+#ifndef OUROBOROS_LIB_FLOW_H
+#define OUROBOROS_LIB_FLOW_H
+
+#include <ouroboros/qos.h>
+
+#include <sys/types.h>
+
+ enum flow_state { /* DO NOT CHANGE ORDER! */
+ FLOW_INIT = 0,
+ FLOW_ALLOC_PENDING,
+ FLOW_ACCEPT_PENDING,
+ FLOW_ALLOCATED,
+ FLOW_DEALLOC_PENDING,
+ FLOW_DEALLOCATED,
+ FLOW_DESTROY, /* TODO: REMOVE! */
+ FLOW_NULL
+};
+
+struct flow_info {
+ int id;
+
+ pid_t n_pid;
+ pid_t n_1_pid;
+
+ time_t mpl;
+
+ struct qos_spec qs;
+
+ enum flow_state state;
+};
+
+#endif /* OUROBOROS_LIB_FLOW_H */
diff --git a/include/ouroboros/fqueue.h b/include/ouroboros/fqueue.h
index 1b102669..8eb2ff50 100644
--- a/include/ouroboros/fqueue.h
+++ b/include/ouroboros/fqueue.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Flow queues
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -28,6 +28,15 @@
#include <stdbool.h>
#include <time.h>
+enum fqtype {
+ FLOW_PKT = (1 << 0),
+ FLOW_DOWN = (1 << 1),
+ FLOW_UP = (1 << 2),
+ FLOW_ALLOC = (1 << 3),
+ FLOW_DEALLOC = (1 << 4),
+ FLOW_PEER = (1 << 5)
+};
+
struct flow_set;
struct fqueue;
@@ -37,30 +46,32 @@ typedef struct fqueue fqueue_t;
__BEGIN_DECLS
-fset_t * fset_create(void);
+fset_t * fset_create(void);
+
+void fset_destroy(fset_t * set);
-void fset_destroy(fset_t * set);
+fqueue_t * fqueue_create(void);
-fqueue_t * fqueue_create(void);
+void fqueue_destroy(struct fqueue * fq);
-void fqueue_destroy(struct fqueue * fq);
+void fset_zero(fset_t * set);
-void fset_zero(fset_t * set);
+int fset_add(fset_t * set,
+ int fd);
-int fset_add(fset_t * set,
- int fd);
+bool fset_has(const fset_t * set,
+ int fd);
-bool fset_has(const fset_t * set,
- int fd);
+void fset_del(fset_t * set,
+ int fd);
-void fset_del(fset_t * set,
- int fd);
+int fqueue_next(fqueue_t * fq);
-int fqueue_next(fqueue_t * fq);
+enum fqtype fqueue_type(fqueue_t * fq);
-int fevent(fset_t * set,
- fqueue_t * fq,
- const struct timespec * timeo);
+ssize_t fevent(fset_t * set,
+ fqueue_t * fq,
+ const struct timespec * timeo);
__END_DECLS
diff --git a/include/ouroboros/hash.h b/include/ouroboros/hash.h
index b4e43f11..6b0087ce 100644
--- a/include/ouroboros/hash.h
+++ b/include/ouroboros/hash.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Hashing functions
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -25,49 +25,60 @@
#include "config.h"
-#include <ouroboros/endian.h>
+#include <ouroboros/ipcp.h>
-#ifdef HAVE_LIBGCRYPT
-#include <gcrypt.h>
-#endif
#include <stdint.h>
#include <stddef.h>
/* Hash algorithms */
enum hash_algo {
-#ifdef HAVE_LIBGCRYPT
- HASH_CRC32 = GCRY_MD_CRC32,
- HASH_MD5 = GCRY_MD_MD5,
- HASH_SHA3_224 = GCRY_MD_SHA3_224,
- HASH_SHA3_256 = GCRY_MD_SHA3_256,
- HASH_SHA3_384 = GCRY_MD_SHA3_384,
- HASH_SHA3_512 = GCRY_MD_SHA3_512
-#else
- HASH_CRC32 = 0,
+ HASH_SHA3_224 = DIR_HASH_SHA3_224,
+ HASH_SHA3_256 = DIR_HASH_SHA3_256,
+ HASH_SHA3_384 = DIR_HASH_SHA3_384,
+ HASH_SHA3_512 = DIR_HASH_SHA3_512,
+ HASH_CRC32,
HASH_MD5,
- HASH_SHA3_224,
- HASH_SHA3_256,
- HASH_SHA3_384,
- HASH_SHA3_512
-#endif
};
-#define HASH_FMT "%02x%02x%02x%02x"
-#define HASH_VAL(hash) \
- (betoh32(*(uint32_t *) hash) & 0xFF000000) >> 24, \
- (betoh32(*(uint32_t *) hash) & 0x00FF0000) >> 16, \
- (betoh32(*(uint32_t *) hash) & 0x0000FF00) >> 8, \
- (betoh32(*(uint32_t *) hash) & 0x000000FF)
+#define HASH_FMT32 "%02x%02x%02x%02x"
+#define HASH_VAL32(hash) \
+ (hash)[0], (hash)[1], (hash)[2], (hash)[3]
+
+#define HASH_FMT64 HASH_FMT32 HASH_FMT32
+#define HASH_VAL64(hash64) \
+ HASH_VAL32(hash64), HASH_VAL32(hash64 + 4)
+
+#define HASH_FMT128 HASH_FMT64 HASH_FMT64
+#define HASH_VAL128(hash128) \
+ HASH_VAL64(hash128), HASH_VAL64(hash128 + 8)
+
+#define HASH_FMT224 HASH_FMT128 HASH_FMT64 HASH_FMT32
+#define HASH_VAL224(hash224) \
+ HASH_VAL128(hash224), HASH_VAL64(hash224 + 16), \
+ HASH_VAL32(hash224 + 24)
+
+#define HASH_FMT256 HASH_FMT128 HASH_FMT128
+#define HASH_VAL256(hash256) \
+ HASH_VAL128(hash256), HASH_VAL128(hash256 + 16)
+
+#define HASH_FMT384 HASH_FMT256 HASH_FMT128
+#define HASH_VAL384(hash384) \
+ HASH_VAL256(hash384), HASH_VAL128(hash384 + 32)
+
+#define HASH_FMT512 HASH_FMT256 HASH_FMT256
+#define HASH_VAL512(hash512) \
+ HASH_VAL256(hash512), HASH_VAL256(hash512 + 32)
+
uint16_t hash_len(enum hash_algo algo);
-void mem_hash(enum hash_algo algo,
- void * dst,
- const uint8_t * buf,
- size_t len);
+void mem_hash(enum hash_algo algo,
+ void * dst,
+ const uint8_t * buf,
+ size_t len);
-void str_hash(enum hash_algo algo,
- void * dst,
- const char * str);
+void str_hash(enum hash_algo algo,
+ void * dst,
+ const char * str);
#endif /* OUROBOROS_LIB_HASH_H */
diff --git a/include/ouroboros/hashtable.h b/include/ouroboros/hashtable.h
deleted file mode 100644
index c9a6f72f..00000000
--- a/include/ouroboros/hashtable.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Ouroboros - Copyright (C) 2016 - 2018
- *
- * Hash table with integer keys with separate chaining on collisions
- *
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., http://www.fsf.org/about/contact/.
- */
-
-#ifndef OUROBOROS_HASHTABLE_H
-#define OUROBOROS_HASHTABLE_H
-
-#include <stdint.h>
-#include <stdbool.h>
-#include <stdlib.h>
-
-struct htable;
-
-/* Buckets is rounded up to the nearest power of 2 */
-struct htable * htable_create(uint64_t buckets,
- bool hash_key);
-
-void htable_destroy(struct htable * table);
-
-void htable_flush(struct htable * table);
-
-/* Passes ownership of the block of memory */
-int htable_insert(struct htable * table,
- uint64_t key,
- void * val,
- size_t len);
-
-/* The block of memory returned is no copy */
-int htable_lookup(struct htable * table,
- uint64_t key,
- void ** val,
- size_t * len);
-
-int htable_delete(struct htable * table,
- uint64_t key);
-
-#endif /* OUROBOROS_HASHTABLE_H */
diff --git a/include/ouroboros/ipcp-dev.h b/include/ouroboros/ipcp-dev.h
index 9a33c25a..378d724a 100644
--- a/include/ouroboros/ipcp-dev.h
+++ b/include/ouroboros/ipcp-dev.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Additional API for IPCPs
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,36 +20,50 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#ifndef OUROBOROS_LIB_IPCP_DEV_H
+#define OUROBOROS_LIB_IPCP_DEV_H
+
+#include <ouroboros/ipcp.h>
+#include <ouroboros/qoscube.h>
#include <ouroboros/shm_rdrbuff.h>
+#include <ouroboros/utils.h>
+
+int ipcp_create_r(const struct ipcp_info * info);
+
+int ipcp_flow_req_arr(const buffer_t * dst,
+ qosspec_t qs,
+ time_t mpl,
+ const buffer_t * data);
+
+int ipcp_flow_alloc_reply(int fd,
+ int response,
+ time_t mpl,
+ const buffer_t * data);
-#ifndef OUROBOROS_IPCP_DEV_H
-#define OUROBOROS_IPCP_DEV_H
+int ipcp_flow_read(int fd,
+ struct shm_du_buff ** sdb);
-int ipcp_create_r(pid_t pid,
- int result);
+int ipcp_flow_write(int fd,
+ struct shm_du_buff * sdb);
-int ipcp_flow_req_arr(pid_t pid,
- const uint8_t * dst,
- size_t len,
- qoscube_t cube);
+int np1_flow_read(int fd,
+ struct shm_du_buff ** sdb);
-int ipcp_flow_alloc_reply(int fd,
- int response);
+int np1_flow_write(int fd,
+ struct shm_du_buff * sdb);
-int ipcp_flow_read(int fd,
- struct shm_du_buff ** sdb);
+int ipcp_flow_dealloc(int fd);
-int ipcp_flow_write(int fd,
- struct shm_du_buff * sdb);
+int ipcp_flow_fini(int fd);
-void ipcp_flow_fini(int fd);
+int ipcp_flow_get_qoscube(int fd,
+ qoscube_t * cube);
-int ipcp_flow_get_qoscube(int fd,
- qoscube_t * cube);
+size_t ipcp_flow_queued(int fd);
-int ipcp_sdb_reserve(struct shm_du_buff ** sdb,
- size_t len);
+int ipcp_sdb_reserve(struct shm_du_buff ** sdb,
+ size_t len);
-void ipcp_sdb_release(struct shm_du_buff * sdb);
+void ipcp_sdb_release(struct shm_du_buff * sdb);
-#endif /* OUROBOROS_IPCP_DEV_H */
+#endif /* OUROBOROS_LIB_IPCP_DEV_H */
diff --git a/include/ouroboros/ipcp.h b/include/ouroboros/ipcp.h
index c7013f08..42c4dfa4 100644
--- a/include/ouroboros/ipcp.h
+++ b/include/ouroboros/ipcp.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* IPCP definitions and policies
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -26,75 +26,164 @@
#include <stdint.h>
#include <unistd.h>
#include <stdbool.h>
+#include <sys/types.h>
+
+#define IPCP_NAME_SIZE 255
+#define LAYER_NAME_SIZE 255
+#define DEV_NAME_SIZE 255
+
+enum ipcp_state {
+ IPCP_INIT = 0,
+ IPCP_BOOT,
+ IPCP_OPERATIONAL,
+ IPCP_BOOTSTRAPPED,
+ IPCP_ENROLLED,
+ IPCP_SHUTDOWN,
+ IPCP_NULL
+};
-#define LAYER_NAME_SIZE 256
-
-/*
- * NOTE: the IRMd uses this order to select an IPCP
- * for flow allocation.
- */
-enum ipcp_type {
+enum ipcp_type { /* IRMd uses order to select an IPCP for flow allocation. */
IPCP_LOCAL = 0,
- IPCP_NORMAL,
- IPCP_RAPTOR,
+ IPCP_UNICAST,
+ IPCP_BROADCAST,
IPCP_ETH_LLC,
IPCP_ETH_DIX,
IPCP_UDP,
IPCP_INVALID
};
-/* Normal IPCP policies */
+struct ipcp_info {
+ enum ipcp_type type;
+ pid_t pid;
+ char name[IPCP_NAME_SIZE + 1];
+ enum ipcp_state state;
+};
+
+/* Unicast IPCP components. */
+#define DT_COMP "Data Transfer"
+#define MGMT_COMP "Management"
+
+/* Unicast IPCP policies */
enum pol_addr_auth {
- ADDR_AUTH_FLAT_RANDOM = 0
+ ADDR_AUTH_FLAT_RANDOM = 0,
+ ADDR_AUTH_INVALID
};
enum pol_routing {
ROUTING_LINK_STATE = 0,
- ROUTING_LINK_STATE_LFA
+ ROUTING_LINK_STATE_LFA,
+ ROUTING_LINK_STATE_ECMP,
+ ROUTING_INVALID
+};
+
+enum pol_cong_avoid {
+ CA_NONE = 0,
+ CA_MB_ECN,
+ CA_INVALID
+};
+
+struct dt_config {
+ uint8_t addr_size;
+ uint8_t eid_size;
+ uint8_t max_ttl;
+ enum pol_routing routing_type;
};
-enum pol_pff {
- PFF_SIMPLE = 0,
- PFF_ALTERNATE
+/* IPCP configuration */
+struct uni_config {
+ struct dt_config dt;
+ enum pol_addr_auth addr_auth_type;
+ enum pol_cong_avoid cong_avoid;
};
+struct eth_config {
+ char dev[DEV_NAME_SIZE + 1];
+ uint16_t ethertype; /* DIX only*/
+};
+
+struct udp_config {
+ uint32_t ip_addr;
+ uint32_t dns_addr;
+ uint16_t port;
+};
+
+/* Layers */
enum pol_dir_hash {
- DIR_HASH_SHA3_224 = 0,
+ DIR_HASH_SHA3_224,
DIR_HASH_SHA3_256,
DIR_HASH_SHA3_384,
- DIR_HASH_SHA3_512
+ DIR_HASH_SHA3_512,
+ DIR_HASH_INVALID
};
-/* Info reported back to the IRMd about the layer on enrollment */
struct layer_info {
- char layer_name[LAYER_NAME_SIZE];
- int dir_hash_algo;
+ char name[LAYER_NAME_SIZE + 1];
+ enum pol_dir_hash dir_hash_algo;
};
/* Structure to configure the first IPCP */
struct ipcp_config {
- struct layer_info layer_info;
+ struct layer_info layer_info;
+ enum ipcp_type type;
+
+ union {
+ struct uni_config unicast;
+ struct udp_config udp;
+ struct eth_config eth;
+ };
+};
- enum ipcp_type type;
+/* default configurations */
+static const struct ipcp_config local_default_conf = {
+ .type = IPCP_LOCAL,
+ .layer_info = {
+ .dir_hash_algo = DIR_HASH_SHA3_256
+ }
+};
- /* Normal */
- uint8_t addr_size;
- uint8_t eid_size;
- uint8_t max_ttl;
+static const struct ipcp_config eth_dix_default_conf = {
+ .type = IPCP_ETH_DIX,
+ .layer_info = {
+ .dir_hash_algo = DIR_HASH_SHA3_256
+ },
+ .eth = {
+ .ethertype=0xA000,
+ }
+};
- enum pol_addr_auth addr_auth_type;
- enum pol_routing routing_type;
- enum pol_pff pff_type;
+static const struct ipcp_config eth_llc_default_conf = {
+ .type = IPCP_ETH_LLC,
+ .layer_info = {
+ .dir_hash_algo = DIR_HASH_SHA3_256
+ }
+};
- /* UDP */
- uint32_t ip_addr;
- uint32_t dns_addr;
+static const struct ipcp_config udp_default_conf = {
+ .type = IPCP_UDP,
+ .udp = {
+ .port = 3435
+ }
+};
- /* Ethernet */
- char * dev;
+static const struct ipcp_config uni_default_conf = {
+ .type = IPCP_UNICAST,
+ .layer_info = {
+ .dir_hash_algo = DIR_HASH_SHA3_256
+ },
+ .unicast = {
+ .dt = {
+ .addr_size = 4,
+ .eid_size = 8,
+ .max_ttl = 60,
+ .routing_type = ROUTING_LINK_STATE
+ },
+ .addr_auth_type = ADDR_AUTH_FLAT_RANDOM,
+ .cong_avoid = CA_MB_ECN
+ }
+};
- /* Ethernet DIX */
- uint16_t ethertype;
+static const struct ipcp_config bc_default_conf = {
+ .type = IPCP_BROADCAST
};
#endif /* OUROBOROS_IPCP_H */
diff --git a/include/ouroboros/irm.h b/include/ouroboros/irm.h
index fe6d2e9f..0105f88e 100644
--- a/include/ouroboros/irm.h
+++ b/include/ouroboros/irm.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* The API to instruct the IPC Resource Manager
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -25,24 +25,16 @@
#include <ouroboros/cdefs.h>
#include <ouroboros/ipcp.h>
+#include <ouroboros/name.h>
+#include <ouroboros/qos.h>
#include <sys/types.h>
-/* Normal IPCP components. */
-#define DT_COMP "Data Transfer"
-#define MGMT_COMP "Management"
-
-/* Name binding options. */
-#define BIND_AUTO 0x01
-
-#define NAME_SIZE 256
-#define LAYER_SIZE LAYER_NAME_SIZE
-
-struct ipcp_info {
+struct ipcp_list_info {
pid_t pid;
enum ipcp_type type;
char name[NAME_SIZE];
- char layer[LAYER_SIZE];;
+ char layer[LAYER_NAME_SIZE];
};
__BEGIN_DECLS
@@ -52,7 +44,7 @@ pid_t irm_create_ipcp(const char * name,
int irm_destroy_ipcp(pid_t pid);
-ssize_t irm_list_ipcps(struct ipcp_info ** ipcps);
+ssize_t irm_list_ipcps(struct ipcp_list_info ** ipcps);
int irm_enroll_ipcp(pid_t pid,
const char * dst);
@@ -62,7 +54,8 @@ int irm_bootstrap_ipcp(pid_t pid,
int irm_connect_ipcp(pid_t pid,
const char * component,
- const char * dst);
+ const char * dst,
+ qosspec_t qs);
int irm_disconnect_ipcp(pid_t pid,
const char * component,
@@ -83,11 +76,18 @@ int irm_bind_process(pid_t pid,
int irm_unbind_process(pid_t pid,
const char * name);
-int irm_reg(pid_t pid,
- const char * name);
+int irm_create_name(const char * name,
+ enum pol_balance pol);
+
+int irm_destroy_name(const char * name);
+
+ssize_t irm_list_names(struct name_info ** names);
+
+int irm_reg_name(const char * name,
+ pid_t pid);
-int irm_unreg(pid_t pid,
- const char * name);
+int irm_unreg_name(const char * name,
+ pid_t pid);
__END_DECLS
diff --git a/include/ouroboros/list.h b/include/ouroboros/list.h
index 0c12fb69..f3ea0e46 100644
--- a/include/ouroboros/list.h
+++ b/include/ouroboros/list.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Simple doubly linked list implementation.
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -61,6 +61,6 @@ void list_del(struct list_head * e);
void list_move(struct list_head * dst,
struct list_head * src);
-bool list_is_empty(struct list_head * h);
+bool list_is_empty(const struct list_head * h);
#endif /* OUROBOROS_LIB_LIST_H */
diff --git a/include/ouroboros/local-dev.h b/include/ouroboros/local-dev.h
index 2e9c900f..da62e31c 100644
--- a/include/ouroboros/local-dev.h
+++ b/include/ouroboros/local-dev.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Optimized calls for the local IPCPs
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,12 +20,12 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_LOCAL_DEV_H
-#define OUROBOROS_LOCAL_DEV_H
+#ifndef OUROBOROS_LIB_LOCAL_DEV_H
+#define OUROBOROS_LIB_LOCAL_DEV_H
ssize_t local_flow_read(int fd);
int local_flow_write(int fd,
size_t idx);
-#endif /* OUROBOROS_LOCAL_DEV_H */
+#endif /* OUROBOROS_LIB_LOCAL_DEV_H */
diff --git a/include/ouroboros/lockfile.h b/include/ouroboros/lockfile.h
index c1d21dac..85a57313 100644
--- a/include/ouroboros/lockfile.h
+++ b/include/ouroboros/lockfile.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Lockfile for Ouroboros
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,8 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_LOCKFILE_H
-#define OUROBOROS_LOCKFILE_H
+#ifndef OUROBOROS_LIB_LOCKFILE_H
+#define OUROBOROS_LIB_LOCKFILE_H
#include <sys/types.h>
@@ -37,4 +37,4 @@ void lockfile_destroy(struct lockfile * lf);
pid_t lockfile_owner(struct lockfile * lf);
-#endif
+#endif /* OUROBOROS_LIB_LOCKFILE_H */
diff --git a/include/ouroboros/logs.h b/include/ouroboros/logs.h
index 936b999b..db49ae32 100644
--- a/include/ouroboros/logs.h
+++ b/include/ouroboros/logs.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Logging facilities
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,21 +20,19 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_LOGS_H
-#define OUROBOROS_LOGS_H
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdbool.h>
-#include <syslog.h>
+#ifndef OUROBOROS_LIB_LOGS_H
+#define OUROBOROS_LIB_LOGS_H
#ifndef OUROBOROS_PREFIX
#error You must define OUROBOROS_PREFIX before including this file
#endif
-void log_init(bool sysout);
+#include <ouroboros/hash.h>
-void log_fini(void);
+#include <unistd.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <syslog.h>
#define CLR_RED "\x1b[31m"
#define CLR_GREEN "\x1b[32m"
@@ -48,28 +46,61 @@ void log_fini(void);
extern bool log_syslog;
-#define __olog(CLR, LVL, SYSLVL, ...) \
- do { \
- if (log_syslog) { \
- syslog(SYSLVL, OUROBOROS_PREFIX ": " \
- __VA_ARGS__); \
- } else { \
- printf(CLR "==%05d== " OUROBOROS_PREFIX \
- "(" LVL "): ", getpid()); \
- printf(__VA_ARGS__); \
- printf(CLR_RESET "\n"); \
- fflush(stdout); \
- } \
+void log_init(bool sysout);
+
+void log_fini(void);
+
+
+#define __olog(CLR, LVL, SYSLVL, ...) \
+ do { \
+ if (log_syslog) { \
+ syslog(SYSLVL, __VA_ARGS__); \
+ } else { \
+ printf(CLR "==%05d== " OUROBOROS_PREFIX \
+ "(" LVL "): ", getpid()); \
+ printf(__VA_ARGS__); \
+ printf(CLR_RESET "\n"); \
+ fflush(stdout); \
+ } \
+ } while (0)
+
+#define __olog_id(CLR, LVL, SYSLVL, id, fmt, ...) \
+ do { \
+ if (log_syslog) { \
+ syslog(SYSLVL, "[" HASH_FMT64 "] " fmt, \
+ HASH_VAL64(id), ## __VA_ARGS__); \
+ } else { \
+ printf(CLR "==%05d== " OUROBOROS_PREFIX \
+ "(" LVL "): ", getpid()); \
+ printf("[" HASH_FMT64 "] " fmt, \
+ HASH_VAL64(id), ## __VA_ARGS__); \
+ printf(CLR_RESET "\n"); \
+ fflush(stdout); \
+ } \
} while (0)
-#define log_err(...) __olog(CLR_RED, ERROR_CODE, LOG_ERR, __VA_ARGS__)
-#define log_warn(...) __olog(CLR_YELLOW, WARN_CODE, LOG_WARNING, __VA_ARGS__)
-#define log_info(...) __olog(CLR_GREEN, INFO_CODE, LOG_INFO, __VA_ARGS__)
+#define log_err(...) \
+ __olog(CLR_RED, ERROR_CODE, LOG_ERR, __VA_ARGS__)
+#define log_warn(...) \
+ __olog(CLR_YELLOW, WARN_CODE, LOG_WARNING, __VA_ARGS__)
+#define log_info(...) \
+ __olog(CLR_GREEN, INFO_CODE, LOG_INFO, __VA_ARGS__)
+
+
+#define log_err_id(id, fmt, ...) \
+ __olog_id(CLR_RED, ERROR_CODE, LOG_ERR, id, fmt, ## __VA_ARGS__)
+#define log_warn_id(id, fmt, ...) \
+ __olog_id(CLR_YELLOW, WARN_CODE, LOG_WARNING, id, fmt, ## __VA_ARGS__)
+#define log_info_id(id, fmt, ...) \
+ __olog_id(CLR_GREEN, INFO_CODE, LOG_INFO, id, fmt, ## __VA_ARGS__)
#ifdef CONFIG_OUROBOROS_DEBUG
#define log_dbg(...) __olog("", DEBUG_CODE, LOG_DEBUG, __VA_ARGS__)
+#define log_dbg_id(id, fmt, ...) \
+ __olog_id("", DEBUG_CODE, LOG_DEBUG, id, fmt, ## __VA_ARGS__)
#else
#define log_dbg(...) do { } while (0)
+#define log_dbg_id(...) do { } while (0)
#endif
-#endif /* OUROBOROS_LOGS_H */
+#endif /* OUROBOROS_LIB_LOGS_H */
diff --git a/include/ouroboros/md5.h b/include/ouroboros/md5.h
index be3e13ac..85a22544 100644
--- a/include/ouroboros/md5.h
+++ b/include/ouroboros/md5.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* MD5 algorithm
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This implementation is adapted and redistributed from the RHASH
* project implementation of the MD5 algorithm
diff --git a/include/ouroboros/name.h b/include/ouroboros/name.h
new file mode 100644
index 00000000..9d77a90b
--- /dev/null
+++ b/include/ouroboros/name.h
@@ -0,0 +1,40 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2024
+ *
+ * Names
+ *
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., http://www.fsf.org/about/contact/.
+ */
+
+#ifndef OUROBOROS_NAME_H
+#define OUROBOROS_NAME_H
+
+#define NAME_SIZE 255
+#define BIND_AUTO 0x01
+
+enum pol_balance {
+ LB_RR = 0,
+ LB_SPILL,
+ LB_INVALID
+};
+
+struct name_info {
+ char name[NAME_SIZE + 1];
+ enum pol_balance pol_lb;
+};
+
+#endif /* OUROBOROS_NAME_H */
diff --git a/include/ouroboros/notifier.h b/include/ouroboros/notifier.h
index 9af2986f..db945f1e 100644
--- a/include/ouroboros/notifier.h
+++ b/include/ouroboros/notifier.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Notifier event system using callbacks
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
diff --git a/include/ouroboros/np1_flow.h b/include/ouroboros/np1_flow.h
index 789e82df..31720eea 100644
--- a/include/ouroboros/np1_flow.h
+++ b/include/ouroboros/np1_flow.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Adapter functions for N + 1 flow descriptors
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,19 +20,31 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_NP1_FLOW_H
-#define OUROBOROS_NP1_FLOW_H
+#ifndef OUROBOROS_LIB_NP1_FLOW_H
+#define OUROBOROS_LIB_NP1_FLOW_H
-#include <ouroboros/qoscube.h>
+#include <ouroboros/qos.h>
#include <unistd.h>
-int np1_flow_alloc(pid_t n_pid,
- int port_id,
- qoscube_t qc);
+int np1_flow_alloc(pid_t n_pid,
+ int flow_id);
-int np1_flow_resp(int port_id);
+int np1_flow_resp(int flow_id);
-int np1_flow_dealloc(int port_id);
+int np1_flow_dealloc(int flow_id,
+ time_t timeo);
-#endif /* OUROBOROS_NP1_FLOW_H */
+static const qosspec_t qos_np1 = {
+ .delay = UINT32_MAX,
+ .bandwidth = 0,
+ .availability = 0,
+ .loss = UINT32_MAX,
+ .ber = UINT32_MAX,
+ .in_order = 0,
+ .max_gap = UINT32_MAX,
+ .cypher_s = 0,
+ .timeout = 0
+};
+
+#endif /* OUROBOROS_LIB_NP1_FLOW_H */
diff --git a/include/ouroboros/proc.h b/include/ouroboros/proc.h
new file mode 100644
index 00000000..80c67227
--- /dev/null
+++ b/include/ouroboros/proc.h
@@ -0,0 +1,44 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2024
+ *
+ * Processes and Programs
+ *
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., http://www.fsf.org/about/contact/.
+ */
+
+#ifndef OUROBOROS_LIB_PROC_H
+#define OUROBOROS_LIB_PROC_H
+
+#include <sys/types.h>
+
+#define PROG_NAME_SIZE 255
+#define PROG_PATH_SIZE 255
+
+/* Processes */
+struct proc_info {
+ pid_t pid;
+ char prog[PROG_NAME_SIZE + 1]; /* program instantiated */
+
+};
+
+/* Programs */
+struct prog_info {
+ char name[PROG_NAME_SIZE + 1];
+ char path[PROG_PATH_SIZE + 1];
+};
+
+#endif /* OUROBOROS_LIB_PROC_H */
diff --git a/include/ouroboros/proto.h b/include/ouroboros/proto.h
index 2489cafe..5c863c8b 100644
--- a/include/ouroboros/proto.h
+++ b/include/ouroboros/proto.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Protocol syntax definitions
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
diff --git a/include/ouroboros/protobuf.h b/include/ouroboros/protobuf.h
new file mode 100644
index 00000000..9d38afb1
--- /dev/null
+++ b/include/ouroboros/protobuf.h
@@ -0,0 +1,117 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2024
+ *
+ * Protobuf syntax conversion
+ *
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., http://www.fsf.org/about/contact/.
+ */
+
+#ifndef OUROBOROS_LIB_PROTOBUF_H
+#define OUROBOROS_LIB_PROTOBUF_H
+
+#include <ouroboros/flow.h>
+#include <ouroboros/qos.h>
+#include <ouroboros/ipcp.h>
+#include <ouroboros/irm.h>
+#include <ouroboros/serdes-irm.h>
+#include <ouroboros/serdes-oep.h>
+
+#include "ipcp_config.pb-c.h"
+typedef IpcpConfigMsg ipcp_config_msg_t;
+typedef DtConfigMsg dt_config_msg_t;
+typedef EthConfigMsg eth_config_msg_t;
+typedef UdpConfigMsg udp_config_msg_t;
+typedef UniConfigMsg uni_config_msg_t;
+
+#include "ipcp.pb-c.h"
+typedef IpcpMsg ipcp_msg_t;
+
+#include "irm.pb-c.h"
+typedef IrmMsg irm_msg_t;
+typedef TimespecMsg timespec_msg_t;
+typedef IpcpInfoMsg ipcp_info_msg_t;
+typedef IpcpListMsg ipcp_list_msg_t;
+
+#include "model.pb-c.h"
+typedef FlowInfoMsg flow_info_msg_t;
+typedef LayerInfoMsg layer_info_msg_t;
+typedef NameInfoMsg name_info_msg_t;
+typedef QosspecMsg qosspec_msg_t;
+
+#include "enroll.pb-c.h"
+typedef EnrollReqMsg enroll_req_msg_t;
+typedef EnrollRespMsg enroll_resp_msg_t;
+typedef EnrollAckMsg enroll_ack_msg_t;
+
+/* IPCP configuration */
+timespec_msg_t * timespec_s_to_msg(const struct timespec * s);
+
+struct timespec timespec_msg_to_s(timespec_msg_t * msg);
+
+flow_info_msg_t * flow_info_s_to_msg(const struct flow_info * s);
+
+struct flow_info flow_info_msg_to_s(const flow_info_msg_t * msg);
+
+layer_info_msg_t * layer_info_s_to_msg(const struct layer_info * s);
+
+struct layer_info layer_info_msg_to_s(const layer_info_msg_t * msg);
+
+ipcp_info_msg_t * ipcp_info_s_to_msg(const struct ipcp_info * s);
+
+struct ipcp_info ipcp_info_msg_to_s(const ipcp_info_msg_t * msg);
+
+dt_config_msg_t * dt_config_s_to_msg(const struct dt_config * s);
+
+struct dt_config dt_config_msg_to_s(const dt_config_msg_t * msg);
+
+uni_config_msg_t * uni_config_s_to_msg(const struct uni_config * s);
+
+struct uni_config uni_config_msg_to_s(const uni_config_msg_t * msg);
+
+eth_config_msg_t * eth_config_s_to_msg(const struct eth_config * s);
+
+struct eth_config eth_config_msg_to_s(const eth_config_msg_t * msg);
+
+udp_config_msg_t * udp_config_s_to_msg(const struct udp_config * s);
+
+struct udp_config udp_config_msg_to_s(const udp_config_msg_t * msg);
+
+ipcp_config_msg_t * ipcp_config_s_to_msg(const struct ipcp_config * s);
+
+struct ipcp_config ipcp_config_msg_to_s(const ipcp_config_msg_t * msg);
+
+/* QoS */
+
+qosspec_msg_t * qos_spec_s_to_msg(const struct qos_spec * s);
+
+struct qos_spec qos_spec_msg_to_s(const qosspec_msg_t * msg);
+
+/* Enrollment */
+
+enroll_req_msg_t * enroll_req_s_to_msg(const struct enroll_req * s);
+
+struct enroll_req enroll_req_msg_to_s(const enroll_req_msg_t * msg);
+
+enroll_resp_msg_t * enroll_resp_s_to_msg(const struct enroll_resp * s);
+
+struct enroll_resp enroll_resp_msg_to_s(const enroll_resp_msg_t * msg);
+
+enroll_ack_msg_t * enroll_ack_s_to_msg(const struct enroll_ack * s);
+
+struct enroll_ack enroll_ack_msg_to_s(const enroll_ack_msg_t * msg);
+
+#endif /* OUROBOROS_LIB_PROTOBUF_H */
diff --git a/include/ouroboros/pthread.h b/include/ouroboros/pthread.h
new file mode 100644
index 00000000..7044cb5e
--- /dev/null
+++ b/include/ouroboros/pthread.h
@@ -0,0 +1,51 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2024
+ *
+ * Useful cleanup functions for pthreads
+ *
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., http://www.fsf.org/about/contact/.
+ */
+
+#ifndef OUROBOROS_LIB_PTHREAD_H
+#define OUROBOROS_LIB_PTHREAD_H
+
+#include <pthread.h>
+
+static int __attribute__((unused)) __timedwait(pthread_cond_t * cond,
+ pthread_mutex_t * mtx,
+ const struct timespec * abstime)
+{
+ if (abstime == NULL)
+ return pthread_cond_wait(cond, mtx);
+
+ return pthread_cond_timedwait(cond, mtx, abstime);
+}
+
+#if defined (_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L
+/* various cleanup functions for pthread_cleanup_push */
+static void __attribute__((unused)) __cleanup_rwlock_unlock(void * rwlock)
+{
+ pthread_rwlock_unlock((pthread_rwlock_t *) rwlock);
+}
+#endif
+
+static void __attribute__((unused)) __cleanup_mutex_unlock(void * mutex)
+{
+ pthread_mutex_unlock((pthread_mutex_t *) mutex);
+}
+
+#endif /* OUROBOROS_LIB_PTHREAD_H */
diff --git a/include/ouroboros/qos.h b/include/ouroboros/qos.h
index f046f8f8..a45e8135 100644
--- a/include/ouroboros/qos.h
+++ b/include/ouroboros/qos.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Quality of Service specification
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -26,19 +26,150 @@
#include <stdint.h>
#include <stdbool.h>
+#define DEFAULT_PEER_TIMEOUT 120000
+
typedef struct qos_spec {
- uint32_t delay; /* In ms */
- uint64_t bandwidth; /* In bits/s */
- uint8_t availability; /* Class of 9s */
- uint32_t maximum_interruption; /* In ms */
+ uint32_t delay; /* In ms. */
+ uint64_t bandwidth; /* In bits/s. */
+ uint8_t availability; /* Class of 9s. */
+ uint32_t loss; /* Packet loss. */
+ uint32_t ber; /* Bit error rate, errors per billion bits. */
+ uint8_t in_order; /* In-order delivery, enables FRCT. */
+ uint32_t max_gap; /* In ms. */
+ uint16_t cypher_s; /* Cypher strength (bits), 0 = no encryption. */
+ uint32_t timeout; /* Peer timeout time, in ms, 0 = no timeout. */
} qosspec_t;
-__BEGIN_DECLS
+static const qosspec_t qos_raw = {
+ .delay = UINT32_MAX,
+ .bandwidth = 0,
+ .availability = 0,
+ .loss = 1,
+ .ber = 1,
+ .in_order = 0,
+ .max_gap = UINT32_MAX,
+ .cypher_s = 0,
+ .timeout = DEFAULT_PEER_TIMEOUT
+};
+
+static const qosspec_t qos_raw_no_errors = {
+ .delay = UINT32_MAX,
+ .bandwidth = 0,
+ .availability = 0,
+ .loss = 1,
+ .ber = 0,
+ .in_order = 0,
+ .max_gap = UINT32_MAX,
+ .cypher_s = 0,
+ .timeout = DEFAULT_PEER_TIMEOUT
+};
+
+static const qosspec_t qos_raw_crypt = {
+ .delay = UINT32_MAX,
+ .bandwidth = 0,
+ .availability = 0,
+ .loss = 1,
+ .ber = 0,
+ .in_order = 0,
+ .max_gap = UINT32_MAX,
+ .cypher_s = 256,
+ .timeout = DEFAULT_PEER_TIMEOUT
+};
+
+static const qosspec_t qos_best_effort = {
+ .delay = UINT32_MAX,
+ .bandwidth = 0,
+ .availability = 0,
+ .loss = 1,
+ .ber = 0,
+ .in_order = 1,
+ .max_gap = UINT32_MAX,
+ .cypher_s = 0,
+ .timeout = DEFAULT_PEER_TIMEOUT
+};
+
+static const qosspec_t qos_best_effort_crypt = {
+ .delay = UINT32_MAX,
+ .bandwidth = 0,
+ .availability = 0,
+ .loss = 1,
+ .ber = 0,
+ .in_order = 1,
+ .max_gap = UINT32_MAX,
+ .cypher_s = 256,
+ .timeout = DEFAULT_PEER_TIMEOUT
+};
+
+static const qosspec_t qos_video = {
+ .delay = 100,
+ .bandwidth = UINT64_MAX,
+ .availability = 3,
+ .loss = 1,
+ .ber = 0,
+ .in_order = 1,
+ .max_gap = 100,
+ .cypher_s = 0,
+ .timeout = DEFAULT_PEER_TIMEOUT
+};
+
+static const qosspec_t qos_video_crypt = {
+ .delay = 100,
+ .bandwidth = UINT64_MAX,
+ .availability = 3,
+ .loss = 1,
+ .ber = 0,
+ .in_order = 1,
+ .max_gap = 100,
+ .cypher_s = 256,
+ .timeout = DEFAULT_PEER_TIMEOUT
+};
+
+static const qosspec_t qos_voice = {
+ .delay = 50,
+ .bandwidth = 100000,
+ .availability = 5,
+ .loss = 1,
+ .ber = 0,
+ .in_order = 1,
+ .max_gap = 50,
+ .cypher_s = 0,
+ .timeout = DEFAULT_PEER_TIMEOUT
+};
-int qosspec_init(qosspec_t * qs);
+static const qosspec_t qos_voice_crypt = {
+ .delay = 50,
+ .bandwidth = 100000,
+ .availability = 5,
+ .loss = 1,
+ .ber = 0,
+ .in_order = 1,
+ .max_gap = 50,
+ .cypher_s = 256,
+ .timeout = DEFAULT_PEER_TIMEOUT
+};
-int qosspec_fini(qosspec_t * qs);
+static const qosspec_t qos_data = {
+ .delay = 1000,
+ .bandwidth = 0,
+ .availability = 0,
+ .loss = 0,
+ .ber = 0,
+ .in_order = 1,
+ .max_gap = 2000,
+ .cypher_s = 0,
+ .timeout = DEFAULT_PEER_TIMEOUT
+};
-__END_DECLS
+static const qosspec_t qos_data_crypt = {
+ .delay = 1000,
+ .bandwidth = 0,
+ .availability = 0,
+ .loss = 0,
+ .ber = 0,
+ .in_order = 1,
+ .max_gap = 2000,
+ .cypher_s = 256,
+ .timeout = DEFAULT_PEER_TIMEOUT
+};
#endif /* OUROBOROS_QOS_H */
diff --git a/include/ouroboros/qoscube.h b/include/ouroboros/qoscube.h
index bce9b361..ed20484c 100644
--- a/include/ouroboros/qoscube.h
+++ b/include/ouroboros/qoscube.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Quality of Service cubes
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,8 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_QOSCUBE_H
-#define OUROBOROS_QOSCUBE_H
+#ifndef OUROBOROS_LIB_QOSCUBE_H
+#define OUROBOROS_LIB_QOSCUBE_H
#include <ouroboros/qos.h>
@@ -35,4 +35,4 @@ typedef enum qos_cube {
qoscube_t qos_spec_to_cube(qosspec_t qs);
qosspec_t qos_cube_to_spec(qoscube_t qc);
-#endif
+#endif /* OUROBOROS_LIB_QOSCUBE_H */
diff --git a/include/ouroboros/random.h b/include/ouroboros/random.h
index 6f3d4438..e1b25e5d 100644
--- a/include/ouroboros/random.h
+++ b/include/ouroboros/random.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Pseudo random generator
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,12 +20,12 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_RANDOM_H
-#define OUROBOROS_RANDOM_H
+#ifndef OUROBOROS_LIB_RANDOM_H
+#define OUROBOROS_LIB_RANDOM_H
#include <sys/types.h>
int random_buffer(void * buf,
size_t len);
-#endif /* OUROBOROS_RANDOM_H */
+#endif /* OUROBOROS_LIB_RANDOM_H */
diff --git a/include/ouroboros/rib.h b/include/ouroboros/rib.h
index 5a3d66dc..6aabe8f7 100644
--- a/include/ouroboros/rib.h
+++ b/include/ouroboros/rib.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* RIB export using FUSE
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -23,20 +23,25 @@
#ifndef OUROBOROS_LIB_RIB_H
#define OUROBOROS_LIB_RIB_H
-#define RIB_PATH_LEN 128
+#define RIB_PATH_LEN 300
+#define RIB_SEPARATOR "/"
-#include <sys/stat.h>
#include <sys/types.h>
struct rib;
+struct rib_attr {
+ size_t size; /* Size of RIB document */
+ time_t mtime; /* Last modified time */
+};
+
struct rib_ops {
int (* read)(const char * path,
char * buf,
size_t len);
int (* readdir)(char *** entries);
- int (* getattr)(const char * path,
- struct stat * st);
+ int (* getattr)(const char * path,
+ struct rib_attr * attr);
};
int rib_init(const char * prefix);
@@ -48,4 +53,6 @@ int rib_reg(const char * path,
void rib_unreg(const char * path);
+void rib_cleanup(const char * mnt);
+
#endif /* OUROBOROS_LIB_RIB_H */
diff --git a/include/ouroboros/serdes-irm.h b/include/ouroboros/serdes-irm.h
new file mode 100644
index 00000000..1d041541
--- /dev/null
+++ b/include/ouroboros/serdes-irm.h
@@ -0,0 +1,79 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2024
+ *
+ * Ouroboros IRM Protocol - serialization/deserialization
+ *
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., http://www.fsf.org/about/contact/.
+ */
+
+#ifndef OUROBOROS_LIB_SERDES_IRM_H
+#define OUROBOROS_LIB_SERDES_IRM_H
+
+#include <ouroboros/flow.h>
+#include <ouroboros/ipcp.h>
+#include <ouroboros/time.h>
+#include <ouroboros/utils.h>
+
+#include <inttypes.h>
+
+int flow_alloc__irm_req_ser(buffer_t * buf,
+ const struct flow_info * flow,
+ const char * dst,
+ const struct timespec * timeo);
+
+int flow_join__irm_req_ser(buffer_t * buf,
+ const struct flow_info * flow,
+ const char * dst,
+ const struct timespec * timeo);
+
+int flow_accept__irm_req_ser(buffer_t * buf,
+ const struct flow_info * flow,
+ const struct timespec * timeo);
+
+int ipcp_flow_req_arr__irm_req_ser(buffer_t * buf,
+ const buffer_t * dst,
+ const struct flow_info * flow,
+ const buffer_t * data);
+
+int ipcp_flow_alloc_reply__irm_msg_ser(buffer_t * buf,
+ const struct flow_info * flow,
+ int response,
+ const buffer_t * data);
+
+/* response to alloc / join / accept / flow_req_arr */
+int flow__irm_result_des(buffer_t * buf,
+ struct flow_info * flow,
+ buffer_t * sk);
+
+int flow_dealloc__irm_req_ser(buffer_t * buf,
+ const struct flow_info * flow,
+ const struct timespec * timeo);
+
+int ipcp_flow_dealloc__irm_req_ser(buffer_t * buf,
+ const struct flow_info * info);
+
+int ipcp_create_r__irm_req_ser(buffer_t * buf,
+ const struct ipcp_info * ipcp);
+
+int proc_announce__irm_req_ser(buffer_t * buf,
+ const char * prog);
+
+int proc_exit__irm_req_ser(buffer_t * buf);
+
+int irm__irm_result_des(buffer_t * buf);
+
+#endif /* OUROBOROS_LIB_SERDES_IRM_H*/
diff --git a/include/ouroboros/serdes-oep.h b/include/ouroboros/serdes-oep.h
new file mode 100644
index 00000000..69ba71a4
--- /dev/null
+++ b/include/ouroboros/serdes-oep.h
@@ -0,0 +1,70 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2024
+ *
+ * Ouroboros Enrollment Protocol - serialization/deserialization
+ *
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., http://www.fsf.org/about/contact/.
+ */
+
+#ifndef OUROBOROS_LIB_SERDES_OEP_H
+#define OUROBOROS_LIB_SERDES_OEP_H
+
+#include <ouroboros/ipcp.h>
+#include <ouroboros/utils.h>
+
+#include <sys/time.h>
+
+/* Enrollment */
+
+#define ENROLL_ID_LEN 8
+
+struct enroll_req {
+ /* TODO: Authentication */
+ uint8_t id[ENROLL_ID_LEN];
+};
+
+struct enroll_resp {
+ uint8_t id[ENROLL_ID_LEN];
+ struct timespec t;
+ int response;
+ struct ipcp_config conf;
+};
+
+struct enroll_ack {
+ uint8_t id[ENROLL_ID_LEN];
+ int result;
+};
+
+ssize_t enroll_req_ser(const struct enroll_req * req,
+ buffer_t buf);
+
+int enroll_req_des(struct enroll_req * req,
+ const buffer_t buf);
+
+ssize_t enroll_resp_ser(const struct enroll_resp * resp,
+ buffer_t buf);
+
+int enroll_resp_des(struct enroll_resp * resp,
+ buffer_t buf);
+
+ssize_t enroll_ack_ser(const struct enroll_ack * ack,
+ buffer_t buf);
+
+int enroll_ack_des(struct enroll_ack * ack,
+ const buffer_t buf);
+
+#endif /* OUROBOROS_LIB_SERDES_OEP_H*/
diff --git a/include/ouroboros/sha3.h b/include/ouroboros/sha3.h
index f0c1204b..04871f3b 100644
--- a/include/ouroboros/sha3.h
+++ b/include/ouroboros/sha3.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* SHA3 algorithm
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This implementation is adapted and redistributed from the RHASH
* project implementation of the sha3 algorithm
diff --git a/include/ouroboros/shm_du_buff.h b/include/ouroboros/shm_du_buff.h
index 31090cd3..c25d4b95 100644
--- a/include/ouroboros/shm_du_buff.h
+++ b/include/ouroboros/shm_du_buff.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Data Buffer element in Random Deletion Ring Buffer
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,8 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_SHM_DU_BUFF_H
-#define OUROBOROS_SHM_DU_BUFF_H
+#ifndef OUROBOROS_LIB_SHM_DU_BUFF_H
+#define OUROBOROS_LIB_SHM_DU_BUFF_H
#include <sys/types.h>
#include <stdint.h>
@@ -34,6 +34,8 @@ uint8_t * shm_du_buff_head(struct shm_du_buff * sdb);
uint8_t * shm_du_buff_tail(struct shm_du_buff * sdb);
+size_t shm_du_buff_len(struct shm_du_buff * sdb);
+
uint8_t * shm_du_buff_head_alloc(struct shm_du_buff * sdb,
size_t size);
@@ -49,4 +51,8 @@ uint8_t * shm_du_buff_tail_release(struct shm_du_buff * sdb,
void shm_du_buff_truncate(struct shm_du_buff * sdb,
size_t len);
-#endif /* OUROBOROS_SHM_DU_BUFF_H */
+int shm_du_buff_wait_ack(struct shm_du_buff * sdb);
+
+int shm_du_buff_ack(struct shm_du_buff * sdb);
+
+#endif /* OUROBOROS_LIB_SHM_DU_BUFF_H */
diff --git a/include/ouroboros/shm_flow_set.h b/include/ouroboros/shm_flow_set.h
index 76849137..09e37649 100644
--- a/include/ouroboros/shm_flow_set.h
+++ b/include/ouroboros/shm_flow_set.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Management of flow_sets for fqueue
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,16 +20,21 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_SHM_FLOW_SET_H
-#define OUROBOROS_SHM_FLOW_SET_H
+#ifndef OUROBOROS_LIB_SHM_FLOW_SET_H
+#define OUROBOROS_LIB_SHM_FLOW_SET_H
#include <ouroboros/fqueue.h>
#include <sys/time.h>
+struct flowevent {
+ int flow_id;
+ int event;
+};
+
struct shm_flow_set;
-struct shm_flow_set * shm_flow_set_create(void);
+struct shm_flow_set * shm_flow_set_create(pid_t pid);
void shm_flow_set_destroy(struct shm_flow_set * set);
@@ -42,22 +47,23 @@ void shm_flow_set_zero(struct shm_flow_set * shm_set,
int shm_flow_set_add(struct shm_flow_set * shm_set,
size_t idx,
- int port_id);
+ int flow_id);
int shm_flow_set_has(struct shm_flow_set * shm_set,
size_t idx,
- int port_id);
+ int flow_id);
void shm_flow_set_del(struct shm_flow_set * shm_set,
size_t idx,
- int port_id);
+ int flow_id);
void shm_flow_set_notify(struct shm_flow_set * set,
- int port_id);
+ int flow_id,
+ int event);
ssize_t shm_flow_set_wait(const struct shm_flow_set * shm_set,
size_t idx,
- int * fqueue,
+ struct flowevent * fqueue,
const struct timespec * abstime);
-#endif /* OUROBOROS_SHM_FLOW_SET_H */
+#endif /* OUROBOROS_LIB_SHM_FLOW_SET_H */
diff --git a/include/ouroboros/shm_rbuff.h b/include/ouroboros/shm_rbuff.h
index b2e27c7b..4323d4e1 100644
--- a/include/ouroboros/shm_rbuff.h
+++ b/include/ouroboros/shm_rbuff.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
- * Ring buffer for incoming SDUs
+ * Ring buffer for incoming packets
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,8 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_SHM_RBUFF_H
-#define OUROBOROS_SHM_RBUFF_H
+#ifndef OUROBOROS_LIB_SHM_RBUFF_H
+#define OUROBOROS_LIB_SHM_RBUFF_H
#include <sys/types.h>
#include <sys/time.h>
@@ -31,14 +31,15 @@
#define ACL_RDWR 0000
#define ACL_RDONLY 0001
#define ACL_FLOWDOWN 0002
+#define ACL_FLOWPEER 0004
struct shm_rbuff;
struct shm_rbuff * shm_rbuff_create(pid_t pid,
- int port_id);
+ int flow_id);
struct shm_rbuff * shm_rbuff_open(pid_t pid,
- int port_id);
+ int flow_id);
void shm_rbuff_close(struct shm_rbuff * rb);
@@ -54,6 +55,10 @@ void shm_rbuff_fini(struct shm_rbuff * rb);
int shm_rbuff_write(struct shm_rbuff * rb,
size_t idx);
+int shm_rbuff_write_b(struct shm_rbuff * rb,
+ size_t idx,
+ const struct timespec * abstime);
+
ssize_t shm_rbuff_read(struct shm_rbuff * rb);
ssize_t shm_rbuff_read_b(struct shm_rbuff * rb,
@@ -61,4 +66,4 @@ ssize_t shm_rbuff_read_b(struct shm_rbuff * rb,
size_t shm_rbuff_queued(struct shm_rbuff * rb);
-#endif /* OUROBOROS_SHM_RBUFF_H */
+#endif /* OUROBOROS_LIB_SHM_RBUFF_H */
diff --git a/include/ouroboros/shm_rdrbuff.h b/include/ouroboros/shm_rdrbuff.h
index c27ff24d..4f9a215a 100644
--- a/include/ouroboros/shm_rdrbuff.h
+++ b/include/ouroboros/shm_rdrbuff.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Random Deletion Ring Buffer for Data Units
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,15 +20,14 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_SHM_RDRBUFF_H
-#define OUROBOROS_SHM_RDRBUFF_H
+#ifndef OUROBOROS_LIB_SHM_RDRBUFF_H
+#define OUROBOROS_LIB_SHM_RDRBUFF_H
#include <ouroboros/shm_du_buff.h>
-#include <ouroboros/qoscube.h>
-#include <ouroboros/time_utils.h>
+#include <ouroboros/time.h>
-#include <stdint.h>
#include <pthread.h>
+#include <stdint.h>
#include <sys/types.h>
struct shm_rdrbuff;
@@ -43,21 +42,16 @@ void shm_rdrbuff_destroy(struct shm_rdrbuff * rdrb);
void shm_rdrbuff_purge(void);
-int shm_rdrbuff_wait_full(struct shm_rdrbuff * rdrb,
- struct timespec * timeo);
-
-/* returns the index of the buffer in the DU map */
-ssize_t shm_rdrbuff_write(struct shm_rdrbuff * rdrb,
- size_t headspace,
- size_t tailspace,
- const uint8_t * data,
- size_t data_len);
+/* Returns block index, a ptr and du_buff. */
+ssize_t shm_rdrbuff_alloc(struct shm_rdrbuff * rdrb,
+ size_t count,
+ uint8_t ** ptr,
+ struct shm_du_buff ** sdb);
-ssize_t shm_rdrbuff_write_b(struct shm_rdrbuff * rdrb,
- size_t headspace,
- size_t tailspace,
- const uint8_t * data,
- size_t data_len,
+ssize_t shm_rdrbuff_alloc_b(struct shm_rdrbuff * rdrb,
+ size_t count,
+ uint8_t ** ptr,
+ struct shm_du_buff ** sdb,
const struct timespec * abstime);
ssize_t shm_rdrbuff_read(uint8_t ** dst,
@@ -70,4 +64,4 @@ struct shm_du_buff * shm_rdrbuff_get(struct shm_rdrbuff * rdrb,
int shm_rdrbuff_remove(struct shm_rdrbuff * rdrb,
size_t idx);
-#endif /* OUROBOROS_SHM_RDRBUFF_H */
+#endif /* OUROBOROS_LIB_SHM_RDRBUFF_H */
diff --git a/include/ouroboros/sockets.h b/include/ouroboros/sockets.h.in
index 36ea4da9..095674a9 100644
--- a/include/ouroboros/sockets.h
+++ b/include/ouroboros/sockets.h.in
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* The sockets layer to communicate between daemons
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,30 +20,20 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_SOCKETS_H
-#define OUROBOROS_SOCKETS_H
+#ifndef OUROBOROS_LIB_SOCKETS_H
+#define OUROBOROS_LIB_SOCKETS_H
-#include <sys/types.h>
-
-#include "ipcp_config.pb-c.h"
-typedef IpcpConfigMsg ipcp_config_msg_t;
-typedef LayerInfoMsg layer_info_msg_t;
-
-#include "irmd_messages.pb-c.h"
-typedef IrmMsg irm_msg_t;
-typedef IpcpInfoMsg ipcp_info_msg_t;
-
-#include "ipcpd_messages.pb-c.h"
-typedef IpcpMsg ipcp_msg_t;
+#include <ouroboros/protobuf.h>
-#define SOCK_PATH "/var/run/ouroboros/"
-#define SOCK_PATH_SUFFIX ".sock"
+#include <sys/types.h>
-#define IRM_SOCK_PATH SOCK_PATH "irm" SOCK_PATH_SUFFIX
-#define IRM_MSG_BUF_SIZE 2048
+#define SOCK_PATH "/var/run/ouroboros/"
+#define SOCK_PATH_SUFFIX ".sock"
+#define IRM_SOCK_PATH SOCK_PATH "irm" SOCK_PATH_SUFFIX
#define IPCP_SOCK_PATH_PREFIX SOCK_PATH "ipcp"
-#define IPCP_MSG_BUF_SIZE IRM_MSG_BUF_SIZE
+
+#define SOCK_BUF_SIZE @SOCK_BUF_SIZE@
/* Returns the full socket path of an IPCP */
char * ipcp_sock_path(pid_t pid);
@@ -52,6 +42,11 @@ int server_socket_open(char * file_name);
int client_socket_open(char * file_name);
+int send_recv_msg(buffer_t * buf);
+
irm_msg_t * send_recv_irm_msg(irm_msg_t * msg);
-#endif
+/* cleanup socket when cancelling thread */
+void __cleanup_close_ptr(void * o);
+
+#endif /* OUROBOROS_LIB_SOCKETS_H */
diff --git a/include/ouroboros/test.h b/include/ouroboros/test.h
new file mode 100644
index 00000000..096e145c
--- /dev/null
+++ b/include/ouroboros/test.h
@@ -0,0 +1,82 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2024
+ *
+ * Test macros
+ *
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., http://www.fsf.org/about/contact/.
+ */
+
+#ifndef OUROBOROS_LIB_TEST_H
+#define OUROBOROS_LIB_TEST_H
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+#define TEST_START() \
+ do { \
+ printf("%s started.\n", __func__); \
+ fflush(stdout); \
+ } while (0)
+#define TEST_SUCCESS() \
+ do { \
+ printf("%s succeeded.\n", __func__); \
+ fflush(stdout); \
+ } while (0)
+
+#define TEST_FAIL() \
+ do { \
+ printf("%s failed.\n", __func__); \
+ fflush(stdout); \
+ } while (0)
+
+#define TEST_END(result) \
+ do { if (result == 0) TEST_SUCCESS(); else TEST_FAIL(); } while (0)
+
+static int __attribute__((unused)) test_assert_fail(int(* testfunc)(void))
+{
+ pid_t pid;
+ int wstatus;
+
+ pid = fork();
+ if (pid == -1) {
+ printf("Failed to fork: %s.\n", strerror(errno));
+ return -1;
+ }
+
+ if (pid == 0)
+ return testfunc(); /* should abort */
+
+ waitpid(pid, &wstatus, 0);
+#ifdef CONFIG_OUROBOROS_DEBUG
+ if (WIFSIGNALED(wstatus) && (wstatus == 134 || wstatus == 6))
+ return 0;
+
+ printf("Process did not abort, status: %d.\n", wstatus);
+#else
+ if (WIFEXITED(wstatus) && wstatus == 0)
+ return 0;
+
+ printf("Process did not exit, status: %d.\n", wstatus);
+#endif
+
+ return -1;
+}
+
+#endif /* OUROBOROS_LIB_TEST_H */
diff --git a/include/ouroboros/time.h b/include/ouroboros/time.h
new file mode 100644
index 00000000..b274c35b
--- /dev/null
+++ b/include/ouroboros/time.h
@@ -0,0 +1,130 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2024
+ *
+ * Time utilities
+ *
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., http://www.fsf.org/about/contact/.
+ */
+
+#ifndef OUROBOROS_LIB_TIME_H
+#define OUROBOROS_LIB_TIME_H
+
+#ifdef MILLION
+#undef MILLION
+#endif
+
+#ifdef BILLION
+#undef BILLION
+#endif
+
+#define MILLION 1000000L
+#define BILLION 1000000000L
+
+#include <time.h>
+#include <sys/time.h>
+
+#define TIMESPEC_INIT_S(s) {(s), 0}
+#define TIMESPEC_INIT_MS(ms) {(ms) / 1000, ((ms) % 1000) * MILLION}
+#define TIMESPEC_INIT_US(us) {(us) / MILLION, ((us) % MILLION) * 1000}
+#define TIMESPEC_INIT_NS(ns) {(ns) / BILLION, ((ns) % BILLION)}
+
+#define TIMEVAL_INIT_S(s) {(s), 0}
+#define TIMEVAL_INIT_MS(ms) {(ms) / 1000, ((ms) % 1000) * 1000}
+#define TIMEVAL_INIT_US(us) {(us) / MILLION, ((us) % MILLION)}
+
+/* functions for timespecs */
+#define ts_diff_ns(t0, tx) (((tx)->tv_sec - (t0)->tv_sec) * BILLION \
+ + ((tx)->tv_nsec - (t0)->tv_nsec))
+#define ts_diff_us(t0, tx) (((tx)->tv_sec - (t0)->tv_sec) * MILLION \
+ + ((tx)->tv_nsec - (t0)->tv_nsec) / 1000L)
+#define ts_diff_ms(t0, tx) (((tx)->tv_sec - (t0)->tv_sec) * 1000L \
+ + ((tx)->tv_nsec - (t0)->tv_nsec) / MILLION)
+
+/* functions for timevals are the same */
+#define tv_diff_us(t0, tx) (((tx)->tv_sec - (t0)->tv_sec) * MILLION \
+ + ((tx)->tv_usec - (t0)->tv_usec) / 1000L)
+#define tv_diff_ms(t0, tx) (((tx)->tv_sec - (t0)->tv_sec) * 1000L \
+ + ((tx)->tv_usec - (t0)->tv_usec) / MILLION)
+
+/* functions for timespecs */
+
+#define ts_add(t, intv, res) \
+ do { \
+ time_t nanos = 0; \
+ nanos = (t)->tv_nsec + (intv)->tv_nsec; \
+ (res)->tv_sec = (t)->tv_sec + (intv)->tv_sec; \
+ while (nanos >= BILLION) { \
+ nanos -= BILLION; \
+ ++((res)->tv_sec); \
+ } \
+ (res)->tv_nsec = nanos; \
+ } while (0);
+
+#define ts_diff(t, intv, res) \
+ do { \
+ time_t nanos = 0; \
+ nanos = (t)->tv_nsec - (intv)->tv_nsec; \
+ (res)->tv_sec = (t)->tv_sec - (intv)->tv_sec; \
+ while (nanos < 0) { \
+ nanos += BILLION; \
+ --((res)->tv_sec); \
+ } \
+ (res)->tv_nsec = nanos; \
+ } while (0);
+
+/* functions for timevals */
+
+#define tv_add(t, intv, res) \
+ do { \
+ time_t micros = 0; \
+ micros = (t)->tv_usec + (intv)->tv_usec; \
+ (res)->tv_sec = (t)->tv_sec + (intv)->tv_sec; \
+ while (micros >= MILLION) { \
+ micros -= MILLION; \
+ ++((res)->tv_sec); \
+ } \
+ (res)->tv_usec = micros; \
+ } while (0);
+
+#define tv_diff(t, intv, res) \
+ do { \
+ time_t micros = 0; \
+ micros = (t)->tv_usec - (intv)->tv_usec; \
+ (res)->tv_sec = (t)->tv_sec - (intv)->tv_sec; \
+ while (micros < 0) { \
+ micros += MILLION; \
+ --((res)->tv_sec); \
+ } \
+ (res)->tv_usec = micros; \
+ } while (0);
+
+
+/* copying a timeval into a timespec */
+#define tv_to_ts(tv, ts) \
+ do { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000L; \
+ } while (0);
+
+/* copying a timespec into a timeval (loss of resolution) */
+#define ts_to_tv(ts, tv) \
+ do { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000L; \
+ } while (0);
+
+#endif /* OUROBOROS_LIB_TIME_H */
diff --git a/include/ouroboros/time_utils.h b/include/ouroboros/time_utils.h
deleted file mode 100644
index d62b4c06..00000000
--- a/include/ouroboros/time_utils.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Ouroboros - Copyright (C) 2016 - 2018
- *
- * Time utilities
- *
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., http://www.fsf.org/about/contact/.
- */
-
-#ifndef OUROBOROS_TIME_UTILS_H
-#define OUROBOROS_TIME_UTILS_H
-
-#ifdef MILLION
-#undef MILLION
-#endif
-
-#ifdef BILLION
-#undef BILLION
-#endif
-
-#define MILLION 1000000L
-#define BILLION 1000000000L
-
-#include <time.h>
-#include <sys/time.h>
-#include <limits.h> /* LONG_MAX */
-
-/* functions for timespecs */
-#define ts_diff_ns(t0, tx) (((tx)->tv_sec - (t0)->tv_sec) * BILLION \
- + ((tx)->tv_nsec - (t0)->tv_nsec))
-#define ts_diff_us(t0, tx) (((tx)->tv_sec - (t0)->tv_sec) * MILLION \
- + ((tx)->tv_nsec - (t0)->tv_nsec) / 1000L)
-#define ts_diff_ms(t0, tx) (((tx)->tv_sec - (t0)->tv_sec) * 1000L \
- + ((tx)->tv_nsec - (t0)->tv_nsec) / MILLION)
-
-/* functions for timevals are the same */
-#define tv_diff_us(t0, tx) (((tx)->tv_sec - (t0)->tv_sec) * MILLION \
- + ((tx)->tv_usec - (t0)->tv_usec) / 1000L)
-#define tv_diff_ms(t0, tx) (((tx)->tv_sec - (t0)->tv_sec) * 1000L \
- + ((tx)->tv_usec - (t0)->tv_usec) / MILLION)
-
-/* functions for timespecs */
-int ts_add(const struct timespec * t,
- const struct timespec * intv,
- struct timespec * res);
-
-int ts_diff(const struct timespec * t,
- const struct timespec * intv,
- struct timespec * res);
-
-/* functions for timevals */
-int tv_add(const struct timeval * t,
- const struct timeval * intv,
- struct timeval * res);
-
-int tv_diff(const struct timeval * t,
- const struct timeval * intv,
- struct timeval * res);
-
-/* copying a timeval into a timespec */
-int tv_to_ts(const struct timeval * src,
- struct timespec * dst);
-
-/* copying a timespec into a timeval (loss of resolution) */
-int ts_to_tv(const struct timespec * src,
- struct timeval * dst);
-
-#endif /* OUROBOROS_TIME_UTILS_H */
diff --git a/include/ouroboros/timerwheel.h b/include/ouroboros/timerwheel.h
deleted file mode 100644
index 231e8103..00000000
--- a/include/ouroboros/timerwheel.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Ouroboros - Copyright (C) 2016 - 2018
- *
- * Ring buffer for incoming SDUs
- *
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., http://www.fsf.org/about/contact/.
- */
-
-#ifndef OUROBOROS_LIB_TIMERWHEEL_H
-#define OUROBOROS_LIB_TIMERWHEEL_H
-
-struct timerwheel;
-
-struct timerwheel * timerwheel_create(time_t resolution,
- time_t max_delay);
-
-void timerwheel_destroy(struct timerwheel * tw);
-
-struct tw_f * timerwheel_start(struct timerwheel * tw,
- void (* func)(void *),
- void * arg,
- time_t delay); /* ms */
-
-int timerwheel_restart(struct timerwheel * tw,
- struct tw_f * f,
- time_t delay); /* ms */
-
-void timerwheel_stop(struct timerwheel * tw,
- struct tw_f * f);
-
-void timerwheel_move(struct timerwheel * tw);
-
-#endif /* OUROBOROS_LIB_TIMERWHEEL_H */
diff --git a/include/ouroboros/tpm.h b/include/ouroboros/tpm.h
index c57ea69b..445f9306 100644
--- a/include/ouroboros/tpm.h
+++ b/include/ouroboros/tpm.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Threadpool management
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
diff --git a/include/ouroboros/utils.h b/include/ouroboros/utils.h
index 1d54c179..93fbf402 100644
--- a/include/ouroboros/utils.h
+++ b/include/ouroboros/utils.h
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Handy utilities
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -20,14 +20,18 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_UTILS_H
-#define OUROBOROS_UTILS_H
+#ifndef OUROBOROS_LIB_UTILS_H
+#define OUROBOROS_LIB_UTILS_H
#include <stdint.h>
#include <unistd.h>
+#include <string.h>
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+#define ABS(a) ((a) > 0 ? (a) : -(a))
+#define clrbuf(buf) do { memset(&(buf), 0, sizeof(buf)); } while (0);
+#define freebuf(buf) do { free((buf).data); clrbuf(buf); } while (0);
typedef struct {
uint8_t * data;
@@ -41,7 +45,14 @@ typedef struct {
int n_digits(unsigned i);
/* gets the application name */
-char * path_strip(char * src);
+char * path_strip(const char * src);
+
+/* functions for copying and destroying arguments list */
+size_t argvlen(const char ** argv);
+
+char ** argvdup(char ** argv);
+
+void argvfree(char ** argv);
/* destroy a ** */
#define freepp(type, ptr, len) \
@@ -53,4 +64,4 @@ char * path_strip(char * src);
free(ptr); \
} while (0);
-#endif /* OUROBOROS_UTILS_H */
+#endif /* OUROBOROS_LIB_UTILS_H */
diff --git a/include/ouroboros/version.h.in b/include/ouroboros/version.h.in
index ad425f68..c006a095 100644
--- a/include/ouroboros/version.h.in
+++ b/include/ouroboros/version.h.in
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2018
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* Ouroboros version
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
diff --git a/include/ouroboros/wrap/CMakeLists.txt b/include/ouroboros/wrap/CMakeLists.txt
deleted file mode 100644
index 18e695b9..00000000
--- a/include/ouroboros/wrap/CMakeLists.txt
+++ /dev/null
@@ -1,71 +0,0 @@
-include_directories(${CMAKE_SOURCE_DIR}/include)
-include_directories(${CMAKE_BINARY_DIR}/include)
-
-find_package(SWIG QUIET)
-if (NOT SWIG_FOUND)
- message(STATUS "Install SWIG to enable bindings for other languages")
-else ()
- set(DISABLE_SWIG FALSE CACHE BOOL "Disable SWIG support")
- if (NOT DISABLE_SWIG)
- message(STATUS "SWIG support enabled")
- include(${SWIG_USE_FILE})
- include_directories(${CMAKE_CURRENT_SOURCE_DIR})
- set(CMAKE_SWIG_FLAGS "")
-
- find_package(PythonInterp QUIET)
- find_package(PythonLibs QUIET)
- if (NOT PYTHONLIBS_FOUND OR NOT PYTHONINTERP_FOUND)
- message(STATUS "Python not found: Python bindings will not be built")
- else ()
- message(STATUS "Python found: Python bindings will be built")
- include_directories(${PYTHON_INCLUDE_PATH})
-
- # Python assumes C99 since Python 3.6
- test_and_set_c_compiler_flag_global(-std=c99)
- # SWIG generates code for varargs with an unused parameter
- test_and_set_c_compiler_flag_global(-Wno-unused-parameter)
-
- # CMake > 3.8 deprecates swig_add_module
- if (${CMAKE_VERSION} VERSION_LESS 3.8.0)
- swig_add_module(ouroboros python ouroboros.i)
- else ()
- swig_add_library(ouroboros
- LANGUAGE python
- SOURCES ouroboros.i
- TYPE MODULE)
- endif()
-
- swig_link_libraries(ouroboros ${PYTHON_LIBRARIES} ouroboros-common
- ouroboros-dev ouroboros-irm)
-
- # Installation directives
- if (CMAKE_INSTALL_PREFIX STREQUAL "")
- execute_process(
- COMMAND ${PYTHON_EXECUTABLE} -c
- "from distutils import sysconfig; print(sysconfig.get_python_lib())"
- OUTPUT_VARIABLE PYTHON_MODULE_PATH
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- else ()
- execute_process(
- COMMAND ${PYTHON_EXECUTABLE} -c
- "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))"
- OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- get_filename_component(_ABS_PYTHON_MODULE_PATH
- ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE)
- file(RELATIVE_PATH PYTHON_MODULE_PATH
- ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH})
- endif ()
-
- install(FILES
- ${CMAKE_CURRENT_BINARY_DIR}/${SWIG_MODULE_ouroboros_REAL_NAME}.so
- DESTINATION ${PYTHON_MODULE_PATH})
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ouroboros.py
- DESTINATION ${PYTHON_MODULE_PATH})
- endif ()
- else ()
- message(STATUS "SWIG support disabled by user")
- endif ()
-endif ()
-
-mark_as_advanced(SWIG_EXECUTABLE)
diff --git a/include/ouroboros/wrap/ouroboros.i b/include/ouroboros/wrap/ouroboros.i
deleted file mode 100644
index a34c45ec..00000000
--- a/include/ouroboros/wrap/ouroboros.i
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Ouroboros - Copyright (C) 2016 - 2018
- *
- * SWIG wrapper file
- *
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., http://www.fsf.org/about/contact/.
- */
-
-%module ouroboros
-%{
-#include "ouroboros/cdefs.h"
-#include "ouroboros/cacep.h"
-#include "ouroboros/dev.h"
-#include "ouroboros/errno.h"
-#include "ouroboros/fccntl.h"
-#include "ouroboros/fqueue.h"
-#include "ouroboros/irm.h"
-#include "ouroboros/ipcp.h"
-#include "ouroboros/qos.h"
-#include "ouroboros/version.h"
-%}
-
-typedef int pid_t;
-
-%include "ouroboros/cdefs.h"
-%include "ouroboros/cacep.h"
-%include "ouroboros/dev.h"
-%include "ouroboros/errno.h"
-%include "ouroboros/fccntl.h"
-%include "ouroboros/fqueue.h"
-%include "ouroboros/irm.h"
-%include "ouroboros/ipcp.h"
-%include "ouroboros/qos.h"
-%include "ouroboros/version.h"