diff --git a/server/include/config.h b/server/include/config.h index 0afaa36ee..9dc96f0f9 100644 --- a/server/include/config.h +++ b/server/include/config.h @@ -65,14 +65,10 @@ /** Global configuration */ struct settings { - /** Process priority (lower is better) */ - int priority; - /** Process affinity of the server and all created threads */ - int affinity; - /** Debug log level */ - int debug; - /** Interval for path statistics. Set to 0 to disable themo disable them. */ - double stats; + int priority; /**< Process priority (lower is better) */ + int affinity; /**< Process affinity of the server and all created threads */ + int debug; /**< Debug log level */ + double stats; /**< Interval for path statistics. Set to 0 to disable themo disable them. */ }; #endif /* _CONFIG_H_ */ diff --git a/server/include/gtfpga.h b/server/include/gtfpga.h index fe20a4192..9f3ce908e 100644 --- a/server/include/gtfpga.h +++ b/server/include/gtfpga.h @@ -38,9 +38,7 @@ struct gtfpga { int fd_mmap; /**< File descriptor for the memory mapped PCI BAR */ void *map; - /* The following descriptor is blocking as long no interrupt was received - * or the timer has not elapsed */ - int fd_irq; /**< File descriptor for the timer */ + int fd_irq; /**< File descriptor for the timer. This is blocking when read(2) until a new IRQ / timer expiration. */ char *name; double rate; diff --git a/server/include/hist.h b/server/include/hist.h index 1f117b088..5c2894d89 100644 --- a/server/include/hist.h +++ b/server/include/hist.h @@ -21,36 +21,24 @@ typedef unsigned hist_cnt_t; /** Histogram structure used to collect statistics. */ struct hist { - /** The distance between two adjacent buckets. */ - double resolution; + double resolution; /**< The distance between two adjacent buckets. */ - /** The value of the highest bucket. */ - double high; - /** The value of the lowest bucket. */ - double low; + double high; /**< The value of the highest bucket. */ + double low; /**< The value of the lowest bucket. */ - /** The highest value observed (may be higher than #high). */ - double highest; - /** The lowest value observed (may be lower than #low). */ - double lowest; - /** The last value which has been put into the buckets */ - double last; + 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 */ - /** The number of buckets in #data. */ - int length; + int length; /**< The number of buckets in #data. */ - /** Total number of counted values. */ - hist_cnt_t total; - /** The number of values which are higher than #high. */ - hist_cnt_t higher; - /** The number of values which are lower than #low. */ - hist_cnt_t lower; + hist_cnt_t total; /**< Total number of counted values. */ + 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. */ - /** Pointer to dynamically allocated array of size length. */ - hist_cnt_t *data; + hist_cnt_t *data; /**< Pointer to dynamically allocated array of size length. */ - /** Private variables for online variance calculation */ - double _m[2], _s[2]; + double _m[2], _s[2]; /**< Private variables for online variance calculation */ }; /** Initialize struct hist with supplied values and allocate memory for buckets. */ diff --git a/server/include/if.h b/server/include/if.h index f76daba68..7901867bd 100644 --- a/server/include/if.h +++ b/server/include/if.h @@ -30,16 +30,12 @@ struct rtnl_link; /** Interface data structure */ struct interface { - /** libnl3: Handle of interface */ - struct rtnl_link *nl_link; - /** libnl3: Root prio qdisc */ - struct rtnl_qdisc *tc_qdisc; + struct rtnl_link *nl_link; /**< libnl3: Handle of interface. */ + struct rtnl_qdisc *tc_qdisc; /**< libnl3: Root priority queuing discipline (qdisc). */ - /** List of IRQs of the NIC */ - char irqs[IF_IRQ_MAX]; + char irqs[IF_IRQ_MAX]; /**< List of IRQs of the NIC. */ - /** Linked list of associated sockets */ - struct list sockets; + struct list sockets; /**< Linked list of associated sockets. */ }; /** Add a new interface to the global list and lookup name, irqs... diff --git a/server/include/ngsi.h b/server/include/ngsi.h index 52e321bd3..dd64cc0c0 100644 --- a/server/include/ngsi.h +++ b/server/include/ngsi.h @@ -33,33 +33,29 @@ struct node; struct ngsi { - /** The NGSI context broker endpoint URL. */ - const char *endpoint; - /** An optional authentication token which will be sent as HTTP header. */ - const char *token; + const char *endpoint; /**< The NGSI context broker endpoint URL. */ + const char *token; /**< An optional authentication token which will be sent as HTTP header. */ + + double timeout; /**< HTTP timeout in seconds */ + + int ssl_verify; /**< Boolean flag whether SSL server certificates should be verified or not. */ - /** HTTP timeout in seconds */ - double timeout; - /** Boolean flag whether SSL server certificates should be verified or not. */ - int ssl_verify; - /** Structure of published entitites */ enum ngsi_structure { NGSI_FLAT, NGSI_CHILDREN - } structure; + } structure; /**< Structure of published entitites */ - /** List of HTTP request headers for libcurl */ - struct curl_slist *headers; - /** libcurl handle */ - CURL *curl; - /** The complete JSON tree which will be used for contextUpdate requests */ - json_t *context; /** A mapping between indices of the S2SS messages and the attributes in ngsi::context */ json_t **context_map; /** The number of mappings in ngsi::context_map */ int context_len; + struct curl_slist *headers; /**< List of HTTP request headers for libcurl */ + + CURL *curl; /**< libcurl: handle */ + + json_t *context; /**< The complete JSON tree which will be used for contextUpdate requests */ }; /** Initialize global NGSI settings and maps shared memory regions. diff --git a/server/include/node.h b/server/include/node.h index a2e5dbf5e..82cc1306b 100644 --- a/server/include/node.h +++ b/server/include/node.h @@ -130,10 +130,28 @@ struct node_type { */ int (*write)(struct node *n, struct msg *pool, int poolsize, int first, int cnt); + /** Global initialization per node type. + * + * This callback is invoked once per node-type. + * + * @param argc Number of arguments passed to the server executable (see main()). + * @param argv Array of arguments passed to the server executable (see main()). + * @param set Global settings. + * @retval 0 Success. Everything went well. + * @retval <0 Error. Something went wrong. + */ int (*init)(int argc, char *argv[], struct settings *set); + + /** Global de-initialization per node type. + * + * This callback is invoked once per node-type. + * + * @retval 0 Success. Everything went well. + * @retval <0 Error. Something went wrong. + */ int (*deinit)(); - int refcnt; + int refcnt; /**< Reference counter: how many nodes are using this node-type? */ }; /** The data structure for a node. @@ -143,28 +161,22 @@ struct node_type { */ struct node { - /** A short identifier of the node, only used for configuration and logging */ - char *name; - /** How many paths are sending / receiving from this node? */ - int refcnt; - /** Number of messages to send / recv at once (scatter / gather) */ - int combine; - /** CPU Affinity of this node */ - int affinity; + char *name; /**< A short identifier of the node, only used for configuration and logging */ + int refcnt; /**< How many paths are sending / receiving from this node? */ + int combine; /**< Number of messages to send / recv at once (scatter / gather) */ + int affinity; /**< CPU Affinity of this node */ + + struct node_type *vt; /**< C++ like virtual function call table */ - /** C++ like virtual function call table */ - struct node_type * vt; - /** Virtual data (used by vtable functions) */ union { struct socket *socket; struct opal *opal; struct gtfpga *gtfpga; struct file *file; struct ngsi *ngsi; - }; + }; /** Virtual data (used by vtable functions) */ - /** A pointer to the libconfig object which instantiated this node */ - config_setting_t *cfg; + config_setting_t *cfg; /**< A pointer to the libconfig object which instantiated this node */ }; /** Initialize node type subsystems. diff --git a/server/src/server.c b/server/src/server.c index b835169ed..8eeeeacab 100644 --- a/server/src/server.c +++ b/server/src/server.c @@ -25,14 +25,10 @@ #include "opal.h" #endif -/** Linked list of nodes */ -struct list nodes; -/** Linked list of paths */ -struct list paths; -/** The global configuration */ -struct settings settings; -/** libconfig handle */ -static config_t config; +struct list nodes; /**< Linked list of nodes */ +struct list paths; /**< Linked list of paths */ +struct settings settings; /**< The global configuration */ +static config_t config; /**< libconfig handle */ static void quit() {