1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-23 00:00:01 +01:00
VILLASnode/include/villas/nodes/socket.hpp

76 lines
1.9 KiB
C++
Raw Normal View History

2020-01-21 14:20:49 +01:00
/** The socket node-type for Layer 2, 3, 4 BSD-style sockets
*
* @file
* @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-02-16 09:04:12 -03:00
#pragma once
#include <villas/node/config.hpp>
#include <villas/socket_addr.hpp>
2021-05-10 00:12:30 +02:00
#include <villas/format.hpp>
namespace villas {
namespace node {
2021-06-21 16:11:42 -04:00
/* Forward declarations */
class NodeCompat;
2021-06-21 16:11:42 -04:00
/** The maximum length of a packet which contains stuct msg. */
#define SOCKET_INITIAL_BUFFER_LEN (64*1024)
struct Socket {
2018-06-29 08:37:14 +02:00
int sd; /**< The socket descriptor */
int verify_source; /**< Verify the source address of incoming packets against socket::remote. */
2019-06-23 16:13:23 +02:00
enum SocketLayer layer; /**< The OSI / IP layer which should be used for this socket */
Format *formatter;
/* Multicast options */
struct multicast {
2018-06-29 08:37:14 +02:00
int enabled; /**< Is multicast enabled? */
unsigned char loop; /** Loopback multicast packets to local host? */
unsigned char ttl; /**< The time to live for multicast packets. */
struct ip_mreq mreq; /**< A multicast group to join. */
} multicast;
struct {
char *buf; /**< Buffer for receiving messages */
size_t buflen;
union sockaddr_union saddr; /**< Remote address of the socket */
} in, out;
};
int socket_type_start(SuperNode *sn);
int socket_type_stop();
int socket_init(NodeCompat *n);
int socket_destroy(NodeCompat *n);
int socket_start(NodeCompat *n);
int socket_check(NodeCompat *n);
int socket_stop(NodeCompat *n);
int socket_reverse(NodeCompat *n);
int socket_fds(NodeCompat *n, int fds[]);
int socket_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
int socket_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
int socket_parse(NodeCompat *n, json_t *json);
char * socket_print(NodeCompat *n);
} // namespace node
} // namespace villas