14 #define MAX_RECV_BUF_LEN 64
25 log_error(
"Error reading from fd %d!", fd);
34 log_error(
"Error setting message key to %d",
id);
44 log_error(
"Error enqueing to baremetal MSU");
50 #define BAREMETAL_EPOLL_TIMEOUT 1000
51 #define BAREMETAL_EPOLL_BATCH 1000
67 log_error(
"Error exiting socket handler main loop");
74 #define INIT_SYNTAX "<PORT> <N_HOPS>"
78 if (static_self != NULL) {
79 log_error(
"Baremental Socket MSU already instantiated. There can be only one!");
85 if ((str = strtok_r(init,
" ", &saveptr)) == NULL) {
91 if ((str = strtok_r(NULL,
" ", &saveptr)) == NULL) {
99 log_error(
"Couldn't initialize socket for baremetal sock MSU %d", self->id);
105 log_error(
"Couldn't initialize epoll_Fd for baremetal sock MSU %d", self->id);
117 .
name =
"baremetal_sock_msu",
Interface for general-purpose socket communication.
Macro for declaring functions or variables as unused to avoid compiler warnings.
Wrapper functions for epoll to manage event-based communication.
int init_call_msu_type(struct local_msu *sender, struct msu_type *dst_type, struct msu_msg_key *key, size_t data_size, void *data)
Sends an MSU message to a destination of the specified type.
int set_msg_key(int32_t id, struct msu_msg_key *key)
Sets the key's ID and composite-ID to be equal to the provided id.
Logging of status messages to the terminal.
Interactions with global dfg from individual runtime.
Declares the methods available for calling an MSU from another MSU.
int init_epoll(int socket_fd)
Initializes a new instance of an epoll file descriptor and adds a socket to it, listening for input o...
#define log_error(fmt,...)
Declares the structures and functions applicable to MSUs on the local machine.
The structure that represents an MSU located on the local machine.
Data with which an MSU is initialized, and the payload for messages of type CTRL_CREATE_MSU.
int init_call_local_msu(struct local_msu *sender, struct local_msu *dest, struct msu_msg_key *key, size_t data_size, void *data)
Enqueues a new message in the queue of a local MSU.
int epoll_loop(int socket_fd, int epoll_fd, int batch_size, int timeout, bool oneshot, int(*connection_handler)(int, void *), int(*accept_handler)(int, void *), void *data)
The event-based loop for epoll_wait.
int init_listening_socket(int port)
Initializes a socket which is bound to and listening on the given port.
A message that is to be delivered to an instance of an MSU.
char * name
Name for the msu type.
Used to uniquely identify the source of a message, used in state storage as well as routing...