mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
Added extern "C" wrapper in all headers of libvillas to use it in C++ code
This commit is contained in:
parent
ac77d7eb85
commit
4ec3cf030b
72 changed files with 977 additions and 349 deletions
|
@ -28,6 +28,10 @@
|
|||
|
||||
#include "crypt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
struct advio {
|
||||
CURL *curl;
|
||||
FILE *file;
|
||||
|
@ -81,3 +85,7 @@ void arewind(AFILE *file);
|
|||
int adownload(AFILE *af, int resume);
|
||||
|
||||
int aupload(AFILE *af, int resume);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
|
||||
#include "api/session.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct lws;
|
||||
struct super_node;
|
||||
|
@ -81,3 +85,7 @@ int api_stop(struct api *a);
|
|||
int api_ws_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len);
|
||||
|
||||
int api_http_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -30,6 +30,10 @@
|
|||
#include <villas/queue.h>
|
||||
#include <villas/buffer.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
enum api_version {
|
||||
API_VERSION_UNKOWN = 0,
|
||||
API_VERSION_1 = 1
|
||||
|
@ -70,3 +74,7 @@ int api_session_destroy(struct api_session *s);
|
|||
int api_session_run_command(struct api_session *s, json_t *req, json_t **resp);
|
||||
|
||||
char * api_session_name(struct api_session *s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct bitset {
|
||||
char *set;
|
||||
size_t dimension;
|
||||
|
@ -62,4 +66,8 @@ int bitset_test(struct bitset *b, size_t bit);
|
|||
int bitset_cmp(struct bitset *a, struct bitset *b);
|
||||
|
||||
/** Return an human readable representation of the bit set */
|
||||
char * bitset_dump(struct bitset *b);
|
||||
char *bitset_dump(struct bitset *b);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -29,9 +29,13 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct buffer {
|
||||
enum state state;
|
||||
|
||||
|
||||
char *buf;
|
||||
size_t len;
|
||||
size_t size;
|
||||
|
@ -40,11 +44,15 @@ struct buffer {
|
|||
int buffer_init(struct buffer *b, size_t size);
|
||||
|
||||
int buffer_destroy(struct buffer *b);
|
||||
|
||||
|
||||
void buffer_clear(struct buffer *b);
|
||||
|
||||
int buffer_append(struct buffer *b, const char *data, size_t len);
|
||||
|
||||
int buffer_parse_json(struct buffer *b, json_t **j);
|
||||
|
||||
int buffer_append_json(struct buffer *b, json_t *j);
|
||||
int buffer_append_json(struct buffer *b, json_t *j);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -23,6 +23,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/* Common states for most objects in VILLASnode (paths, nodes, hooks, plugins) */
|
||||
enum state {
|
||||
STATE_DESTROYED = 0,
|
||||
|
@ -36,3 +40,7 @@ enum state {
|
|||
STATE_UNLOADED = 5, /* alias for STATE_STARTED used by struct plugin */
|
||||
STATE_CLOSED = 5 /* alias for STATE_STARTED used by struct io */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -22,13 +22,25 @@
|
|||
|
||||
#include <jansson.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if JANSSON_VERSION_HEX < 0x020A00
|
||||
size_t json_dumpb(const json_t *json, char *buffer, size_t size, size_t flags);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __MACH__
|
||||
#include <libkern/OSByteOrder.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
#define le16toh(x) OSSwapLittleToHostInt16(x)
|
||||
#define le32toh(x) OSSwapLittleToHostInt32(x)
|
||||
#define le64toh(x) OSSwapLittleToHostInt64(x)
|
||||
|
@ -42,4 +54,8 @@ size_t json_dumpb(const json_t *json, char *buffer, size_t size, size_t flags);
|
|||
#define htobe16(x) OSSwapHostToBigInt16(x)
|
||||
#define htobe32(x) OSSwapHostToBigInt32(x)
|
||||
#define htobe64(x) OSSwapHostToBigInt64(x)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __MACH__ */
|
||||
|
|
69
include/villas/config.h
Normal file
69
include/villas/config.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/** Static server configuration
|
||||
*
|
||||
* This file contains some compiled-in settings.
|
||||
* This settings are not part of the configuration file.
|
||||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/* Paths */
|
||||
#define PLUGIN_PATH PREFIX "/share/villas/node/plugins"
|
||||
#define WEB_PATH PREFIX "/share/villas/node/web"
|
||||
#define SYSFS_PATH "/sys"
|
||||
#define PROCFS_PATH "/proc"
|
||||
|
||||
/** Default number of values in a sample */
|
||||
#define DEFAULT_SAMPLELEN 64
|
||||
#define DEFAULT_QUEUELEN 1024
|
||||
|
||||
/** Number of hugepages which are requested from the the kernel.
|
||||
* @see https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt */
|
||||
#define DEFAULT_NR_HUGEPAGES 100
|
||||
|
||||
/** Width of log output in characters */
|
||||
#define LOG_WIDTH 80
|
||||
#define LOG_HEIGHT 25
|
||||
|
||||
/** Socket priority */
|
||||
#define SOCKET_PRIO 7
|
||||
|
||||
/* Protocol numbers */
|
||||
#define IPPROTO_VILLAS 137
|
||||
#define ETH_P_VILLAS 0xBABE
|
||||
|
||||
#define USER_AGENT "VILLASnode (" BUILDID ")"
|
||||
|
||||
/* Required kernel version */
|
||||
#define KERNEL_VERSION_MAJ 3
|
||||
#define KERNEL_VERSION_MIN 6
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -24,8 +24,14 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/* Paths */
|
||||
#define PLUGIN_PATH PREFIX "/share/villas/node/plugins"
|
||||
#define WEB_PATH PREFIX "/share/villas/node/web"
|
||||
|
@ -56,3 +62,8 @@
|
|||
/* Required kernel version */
|
||||
#define KERNEL_VERSION_MAJ 3
|
||||
#define KERNEL_VERSION_MIN 6
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -27,14 +27,18 @@
|
|||
|
||||
#include "sample.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Convert a libconfig object to a jansson object */
|
||||
json_t * config_to_json(config_setting_t *cfg);
|
||||
json_t *config_to_json(config_setting_t *cfg);
|
||||
|
||||
/* Convert a jansson object into a libconfig object. */
|
||||
int json_to_config(json_t *json, config_setting_t *parent);
|
||||
|
||||
/* Create a JSON object from command line parameters. */
|
||||
json_t * json_load_cli(int argc, char *argv[]);
|
||||
json_t *json_load_cli(int argc, char *argv[]);
|
||||
|
||||
int json_object_extend_str(json_t *orig, const char *str);
|
||||
|
||||
|
@ -42,3 +46,7 @@ void json_object_extend_key_value(json_t *obj, const char *key, const char *valu
|
|||
|
||||
/* Merge two JSON objects recursively. */
|
||||
int json_object_extend(json_t *orig, json_t *merge);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -25,9 +25,17 @@
|
|||
#include <stdio.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/** Calculate SHA1 hash of complete file \p f and place it into \p sha1.
|
||||
*
|
||||
* @param sha1[out] Must be SHA_DIGEST_LENGTH (20) in size.
|
||||
* @retval 0 Everything was okay.
|
||||
*/
|
||||
int sha1sum(FILE *f, unsigned char *sha1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -25,6 +25,10 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct sample;
|
||||
struct io;
|
||||
|
@ -104,3 +108,7 @@ struct format_type {
|
|||
};
|
||||
|
||||
struct format_type * format_type_lookup(const char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -25,6 +25,9 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* Forward declarations. */
|
||||
struct sample;
|
||||
|
||||
|
@ -32,3 +35,7 @@ void csv_header(struct io *io);
|
|||
|
||||
int csv_sscan(struct io *io, char *buf, size_t len, size_t *rbytes, struct sample *smps[], unsigned cnt);
|
||||
int csv_sprint(struct io *io, char *buf, size_t len, size_t *rbytes, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
|
||||
#include <jansson.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct sample;
|
||||
struct io;
|
||||
|
@ -33,3 +37,7 @@ int json_reserve_sscan(struct io *io, char *buf, size_t len, size_t *rbytes, str
|
|||
|
||||
int json_reserve_print(struct io *io, struct sample *smps[], unsigned cnt);
|
||||
int json_reserve_scan(struct io *io, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -24,6 +24,10 @@
|
|||
|
||||
#include <jansson.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct sample;
|
||||
|
||||
|
@ -32,3 +36,7 @@ int json_sscan(struct io *io, char *buf, size_t len, size_t *wbytes, struct samp
|
|||
|
||||
int json_print(struct io *io, struct sample *smps[], unsigned cnt);
|
||||
int json_scan(struct io *io, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declaration */
|
||||
struct msg;
|
||||
struct sample;
|
||||
|
@ -53,3 +57,7 @@ int msg_to_sample(struct msg *msg, struct sample *smp);
|
|||
|
||||
/** Copy fields form \p smp into \p msg. */
|
||||
int msg_from_sample(struct msg *msg, struct sample *smp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -25,68 +25,73 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** The current version number for the message format */
|
||||
#define MSG_VERSION 2
|
||||
#define MSG_VERSION 2
|
||||
|
||||
/** @todo Implement more message types */
|
||||
#define MSG_TYPE_DATA 0 /**< Message contains float / integer values */
|
||||
#define MSG_TYPE_START 1 /**< Message marks the beginning of a new simulation case */
|
||||
#define MSG_TYPE_STOP 2 /**< Message marks the end of a simulation case */
|
||||
#define MSG_TYPE_DATA 0 /**< Message contains float / integer values */
|
||||
#define MSG_TYPE_START 1 /**< Message marks the beginning of a new simulation case */
|
||||
#define MSG_TYPE_STOP 2 /**< Message marks the end of a simulation case */
|
||||
|
||||
/** The total size in bytes of a message */
|
||||
#define MSG_LEN(values) (sizeof(struct msg) + MSG_DATA_LEN(values))
|
||||
#define MSG_LEN(values) (sizeof(struct msg) + MSG_DATA_LEN(values))
|
||||
|
||||
/** The length of \p values values in bytes. */
|
||||
#define MSG_DATA_LEN(values) (sizeof(float) * (values))
|
||||
#define MSG_DATA_LEN(values) (sizeof(float) * (values))
|
||||
|
||||
/** The offset to the first data value in a message. */
|
||||
#define MSG_DATA_OFFSET(msg) ((char *) (msg) + offsetof(struct msg, data))
|
||||
#define MSG_DATA_OFFSET(msg) ((char *) (msg) + offsetof(struct msg, data))
|
||||
|
||||
/** Initialize a message with default values */
|
||||
#define MSG_INIT(len, seq) (struct msg) {\
|
||||
.version = MSG_VERSION, \
|
||||
.type = MSG_TYPE_DATA, \
|
||||
.length = len, \
|
||||
.sequence = seq, \
|
||||
.version = MSG_VERSION, \
|
||||
.type = MSG_TYPE_DATA, \
|
||||
.length = len, \
|
||||
.sequence = seq, \
|
||||
}
|
||||
|
||||
/** The timestamp of a message in struct timespec format */
|
||||
#define MSG_TS(msg) (struct timespec) { \
|
||||
.tv_sec = (msg)->ts.sec, \
|
||||
.tv_nsec = (msg)->ts.nsec \
|
||||
#define MSG_TS(msg) (struct timespec) { \
|
||||
.tv_sec = (msg)->ts.sec, \
|
||||
.tv_nsec = (msg)->ts.nsec \
|
||||
}
|
||||
|
||||
/** This message format is used by all clients
|
||||
*
|
||||
* @diafile msg_format.dia
|
||||
**/
|
||||
struct msg
|
||||
{
|
||||
struct msg {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
unsigned version: 4; /**< Specifies the format of the remaining message (see MGS_VERSION) */
|
||||
unsigned type : 2; /**< Data or control message (see MSG_TYPE_*) */
|
||||
unsigned rsvd1 : 2; /**< Reserved bits */
|
||||
unsigned version: 4; /**< Specifies the format of the remaining message (see MGS_VERSION) */
|
||||
unsigned type : 2; /**< Data or control message (see MSG_TYPE_*) */
|
||||
unsigned rsvd1 : 2; /**< Reserved bits */
|
||||
#elif BYTE_ORDER == LITTLE_ENDIAN
|
||||
unsigned rsvd1 : 2; /**< Reserved bits */
|
||||
unsigned type : 2; /**< Data or control message (see MSG_TYPE_*) */
|
||||
unsigned version: 4; /**< Specifies the format of the remaining message (see MGS_VERSION) */
|
||||
#else
|
||||
#error Invalid byte-order
|
||||
unsigned rsvd1 : 2; /**< Reserved bits */
|
||||
unsigned type : 2; /**< Data or control message (see MSG_TYPE_*) */
|
||||
unsigned version: 4; /**< Specifies the format of the remaining message (see MGS_VERSION) */
|
||||
#endif
|
||||
|
||||
uint8_t resv2; /**< An id which identifies the source of this sample. */
|
||||
uint16_t length; /**< The number of values in msg::data[]. */
|
||||
uint32_t sequence; /**< The sequence number is incremented by one for consecutive messages. */
|
||||
uint8_t resv2; /**< An id which identifies the source of this sample. */
|
||||
uint16_t length; /**< The number of values in msg::data[]. */
|
||||
uint32_t sequence; /**< The sequence number is incremented by one for consecutive messages. */
|
||||
|
||||
/** A timestamp per message. */
|
||||
struct {
|
||||
uint32_t sec; /**< Seconds since 1970-01-01 00:00:00 */
|
||||
uint32_t nsec; /**< Nanoseconds of the current second. */
|
||||
uint32_t sec; /**< Seconds since 1970-01-01 00:00:00 */
|
||||
uint32_t nsec; /**< Nanoseconds of the current second. */
|
||||
} ts;
|
||||
|
||||
/** The message payload. */
|
||||
union {
|
||||
float f; /**< Floating point values. */
|
||||
uint32_t i; /**< Integer values. */
|
||||
float f; /**< Floating point values. */
|
||||
uint32_t i; /**< Integer values. */
|
||||
} data[];
|
||||
} __attribute__((packed));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -25,6 +25,10 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct sample;
|
||||
|
||||
|
@ -33,3 +37,7 @@ int protobuf_sprint(struct io *io, char *buf, size_t len, size_t *wbytes, struct
|
|||
|
||||
/** Read struct sample's from buffer \p buf into samples \p smps. */
|
||||
int protobuf_sscan(struct io *io, char *buf, size_t len, size_t *rbytes, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -25,32 +25,36 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct sample;
|
||||
|
||||
enum raw_flags {
|
||||
RAW_FAKE = (1 << 16), /**< Treat the first three values as: sequenceno, seconds, nanoseconds */
|
||||
RAW_FAKE = (1 << 16), /**< Treat the first three values as: sequenceno, seconds, nanoseconds */
|
||||
|
||||
RAW_BE_INT = (1 << 17), /**< Byte-order for integer data: big-endian if set. */
|
||||
RAW_BE_FLT = (1 << 18), /**< Byte-order for floating point data: big-endian if set. */
|
||||
RAW_BE_HDR = (1 << 19), /**< Byte-order for fake header fields: big-endian if set. */
|
||||
RAW_BE_INT = (1 << 17), /**< Byte-order for integer data: big-endian if set. */
|
||||
RAW_BE_FLT = (1 << 18), /**< Byte-order for floating point data: big-endian if set. */
|
||||
RAW_BE_HDR = (1 << 19), /**< Byte-order for fake header fields: big-endian if set. */
|
||||
|
||||
/** Byte-order for all fields: big-endian if set. */
|
||||
RAW_BE = RAW_BE_INT | RAW_BE_FLT | RAW_BE_HDR,
|
||||
RAW_BE = RAW_BE_INT | RAW_BE_FLT | RAW_BE_HDR,
|
||||
|
||||
/** Mix floating and integer types.
|
||||
*
|
||||
* io_raw_sscan() parses all values as single / double precission fp.
|
||||
* io_raw_sprint() uses sample::format to determine the type.
|
||||
*/
|
||||
RAW_AUTO = (1 << 22),
|
||||
RAW_FLT = (1 << 23), /**< Data-type: floating point otherwise integer. */
|
||||
RAW_AUTO = (1 << 22),
|
||||
RAW_FLT = (1 << 23), /**< Data-type: floating point otherwise integer. */
|
||||
|
||||
//RAW_1 = (0 << 24), /**< Pack each value as a single bit. */
|
||||
RAW_8 = (3 << 24), /**< Pack each value as a byte. */
|
||||
RAW_16 = (4 << 24), /**< Pack each value as a word. */
|
||||
RAW_32 = (5 << 24), /**< Pack each value as a double word. */
|
||||
RAW_64 = (6 << 24) /**< Pack each value as a quad word. */
|
||||
RAW_8 = (3 << 24), /**< Pack each value as a byte. */
|
||||
RAW_16 = (4 << 24), /**< Pack each value as a word. */
|
||||
RAW_32 = (5 << 24), /**< Pack each value as a double word. */
|
||||
RAW_64 = (6 << 24) /**< Pack each value as a quad word. */
|
||||
};
|
||||
|
||||
/** Copy / read struct msg's from buffer \p buf to / fram samples \p smps. */
|
||||
|
@ -58,3 +62,6 @@ int raw_sprint(struct io *io, char *buf, size_t len, size_t *wbytes, struct samp
|
|||
|
||||
/** Read struct sample's from buffer \p buf into samples \p smps. */
|
||||
int raw_sscan(struct io *io, char *buf, size_t len, size_t *rbytes, struct sample *smps[], unsigned cnt);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -25,17 +25,26 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations. */
|
||||
struct sample;
|
||||
struct msg;
|
||||
struct io;
|
||||
|
||||
enum villas_binary_flags {
|
||||
VILLAS_BINARY_WEB = (1 << 16) /**< Use webmsg format (everying little endian) */
|
||||
VILLAS_BINARY_WEB = (1 << 16) /**< Use webmsg format (everying little endian) */
|
||||
};
|
||||
|
||||
/** Copy / read struct msg's from buffer \p buf to / fram samples \p smps. */
|
||||
int villas_binary_sprint(struct io *io, char *buf, size_t len, size_t *wbytes, struct sample *smps[], unsigned cnt);
|
||||
int
|
||||
villas_binary_sprint(struct io *io, char *buf, size_t len, size_t *wbytes, struct sample *smps[], unsigned cnt);
|
||||
|
||||
/** Read struct sample's from buffer \p buf into samples \p smps. */
|
||||
int villas_binary_sscan(struct io *io, char *buf, size_t len, size_t *rbytes, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct io;
|
||||
struct sample;
|
||||
|
@ -33,3 +37,7 @@ void villas_human_header(struct io *io);
|
|||
|
||||
int villas_human_print(struct io *io, struct sample *smps[], unsigned cnt);
|
||||
int villas_human_scan(struct io *io, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -28,39 +28,43 @@
|
|||
|
||||
#include <jansson.h>
|
||||
|
||||
#define HIST_HEIGHT (LOG_WIDTH - 55)
|
||||
#define HIST_SEQ 17
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define HIST_HEIGHT (LOG_WIDTH - 55)
|
||||
#define HIST_SEQ 17
|
||||
|
||||
typedef uintmax_t hist_cnt_t;
|
||||
|
||||
/** Histogram structure used to collect statistics. */
|
||||
struct hist {
|
||||
double resolution; /**< The distance between two adjacent buckets. */
|
||||
double resolution; /**< The distance between two adjacent buckets. */
|
||||
|
||||
double high; /**< The value of the highest bucket. */
|
||||
double low; /**< The value of the lowest bucket. */
|
||||
double high; /**< The value of the highest bucket. */
|
||||
double low; /**< The value of the lowest bucket. */
|
||||
|
||||
double highest; /**< The highest value observed (may be higher than #high). */
|
||||
double lowest; /**< The lowest value observed (may be lower than #low). */
|
||||
double last; /**< The last value which has been put into the buckets */
|
||||
double highest; /**< The highest value observed (may be higher than #high). */
|
||||
double lowest; /**< The lowest value observed (may be lower than #low). */
|
||||
double last; /**< The last value which has been put into the buckets */
|
||||
|
||||
int length; /**< The number of buckets in #data. */
|
||||
int length; /**< The number of buckets in #data. */
|
||||
|
||||
hist_cnt_t total; /**< Total number of counted values. */
|
||||
hist_cnt_t warmup; /**< Number of values which are used during warmup phase. */
|
||||
hist_cnt_t total; /**< Total number of counted values. */
|
||||
hist_cnt_t warmup; /**< Number of values which are used during warmup phase. */
|
||||
|
||||
hist_cnt_t higher; /**< The number of values which are higher than #high. */
|
||||
hist_cnt_t lower; /**< The number of values which are lower than #low. */
|
||||
hist_cnt_t higher; /**< The number of values which are higher than #high. */
|
||||
hist_cnt_t lower; /**< The number of values which are lower than #low. */
|
||||
|
||||
hist_cnt_t *data; /**< Pointer to dynamically allocated array of size length. */
|
||||
hist_cnt_t *data; /**< Pointer to dynamically allocated array of size length. */
|
||||
|
||||
double _m[2], _s[2]; /**< Private variables for online variance calculation */
|
||||
double _m[2], _s[2]; /**< Private variables for online variance calculation */
|
||||
};
|
||||
|
||||
#define hist_last(h) ((h)->last)
|
||||
#define hist_highest(h) ((h)->highest)
|
||||
#define hist_lowest(h) ((h)->lowest)
|
||||
#define hist_total(h) ((h)->total)
|
||||
#define hist_last(h) ((h)->last)
|
||||
#define hist_highest(h) ((h)->highest)
|
||||
#define hist_lowest(h) ((h)->lowest)
|
||||
#define hist_total(h) ((h)->total)
|
||||
|
||||
/** Initialize struct hist with supplied values and allocate memory for buckets. */
|
||||
int hist_init(struct hist *h, int buckets, hist_cnt_t warmup);
|
||||
|
@ -93,7 +97,7 @@ void hist_plot(struct hist *h);
|
|||
*
|
||||
* @return The string containing the dump. The caller is responsible to free() the buffer.
|
||||
*/
|
||||
char * hist_dump(struct hist *h);
|
||||
char *hist_dump(struct hist *h);
|
||||
|
||||
/** Prints Matlab struct containing all infos to file. */
|
||||
int hist_dump_matlab(struct hist *h, FILE *f);
|
||||
|
@ -102,4 +106,8 @@ int hist_dump_matlab(struct hist *h, FILE *f);
|
|||
int hist_dump_json(struct hist *h, FILE *f);
|
||||
|
||||
/** Build a libjansson / JSON object of the histogram. */
|
||||
json_t * hist_json(struct hist *h);
|
||||
json_t *hist_json(struct hist *h);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -37,6 +37,10 @@
|
|||
#include "hook_type.h"
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct path;
|
||||
struct sample;
|
||||
|
@ -44,17 +48,17 @@ struct list;
|
|||
|
||||
/** Descriptor for user defined hooks. See hooks[]. */
|
||||
struct hook {
|
||||
enum state state;
|
||||
enum state state;
|
||||
|
||||
struct path *path;
|
||||
struct node *node;
|
||||
struct path *path;
|
||||
struct node *node;
|
||||
|
||||
struct hook_type *_vt; /**< C++ like Vtable pointer. */
|
||||
void *_vd; /**< Private data for this hook. This pointer can be used to pass data between consecutive calls of the callback. */
|
||||
struct hook_type *_vt; /**< C++ like Vtable pointer. */
|
||||
void *_vd; /**< Private data for this hook. This pointer can be used to pass data between consecutive calls of the callback. */
|
||||
|
||||
int priority; /**< A priority to change the order of execution within one type of hook. */
|
||||
int priority; /**< A priority to change the order of execution within one type of hook. */
|
||||
|
||||
json_t *cfg; /**< A JSON object containing the configuration of the hook. */
|
||||
json_t *cfg; /**< A JSON object containing the configuration of the hook. */
|
||||
};
|
||||
|
||||
int hook_init(struct hook *h, struct hook_type *vt, struct path *p, struct node *n);
|
||||
|
@ -96,3 +100,7 @@ int hook_cmp_priority(const void *a, const void *b);
|
|||
* }
|
||||
*/
|
||||
int hook_parse_list(struct list *list, json_t *cfg, struct path *p, struct node *n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -39,6 +39,10 @@
|
|||
|
||||
#include <jansson.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct hook;
|
||||
struct sample;
|
||||
|
@ -74,3 +78,6 @@ struct hook_type {
|
|||
|
||||
struct hook_type * hook_type_lookup(const char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -27,21 +27,25 @@
|
|||
#include "common.h"
|
||||
#include "node.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct sample;
|
||||
struct format_type;
|
||||
|
||||
enum io_flags {
|
||||
IO_FLUSH = (1 << 8), /**< Flush the output stream after each chunk of samples. */
|
||||
IO_NONBLOCK = (1 << 9), /**< Dont block io_read() while waiting for new samples. */
|
||||
IO_NEWLINES = (1 << 10) /**< The samples of this format are newline delimited. */
|
||||
IO_FLUSH = (1 << 8), /**< Flush the output stream after each chunk of samples. */
|
||||
IO_NONBLOCK = (1 << 9), /**< Dont block io_read() while waiting for new samples. */
|
||||
IO_NEWLINES = (1 << 10) /**< The samples of this format are newline delimited. */
|
||||
};
|
||||
|
||||
struct io {
|
||||
enum state state;
|
||||
int flags;
|
||||
char delimiter; /**< Newline delimiter. */
|
||||
char separator; /**< Column separator (used by csv and villas.human formats only) */
|
||||
char delimiter; /**< Newline delimiter. */
|
||||
char separator; /**< Column separator (used by csv and villas.human formats only) */
|
||||
|
||||
struct {
|
||||
/** A format type can use this file handle or overwrite the
|
||||
|
@ -106,8 +110,8 @@ int io_stream_fd(struct io *io);
|
|||
|
||||
int io_stream_flush(struct io *io);
|
||||
|
||||
FILE * io_stream_input(struct io *io);
|
||||
FILE * io_stream_output(struct io *io);
|
||||
FILE *io_stream_input(struct io *io);
|
||||
FILE *io_stream_output(struct io *io);
|
||||
|
||||
/** Parse samples from the buffer \p buf with a length of \p len bytes.
|
||||
*
|
||||
|
@ -134,3 +138,7 @@ int io_sscan(struct io *io, char *buf, size_t len, size_t *rbytes, struct sample
|
|||
* @retval <0 Something went wrong.
|
||||
*/
|
||||
int io_sprint(struct io *io, char *buf, size_t len, size_t *wbytes, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
|
||||
#include <villas/list.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
#define IF_IRQ_MAX 3 /**< Maxmimal number of IRQs of an interface */
|
||||
|
||||
#ifndef SO_MARK
|
||||
|
@ -121,4 +125,8 @@ int if_get_irqs(struct interface *i);
|
|||
*/
|
||||
int if_set_affinity(struct interface *i, int affinity);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/** @} */
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct version;
|
||||
|
||||
|
@ -85,6 +89,10 @@ int kernel_get_page_size();
|
|||
int kernel_get_hugepage_size();
|
||||
|
||||
/** Set SMP affinity of IRQ */
|
||||
int kernel_irq_setaffinity(unsigned irq, uintmax_t new, uintmax_t *old);
|
||||
int kernel_irq_setaffinity(unsigned irq, uintmax_t new , uintmax_t *old ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -1,45 +1,48 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SCH_NETEM_ATTR_DIST 0x2000
|
||||
|
||||
struct rtnl_netem_corr
|
||||
{
|
||||
uint32_t nmc_delay;
|
||||
uint32_t nmc_loss;
|
||||
uint32_t nmc_duplicate;
|
||||
struct rtnl_netem_corr {
|
||||
uint32_t nmc_delay;
|
||||
uint32_t nmc_loss;
|
||||
uint32_t nmc_duplicate;
|
||||
};
|
||||
|
||||
struct rtnl_netem_reo
|
||||
{
|
||||
uint32_t nmro_probability;
|
||||
uint32_t nmro_correlation;
|
||||
struct rtnl_netem_reo {
|
||||
uint32_t nmro_probability;
|
||||
uint32_t nmro_correlation;
|
||||
};
|
||||
|
||||
struct rtnl_netem_crpt
|
||||
{
|
||||
uint32_t nmcr_probability;
|
||||
uint32_t nmcr_correlation;
|
||||
struct rtnl_netem_crpt {
|
||||
uint32_t nmcr_probability;
|
||||
uint32_t nmcr_correlation;
|
||||
};
|
||||
|
||||
struct rtnl_netem_dist
|
||||
{
|
||||
int16_t * dist_data;
|
||||
size_t dist_size;
|
||||
struct rtnl_netem_dist {
|
||||
int16_t *dist_data;
|
||||
size_t dist_size;
|
||||
};
|
||||
|
||||
struct rtnl_netem
|
||||
{
|
||||
uint32_t qnm_latency;
|
||||
uint32_t qnm_limit;
|
||||
uint32_t qnm_loss;
|
||||
uint32_t qnm_gap;
|
||||
uint32_t qnm_duplicate;
|
||||
uint32_t qnm_jitter;
|
||||
uint32_t qnm_mask;
|
||||
struct rtnl_netem_corr qnm_corr;
|
||||
struct rtnl_netem_reo qnm_ro;
|
||||
struct rtnl_netem_crpt qnm_crpt;
|
||||
struct rtnl_netem_dist qnm_dist;
|
||||
struct rtnl_netem {
|
||||
uint32_t qnm_latency;
|
||||
uint32_t qnm_limit;
|
||||
uint32_t qnm_loss;
|
||||
uint32_t qnm_gap;
|
||||
uint32_t qnm_duplicate;
|
||||
uint32_t qnm_jitter;
|
||||
uint32_t qnm_mask;
|
||||
struct rtnl_netem_corr qnm_corr;
|
||||
struct rtnl_netem_reo qnm_ro;
|
||||
struct rtnl_netem_crpt qnm_crpt;
|
||||
struct rtnl_netem_dist qnm_dist;
|
||||
};
|
||||
|
||||
void *rtnl_tc_data(struct rtnl_tc *tc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
#include <netlink/route/route.h>
|
||||
#include <netlink/route/link.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Get index of outgoing interface for given destination address.
|
||||
*
|
||||
* @retval >=0 Interface index of outgoing interface.
|
||||
|
@ -37,9 +41,13 @@
|
|||
int nl_get_egress(struct nl_addr *addr);
|
||||
|
||||
/** Get or create global netlink socket. */
|
||||
struct nl_sock * nl_init();
|
||||
struct nl_sock *nl_init();
|
||||
|
||||
/** Close and free global netlink socket. */
|
||||
void nl_shutdown();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int rt_init(int priority, int affinity);
|
||||
|
||||
int rt_set_affinity(int affinity);
|
||||
|
@ -43,4 +47,8 @@ int rt_lock_memory();
|
|||
*/
|
||||
int rt_is_preemptible();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -37,6 +37,10 @@
|
|||
|
||||
#include <jansson.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
typedef uint32_t tc_hdl_t;
|
||||
|
||||
struct interface;
|
||||
|
@ -72,4 +76,8 @@ int tc_prio(struct interface *i, struct rtnl_qdisc **qd, tc_hdl_t handle, tc_hdl
|
|||
*/
|
||||
int tc_mark(struct interface *i, struct rtnl_cls **cls, tc_hdl_t flowid, uint32_t mark);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -37,6 +37,10 @@
|
|||
|
||||
#include <jansson.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
typedef uint32_t tc_hdl_t;
|
||||
|
||||
struct interface;
|
||||
|
@ -70,4 +74,8 @@ int tc_netem(struct interface *i, struct rtnl_qdisc **qd, tc_hdl_t handle, tc_hd
|
|||
|
||||
int tc_netem_set_delay_distribution(struct rtnl_qdisc *qdisc, json_t *json);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
#define LIST_CHUNKSIZE 16
|
||||
|
||||
/** Static list initialization */
|
||||
|
@ -120,3 +124,7 @@ int list_set(struct list *l, int index, void *value);
|
|||
* @retval >=0 Entry \p value was found at returned index.
|
||||
*/
|
||||
ssize_t list_index(struct list *l, void *value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -29,9 +29,18 @@ struct log;
|
|||
|
||||
#include "log.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/** Parse logging configuration. */
|
||||
int log_parse(struct log *l, json_t *cfg);
|
||||
|
||||
/** Print configuration error and exit. */
|
||||
void jerror(json_error_t *err, const char *fmt, ...)
|
||||
__attribute__ ((format(printf, 2, 3)));
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -29,6 +29,10 @@
|
|||
#include "common.h"
|
||||
#include "list.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct stats;
|
||||
struct node;
|
||||
|
@ -38,8 +42,8 @@ struct list;
|
|||
struct mapping_entry {
|
||||
struct node *node;
|
||||
|
||||
int offset; /**< Offset of this mapping entry within sample::data */
|
||||
int length; /**< The number of values which is covered by this mapping entry. */
|
||||
int offset; /**< Offset of this mapping entry within sample::data */
|
||||
int length; /**< The number of values which is covered by this mapping entry. */
|
||||
|
||||
enum {
|
||||
MAPPING_TYPE_DATA,
|
||||
|
@ -84,12 +88,17 @@ struct mapping_entry {
|
|||
};
|
||||
};
|
||||
|
||||
int mapping_remap(struct list *m, struct sample *remapped, struct sample *original, struct stats *s);
|
||||
int
|
||||
mapping_remap(struct list *m, struct sample *remapped, struct sample *original, struct stats *s);
|
||||
|
||||
int mapping_update(struct mapping_entry *e, struct sample *remapped, struct sample *new, struct stats *s);
|
||||
int mapping_update(struct mapping_entry *e, struct sample *remapped, struct sample * new , struct stats *s ) ;
|
||||
|
||||
int mapping_parse(struct mapping_entry *e, json_t *cfg, struct list *nodes);
|
||||
|
||||
int mapping_parse_str(struct mapping_entry *e, const char *str, struct list *nodes);
|
||||
|
||||
int mapping_parse_list(struct list *l, json_t *cfg, struct list *nodes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -26,7 +26,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define HUGEPAGESIZE (1 << 21)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define HUGEPAGESIZE (1 << 21)
|
||||
|
||||
struct memtype;
|
||||
|
||||
|
@ -34,10 +38,10 @@ typedef void *(*memzone_allocator_t)(struct memtype *mem, size_t len, size_t ali
|
|||
typedef int (*memzone_deallocator_t)(struct memtype *mem, void *ptr, size_t len);
|
||||
|
||||
enum memtype_flags {
|
||||
MEMORY_MMAP = (1 << 0),
|
||||
MEMORY_DMA = (1 << 1),
|
||||
MEMORY_HUGEPAGE = (1 << 2),
|
||||
MEMORY_HEAP = (1 << 3)
|
||||
MEMORY_MMAP = (1 << 0),
|
||||
MEMORY_DMA = (1 << 1),
|
||||
MEMORY_HUGEPAGE = (1 << 2),
|
||||
MEMORY_HEAP = (1 << 3)
|
||||
};
|
||||
|
||||
struct memtype {
|
||||
|
@ -59,15 +63,15 @@ enum memblock_flags {
|
|||
/** Descriptor of a memory block. Associated block always starts at
|
||||
* &m + sizeof(struct memblock). */
|
||||
struct memblock {
|
||||
struct memblock* prev;
|
||||
struct memblock* next;
|
||||
struct memblock *prev;
|
||||
struct memblock *next;
|
||||
size_t len; /**<Length of the block; doesn't include the descriptor itself */
|
||||
int flags;
|
||||
};
|
||||
|
||||
/** @todo Unused for now */
|
||||
struct memzone {
|
||||
struct memtype * const type;
|
||||
struct memtype *const type;
|
||||
|
||||
void *addr;
|
||||
uintptr_t physaddr;
|
||||
|
@ -82,13 +86,17 @@ int memory_init(int hugepages);
|
|||
* @retval NULL If allocation failed.
|
||||
* @retval <>0 If allocation was successful.
|
||||
*/
|
||||
void * memory_alloc(struct memtype *m, size_t len);
|
||||
void *memory_alloc(struct memtype *m, size_t len);
|
||||
|
||||
void * memory_alloc_aligned(struct memtype *m, size_t len, size_t alignment);
|
||||
void *memory_alloc_aligned(struct memtype *m, size_t len, size_t alignment);
|
||||
|
||||
int memory_free(struct memtype *m, void *ptr, size_t len);
|
||||
|
||||
struct memtype * memtype_managed_init(void *ptr, size_t len);
|
||||
struct memtype *memtype_managed_init(void *ptr, size_t len);
|
||||
|
||||
extern struct memtype memtype_heap;
|
||||
extern struct memtype memtype_hugepage;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
@ -38,6 +39,10 @@
|
|||
#include "queue.h"
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
struct node_direction {
|
||||
int enabled;
|
||||
int builtin; /**< This node should use built-in hooks by default. */
|
||||
|
@ -158,4 +163,8 @@ int node_write(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
|
||||
int node_fd(struct node *n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
* @{
|
||||
*********************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jansson.h>
|
||||
|
@ -168,4 +172,8 @@ const char * node_type_name(struct node_type *vt);
|
|||
|
||||
struct node_type * node_type_lookup(const char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,6 +35,10 @@
|
|||
#include <villas/list.h>
|
||||
#include <villas/io.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct format_type;
|
||||
|
||||
|
@ -64,7 +68,7 @@ struct amqp {
|
|||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * amqp_print(struct node *n);
|
||||
char *amqp_print(struct node *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int amqp_parse(struct node *n, json_t *json);
|
||||
|
@ -81,4 +85,8 @@ int amqp_read(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
/** @see node_type::write */
|
||||
int amqp_write(struct node *n, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
|
||||
#include <villas/list.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/* Forward declaration */
|
||||
struct cbuilder;
|
||||
|
||||
|
@ -65,4 +69,8 @@ struct cbuilder {
|
|||
int eventfd; /**< Eventfd for synchronizing cbuilder_read() / cbuilder_write() access. */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,6 +35,10 @@
|
|||
#include <villas/list.h>
|
||||
#include <villas/timing.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// whether to use read() or mmap() kernel interface
|
||||
#define COMEDI_USE_READ (1)
|
||||
//#define COMEDI_USE_READ (0)
|
||||
|
@ -45,23 +49,23 @@ struct comedi_chanspec {
|
|||
};
|
||||
|
||||
struct comedi_direction {
|
||||
int subdevice; ///< Comedi subdevice
|
||||
int buffer_size; ///< Comedi's kernel buffer size in kB
|
||||
int sample_size; ///< Size of a single measurement sample
|
||||
int sample_rate_hz; ///< Sample rate in Hz
|
||||
bool present; ///< Config present
|
||||
bool enabled; ///< Card is started successfully
|
||||
bool running; ///< Card is actively transfering samples
|
||||
struct timespec started; ///< Timestamp when sampling started
|
||||
struct timespec last_debug; ///< Timestamp of last debug output
|
||||
size_t counter; ///< Number of villas samples transfered
|
||||
struct comedi_chanspec *chanspecs; ///< Range and maxdata config of channels
|
||||
unsigned *chanlist; ///< Channel list in comedi's packed format
|
||||
size_t chanlist_len; ///< Number of channels for this direction
|
||||
int subdevice; ///< Comedi subdevice
|
||||
int buffer_size; ///< Comedi's kernel buffer size in kB
|
||||
int sample_size; ///< Size of a single measurement sample
|
||||
int sample_rate_hz; ///< Sample rate in Hz
|
||||
bool present; ///< Config present
|
||||
bool enabled; ///< Card is started successfully
|
||||
bool running; ///< Card is actively transfering samples
|
||||
struct timespec started; ///< Timestamp when sampling started
|
||||
struct timespec last_debug; ///< Timestamp of last debug output
|
||||
size_t counter; ///< Number of villas samples transfered
|
||||
struct comedi_chanspec *chanspecs; ///< Range and maxdata config of channels
|
||||
unsigned *chanlist; ///< Channel list in comedi's packed format
|
||||
size_t chanlist_len; ///< Number of channels for this direction
|
||||
|
||||
|
||||
char* buffer;
|
||||
char* bufptr;
|
||||
char *buffer;
|
||||
char *bufptr;
|
||||
};
|
||||
|
||||
struct comedi {
|
||||
|
@ -70,19 +74,19 @@ struct comedi {
|
|||
comedi_t *dev;
|
||||
|
||||
#if COMEDI_USE_READ
|
||||
char* buf;
|
||||
char* bufptr;
|
||||
char *buf;
|
||||
char *bufptr;
|
||||
#else
|
||||
char *map;
|
||||
size_t bufpos;
|
||||
size_t front;
|
||||
size_t back;
|
||||
char *map;
|
||||
size_t bufpos;
|
||||
size_t front;
|
||||
size_t back;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * comedi_print(struct node *n);
|
||||
char *comedi_print(struct node *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int comedi_parse(struct node *n, json_t *cfg);
|
||||
|
@ -99,4 +103,8 @@ int comedi_read(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
/** @see node_type::write */
|
||||
int comedi_write(struct node *n, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -33,19 +33,23 @@
|
|||
#include <villas/node.h>
|
||||
#include <villas/task.h>
|
||||
|
||||
#define FILE_MAX_PATHLEN 512
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FILE_MAX_PATHLEN 512
|
||||
|
||||
struct file {
|
||||
struct io io; /**< Format and file IO */
|
||||
struct io io; /**< Format and file IO */
|
||||
struct format_type *format;
|
||||
|
||||
char *uri_tmpl; /**< Format string for file name. */
|
||||
char *uri; /**< Real file name. */
|
||||
char *mode; /**< File access mode. */
|
||||
char *uri_tmpl; /**< Format string for file name. */
|
||||
char *uri; /**< Real file name. */
|
||||
char *mode; /**< File access mode. */
|
||||
|
||||
int flush; /**< Flush / upload file contents after each write. */
|
||||
struct task task; /**< Timer file descriptor. Blocks until 1 / rate seconds are elapsed. */
|
||||
double rate; /**< The read rate. */
|
||||
int flush; /**< Flush / upload file contents after each write. */
|
||||
struct task task; /**< Timer file descriptor. Blocks until 1 / rate seconds are elapsed. */
|
||||
double rate; /**< The read rate. */
|
||||
|
||||
enum epoch_mode {
|
||||
FILE_EPOCH_DIRECT,
|
||||
|
@ -53,21 +57,21 @@ struct file {
|
|||
FILE_EPOCH_RELATIVE,
|
||||
FILE_EPOCH_ABSOLUTE,
|
||||
FILE_EPOCH_ORIGINAL
|
||||
} epoch_mode; /**< Specifies how file::offset is calculated. */
|
||||
} epoch_mode; /**< Specifies how file::offset is calculated. */
|
||||
|
||||
enum {
|
||||
FILE_EOF_EXIT, /**< Terminate when EOF is reached. */
|
||||
FILE_EOF_REWIND, /**< Rewind the file when EOF is reached. */
|
||||
FILE_EOF_WAIT /**< Blocking wait when EOF is reached. */
|
||||
FILE_EOF_EXIT, /**< Terminate when EOF is reached. */
|
||||
FILE_EOF_REWIND, /**< Rewind the file when EOF is reached. */
|
||||
FILE_EOF_WAIT /**< Blocking wait when EOF is reached. */
|
||||
} eof;
|
||||
|
||||
struct timespec first; /**< The first timestamp in the file file::{read,write}::uri */
|
||||
struct timespec epoch; /**< The epoch timestamp from the configuration. */
|
||||
struct timespec offset; /**< An offset between the timestamp in the input file and the current time */
|
||||
struct timespec first; /**< The first timestamp in the file file::{read,write}::uri */
|
||||
struct timespec epoch; /**< The epoch timestamp from the configuration. */
|
||||
struct timespec offset; /**< An offset between the timestamp in the input file and the current time */
|
||||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * file_print(struct node *n);
|
||||
char *file_print(struct node *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int file_parse(struct node *n, json_t *cfg);
|
||||
|
@ -84,4 +88,7 @@ int file_read(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
/** @see node_type::write */
|
||||
int file_write(struct node *n, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/** @} */
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
#include <villas/node.h>
|
||||
#include <villas/list.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
enum iec61850_type {
|
||||
/* According to IEC 61850-7-2 */
|
||||
IEC61850_TYPE_BOOLEAN,
|
||||
|
@ -107,4 +111,8 @@ int iec61850_receiver_stop(struct iec61850_receiver *r);
|
|||
|
||||
int iec61850_receiver_destroy(struct iec61850_receiver *r);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -40,6 +40,10 @@
|
|||
#include <villas/list.h>
|
||||
#include <villas/nodes/iec61850.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
struct iec61850_sv {
|
||||
char *interface;
|
||||
int app_id;
|
||||
|
@ -97,4 +101,8 @@ int iec61850_sv_write(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
|
||||
int iec61850_sv_fd(struct node *n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
|
||||
#include <villas/list.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct node;
|
||||
struct sample;
|
||||
|
@ -49,7 +53,7 @@ struct influxdb {
|
|||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * influxdb_print(struct node *n);
|
||||
char *influxdb_print(struct node *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int influxdb_parse(struct node *n, json_t *cfg);
|
||||
|
@ -63,4 +67,8 @@ int influxdb_close(struct node *n);
|
|||
/** @see node_type::write */
|
||||
int influxdb_write(struct node *n, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -32,6 +32,10 @@
|
|||
#include <villas/queue_signalled.h>
|
||||
#include <villas/pool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct node;
|
||||
struct sample;
|
||||
|
@ -47,7 +51,7 @@ struct loopback {
|
|||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * loopback_print(struct node *n);
|
||||
char *loopback_print(struct node *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int loopback_parse(struct node *n, json_t *cfg);
|
||||
|
@ -64,4 +68,8 @@ int loopback_read(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
/** @see node_type::write */
|
||||
int loopback_write(struct node *n, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
#include <villas/io.h>
|
||||
#include <villas/queue_signalled.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct format_type;
|
||||
struct mosquitto;
|
||||
|
@ -96,4 +100,8 @@ int mqtt_read(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
/** @see node_type::write */
|
||||
int mqtt_write(struct node *n, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
#include <villas/list.h>
|
||||
#include <villas/io.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** The maximum length of a packet which contains stuct msg. */
|
||||
#define NANOMSG_MAX_PACKET_LEN 1500
|
||||
|
||||
|
@ -55,7 +59,7 @@ struct nanomsg {
|
|||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * nanomsg_print(struct node *n);
|
||||
char *nanomsg_print(struct node *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int nanomsg_parse(struct node *n, json_t *cfg);
|
||||
|
@ -72,4 +76,8 @@ int nanomsg_read(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
/** @see node_type::write */
|
||||
int nanomsg_write(struct node *n, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -43,25 +43,29 @@
|
|||
#include <villas/node.h>
|
||||
#include <villas/task.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct node;
|
||||
|
||||
struct ngsi {
|
||||
const char *endpoint; /**< The NGSI context broker endpoint URL. */
|
||||
const char *entity_id; /**< The context broker entity id related to this node */
|
||||
const char *entity_type; /**< The type of the entity */
|
||||
const char *access_token; /**< An optional authentication token which will be sent as HTTP header. */
|
||||
const char *endpoint; /**< The NGSI context broker endpoint URL. */
|
||||
const char *entity_id; /**< The context broker entity id related to this node */
|
||||
const char *entity_type; /**< The type of the entity */
|
||||
const char *access_token; /**< An optional authentication token which will be sent as HTTP header. */
|
||||
|
||||
double timeout; /**< HTTP timeout in seconds */
|
||||
double rate; /**< Rate used for polling. */
|
||||
double timeout; /**< HTTP timeout in seconds */
|
||||
double rate; /**< Rate used for polling. */
|
||||
|
||||
struct task task; /**< Timer for periodic events. */
|
||||
int ssl_verify; /**< Boolean flag whether SSL server certificates should be verified or not. */
|
||||
struct task task; /**< Timer for periodic events. */
|
||||
int ssl_verify; /**< Boolean flag whether SSL server certificates should be verified or not. */
|
||||
|
||||
struct curl_slist *headers; /**< List of HTTP request headers for libcurl */
|
||||
struct curl_slist *headers; /**< List of HTTP request headers for libcurl */
|
||||
|
||||
CURL *curl; /**< libcurl: handle */
|
||||
CURL *curl; /**< libcurl: handle */
|
||||
|
||||
struct list mapping; /**< A mapping between indices of the VILLASnode samples and the attributes in ngsi::context */
|
||||
struct list mapping; /**< A mapping between indices of the VILLASnode samples and the attributes in ngsi::context */
|
||||
};
|
||||
|
||||
/** Initialize global NGSI settings and maps shared memory regions.
|
||||
|
@ -80,7 +84,7 @@ int ngsi_deinit();
|
|||
int ngsi_parse(struct node *n, json_t *cfg);
|
||||
|
||||
/** @see node_type::print */
|
||||
char * ngsi_print(struct node *n);
|
||||
char *ngsi_print(struct node *n);
|
||||
|
||||
/** @see node_type::open */
|
||||
int ngsi_start(struct node *n);
|
||||
|
@ -94,4 +98,8 @@ int ngsi_read(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
/** @see node_type::write */
|
||||
int ngsi_write(struct node *n, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -41,6 +41,10 @@
|
|||
#include "AsyncApi.h"
|
||||
#include "OpalGenAsyncParamCtrl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct opal {
|
||||
int reply;
|
||||
int mode;
|
||||
|
@ -68,7 +72,7 @@ int opal_deinit();
|
|||
int opal_parse(struct node *n, json_t *cfg);
|
||||
|
||||
/** @see node_type::print */
|
||||
char * opal_print(struct node *n);
|
||||
char *opal_print(struct node *n);
|
||||
|
||||
/** Print global settings of the OPAL node type. */
|
||||
int opal_print_global();
|
||||
|
@ -85,4 +89,8 @@ int opal_read(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
/** @see node_type::write */
|
||||
int opal_write(struct node *n, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -36,19 +36,23 @@
|
|||
#include <villas/config.h>
|
||||
#include <villas/shmem.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Node-type for shared memory communication.
|
||||
* @see node_type
|
||||
*/
|
||||
struct shmem {
|
||||
const char* out_name; /**< Name of the shm object for the output queue. */
|
||||
const char* in_name; /**< Name of the shm object for the input queue. */
|
||||
struct shmem_conf conf; /**< Interface configuration struct. */
|
||||
char **exec; /**< External program to execute on start. */
|
||||
struct shmem_int intf; /**< Shmem interface */
|
||||
const char *out_name; /**< Name of the shm object for the output queue. */
|
||||
const char *in_name; /**< Name of the shm object for the input queue. */
|
||||
struct shmem_conf conf; /**< Interface configuration struct. */
|
||||
char **exec; /**< External program to execute on start. */
|
||||
struct shmem_int intf; /**< Shmem interface */
|
||||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * shmem_print(struct node *n);
|
||||
char *shmem_print(struct node *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int shmem_parse(struct node *n, json_t *cfg);
|
||||
|
@ -65,4 +69,8 @@ int shmem_read(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
/** @see node_type::write */
|
||||
int shmem_write(struct node *n, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -32,6 +32,10 @@
|
|||
#include <villas/timing.h>
|
||||
#include <villas/task.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct node;
|
||||
struct sample;
|
||||
|
@ -51,29 +55,29 @@ enum signal_generator_type {
|
|||
* @see node_type
|
||||
*/
|
||||
struct signal_generator {
|
||||
struct task task; /**< Timer for periodic events. */
|
||||
int rt; /**< Real-time mode? */
|
||||
struct task task; /**< Timer for periodic events. */
|
||||
int rt; /**< Real-time mode? */
|
||||
|
||||
enum signal_generator_type type; /**< Signal type */
|
||||
|
||||
double rate; /**< Sampling rate. */
|
||||
double frequency; /**< Frequency of the generated signals. */
|
||||
double amplitude; /**< Amplitude of the generated signals. */
|
||||
double stddev; /**< Standard deviation of random signals (normal distributed). */
|
||||
double offset; /**< A constant bias. */
|
||||
double rate; /**< Sampling rate. */
|
||||
double frequency; /**< Frequency of the generated signals. */
|
||||
double amplitude; /**< Amplitude of the generated signals. */
|
||||
double stddev; /**< Standard deviation of random signals (normal distributed). */
|
||||
double offset; /**< A constant bias. */
|
||||
|
||||
double *last; /**< The values from the previous period which are required for random walk. */
|
||||
double *last; /**< The values from the previous period which are required for random walk. */
|
||||
|
||||
int values; /**< The number of values which will be emitted by this node. */
|
||||
int limit; /**< The number of values which should be generated by this node. <0 for infinitve. */
|
||||
int values; /**< The number of values which will be emitted by this node. */
|
||||
int limit; /**< The number of values which should be generated by this node. <0 for infinitve. */
|
||||
|
||||
struct timespec started; /**< Point in time when this node was started. */
|
||||
int counter; /**< The number of packets already emitted. */
|
||||
int missed_steps; /**< Total number of missed steps. */
|
||||
struct timespec started; /**< Point in time when this node was started. */
|
||||
int counter; /**< The number of packets already emitted. */
|
||||
int missed_steps; /**< Total number of missed steps. */
|
||||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * signal_generator_print(struct node *n);
|
||||
char *signal_generator_print(struct node *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int signal_generator_parse(struct node *n, json_t *cfg);
|
||||
|
@ -89,4 +93,8 @@ int signal_generator_read(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
|
||||
enum signal_generator_type signal_generator_lookup_type(const char *type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -50,6 +50,10 @@
|
|||
|
||||
#include <villas/node.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct format_type;
|
||||
|
||||
|
@ -75,29 +79,29 @@ union sockaddr_union {
|
|||
};
|
||||
|
||||
struct socket {
|
||||
int sd; /**< The socket descriptor */
|
||||
int mark; /**< Socket mark for netem, routing and filtering */
|
||||
int verify_source; /**< Verify the source address of incoming packets against socket::remote. */
|
||||
int sd; /**< The socket descriptor */
|
||||
int mark; /**< Socket mark for netem, routing and filtering */
|
||||
int verify_source; /**< Verify the source address of incoming packets against socket::remote. */
|
||||
|
||||
enum socket_layer layer; /**< The OSI / IP layer which should be used for this socket */
|
||||
enum socket_layer layer; /**< The OSI / IP layer which should be used for this socket */
|
||||
|
||||
union sockaddr_union local; /**< Local address of the socket */
|
||||
union sockaddr_union remote; /**< Remote address of the socket */
|
||||
union sockaddr_union local; /**< Local address of the socket */
|
||||
union sockaddr_union remote; /**< Remote address of the socket */
|
||||
|
||||
struct format_type *format;
|
||||
struct io io;
|
||||
|
||||
/* Multicast options */
|
||||
struct multicast {
|
||||
int enabled; /**< Is multicast enabled? */
|
||||
unsigned char loop; /** Loopback multicast packets to local host? */
|
||||
unsigned char ttl; /**< The time to live for multicast packets. */
|
||||
struct ip_mreq mreq; /**< A multicast group to join. */
|
||||
int enabled; /**< Is multicast enabled? */
|
||||
unsigned char loop; /** Loopback multicast packets to local host? */
|
||||
unsigned char ttl; /**< The time to live for multicast packets. */
|
||||
struct ip_mreq mreq; /**< A multicast group to join. */
|
||||
} multicast;
|
||||
|
||||
#ifdef WITH_NETEM
|
||||
struct rtnl_qdisc *tc_qdisc; /**< libnl3: Network emulator queuing discipline */
|
||||
struct rtnl_cls *tc_classifier; /**< libnl3: Firewall mark classifier */
|
||||
struct rtnl_qdisc *tc_qdisc; /**< libnl3: Network emulator queuing discipline */
|
||||
struct rtnl_cls *tc_classifier; /**< libnl3: Firewall mark classifier */
|
||||
#endif /* WITH_NETEM */
|
||||
};
|
||||
|
||||
|
@ -124,7 +128,7 @@ int socket_read(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
int socket_parse(struct node *n, json_t *cfg);
|
||||
|
||||
/** @see node_type::print */
|
||||
char * socket_print(struct node *n);
|
||||
char *socket_print(struct node *n);
|
||||
|
||||
/** Generate printable socket address depending on the address family
|
||||
*
|
||||
|
@ -134,7 +138,7 @@ char * socket_print(struct node *n);
|
|||
* @param sa A pointer to the socket address.
|
||||
* @return The buffer containing the textual representation of the address. The caller is responsible to free() this buffer!
|
||||
*/
|
||||
char * socket_print_addr(struct sockaddr *saddr);
|
||||
char *socket_print_addr(struct sockaddr *saddr);
|
||||
|
||||
/** Parse a socket address depending on the address family
|
||||
*
|
||||
|
@ -154,4 +158,8 @@ int socket_parse_addr(const char *str, struct sockaddr *sa, enum socket_layer la
|
|||
|
||||
int socket_compare_addr(struct sockaddr *x, struct sockaddr *y);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
|
||||
#include <villas/task.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct node;
|
||||
struct sample;
|
||||
|
@ -51,7 +55,7 @@ struct stats_node {
|
|||
int stats_node_init(struct super_node *sn);
|
||||
|
||||
/** @see node_type::print */
|
||||
char * stats_node_print(struct node *n);
|
||||
char *stats_node_print(struct node *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int stats_node_parse(struct node *n, json_t *cfg);
|
||||
|
@ -65,4 +69,8 @@ int stats_node_stop(struct node *n);
|
|||
/** @see node_type::read */
|
||||
int stats_node_read(struct node *n, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
#include <villas/io.h>
|
||||
#include <villas/task.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct test_rtt;
|
||||
struct node;
|
||||
|
@ -41,29 +45,29 @@ struct sample;
|
|||
struct test_rtt_case {
|
||||
double rate;
|
||||
int values;
|
||||
int limit; /**< The number of samples we take per test. */
|
||||
int limit; /**< The number of samples we take per test. */
|
||||
|
||||
char *filename;
|
||||
};
|
||||
|
||||
struct test_rtt {
|
||||
struct task task; /**< The periodic task for test_rtt_read() */
|
||||
struct io io; /**< The format of the output file */
|
||||
struct task task; /**< The periodic task for test_rtt_read() */
|
||||
struct io io; /**< The format of the output file */
|
||||
struct format_type *format;
|
||||
|
||||
double cooldown; /**< Number of seconds to wait beween tests. */
|
||||
double cooldown; /**< Number of seconds to wait beween tests. */
|
||||
|
||||
int current; /**< Index of current test in test_rtt::cases */
|
||||
int current; /**< Index of current test in test_rtt::cases */
|
||||
int counter;
|
||||
|
||||
struct list cases; /**< List of test cases */
|
||||
struct list cases; /**< List of test cases */
|
||||
|
||||
char *output; /**< The directory where we place the results. */
|
||||
char *prefix; /**< An optional prefix in the filename. */
|
||||
char *output; /**< The directory where we place the results. */
|
||||
char *prefix; /**< An optional prefix in the filename. */
|
||||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * test_rtt_print(struct node *n);
|
||||
char *test_rtt_print(struct node *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int test_rtt_parse(struct node *n, json_t *cfg);
|
||||
|
@ -80,4 +84,8 @@ int test_rtt_read(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
/** @see node_type::write */
|
||||
int test_rtt_write(struct node *n, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -38,56 +38,60 @@
|
|||
#include <villas/io.h>
|
||||
#include <villas/config.h>
|
||||
|
||||
#define DEFAULT_WEBSOCKET_QUEUELEN (DEFAULT_QUEUELEN * 64)
|
||||
#define DEFAULT_WEBSOCKET_SAMPLELEN DEFAULT_SAMPLELEN
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DEFAULT_WEBSOCKET_QUEUELEN (DEFAULT_QUEUELEN * 64)
|
||||
#define DEFAULT_WEBSOCKET_SAMPLELEN DEFAULT_SAMPLELEN
|
||||
|
||||
/* Forward declaration */
|
||||
struct lws;
|
||||
|
||||
/** Internal data per websocket node */
|
||||
struct websocket {
|
||||
struct list destinations; /**< List of websocket servers connect to in client mode (struct websocket_destination). */
|
||||
struct list destinations; /**< List of websocket servers connect to in client mode (struct websocket_destination). */
|
||||
|
||||
struct pool pool;
|
||||
struct queue_signalled queue; /**< For samples which are received from WebSockets */
|
||||
struct pool pool;
|
||||
struct queue_signalled queue; /**< For samples which are received from WebSockets */
|
||||
};
|
||||
|
||||
/* Internal datastructures */
|
||||
struct websocket_connection {
|
||||
enum websocket_connection_state {
|
||||
WEBSOCKET_CONNECTION_STATE_DESTROYED,
|
||||
WEBSOCKET_CONNECTION_STATE_INITIALIZED,
|
||||
WEBSOCKET_CONNECTION_STATE_CONNECTING,
|
||||
WEBSOCKET_CONNECTION_STATE_RECONNECTING,
|
||||
WEBSOCKET_CONNECTION_STATE_ESTABLISHED,
|
||||
WEBSOCKET_CONNECTION_STATE_SHUTDOWN,
|
||||
WEBSOCKET_CONNECTION_STATE_ERROR
|
||||
} state; /**< The current status of this connection. */
|
||||
enum websocket_connection_state {
|
||||
WEBSOCKET_CONNECTION_STATE_DESTROYED,
|
||||
WEBSOCKET_CONNECTION_STATE_INITIALIZED,
|
||||
WEBSOCKET_CONNECTION_STATE_CONNECTING,
|
||||
WEBSOCKET_CONNECTION_STATE_RECONNECTING,
|
||||
WEBSOCKET_CONNECTION_STATE_ESTABLISHED,
|
||||
WEBSOCKET_CONNECTION_STATE_SHUTDOWN,
|
||||
WEBSOCKET_CONNECTION_STATE_ERROR
|
||||
} state; /**< The current status of this connection. */
|
||||
|
||||
enum {
|
||||
WEBSOCKET_MODE_CLIENT,
|
||||
WEBSOCKET_MODE_SERVER,
|
||||
} mode;
|
||||
enum {
|
||||
WEBSOCKET_MODE_CLIENT,
|
||||
WEBSOCKET_MODE_SERVER,
|
||||
} mode;
|
||||
|
||||
struct lws *wsi;
|
||||
struct node *node;
|
||||
struct io io;
|
||||
struct queue queue; /**< For samples which are sent to the WebSocket */
|
||||
struct lws *wsi;
|
||||
struct node *node;
|
||||
struct io io;
|
||||
struct queue queue; /**< For samples which are sent to the WebSocket */
|
||||
|
||||
struct format_type *format;
|
||||
struct websocket_destination *destination;
|
||||
struct format_type *format;
|
||||
struct websocket_destination *destination;
|
||||
|
||||
struct {
|
||||
struct buffer recv; /**< A buffer for reconstructing fragmented messags. */
|
||||
struct buffer send; /**< A buffer for contsructing messages before calling lws_write() */
|
||||
} buffers;
|
||||
struct {
|
||||
struct buffer recv; /**< A buffer for reconstructing fragmented messags. */
|
||||
struct buffer send; /**< A buffer for contsructing messages before calling lws_write() */
|
||||
} buffers;
|
||||
|
||||
char *_name;
|
||||
char *_name;
|
||||
};
|
||||
|
||||
struct websocket_destination {
|
||||
char *uri;
|
||||
struct lws_client_connect_info info;
|
||||
char *uri;
|
||||
struct lws_client_connect_info info;
|
||||
};
|
||||
|
||||
int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len);
|
||||
|
@ -113,4 +117,8 @@ int websocket_read(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
/** @see node_type::write */
|
||||
int websocket_write(struct node *n, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,8 +35,12 @@
|
|||
#include <villas/list.h>
|
||||
#include <villas/io.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if ZMQ_BUILD_DRAFT_API && (ZMQ_VERSION_MAJOR > 4 || (ZMQ_VERSION_MAJOR == 4 && ZMQ_VERSION_MINOR >= 2))
|
||||
#define ZMQ_BUILD_DISH 1
|
||||
#define ZMQ_BUILD_DISH 1
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
|
@ -68,19 +72,19 @@ struct zeromq {
|
|||
} pattern;
|
||||
|
||||
struct {
|
||||
void *socket; /**< ZeroMQ socket. */
|
||||
void *socket; /**< ZeroMQ socket. */
|
||||
void *mon_socket;
|
||||
char *endpoint;
|
||||
} subscriber;
|
||||
|
||||
struct {
|
||||
void *socket; /**< ZeroMQ socket. */
|
||||
void *socket; /**< ZeroMQ socket. */
|
||||
struct list endpoints;
|
||||
} publisher;
|
||||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * zeromq_print(struct node *n);
|
||||
char *zeromq_print(struct node *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int zeromq_parse(struct node *n, json_t *cfg);
|
||||
|
@ -103,4 +107,8 @@ int zeromq_read(struct node *n, struct sample *smps[], unsigned cnt);
|
|||
/** @see node_type::write */
|
||||
int zeromq_write(struct node *n, struct sample *smps[], unsigned cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -41,6 +41,10 @@
|
|||
#include "mapping.h"
|
||||
#include "task.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct stats;
|
||||
struct node;
|
||||
|
@ -52,7 +56,7 @@ struct path_source {
|
|||
bool masked;
|
||||
|
||||
struct pool pool;
|
||||
struct list mappings; /**< List of mappings (struct mapping_entry). */
|
||||
struct list mappings; /**< List of mappings (struct mapping_entry). */
|
||||
};
|
||||
|
||||
struct path_destination {
|
||||
|
@ -63,15 +67,15 @@ struct path_destination {
|
|||
|
||||
/** The register mode determines under which condition the path is triggered. */
|
||||
enum path_mode {
|
||||
PATH_MODE_ANY, /**< The path is triggered whenever one of the sources receives samples. */
|
||||
PATH_MODE_ALL /**< The path is triggered only after all sources have received at least 1 sample. */
|
||||
PATH_MODE_ANY, /**< The path is triggered whenever one of the sources receives samples. */
|
||||
PATH_MODE_ALL /**< The path is triggered only after all sources have received at least 1 sample. */
|
||||
};
|
||||
|
||||
/** The datastructure for a path. */
|
||||
struct path {
|
||||
enum state state; /**< Path state. */
|
||||
enum state state; /**< Path state. */
|
||||
|
||||
enum path_mode mode; /**< Determines when this path is triggered. */
|
||||
enum path_mode mode; /**< Determines when this path is triggered. */
|
||||
|
||||
struct {
|
||||
int nfds;
|
||||
|
@ -82,27 +86,27 @@ struct path {
|
|||
struct sample *last_sample;
|
||||
int last_sequence;
|
||||
|
||||
struct list sources; /**< List of all incoming nodes (struct path_source). */
|
||||
struct list destinations; /**< List of all outgoing nodes (struct path_destination). */
|
||||
struct list hooks; /**< List of processing hooks (struct hook). */
|
||||
struct list sources; /**< List of all incoming nodes (struct path_source). */
|
||||
struct list destinations; /**< List of all outgoing nodes (struct path_destination). */
|
||||
struct list hooks; /**< List of processing hooks (struct hook). */
|
||||
|
||||
struct task timeout;
|
||||
|
||||
double rate; /**< A timeout for */
|
||||
int enabled; /**< Is this path enabled. */
|
||||
int poll; /**< Weather or not to use poll(2). */
|
||||
int reverse; /**< This path as a matching reverse path. */
|
||||
int builtin; /**< This path should use built-in hooks by default. */
|
||||
int queuelen; /**< The queue length for each path_destination::queue */
|
||||
int samplelen; /**< Will be calculated based on path::sources.mappings */
|
||||
double rate; /**< A timeout for */
|
||||
int enabled; /**< Is this path enabled. */
|
||||
int poll; /**< Weather or not to use poll(2). */
|
||||
int reverse; /**< This path as a matching reverse path. */
|
||||
int builtin; /**< This path should use built-in hooks by default. */
|
||||
int queuelen; /**< The queue length for each path_destination::queue */
|
||||
int samplelen; /**< Will be calculated based on path::sources.mappings */
|
||||
|
||||
char *_name; /**< Singleton: A string which is used to print this path to screen. */
|
||||
char *_name; /**< Singleton: A string which is used to print this path to screen. */
|
||||
|
||||
struct bitset mask; /**< A mask of path_sources which are enabled for poll(). */
|
||||
struct bitset received; /**< A mask of path_sources for which we already received samples. */
|
||||
struct bitset mask; /**< A mask of path_sources which are enabled for poll(). */
|
||||
struct bitset received; /**< A mask of path_sources for which we already received samples. */
|
||||
|
||||
pthread_t tid; /**< The thread id for this path. */
|
||||
json_t *cfg; /**< A JSON object containing the configuration of the path. */
|
||||
pthread_t tid; /**< The thread id for this path. */
|
||||
json_t *cfg; /**< A JSON object containing the configuration of the path. */
|
||||
};
|
||||
|
||||
/** Initialize internal data structures. */
|
||||
|
@ -150,7 +154,7 @@ void path_print_stats(struct path *p);
|
|||
* @param p A pointer to the path structure.
|
||||
* @return A pointer to a string containing a textual representation of the path.
|
||||
*/
|
||||
const char * path_name(struct path *p);
|
||||
const char *path_name(struct path *p);
|
||||
|
||||
/** Reverse a path */
|
||||
int path_reverse(struct path *p, struct path *r);
|
||||
|
@ -168,4 +172,8 @@ int path_uses_node(struct path *p, struct node *n);
|
|||
*/
|
||||
int path_parse(struct path *p, json_t *cfg, struct list *nodes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
#include "node_type.h"
|
||||
#include "format_type.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/** @todo This is ugly as hell and broken on OS X / Clang anyway. */
|
||||
#define REGISTER_PLUGIN(p) \
|
||||
__attribute__((constructor(110))) static void UNIQUE(__ctor)() {\
|
||||
|
@ -95,3 +99,7 @@ void plugin_dump(enum plugin_type type);
|
|||
|
||||
/** Find registered and loaded plugin with given name and type. */
|
||||
struct plugin * plugin_lookup(enum plugin_type type, const char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -32,17 +32,21 @@
|
|||
#include "common.h"
|
||||
#include "memory.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** A thread-safe memory pool */
|
||||
struct pool {
|
||||
off_t buffer_off; /**< Offset from the struct address to the underlying memory area */
|
||||
off_t buffer_off; /**< Offset from the struct address to the underlying memory area */
|
||||
struct memtype *mem;
|
||||
|
||||
enum state state;
|
||||
|
||||
size_t len; /**< Length of the underlying memory area */
|
||||
size_t len; /**< Length of the underlying memory area */
|
||||
|
||||
size_t blocksz; /**< Length of a block in bytes */
|
||||
size_t alignment; /**< Alignment of a block in bytes */
|
||||
size_t blocksz; /**< Length of a block in bytes */
|
||||
size_t alignment; /**< Alignment of a block in bytes */
|
||||
|
||||
struct queue queue; /**< The queue which is used to keep track of free blocks */
|
||||
};
|
||||
|
@ -69,26 +73,26 @@ int pool_destroy(struct pool *p);
|
|||
* This number can be smaller than the requested \p cnt blocks
|
||||
* in case the pool currently holds less than \p cnt blocks.
|
||||
*/
|
||||
INLINE ssize_t pool_get_many(struct pool *p, void *blocks[], size_t cnt)
|
||||
{
|
||||
INLINE ssize_t pool_get_many(struct pool *p, void *blocks[], size_t cnt) {
|
||||
return queue_pull_many(&p->queue, blocks, cnt);
|
||||
}
|
||||
|
||||
/** Push \p cnt values which are giving by the array values to the stack. */
|
||||
INLINE ssize_t pool_put_many(struct pool *p, void *blocks[], size_t cnt)
|
||||
{
|
||||
INLINE ssize_t pool_put_many(struct pool *p, void *blocks[], size_t cnt) {
|
||||
return queue_push_many(&p->queue, blocks, cnt);
|
||||
}
|
||||
|
||||
/** Get a free memory block from pool. */
|
||||
INLINE void * pool_get(struct pool *p)
|
||||
{
|
||||
INLINE void *pool_get(struct pool *p) {
|
||||
void *ptr;
|
||||
return queue_pull(&p->queue, &ptr) == 1 ? ptr : NULL;
|
||||
}
|
||||
|
||||
/** Release a memory block back to the pool. */
|
||||
INLINE int pool_put(struct pool *p, void *buf)
|
||||
{
|
||||
INLINE int pool_put(struct pool *p, void *buf) {
|
||||
return queue_push(&p->queue, buf);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
@ -41,6 +43,10 @@
|
|||
#include "atomic.h"
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct memtype;
|
||||
|
||||
|
@ -112,3 +118,7 @@ int queue_pull_many(struct queue *q, void *ptr[], size_t cnt);
|
|||
* @return -1 on failure.
|
||||
*/
|
||||
int queue_close(struct queue *q);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -27,6 +27,10 @@
|
|||
|
||||
#include "queue.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
enum queue_signalled_flags {
|
||||
/* Mode */
|
||||
QUEUE_SIGNALLED_AUTO = (0 << 0), /**< We will choose the best method available on the platform */
|
||||
|
@ -80,3 +84,7 @@ int queue_signalled_close(struct queue_signalled *qs);
|
|||
|
||||
/** Returns a file descriptor which can be used with poll / select to wait for new data */
|
||||
int queue_signalled_fd(struct queue_signalled *qs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -21,20 +21,22 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "atomic.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct pool;
|
||||
|
||||
|
|
|
@ -25,12 +25,16 @@
|
|||
|
||||
#include <jansson.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct list;
|
||||
struct node;
|
||||
|
||||
struct signal {
|
||||
char *name; /**< The name of the signal. */
|
||||
char *name; /**< The name of the signal. */
|
||||
char *unit;
|
||||
int enabled;
|
||||
enum {
|
||||
|
@ -46,3 +50,7 @@ int signal_parse(struct signal *s, json_t *cfg);
|
|||
int signal_parse_list(struct list *list, json_t *cfg);
|
||||
|
||||
int signal_get_offset(const char *str, struct node *n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -29,6 +29,10 @@
|
|||
|
||||
#include "hist.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct sample;
|
||||
struct node;
|
||||
|
@ -40,19 +44,19 @@ enum stats_format {
|
|||
};
|
||||
|
||||
enum stats_id {
|
||||
STATS_SKIPPED, /**< Counter for skipped samples due to hooks. */
|
||||
STATS_TIME, /**< The processing time per sample within VILLAsnode. */
|
||||
STATS_REORDERED, /**< Counter for reordered samples. */
|
||||
STATS_GAP_SAMPLE, /**< Histogram for inter sample timestamps (as sent by remote). */
|
||||
STATS_GAP_RECEIVED, /**< Histogram for inter sample arrival time (as seen by this instance). */
|
||||
STATS_OWD, /**< Histogram for one-way-delay (OWD) of received samples. */
|
||||
STATS_COUNT /**< Just here to have an updated number of statistics. */
|
||||
STATS_SKIPPED, /**< Counter for skipped samples due to hooks. */
|
||||
STATS_TIME, /**< The processing time per sample within VILLAsnode. */
|
||||
STATS_REORDERED, /**< Counter for reordered samples. */
|
||||
STATS_GAP_SAMPLE, /**< Histogram for inter sample timestamps (as sent by remote). */
|
||||
STATS_GAP_RECEIVED, /**< Histogram for inter sample arrival time (as seen by this instance). */
|
||||
STATS_OWD, /**< Histogram for one-way-delay (OWD) of received samples. */
|
||||
STATS_COUNT /**< Just here to have an updated number of statistics. */
|
||||
};
|
||||
|
||||
struct stats_delta {
|
||||
double values[STATS_COUNT];
|
||||
|
||||
int update; /**< Bitmask of stats_id. Only those which are masked will be updated */
|
||||
int update; /**< Bitmask of stats_id. Only those which are masked will be updated */
|
||||
};
|
||||
|
||||
struct stats {
|
||||
|
@ -73,7 +77,7 @@ void stats_collect(struct stats *s, struct sample *smps[], size_t cnt);
|
|||
|
||||
int stats_commit(struct stats *s);
|
||||
|
||||
json_t * stats_json(struct stats *s);
|
||||
json_t *stats_json(struct stats *s);
|
||||
|
||||
void stats_reset(struct stats *s);
|
||||
|
||||
|
@ -86,4 +90,8 @@ void stats_print(struct stats *s, FILE *f, enum stats_format fmt, int verbose);
|
|||
|
||||
enum stats_id stats_lookup_id(const char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _STATS_H_ */
|
||||
|
|
|
@ -29,33 +29,37 @@
|
|||
#include "log.h"
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Global configuration */
|
||||
struct super_node {
|
||||
int priority; /**< Process priority (lower is better) */
|
||||
int affinity; /**< Process affinity of the server and all created threads */
|
||||
int hugepages; /**< Number of hugepages to reserve. */
|
||||
double stats; /**< Interval for path statistics. Set to 0 to disable them. */
|
||||
int priority; /**< Process priority (lower is better) */
|
||||
int affinity; /**< Process affinity of the server and all created threads */
|
||||
int hugepages; /**< Number of hugepages to reserve. */
|
||||
double stats; /**< Interval for path statistics. Set to 0 to disable them. */
|
||||
|
||||
struct list nodes;
|
||||
struct list paths;
|
||||
struct list plugins;
|
||||
struct list nodes;
|
||||
struct list paths;
|
||||
struct list plugins;
|
||||
|
||||
struct log log;
|
||||
struct api api;
|
||||
struct web web;
|
||||
struct log log;
|
||||
struct api api;
|
||||
struct web web;
|
||||
|
||||
char *name; /**< A name of this super node. Usually the hostname. */
|
||||
char *name; /**< A name of this super node. Usually the hostname. */
|
||||
|
||||
enum state state;
|
||||
enum state state;
|
||||
|
||||
char *uri; /**< URI of configuration */
|
||||
char *uri; /**< URI of configuration */
|
||||
|
||||
json_t *cfg; /**< JSON representation of the configuration. */
|
||||
json_t *cfg; /**< JSON representation of the configuration. */
|
||||
};
|
||||
|
||||
/* Compatibility with libconfig < 1.5 */
|
||||
#if (LIBCONFIG_VER_MAJOR <= 1) && (LIBCONFIG_VER_MINOR < 5)
|
||||
#define config_setting_lookup config_lookup_from
|
||||
#define config_setting_lookup config_lookup_from
|
||||
#endif
|
||||
|
||||
/** Inititalize configuration object before parsing the configuration. */
|
||||
|
@ -83,3 +87,7 @@ int super_node_stop(struct super_node *sn);
|
|||
|
||||
/** Desctroy configuration object. */
|
||||
int super_node_destroy(struct super_node *sn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -25,18 +25,22 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct table_column {
|
||||
int width; /**< Width of the column. */
|
||||
char *title; /**< The title as shown in the table header. */
|
||||
char *format; /**< The format which is used to print the table rows. */
|
||||
char *unit; /**< An optional unit which will be shown in the table header. */
|
||||
int width; /**< Width of the column. */
|
||||
char *title; /**< The title as shown in the table header. */
|
||||
char *format; /**< The format which is used to print the table rows. */
|
||||
char *unit; /**< An optional unit which will be shown in the table header. */
|
||||
|
||||
enum {
|
||||
TABLE_ALIGN_LEFT,
|
||||
TABLE_ALIGN_RIGHT
|
||||
} align;
|
||||
|
||||
int _width; /**< The real width of this column. Calculated by table_header() */
|
||||
int _width; /**< The real width of this column. Calculated by table_header() */
|
||||
};
|
||||
|
||||
struct table {
|
||||
|
@ -54,4 +58,8 @@ void table_row(struct table *t, ...);
|
|||
/** Print the table footer. */
|
||||
void table_footer(struct table *t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -28,27 +28,31 @@
|
|||
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** We can choose between two periodic task implementations */
|
||||
//#define PERIODIC_TASK_IMPL NANOSLEEP
|
||||
#define TIMERFD 1
|
||||
#define CLOCK_NANOSLEEP 2
|
||||
#define NANOSLEEP 3
|
||||
#define TIMERFD 1
|
||||
#define CLOCK_NANOSLEEP 2
|
||||
#define NANOSLEEP 3
|
||||
|
||||
#if defined(__MACH__)
|
||||
#define PERIODIC_TASK_IMPL NANOSLEEP
|
||||
#define PERIODIC_TASK_IMPL NANOSLEEP
|
||||
#elif defined(__linux__)
|
||||
#define PERIODIC_TASK_IMPL TIMERFD
|
||||
#define PERIODIC_TASK_IMPL TIMERFD
|
||||
#else
|
||||
#error "Platform not supported"
|
||||
#error "Platform not supported"
|
||||
#endif
|
||||
|
||||
struct task {
|
||||
int clock; /**< CLOCK_{MONOTONIC,REALTIME} */
|
||||
int clock; /**< CLOCK_{MONOTONIC,REALTIME} */
|
||||
|
||||
struct timespec period; /**< The period of periodic invations of this task */
|
||||
struct timespec next; /**< The timer value for the next invocation */
|
||||
struct timespec period; /**< The period of periodic invations of this task */
|
||||
struct timespec next; /**< The timer value for the next invocation */
|
||||
#if PERIODIC_TASK_IMPL == TIMERFD
|
||||
int fd; /**< The timerfd_create(2) file descriptior. */
|
||||
int fd; /**< The timerfd_create(2) file descriptior. */
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -73,3 +77,8 @@ int task_set_rate(struct task *t, double rate);
|
|||
* Note: currently not supported on all platforms.
|
||||
*/
|
||||
int task_fd(struct task *t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/** Get delta between two timespec structs */
|
||||
struct timespec time_diff(const struct timespec *start, const struct timespec *end);
|
||||
|
||||
|
@ -45,3 +49,7 @@ double time_to_double(const struct timespec *ts);
|
|||
|
||||
/** Convert double containing seconds after 1970 to timespec. */
|
||||
struct timespec time_from_double(double secs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,11 @@
|
|||
#include <villas/config.h>
|
||||
#include <villas/log.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define LIKELY(x) __builtin_expect((x),1)
|
||||
#define UNLIKELY(x) __builtin_expect((x),0)
|
||||
|
@ -275,3 +280,8 @@ pid_t spawn(const char *name, char *const argv[]);
|
|||
|
||||
/** Determines the string length as printed on the screen (ignores escable sequences). */
|
||||
size_t strlenp(const char *str);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -27,6 +27,10 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct api;
|
||||
|
||||
|
@ -35,13 +39,13 @@ struct web {
|
|||
|
||||
enum state state;
|
||||
|
||||
struct lws_context *context; /**< The libwebsockets server context. */
|
||||
struct lws_vhost *vhost; /**< The libwebsockets vhost. */
|
||||
struct lws_context *context; /**< The libwebsockets server context. */
|
||||
struct lws_vhost *vhost; /**< The libwebsockets vhost. */
|
||||
|
||||
int port; /**< Port of the build in HTTP / WebSocket server. */
|
||||
char *htdocs; /**< The root directory for files served via HTTP. */
|
||||
char *ssl_cert; /**< Path to the SSL certitifcate for HTTPS / WSS. */
|
||||
char *ssl_private_key; /**< Path to the SSL private key for HTTPS / WSS. */
|
||||
int port; /**< Port of the build in HTTP / WebSocket server. */
|
||||
char *htdocs; /**< The root directory for files served via HTTP. */
|
||||
char *ssl_cert; /**< Path to the SSL certitifcate for HTTPS / WSS. */
|
||||
char *ssl_private_key; /**< Path to the SSL private key for HTTPS / WSS. */
|
||||
|
||||
pthread_t thread;
|
||||
};
|
||||
|
@ -60,3 +64,7 @@ int web_stop(struct web *w);
|
|||
|
||||
/** Parse HTTPd and WebSocket related options */
|
||||
int web_parse(struct web *w, json_t *cfg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue