diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ouroboros/CMakeLists.txt | 4 | ||||
-rw-r--r-- | include/ouroboros/config.h.in | 88 | ||||
-rw-r--r-- | include/ouroboros/endian.h | 51 | ||||
-rw-r--r-- | include/ouroboros/frct_pci.h | 69 | ||||
-rw-r--r-- | include/ouroboros/hash.h | 10 | ||||
-rw-r--r-- | include/ouroboros/shm_flow_set.h | 2 | ||||
-rw-r--r-- | include/ouroboros/shm_rbuff.h | 2 | ||||
-rw-r--r-- | include/ouroboros/timerwheel.h | 47 | ||||
-rw-r--r-- | include/ouroboros/wrap/CMakeLists.txt | 9 |
9 files changed, 146 insertions, 136 deletions
diff --git a/include/ouroboros/CMakeLists.txt b/include/ouroboros/CMakeLists.txt index 8f57d4d7..e39759fd 100644 --- a/include/ouroboros/CMakeLists.txt +++ b/include/ouroboros/CMakeLists.txt @@ -1,7 +1,3 @@ -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" - "${CMAKE_CURRENT_BINARY_DIR}/config.h") - set(HEADER_FILES cacep.h cdap.h diff --git a/include/ouroboros/config.h.in b/include/ouroboros/config.h.in deleted file mode 100644 index d5871624..00000000 --- a/include/ouroboros/config.h.in +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * Configuration information - * - * Dimitri Staessens <[email protected]> - * Sander Vrijders <[email protected]> - * - * 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_CONFIG -#define OUROBOROS_CONFIG - -#define PROJECT_NAME "@CMAKE_PROJECT_NAME@" -#define PROJECT_VERSION "@PACKAGE_VERSION@" -#define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@" -#define _POSIX_C_SOURCE 200809L -#define __XSI_VISIBLE 500 -#ifdef __FreeBSD__ -#define __BSD_VISIBLE 1 -#endif -#ifdef __APPLE__ -#define _BSD_SOURCE -#define _DARWIN_C_SOURCE -#endif -#define IPCP_SHIM_UDP_EXEC "@IPCP_SHIM_UDP_TARGET@" -#define IPCP_SHIM_ETH_LLC_EXEC "@IPCP_SHIM_ETH_LLC_TARGET@" -#define IPCP_NORMAL_EXEC "@IPCP_NORMAL_TARGET@" -#define IPCP_LOCAL_EXEC "@IPCP_LOCAL_TARGET@" -#cmakedefine HAVE_ROBUST_MUTEX -#cmakedefine HAVE_SYS_RANDOM -#cmakedefine HAVE_LIBGCRYPT -#cmakedefine HAVE_OPENSSL -#cmakedefine HAVE_NETMAP -#cmakedefine HAVE_BPF -#define AP_MAX_FLOWS 2048 -#define AP_RES_FDS 64 -#define AP_MAX_FQUEUES 64 -#define SHM_RDRB_BLOCK_SIZE sysconf(_SC_PAGESIZE) -#define SHM_RDRB_MULTI_BLOCK -#define SHM_RDRB_NAME "/ouroboros.rdrb" -#define LOCKFILE_NAME "/ouroboros.lockfile" -#define SHM_BUFFER_SIZE 1 << 14 -#define DU_BUFF_HEADSPACE 128 -#define DU_BUFF_TAILSPACE 0 -#define SHM_RBUFF_LOCKLESS 0 -#define SHM_RBUFF_PREFIX "/ouroboros.rbuff." -#define SHM_FLOW_SET_PREFIX "/ouroboros.sets." -#define IRMD_MAX_FLOWS 4096 -/* IRMD dynamic threadpooling */ -#define IRMD_MIN_THREADS 16 -#define IRMD_ADD_THREADS 32 -/* IPCP dynamic threadpooling */ -#define IPCP_MIN_THREADS 4 -#define IPCP_ADD_THREADS 16 -#define IPCP_SCHED_THREADS 2 -#define IPCPD_MAX_CONNS IRMD_MAX_FLOWS -#ifdef __APPLE__ -#define PTHREAD_COND_CLOCK CLOCK_REALTIME -#else -#define PTHREAD_COND_CLOCK CLOCK_MONOTONIC -#endif -#define PFT_SIZE 1 << 12 -/* Timeout values */ -#define IRMD_ACCEPT_TIMEOUT 100 -#define IRMD_REQ_ARR_TIMEOUT 500 -#define IRMD_FLOW_TIMEOUT 5000 -#define IPCP_ACCEPT_TIMEOUT 100 -#define SOCKET_TIMEOUT 1000 -#define BOOTSTRAP_TIMEOUT 5000 -#define ENROLL_TIMEOUT 60000 -#define REG_TIMEOUT 10000 -#define QUERY_TIMEOUT 3000 -#define CDAP_REPLY_TIMEOUT 1000 - -#endif /* OUROBOROS_CONFIG */ diff --git a/include/ouroboros/endian.h b/include/ouroboros/endian.h index 18df0e99..00c7e043 100644 --- a/include/ouroboros/endian.h +++ b/include/ouroboros/endian.h @@ -24,42 +24,18 @@ #define OUROBOROS_ENDIAN_H #if defined(__linux__) || defined(__CYGWIN__) || \ - (defined(__MACH__) && !defined(__APPLE__)) - -#ifndef _BSD_SOURCE -#define _BSD_SOURCE -#endif -#ifndef __USE_BSD -#define __USE_BSD -#endif -#ifndef _DEFAULT_SOURCE + (defined(__MACH__) && !defined(__APPLE__)) #define _DEFAULT_SOURCE -#endif - #include <endian.h> -#include <features.h> - -#define betoh16(x) be16toh(x) -#define letoh16(x) le16toh(x) -#define betoh32(x) be32toh(x) -#define letoh32(x) le32toh(x) -#define betoh64(x) be64toh(x) -#define letoh64(x) le64toh(x) - -#elif defined(__NetBSD__) || defined(__FreeBSD__) - +#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) #include <sys/endian.h> - -#define betoh16(x) be16toh(x) -#define letoh16(x) le16toh(x) -#define betoh32(x) be32toh(x) -#define letoh32(x) le32toh(x) -#define betoh64(x) be64toh(x) -#define letoh64(x) le64toh(x) - #elif defined(__APPLE__) - #include <libkern/OSByteOrder.h> +#else +#error OS currently not supported +#endif + +#if defined (__APPLE__) #define htobe16(x) OSSwapHostToBigInt16(x) #define htole16(x) OSSwapHostToLittleInt16(x) @@ -76,13 +52,14 @@ #define betoh64(x) OSSwapBigToHostInt64(x) #define letoh64(x) OSSwapLittleToHostInt64(x) -#elif defined(__OpenBSD__) - -#include <sys/endian.h> +#elif !defined(__OpenBSD__) -#else - -#error OS currently not supported +#define betoh16(x) be16toh(x) +#define letoh16(x) le16toh(x) +#define betoh32(x) be32toh(x) +#define letoh32(x) le32toh(x) +#define betoh64(x) be64toh(x) +#define letoh64(x) le64toh(x) #endif diff --git a/include/ouroboros/frct_pci.h b/include/ouroboros/frct_pci.h new file mode 100644 index 00000000..3a93ac1c --- /dev/null +++ b/include/ouroboros/frct_pci.h @@ -0,0 +1,69 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2017 + * + * Protocol Control Information of FRCT + * + * Dimitri Staessens <[email protected]> + * Sander Vrijders <[email protected]> + * + * 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_FRCT_PCI_H +#define OUROBOROS_LIB_FRCT_PCI_H + +#include <ouroboros/shm_du_buff.h> + +#include <stdint.h> +#include <stdbool.h> + +struct frct_pci { + uint8_t type; + uint8_t flags; + uint64_t seqno; + uint64_t lwe; + uint64_t rwe; +}; + +enum pdu_types { + PDU_TYPE_DATA = 0x01, + PDU_TYPE_ACK = 0x02, + PDU_TYPE_FC = 0x04, + PDU_TYPE_ACK_AND_FC = (PDU_TYPE_ACK | PDU_TYPE_FC), + PDU_TYPE_CONFIG = 0x08, + PDU_TYPE_RENDEZ_VOUS = 0x10 +}; + +enum config_flags { + CONF_RESOURCE_CONTROL = 0x01, + CONF_RELIABLE = 0x02, + CONF_ERROR_CHECK = 0x04, + CONF_ORDERED = 0x08, + CONF_PARTIAL = 0x10 +}; + +enum data_flags { + FLAG_DATA_RUN = 0x01, + FLAG_MORE_FRAGMENTS = 0x02 +}; + +int frct_pci_ser(struct shm_du_buff * sdb, + struct frct_pci * pci, + bool error_check); + +int frct_pci_des(struct shm_du_buff * sdb, + struct frct_pci * pci, + bool error_check); + +#endif /* OUROBOROS_LIB_FRCT_PCI_H */ diff --git a/include/ouroboros/hash.h b/include/ouroboros/hash.h index db47c9fe..b2896293 100644 --- a/include/ouroboros/hash.h +++ b/include/ouroboros/hash.h @@ -23,12 +23,15 @@ #ifndef OUROBOROS_LIB_HASH_H #define OUROBOROS_LIB_HASH_H +#include "config.h" + #include <ouroboros/endian.h> #ifdef HAVE_LIBGCRYPT #include <gcrypt.h> #endif #include <stdint.h> +#include <stddef.h> /* Hash algorithms */ enum hash_algo { @@ -58,8 +61,13 @@ enum hash_algo { 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 str_hash(enum hash_algo algo, - void * buf, + void * dst, const char * str); #endif /* OUROBOROS_LIB_HASH_H */ diff --git a/include/ouroboros/shm_flow_set.h b/include/ouroboros/shm_flow_set.h index 5c498336..be2f836b 100644 --- a/include/ouroboros/shm_flow_set.h +++ b/include/ouroboros/shm_flow_set.h @@ -58,6 +58,6 @@ void shm_flow_set_notify(struct shm_flow_set * set, ssize_t shm_flow_set_wait(const struct shm_flow_set * shm_set, size_t idx, int * fqueue, - const struct timespec * timeout); + const struct timespec * abstime); #endif /* OUROBOROS_SHM_FLOW_SET_H */ diff --git a/include/ouroboros/shm_rbuff.h b/include/ouroboros/shm_rbuff.h index 1557e50c..55d03b41 100644 --- a/include/ouroboros/shm_rbuff.h +++ b/include/ouroboros/shm_rbuff.h @@ -50,7 +50,7 @@ int shm_rbuff_write(struct shm_rbuff * rb, ssize_t shm_rbuff_read(struct shm_rbuff * rb); ssize_t shm_rbuff_read_b(struct shm_rbuff * rb, - const struct timespec * timeout); + const struct timespec * abstime); size_t shm_rbuff_queued(struct shm_rbuff * rb); diff --git a/include/ouroboros/timerwheel.h b/include/ouroboros/timerwheel.h new file mode 100644 index 00000000..b0c9ee29 --- /dev/null +++ b/include/ouroboros/timerwheel.h @@ -0,0 +1,47 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2017 + * + * Ring buffer for incoming SDUs + * + * Dimitri Staessens <[email protected]> + * Sander Vrijders <[email protected]> + * + * 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/wrap/CMakeLists.txt b/include/ouroboros/wrap/CMakeLists.txt index eb44ed33..435b3b70 100644 --- a/include/ouroboros/wrap/CMakeLists.txt +++ b/include/ouroboros/wrap/CMakeLists.txt @@ -1,10 +1,9 @@ -find_package(SWIG) - include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CMAKE_BINARY_DIR}/include) +find_package(SWIG) if (NOT SWIG_FOUND) - message(STATUS "SWIG not found: Bindings for other languages disabled.") + message(STATUS "SWIG not found: Bindings for other languages disabled") else () include(${SWIG_USE_FILE}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) @@ -12,7 +11,7 @@ else () find_package(PythonLibs) if (NOT PYTHONLIBS_FOUND) - message(STATUS "Python not found: Python bindings will not be built.") + message(STATUS "Python not found: Python bindings will not be built") else () include_directories(${PYTHON_INCLUDE_PATH}) @@ -55,3 +54,5 @@ else () DESTINATION ${PYTHON_MODULE_PATH}) endif () endif () + +mark_as_advanced(SWIG_EXECUTABLE) |