diff --git a/server/include/if.h b/server/include/if.h index cca9b5e03..931f20234 100644 --- a/server/include/if.h +++ b/server/include/if.h @@ -20,7 +20,7 @@ #define IF_IRQ_MAX 3 /**< Maxmimal number of IRQs of an interface */ #ifndef SO_MARK -#define SO_MARK 36 /**< Workaround: add missing constant for OPAL-RT Redhawk target */ + #define SO_MARK 36 /**< Workaround: add missing constant for OPAL-RT Redhawk target */ #endif struct socket; diff --git a/server/include/msg_format.h b/server/include/msg_format.h index 40c21453b..c3c188721 100644 --- a/server/include/msg_format.h +++ b/server/include/msg_format.h @@ -14,7 +14,7 @@ #define _BSD_SOURCE 1 #include #elif defined(__PPC__) /* Xilinx toolchain */ - #include + #include #endif #include "config.h" @@ -30,8 +30,8 @@ #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_ENDIAN_LITTLE 0 /**< Message values are in little endian format (float too!) */ -#define MSG_ENDIAN_BIG 1 /**< Message values are in bit endian format */ +#define MSG_ENDIAN_LITTLE 0 /**< Message values are in little endian format (float too!) */ +#define MSG_ENDIAN_BIG 1 /**< Message values are in bit endian format */ #if BYTE_ORDER == LITTLE_ENDIAN #define MSG_ENDIAN_HOST MSG_ENDIAN_LITTLE diff --git a/server/include/node.h b/server/include/node.h index 60a65241e..fe5ac91c9 100644 --- a/server/include/node.h +++ b/server/include/node.h @@ -133,7 +133,7 @@ struct node * node_lookup_name(const char *str, struct list *nodes); * This is usefull for the helper programs: send, receive, test * because they usually use the same configuration file as the * server and therefore the direction needs to be swapped. */ -int node_reverse(struct node *n); +void node_reverse(struct node *n); /** Create a node by allocating dynamic memory. */ struct node * node_create(); diff --git a/server/src/cfg.c b/server/src/cfg.c index 1e4a0474c..6a3cf53ba 100644 --- a/server/src/cfg.c +++ b/server/src/cfg.c @@ -243,19 +243,14 @@ int config_parse_node(config_setting_t *cfg, struct list *nodes) if (!n->name) cerror(cfg, "Missing node name"); - if (config_setting_lookup_string(cfg, "type", &type)) { - n->vt = node_lookup_vtable(type); - if (!n->vt) - cerror(cfg, "Invalid type for node '%s'", n->name); - - if (!n->vt->parse) - cerror(cfg, "Node type '%s' is not allowed in the config", type); - } - else - n->vt = node_lookup_vtable("udp"); + if (!config_setting_lookup_string(cfg, "type", &type)) + cerror(cfg, "Missing node name"); + + n->vt = node_lookup_vtable(type); + if (!n->vt) + cerror(cfg, "Invalid type for node '%s'", n->name); ret = n->vt->parse(cfg, n); - if (!ret) list_push(nodes, n); @@ -273,7 +268,7 @@ int config_parse_opal(config_setting_t *cfg, struct node *n) return -1; } - struct opal *o = (struct opal *) alloc(sizeof(struct opal)); + struct opal *o = alloc(sizeof(struct opal)); config_setting_lookup_int(cfg, "send_id", &o->send_id); config_setting_lookup_int(cfg, "recv_id", &o->recv_id); @@ -334,7 +329,7 @@ int config_parse_socket(config_setting_t *cfg, struct node *n) /** @todo Netem settings are not usable AF_UNIX */ config_setting_t *cfg_netem = config_setting_get_member(cfg, "netem"); if (cfg_netem) { - s->netem = (struct netem *) alloc(sizeof(struct netem)); + s->netem = alloc(sizeof(struct netem)); config_parse_netem(cfg_netem, s->netem); } diff --git a/server/src/hooks.c b/server/src/hooks.c index 3f5072e25..637328ce9 100644 --- a/server/src/hooks.c +++ b/server/src/hooks.c @@ -71,7 +71,7 @@ int hook_log(struct msg *m, struct path *p) if (file) debug(5, "Opened log file for path %s: %s", pstr, fstr); - pthread_key_create(&pkey, (void (*)(void *)) fclose); + pthread_key_create(&pkey, (dtor_cb_t) fclose); pthread_setspecific(pkey, file); } @@ -128,7 +128,6 @@ int hook_fir(struct msg *m, struct path *p) /* Create thread local storage for circular history buffer */ if (!history) { history = alloc(len * sizeof(float)); - pthread_key_create(&pkey, free); pthread_setspecific(pkey, history); } diff --git a/server/src/if.c b/server/src/if.c index 6d341d41f..64e7caf27 100644 --- a/server/src/if.c +++ b/server/src/if.c @@ -60,6 +60,7 @@ int if_start(struct interface *i, int affinity) int mark = 0; FOREACH(&i->sockets, it) { struct socket *s = it->socket; + if (s->netem) { s->mark = 1 + mark++; @@ -88,7 +89,7 @@ int if_start(struct interface *i, int affinity) int if_stop(struct interface *i) { INDENT - info("Stopping interface '%s'", i->name); + info("Stopping interface '%s'", i->name); { INDENT if_setaffinity(i, -1L); diff --git a/server/src/node.c b/server/src/node.c index e6252cb9d..2a6e71db4 100644 --- a/server/src/node.c +++ b/server/src/node.c @@ -60,7 +60,7 @@ struct node_vtable const * node_lookup_vtable(const char *str) } int node_start(struct node *n) -{ +{ INDENT if (!n->refcnt) { warn("Node '%s' is unused. Skipping...", n->name); return -1; @@ -98,7 +98,7 @@ int node_start_defer(struct node *n) } int node_stop(struct node *n) -{ +{ INDENT int ret; info("Stopping node '%s'", n->name); @@ -109,7 +109,7 @@ int node_stop(struct node *n) return ret; } -int node_reverse(struct node *n) +void node_reverse(struct node *n) { switch (n->vt->type) { case IEEE_802_3: @@ -120,7 +120,7 @@ int node_reverse(struct node *n) break; default: { } } - return n->vt->open == socket_open; +} struct node * node_create() { diff --git a/server/src/opal.c b/server/src/opal.c index 24bc21d10..11da0d17c 100644 --- a/server/src/opal.c +++ b/server/src/opal.c @@ -22,7 +22,7 @@ int opal_init(int argc, char *argv[]) if (argc != 4) return -1; - struct opal_global *g = (struct opal_global *) alloc(sizeof(struct opal_global)); + struct opal_global *g = alloc(sizeof(struct opal_global)); pthread_mutex_init(&g->lock, NULL); diff --git a/server/src/path.c b/server/src/path.c index 19f39c6b7..7a2a29b33 100644 --- a/server/src/path.c +++ b/server/src/path.c @@ -16,7 +16,9 @@ #include "utils.h" #include "path.h" -#define sigev_notify_thread_id _sigev_un._tid +#ifndef sigev_notify_thread_id + #define sigev_notify_thread_id _sigev_un._tid +#endif /** Linked list of paths. */ struct list paths; diff --git a/server/src/random.c b/server/src/random.c index 7e3849cd6..9350e4f2d 100644 --- a/server/src/random.c +++ b/server/src/random.c @@ -22,7 +22,7 @@ void tick(int sig, siginfo_t *si, void *ptr) { - struct msg *m = (struct msg*) si->si_value.sival_ptr; + struct msg *m = (struct msg *) si->si_value.sival_ptr; msg_random(m); msg_fprint(stdout, m); diff --git a/server/src/server.c b/server/src/server.c index 0b56b5d3e..ce0d7e3b2 100644 --- a/server/src/server.c +++ b/server/src/server.c @@ -150,16 +150,17 @@ int main(int argc, char *argv[]) info("Setup signals:"); signals_init(); + info("Parsing configuration:"); config_init(&config); #ifdef ENABLE_OPAL_ASYNC - /* Check if called as asynchronous process from RT-LAB */ + /* Check if called we are called as an asynchronous process from RT-LAB. */ opal_init(argc, argv); - + + /* @todo: look in predefined locations for a file */ char *configfile = "opal-shmem.conf"; #else - char *configfile = argv[1]; #endif diff --git a/server/src/socket.c b/server/src/socket.c index 9b6f8fd68..3e4fc85d6 100644 --- a/server/src/socket.c +++ b/server/src/socket.c @@ -34,8 +34,8 @@ int socket_print(struct node *n, char *buf, int len) char local[INET6_ADDRSTRLEN + 16]; char remote[INET6_ADDRSTRLEN + 16]; - socket_print_addr(local, sizeof(local), (struct sockaddr*) &s->local); - socket_print_addr(remote, sizeof(remote), (struct sockaddr*) &s->remote); + socket_print_addr(local, sizeof(local), (struct sockaddr *) &s->local); + socket_print_addr(remote, sizeof(remote), (struct sockaddr *) &s->remote); return snprintf(buf, len, "local=%s, remote=%s", local, remote); }