|
|
|
#ifndef NODE_H_
|
|
|
|
#define NODE_H_
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
// Node structure
|
|
|
|
typedef struct node_t node_t;
|
|
|
|
// and handle type
|
|
|
|
typedef node_t *node_handle_t;
|
|
|
|
|
|
|
|
typedef enum node_status { NODE_INITIALIAZED, NODE_PRESENT, NODE_GONE } node_status;
|
|
|
|
|
|
|
|
// Initializes a node structure and returns the node handle.
|
|
|
|
node_handle_t node_init(address_t addr, node_id_t id);
|
|
|
|
|
|
|
|
// Frees a node structure.
|
|
|
|
void node_free(node_handle_t node);
|
|
|
|
|
|
|
|
// Adds an event timestamp to the node.
|
|
|
|
void node_add_timestamp(node_handle_t node, timestamp_t timestamp, bool visible);
|
|
|
|
|
|
|
|
// Returns the address of the node
|
|
|
|
address_t node_get_addr(node_handle_t node);
|
|
|
|
|
|
|
|
// Returns the id of the node
|
|
|
|
node_id_t node_get_id(node_handle_t node);
|
|
|
|
|
|
|
|
// Returns the latest node status.
|
|
|
|
node_status node_get_status(node_handle_t node);
|
|
|
|
|
|
|
|
// Returns the current communication socket id of the node
|
|
|
|
int node_get_comm_socket(node_handle_t node);
|
|
|
|
|
|
|
|
// Sets the current communication socket id of the node
|
|
|
|
void node_set_comm_socket(node_handle_t node, int comm_socket);
|
|
|
|
|
|
|
|
// Returns the event tables for this node.
|
|
|
|
uint16_t node_get_events(node_handle_t node, timestamp_t **events_timestamps, node_status **events_status);
|
|
|
|
|
|
|
|
//TODO node save thingy
|
|
|
|
|
|
|
|
#endif //NODE_H_
|