2017-10-16 09:40:27 +02:00
|
|
|
/** Node type: amqp
|
|
|
|
*
|
|
|
|
* @file
|
2022-12-14 17:41:58 +01:00
|
|
|
* @author Steffen Vogel <post@steffenvogel.de>
|
2022-03-15 09:28:57 -04:00
|
|
|
* @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC
|
2022-07-04 18:20:03 +02:00
|
|
|
* @license Apache 2.0
|
2017-10-16 09:40:27 +02:00
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-06-21 15:36:10 +02:00
|
|
|
#include <villas/node/config.hpp>
|
|
|
|
|
|
|
|
#ifdef RABBITMQ_C_NEW_INCLUDE_DIR
|
|
|
|
#include <rabbitmq-c/amqp.h>
|
|
|
|
#else
|
2017-10-16 09:40:27 +02:00
|
|
|
#include <amqp.h>
|
2023-06-21 15:36:10 +02:00
|
|
|
#endif
|
2017-10-16 09:40:27 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
#include <villas/list.hpp>
|
2021-05-10 00:12:30 +02:00
|
|
|
#include <villas/format.hpp>
|
2017-10-16 09:40:27 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
|
|
|
|
2021-06-21 16:11:42 -04:00
|
|
|
/* Forward declarations */
|
2021-08-10 10:12:48 -04:00
|
|
|
class NodeCompat;
|
2021-06-21 16:11:42 -04:00
|
|
|
|
2017-11-18 01:05:18 +01:00
|
|
|
struct amqp_ssl_info {
|
|
|
|
int verify_peer;
|
|
|
|
int verify_hostname;
|
|
|
|
char *ca_cert;
|
|
|
|
char *client_cert;
|
|
|
|
char *client_key;
|
|
|
|
};
|
2017-10-16 09:40:27 +02:00
|
|
|
|
2017-11-18 01:05:18 +01:00
|
|
|
struct amqp {
|
|
|
|
char *uri;
|
2017-10-16 09:40:27 +02:00
|
|
|
|
2017-11-18 01:05:18 +01:00
|
|
|
struct amqp_connection_info connection_info;
|
|
|
|
struct amqp_ssl_info ssl_info;
|
2017-10-16 09:40:27 +02:00
|
|
|
|
2017-11-18 01:05:18 +01:00
|
|
|
amqp_bytes_t routing_key;
|
|
|
|
amqp_bytes_t exchange;
|
2017-10-16 09:40:27 +02:00
|
|
|
|
2017-11-18 01:05:18 +01:00
|
|
|
/* We need to create two connection because rabbitmq-c is not thread-safe! */
|
|
|
|
amqp_connection_state_t producer;
|
|
|
|
amqp_connection_state_t consumer;
|
2017-10-16 09:40:27 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
Format *formatter;
|
2017-10-16 09:40:27 +02:00
|
|
|
};
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
char * amqp_print(NodeCompat *n);
|
|
|
|
|
|
|
|
int amqp_parse(NodeCompat *n, json_t *json);
|
|
|
|
|
|
|
|
int amqp_start(NodeCompat *n);
|
|
|
|
|
|
|
|
int amqp_init(NodeCompat *n);
|
2017-10-16 09:40:27 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int amqp_destroy(NodeCompat *n);
|
2017-10-16 09:40:27 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int amqp_poll_fds(NodeCompat *n, int fds[]);
|
2017-10-16 09:40:27 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int amqp_stop(NodeCompat *n);
|
2017-10-16 09:40:27 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int amqp_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
2017-10-16 09:40:27 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int amqp_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
2017-10-16 09:40:27 +02:00
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|