mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
made most of Linux dependencies optional
VILLASnode now compiles on OS X Yosemite :-)
This commit is contained in:
parent
f569f14602
commit
522ded3ea7
35 changed files with 189 additions and 53 deletions
8
Makefile
8
Makefile
|
@ -50,7 +50,9 @@ CFLAGS += -Wall -Werror -fdiagnostics-color=auto
|
|||
LDFLAGS += -L$(BUILDDIR)
|
||||
|
||||
# Some tools
|
||||
PKGCONFIG := PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:$(PKG_CONFIG_PATH) pkg-config
|
||||
PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):/opt/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
|
||||
|
||||
PKGCONFIG := PKG_CONFIG_PATH=:$(PKG_CONFIG_PATH) pkg-config
|
||||
SHELL := bash
|
||||
|
||||
# We must compile without optimizations for gcov!
|
||||
|
@ -104,7 +106,7 @@ else
|
|||
endif
|
||||
|
||||
# pkg-config dependencies
|
||||
PKGS = libconfig
|
||||
PKGS = libconfig openssl
|
||||
|
||||
######## Targets ########
|
||||
|
||||
|
@ -132,7 +134,7 @@ escape = $(shell echo $1 | tr a-z- A-Z_ | tr -dc ' A-Z0-9_')
|
|||
|
||||
CFLAGS += -DV=$(V) -DPREFIX=\"$(PREFIX)\"
|
||||
CFLAGS += -DBUILDID=\"$(VERSION)-$(GIT_REV)-$(VARIANT)\"
|
||||
CFLAGS += -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1
|
||||
CFLAGS += -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1 -D_DARWIN_C_SOURCE
|
||||
CFLAGS += $(addprefix -DWITH_, $(call escape,$(PKGS)))
|
||||
|
||||
install: $(addprefix install-,$(filter-out thirdparty doc clients,$(MODULES)))
|
||||
|
|
|
@ -24,4 +24,18 @@
|
|||
|
||||
#if JANSSON_VERSION_HEX < 0x020A00
|
||||
size_t json_dumpb(const json_t *json, char *buffer, size_t size, size_t flags);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __MACH__
|
||||
#include <libkern/OSByteOrder.h>
|
||||
|
||||
#define le16toh(x) OSSwapLittleToHostInt16(x)
|
||||
#define le32toh(x) OSSwapLittleToHostInt32(x)
|
||||
#define be16toh(x) OSSwapBigToHostInt16(x)
|
||||
#define be32toh(x) OSSwapBigToHostInt32(x)
|
||||
|
||||
#define htole16(x) OSSwapHostToLittleInt16(x)
|
||||
#define htole32(x) OSSwapHostToLittleInt32(x)
|
||||
#define htobe16(x) OSSwapHostToBigInt16(x)
|
||||
#define htobe32(x) OSSwapHostToBigInt32(x)
|
||||
#endif /* __MACH__ */
|
||||
|
|
|
@ -30,11 +30,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <libconfig.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "nodes/fpga.h"
|
||||
|
||||
#include "fpga/vlnv.h"
|
||||
|
||||
#include "fpga/ips/dma.h"
|
||||
|
|
|
@ -30,10 +30,11 @@
|
|||
}
|
||||
|
||||
#define LIST_INIT_STATIC(l) \
|
||||
__attribute__((constructor(105))) static void UNIQUE(__ctor)() {\
|
||||
list_init(l); \
|
||||
__attribute__((constructor(100))) static void UNIQUE(__ctor)() {\
|
||||
if ((l)->state == STATE_DESTROYED) \
|
||||
list_init(l); \
|
||||
} \
|
||||
__attribute__((destructor(105))) static void UNIQUE(__dtor)() { \
|
||||
__attribute__((destructor(100))) static void UNIQUE(__dtor)() { \
|
||||
list_destroy(l, NULL, false); \
|
||||
}
|
||||
|
||||
|
@ -108,4 +109,4 @@ int list_contains(struct list *l, void *p);
|
|||
void list_sort(struct list *l, cmp_cb_t cmp);
|
||||
|
||||
/** Set single element in list */
|
||||
int list_set(struct list *l, int index, void *value);
|
||||
int list_set(struct list *l, int index, void *value);
|
||||
|
|
|
@ -33,9 +33,12 @@
|
|||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <linux/if_packet.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <linux/if_packet.h>
|
||||
#endif
|
||||
|
||||
#include "node.h"
|
||||
|
||||
enum socket_layer {
|
||||
|
@ -55,8 +58,10 @@ union sockaddr_union {
|
|||
struct sockaddr_storage ss;
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in6 sin6;
|
||||
struct sockaddr_ll sll;
|
||||
struct sockaddr_un sun;
|
||||
#ifdef __linux__
|
||||
struct sockaddr_ll sll;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct socket {
|
||||
|
|
|
@ -27,13 +27,18 @@
|
|||
#include "api.h"
|
||||
#include "common.h"
|
||||
#include "utils.h"
|
||||
#include "node_type.h"
|
||||
|
||||
#include "fpga/ip.h"
|
||||
#ifdef WITH_FPGA
|
||||
#include "fpga/ip.h"
|
||||
#endif
|
||||
|
||||
#include "nodes/cbuilder.h"
|
||||
|
||||
#define REGISTER_PLUGIN(p) \
|
||||
__attribute__((constructor(110))) static void UNIQUE(__ctor)() {\
|
||||
if (plugins.state == STATE_DESTROYED) \
|
||||
list_init(&plugins); \
|
||||
list_push(&plugins, p); \
|
||||
} \
|
||||
__attribute__((destructor(110))) static void UNIQUE(__dtor)() { \
|
||||
|
@ -66,7 +71,9 @@ struct plugin {
|
|||
union {
|
||||
struct api_action api;
|
||||
struct node_type node;
|
||||
#ifdef WITH_FPGA
|
||||
struct fpga_ip_type ip;
|
||||
#endif
|
||||
struct hook_type hook;
|
||||
struct cbuilder_model cb;
|
||||
};
|
||||
|
|
|
@ -27,7 +27,10 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/timerfd.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <sys/timerfd.h>
|
||||
#endif
|
||||
|
||||
/** Create a new timer with the given rate. */
|
||||
int timerfd_create_rate(double rate);
|
||||
|
|
|
@ -170,6 +170,7 @@ char * vstrcatf(char **dest, const char *fmt, va_list va)
|
|||
#define strf(fmt, ...) strcatf(&(char *) { NULL }, fmt, ##__VA_ARGS__)
|
||||
#define vstrf(fmt, va) vstrcatf(&(char *) { NULL }, fmt, va)
|
||||
|
||||
#ifdef __linux__
|
||||
/** Convert integer to cpu_set_t.
|
||||
*
|
||||
* @param set An integer number which is used as the mask
|
||||
|
@ -199,6 +200,7 @@ int cpulist_parse(const char *str, cpu_set_t *set, int fail);
|
|||
* The output format is a list of CPUs with ranges (for example, "0,1,3-9").
|
||||
*/
|
||||
char * cpulist_create(char *str, size_t len, cpu_set_t *set);
|
||||
#endif
|
||||
|
||||
/** Allocate and initialize memory. */
|
||||
void * alloc(size_t bytes);
|
||||
|
|
|
@ -30,7 +30,11 @@ LIBEXT_SRCS += $(addprefix lib/, sample.c queue.c queue_signalled.c \
|
|||
)
|
||||
|
||||
LIBEXT_LDFLAGS = -shared
|
||||
LIBEXT_LDLIBS = -ldl -lrt -Wl,-soname,$(LIBEXT_NAME).so.$(LIBEXT_ABI_VERSION)
|
||||
LIBEXT_LDLIBS =
|
||||
|
||||
ifeq ($(shell uname),Linux)
|
||||
LIBEXT_LDLIBS += -ldl -lrt -Wl,-soname,$(LIBEXT_NAME).so.$(LIBEXT_ABI_VERSION)
|
||||
endif
|
||||
|
||||
LIBEXT_OBJS = $(patsubst %.c, $(BUILDDIR)/%.o, $(LIBEXT_SRCS))
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ LIB_ABI_VERSION = 1
|
|||
LIB = $(BUILDDIR)/$(LIB_NAME).so.$(LIB_ABI_VERSION)
|
||||
|
||||
# Object files for libvillas
|
||||
LIB_SRCS += $(addprefix lib/nodes/, file.c cbuilder.c shmem.c signal.c loopback.c) \
|
||||
LIB_SRCS += $(addprefix lib/nodes/, cbuilder.c loopback.c) \
|
||||
$(addprefix lib/kernel/, kernel.c rt.c) \
|
||||
$(addprefix lib/, sample.c path.c node.c hook.c \
|
||||
log.c log_config.c utils.c super_node.c hist.c timing.c pool.c \
|
||||
|
@ -36,20 +36,36 @@ LIB_SRCS += $(addprefix lib/nodes/, file.c cbuilder.c shmem.c signal.c loopback.
|
|||
)
|
||||
|
||||
LIB_LDFLAGS = -shared
|
||||
LIB_LDLIBS = $(LDLIBS) -ldl -lrt -Wl,-soname,$(LIB_NAME).so.$(LIB_ABI_VERSION)
|
||||
LIB_LDLIBS = $(LDLIBS)
|
||||
|
||||
LIB_PKGS += libwebsockets openssl
|
||||
ifeq ($(shell uname),Linux)
|
||||
LIB_LDLIBS += -ldl -lrt -Wl,-soname,$(LIB_NAME).so.$(LIB_ABI_VERSION)
|
||||
endif
|
||||
|
||||
LIB_PKGS = libwebsockets openssl libcurl
|
||||
|
||||
######## Features ##########
|
||||
|
||||
ifeq ($(shell uname),Linux)
|
||||
CFLAGS += -DWITH_FPGA
|
||||
endif
|
||||
|
||||
######## Node-types ########
|
||||
|
||||
ifeq ($(shell uname),Linux)
|
||||
LIB_SRCS += $(addprefix lib/nodes/,file.c shmem.c signal.c)
|
||||
endif
|
||||
|
||||
# Enable Socket node type when libnl3 is available
|
||||
ifndef WITHOUT_SOCKET
|
||||
ifeq ($(shell $(PKGCONFIG) libnl-route-3.0; echo $$?),0)
|
||||
LIB_SRCS += $(addprefix lib/nodes/, socket.c)
|
||||
LIB_SRCS += $(addprefix lib/kernel/, nl.c tc.c if.c)
|
||||
LIB_SRCS += $(addprefix lib/, msg.c)
|
||||
LIB_PKGS += libnl-route-3.0
|
||||
endif
|
||||
|
||||
# libnl3 is optional but required for network emulation and IRQ pinning
|
||||
ifeq ($(shell $(PKGCONFIG) libnl-route-3.0; echo $$?),0)
|
||||
LIB_SRCS += $(addprefix lib/kernel/, nl.c tc.c if.c)
|
||||
LIB_PKGS += libnl-route-3.0
|
||||
endif
|
||||
endif
|
||||
|
||||
# Enable nanomsg node type when libnanomsg is available
|
||||
|
@ -73,6 +89,7 @@ endif
|
|||
|
||||
# Enable VILLASfpga support when libxil is available
|
||||
ifndef WITHOUT_FPGA
|
||||
ifeq ($(shell uname),Linux)
|
||||
ifeq ($(shell $(PKGCONFIG) libxil; echo $$?),0)
|
||||
LIB_SRCS += $(addprefix lib/nodes/, fpga.c) \
|
||||
$(addprefix lib/kernel/, pci.c vfio.c) \
|
||||
|
@ -82,14 +99,17 @@ ifeq ($(shell $(PKGCONFIG) libxil; echo $$?),0)
|
|||
LIB_PKGS += libxil
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Enable NGSI support
|
||||
ifndef WITHOUT_NGSI
|
||||
ifeq ($(shell uname),Linux)
|
||||
ifeq ($(shell $(PKGCONFIG) libcurl jansson; echo $$?),0)
|
||||
LIB_SRCS += lib/nodes/ngsi.c
|
||||
LIB_PKGS += libcurl jansson
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Enable WebSocket support
|
||||
ifeq ($(shell $(PKGCONFIG) libwebsockets jansson; echo $$?),0)
|
||||
|
@ -99,6 +119,7 @@ endif
|
|||
|
||||
# Enable OPAL-RT Asynchronous Process support (will result in 32bit binary!!!)
|
||||
ifdef WITH_OPAL
|
||||
ifeq ($(shell uname),Linux)
|
||||
ifneq ($(wildcard thirdparty/libopal/include/opal/AsyncApi.h),)
|
||||
LIB_OBJS += opal.o
|
||||
|
||||
|
@ -112,6 +133,7 @@ ifneq ($(wildcard thirdparty/libopal/include/opal/AsyncApi.h),)
|
|||
BUILDDIR := $(BUILDDIR)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Add flags by pkg-config
|
||||
LIB_LDLIBS += $(shell $(PKGCONFIG) --libs $(LIB_PKGS))
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "hook.h"
|
||||
#include "plugin.h"
|
||||
#include "sample.h"
|
||||
|
||||
struct convert {
|
||||
enum {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "plugin.h"
|
||||
#include "stats.h"
|
||||
#include "path.h"
|
||||
#include "sample.h"
|
||||
|
||||
struct drop {
|
||||
struct sample *prev;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "hook.h"
|
||||
#include "plugin.h"
|
||||
#include "timing.h"
|
||||
#include "sample.h"
|
||||
|
||||
int fix_ts_read(struct hook *h, struct sample *smps[], size_t *cnt)
|
||||
{
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "hook.h"
|
||||
#include "plugin.h"
|
||||
#include "timing.h"
|
||||
#include "sample.h"
|
||||
|
||||
#define CALC_GPS_NTP_DELAY 0 /* @todo move to global config file */
|
||||
#define GPS_NTP_DELAY_WIN_SIZE 16
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "list.h"
|
||||
#include "utils.h"
|
||||
#include "path.h"
|
||||
#include "sample.h"
|
||||
|
||||
struct map {
|
||||
struct mapping mapping;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "hook.h"
|
||||
#include "plugin.h"
|
||||
#include "path.h"
|
||||
#include "sample.h"
|
||||
|
||||
struct restart {
|
||||
struct sample *prev;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "hook.h"
|
||||
#include "plugin.h"
|
||||
#include "sample.h"
|
||||
|
||||
struct shift {
|
||||
int offset;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "hook.h"
|
||||
#include "plugin.h"
|
||||
#include "timing.h"
|
||||
#include "sample.h"
|
||||
|
||||
struct shift_ts {
|
||||
struct timespec offset;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "hook.h"
|
||||
#include "plugin.h"
|
||||
#include "timing.h"
|
||||
#include "sample.h"
|
||||
|
||||
struct skip_first {
|
||||
enum {
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include "stats.h"
|
||||
#include "path.h"
|
||||
#include "super_node.h"
|
||||
#include "sample.h"
|
||||
#include "node.h"
|
||||
|
||||
struct stats_send {
|
||||
struct node *dest;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "hook.h"
|
||||
#include "plugin.h"
|
||||
#include "timing.h"
|
||||
#include "sample.h"
|
||||
|
||||
static int ts_read(struct hook *h, struct sample *smps[], size_t *cnt)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -36,6 +35,17 @@
|
|||
#include "config.h"
|
||||
#include "kernel/kernel.h"
|
||||
|
||||
int kernel_get_cacheline_size()
|
||||
{
|
||||
#ifdef __linux__
|
||||
return sysconf(_SC_LEVEL1_ICACHE_LINESIZE);
|
||||
#else
|
||||
return 64; /** @todo fixme */
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
int kernel_module_set_param(const char *module, const char *param, const char *value)
|
||||
{
|
||||
FILE *f;
|
||||
|
@ -154,11 +164,6 @@ out:
|
|||
return -1; /* not found or error */
|
||||
}
|
||||
|
||||
int kernel_get_cacheline_size()
|
||||
{
|
||||
return sysconf(_SC_LEVEL1_ICACHE_LINESIZE);
|
||||
}
|
||||
|
||||
int kernel_get_page_size()
|
||||
{
|
||||
return sysconf(_SC_PAGESIZE);
|
||||
|
@ -273,3 +278,5 @@ int kernel_irq_setaffinity(unsigned irq, uintmax_t new, uintmax_t *old)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
|
|
@ -35,7 +35,7 @@ int rt_init(int priority, int affinity)
|
|||
info("Initialize real-time sub-system");
|
||||
|
||||
{ INDENT
|
||||
|
||||
#ifdef __linux__
|
||||
int is_rt;
|
||||
|
||||
/* Use FIFO scheduler with real time priority */
|
||||
|
@ -52,12 +52,16 @@ int rt_init(int priority, int affinity)
|
|||
rt_set_affinity(affinity);
|
||||
else
|
||||
warn("You might want to use the 'affinity' setting to pin VILLASnode to dedicate CPU cores");
|
||||
|
||||
#else
|
||||
warn("This platform is not optimized for real-time execution");
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
int rt_set_affinity(int affinity)
|
||||
{
|
||||
char isolcpus[255];
|
||||
|
@ -121,4 +125,6 @@ int rt_set_priority(int priority)
|
|||
int rt_is_preemptible()
|
||||
{
|
||||
return access(SYSFS_PATH "/kernel/realtime", R_OK);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
|
|
@ -231,7 +231,7 @@ int nanomsg_write(struct node *n, struct sample *smps[], unsigned cnt)
|
|||
|
||||
static struct plugin p = {
|
||||
.name = "nanomsg",
|
||||
.description = "scalability protocols library",
|
||||
.description = "scalability protocols library (libnanomsg)",
|
||||
.type = PLUGIN_TYPE_NODE,
|
||||
.node = {
|
||||
.vectorize = 0,
|
||||
|
|
|
@ -23,22 +23,31 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/ether.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <endian.h>
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <netinet/ether.h>
|
||||
#include <endian.h>
|
||||
#endif
|
||||
|
||||
#include "nodes/socket.h"
|
||||
#include "config.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "kernel/if.h"
|
||||
#include "kernel/nl.h"
|
||||
#include "kernel/tc.h"
|
||||
#ifdef WITH_LIBNL_ROUTE_30
|
||||
#include "kernel/if.h"
|
||||
#include "kernel/nl.h"
|
||||
#include "kernel/tc.h"
|
||||
|
||||
#define WITH_NETEM
|
||||
#endif /* WITH_LIBNL_ROUTE_30 */
|
||||
|
||||
#include "msg.h"
|
||||
#include "msg_format.h"
|
||||
#include "sample.h"
|
||||
#include "queue.h"
|
||||
#include "plugin.h"
|
||||
#include "compat.h"
|
||||
|
||||
/* Forward declartions */
|
||||
static struct plugin p;
|
||||
|
@ -48,6 +57,7 @@ struct list interfaces = { .state = STATE_DESTROYED };
|
|||
|
||||
int socket_init(struct super_node *sn)
|
||||
{
|
||||
#ifdef WITH_NETEM
|
||||
int ret;
|
||||
|
||||
nl_init(); /* Fill link cache */
|
||||
|
@ -94,12 +104,14 @@ found: list_push(&i->sockets, s);
|
|||
|
||||
if_start(i);
|
||||
}
|
||||
#endif /* WITH_NETEM */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int socket_deinit()
|
||||
{
|
||||
#ifdef WITH_NETEM
|
||||
for (size_t j = 0; j < list_length(&interfaces); j++) {
|
||||
struct interface *i = list_at(&interfaces, j);
|
||||
|
||||
|
@ -107,6 +119,7 @@ int socket_deinit()
|
|||
}
|
||||
|
||||
list_destroy(&interfaces, (dtor_cb_t) if_destroy, false);
|
||||
#endif /* WITH_NETEM */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -184,6 +197,7 @@ int socket_start(struct node *n)
|
|||
if (ntohs(s->local.sin.sin_port) != ntohs(s->remote.sin.sin_port))
|
||||
error("IP protocol numbers of local and remote must match!");
|
||||
}
|
||||
#ifdef __linux__
|
||||
else if (s->layer == SOCKET_LAYER_ETH) {
|
||||
if (ntohs(s->local.sll.sll_protocol) != ntohs(s->remote.sll.sll_protocol))
|
||||
error("Ethertypes of local and remote must match!");
|
||||
|
@ -191,12 +205,15 @@ int socket_start(struct node *n)
|
|||
if (ntohs(s->local.sll.sll_protocol) <= 0x5DC)
|
||||
error("Ethertype must be large than %d or it is interpreted as an IEEE802.3 length field!", 0x5DC);
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
|
||||
/* Create socket */
|
||||
switch (s->layer) {
|
||||
case SOCKET_LAYER_UDP: s->sd = socket(s->local.sa.sa_family, SOCK_DGRAM, IPPROTO_UDP); break;
|
||||
case SOCKET_LAYER_IP: s->sd = socket(s->local.sa.sa_family, SOCK_RAW, ntohs(s->local.sin.sin_port)); break;
|
||||
#ifdef __linux__
|
||||
case SOCKET_LAYER_ETH: s->sd = socket(s->local.sa.sa_family, SOCK_DGRAM, s->local.sll.sll_protocol); break;
|
||||
#endif /* __linux__ */
|
||||
default:
|
||||
error("Invalid socket type!");
|
||||
}
|
||||
|
@ -209,6 +226,7 @@ int socket_start(struct node *n)
|
|||
if (ret < 0)
|
||||
serror("Failed to bind socket");
|
||||
|
||||
#ifdef __linux__
|
||||
/* Set fwmark for outgoing packets if netem is enabled for this node */
|
||||
if (s->mark) {
|
||||
ret = setsockopt(s->sd, SOL_SOCKET, SO_MARK, &s->mark, sizeof(s->mark));
|
||||
|
@ -217,13 +235,14 @@ int socket_start(struct node *n)
|
|||
else
|
||||
debug(LOG_SOCKET | 4, "Set FW mark for socket (sd=%u) to %u", s->sd, s->mark);
|
||||
}
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
if (s->multicast.enabled) {
|
||||
ret = setsockopt(s->sd, IPPROTO_IP, IP_MULTICAST_LOOP, &s->multicast.loop, sizeof(s->multicast.loop));
|
||||
if (ret)
|
||||
serror("Failed to set multicast loop option");
|
||||
|
||||
ret = setsockopt(s->sd, IPPROTO_IP, IP_MULTICAST_TTL, &s->multicast.ttl, sizeof(s->multicast.ttl));
|
||||
ret = setsockopt(s->sd, IPPROTO_IP, IP_MULTICAST_TTL, &s->multicast.ttl, sizeof(s->multicast.ttl));
|
||||
if (ret)
|
||||
serror("Failed to set multicast ttl option");
|
||||
|
||||
|
@ -245,12 +264,16 @@ int socket_start(struct node *n)
|
|||
break;
|
||||
|
||||
default:
|
||||
#ifdef __linux__
|
||||
prio = SOCKET_PRIO;
|
||||
if (setsockopt(s->sd, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio)))
|
||||
serror("Failed to set socket priority");
|
||||
else
|
||||
debug(LOG_SOCKET | 4, "Set socket priority for node %s to %d", node_name(n), prio);
|
||||
break;
|
||||
#else
|
||||
{ }
|
||||
#endif /* __linux__ */
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -287,10 +310,12 @@ int socket_stop(struct node *n)
|
|||
|
||||
int socket_destroy(struct node *n)
|
||||
{
|
||||
#ifdef WITH_NETEM
|
||||
struct socket *s = n->_vd;
|
||||
|
||||
rtnl_qdisc_put(s->tc_qdisc);
|
||||
rtnl_cls_put(s->tc_classifier);
|
||||
#endif /* WITH_NETEM */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -538,7 +563,7 @@ int socket_write(struct node *n, struct sample *smps[], unsigned cnt)
|
|||
|
||||
int socket_parse(struct node *n, config_setting_t *cfg)
|
||||
{
|
||||
config_setting_t *cfg_netem, *cfg_multicast;
|
||||
config_setting_t *cfg_multicast;
|
||||
const char *local, *remote, *layer, *hdr, *endian;
|
||||
int ret;
|
||||
|
||||
|
@ -548,10 +573,12 @@ int socket_parse(struct node *n, config_setting_t *cfg)
|
|||
if (!config_setting_lookup_string(cfg, "layer", &layer))
|
||||
s->layer = SOCKET_LAYER_UDP;
|
||||
else {
|
||||
if (!strcmp(layer, "eth"))
|
||||
s->layer = SOCKET_LAYER_ETH;
|
||||
else if (!strcmp(layer, "ip"))
|
||||
if (!strcmp(layer, "ip"))
|
||||
s->layer = SOCKET_LAYER_IP;
|
||||
#ifdef __linux__
|
||||
else if (!strcmp(layer, "eth"))
|
||||
s->layer = SOCKET_LAYER_ETH;
|
||||
#endif /*__linux__ */
|
||||
else if (!strcmp(layer, "udp"))
|
||||
s->layer = SOCKET_LAYER_UDP;
|
||||
else
|
||||
|
@ -644,6 +671,9 @@ int socket_parse(struct node *n, config_setting_t *cfg)
|
|||
s->multicast.ttl = ttl;
|
||||
}
|
||||
|
||||
#ifdef WITH_NETEM
|
||||
config_setting_t *cfg_netem;
|
||||
|
||||
cfg_netem = config_setting_get_member(cfg, "netem");
|
||||
if (cfg_netem) {
|
||||
int enabled = 1;
|
||||
|
@ -654,6 +684,7 @@ int socket_parse(struct node *n, config_setting_t *cfg)
|
|||
}
|
||||
else
|
||||
s->tc_qdisc = NULL;
|
||||
#endif /* WITH_NETEM */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -673,11 +704,13 @@ char * socket_print_addr(struct sockaddr *saddr)
|
|||
inet_ntop(AF_INET, &sa->sin.sin_addr, buf, 64);
|
||||
break;
|
||||
|
||||
#ifdef __linux__
|
||||
case AF_PACKET:
|
||||
strcatf(&buf, "%02x", sa->sll.sll_addr[0]);
|
||||
for (int i = 1; i < sa->sll.sll_halen; i++)
|
||||
strcatf(&buf, ":%02x", sa->sll.sll_addr[i]);
|
||||
break;
|
||||
#endif /* __linux__ */
|
||||
|
||||
default:
|
||||
error("Unknown address family: '%u'", sa->sa.sa_family);
|
||||
|
@ -690,6 +723,7 @@ char * socket_print_addr(struct sockaddr *saddr)
|
|||
strcatf(&buf, ":%hu", ntohs(sa->sin.sin_port));
|
||||
break;
|
||||
|
||||
#ifdef __linux__
|
||||
case AF_PACKET: {
|
||||
struct nl_cache *cache = nl_cache_mngt_require("route/link");
|
||||
struct rtnl_link *link = rtnl_link_get(cache, sa->sll.sll_ifindex);
|
||||
|
@ -700,6 +734,7 @@ char * socket_print_addr(struct sockaddr *saddr)
|
|||
strcatf(&buf, ":%hu", ntohs(sa->sll.sll_protocol));
|
||||
break;
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
}
|
||||
|
||||
return buf;
|
||||
|
@ -713,6 +748,7 @@ int socket_parse_addr(const char *addr, struct sockaddr *saddr, enum socket_laye
|
|||
char *copy = strdup(addr);
|
||||
int ret;
|
||||
|
||||
#ifdef __linux__
|
||||
if (layer == SOCKET_LAYER_ETH) { /* Format: "ab:cd:ef:12:34:56%ifname:protocol" */
|
||||
/* Split string */
|
||||
char *node = strtok(copy, "%");
|
||||
|
@ -741,6 +777,7 @@ int socket_parse_addr(const char *addr, struct sockaddr *saddr, enum socket_laye
|
|||
ret = 0;
|
||||
}
|
||||
else { /* Format: "192.168.0.10:12001" */
|
||||
#endif /* __linux__ */
|
||||
struct addrinfo hint = {
|
||||
.ai_flags = flags,
|
||||
.ai_family = AF_UNSPEC
|
||||
|
@ -785,8 +822,9 @@ int socket_parse_addr(const char *addr, struct sockaddr *saddr, enum socket_laye
|
|||
memcpy(sa, result->ai_addr, result->ai_addrlen);
|
||||
freeaddrinfo(result);
|
||||
}
|
||||
#ifdef __linux__
|
||||
}
|
||||
|
||||
#endif /* __linux__ */
|
||||
free(copy);
|
||||
|
||||
return ret;
|
||||
|
@ -817,6 +855,7 @@ int socket_compare_addr(struct sockaddr *x, struct sockaddr *y)
|
|||
|
||||
return memcmp(xu->sin6.sin6_addr.s6_addr, yu->sin6.sin6_addr.s6_addr, sizeof(xu->sin6.sin6_addr.s6_addr));
|
||||
|
||||
#ifdef __linux__
|
||||
case AF_PACKET:
|
||||
CMP(ntohs(xu->sll.sll_protocol), ntohs(yu->sll.sll_protocol));
|
||||
CMP(xu->sll.sll_ifindex, yu->sll.sll_ifindex);
|
||||
|
@ -825,7 +864,7 @@ int socket_compare_addr(struct sockaddr *x, struct sockaddr *y)
|
|||
|
||||
CMP(xu->sll.sll_halen, yu->sll.sll_halen);
|
||||
return memcmp(xu->sll.sll_addr, yu->sll.sll_addr, xu->sll.sll_halen);
|
||||
|
||||
#endif /* __linux__ */
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
@ -835,7 +874,7 @@ int socket_compare_addr(struct sockaddr *x, struct sockaddr *y)
|
|||
|
||||
static struct plugin p = {
|
||||
.name = "socket",
|
||||
.description = "BSD network sockets",
|
||||
.description = "BSD network sockets for Ethernet / IP / UDP (libnl3)",
|
||||
.type = PLUGIN_TYPE_NODE,
|
||||
.node = {
|
||||
.vectorize = 0,
|
||||
|
|
|
@ -471,7 +471,7 @@ fail:
|
|||
|
||||
static struct plugin p = {
|
||||
.name = "zeromq",
|
||||
.description = "ZeroMQ Distributed Messaging",
|
||||
.description = "ZeroMQ Distributed Messaging (libzmq)",
|
||||
.type = PLUGIN_TYPE_NODE,
|
||||
.node = {
|
||||
.vectorize = 0,
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "super_node.h"
|
||||
#include "memory.h"
|
||||
#include "stats.h"
|
||||
#include "node.h"
|
||||
|
||||
static void path_read(struct path *p)
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "plugin.h"
|
||||
|
||||
/** Global list of all known plugins */
|
||||
struct list plugins;
|
||||
struct list plugins = { .state = STATE_DESTROYED };
|
||||
|
||||
LIST_INIT_STATIC(&plugins)
|
||||
|
||||
|
|
|
@ -21,10 +21,11 @@
|
|||
*********************************************************************************/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/timerfd.h>
|
||||
|
||||
#include "timing.h"
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
int timerfd_create_rate(double rate)
|
||||
{
|
||||
int fd, ret;
|
||||
|
@ -69,6 +70,8 @@ uint64_t timerfd_wait_until(int fd, const struct timespec *until)
|
|||
return timerfd_wait(fd);
|
||||
}
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
struct timespec time_now()
|
||||
{
|
||||
struct timespec ts;
|
||||
|
|
|
@ -113,6 +113,8 @@ char * vstrcatf(char **dest, const char *fmt, va_list ap)
|
|||
return *dest;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
void cpuset_to_integer(cpu_set_t *cset, uintmax_t *set)
|
||||
{
|
||||
*set = 0;
|
||||
|
@ -231,6 +233,7 @@ char *cpulist_create(char *str, size_t len, cpu_set_t *set)
|
|||
|
||||
return str;
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
|
||||
void * alloc(size_t bytes)
|
||||
{
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
|
||||
#include <libconfig.h>
|
||||
#include <libwebsockets.h>
|
||||
|
||||
#include <linux/limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
#include <endian.h>
|
||||
#ifdef __MACH__
|
||||
#include "compat.h"
|
||||
#elif defined(__linux__)
|
||||
#include <endian.h>
|
||||
#endif
|
||||
|
||||
#include "webmsg.h"
|
||||
#include "webmsg_format.h"
|
||||
|
|
|
@ -113,10 +113,12 @@ int main(int argc, char *argv[])
|
|||
info("This is VILLASnode %s (built on %s, %s)", CLR_BLD(CLR_YEL(BUILDID)),
|
||||
CLR_BLD(CLR_MAG(__DATE__)), CLR_BLD(CLR_MAG(__TIME__)));
|
||||
|
||||
#ifdef __linux__
|
||||
/* Checks system requirements*/
|
||||
struct version kver, reqv = { KERNEL_VERSION_MAJ, KERNEL_VERSION_MIN };
|
||||
if (kernel_get_version(&kver) == 0 && version_cmp(&kver, &reqv) < 0)
|
||||
error("Your kernel version is to old: required >= %u.%u", KERNEL_VERSION_MAJ, KERNEL_VERSION_MIN);
|
||||
#endif /* __linux__ */
|
||||
|
||||
signals_init(quit);
|
||||
log_init(&sn.log, V, LOG_ALL);
|
||||
|
|
2
thirdparty/Makefile.inc
vendored
2
thirdparty/Makefile.inc
vendored
|
@ -46,7 +46,7 @@ $(DEPS_AUTOCONF): | $(BUILDDIR)/thirdparty/$$@/
|
|||
# Install & compile CMake based projects
|
||||
$(DEPS_CMAKE): | $(BUILDDIR)/thirdparty/$$@/
|
||||
cmake -DCMAKE_INSTALL_PREFIX:PATH=$(PREFIX) \
|
||||
-DCMAKE_INSTALL_LIBDIR=$(PREFIX)/lib64 -DLIB_SUFFIX=64 \
|
||||
-DCMAKE_INSTALL_LIBDIR=lib64 -DLIB_SUFFIX=64 \
|
||||
-H$(SRCDIR)/thirdparty/$@ \
|
||||
-B$(BUILDDIR)/thirdparty/$@ $(CMAKE_OPTS)
|
||||
make -C$(BUILDDIR)/thirdparty/$@
|
||||
|
|
Loading…
Add table
Reference in a new issue