#ifndef AVREMU_IPC_H_ #define AVREMU_IPC_H_ #include "util.h" #include /* The sender side of an IPC connection. */ struct ipc_tx { /* Filedescriptor for the transmit side of the message pipe. */ int message_pipe; /* Filedescriptor for the result message pipe. */ int result_pipe; }; /* The receiver side of an IPC connection. */ struct ipc_rx { /* Filedescriptor for the receive side of the message pipe. */ int message_pipe; /* Filedescriptor for the result message pipe. */ int result_pipe; }; /* Type of a message result code. */ typedef uint16_t ipc_result_t; /* Type of a message size descriptor. */ typedef uint16_t ipc_size_t; /* Create a communication pipe. */ int ipc_pipe_create(struct ipc_tx *tx, struct ipc_rx *rx); void ipc_pipe_destroy_tx(struct ipc_tx *tx); void ipc_pipe_destroy_rx(struct ipc_rx *rx); void ipc_pipe_destroy(struct ipc_tx *tx, struct ipc_rx *rx); /* Map a given file descriptor to an IPC pipe. */ int ipc_dup2(struct ipc_tx *tx, int fd); /* Send a message through the IPC pipe. * The result (if requested) is returned as a positive number. * If an IPC error occured, a negative number is returned. */ int ipc_message_send(struct ipc_tx *tx, const void *message, ipc_size_t msg_size, bool read_result); /* Poll a message pipe to receive the next message. */ int ipc_message_poll(struct ipc_rx *rx, void *message_buf, ipc_size_t buf_size); /* Poll a raw line of data from the pipe. */ int ipc_raw_line_poll(struct ipc_rx *rx, char *line_buf, size_t buf_size); /* Send the result for a message. */ int ipc_send_result(struct ipc_rx *rx, ipc_result_t result_code); /* Payload data transmission. */ int ipc_payload_send(struct ipc_tx *tx, const void *buf, size_t size); int ipc_payload_receive(struct ipc_rx *rx, void *buf, size_t size); #endif /* AVREMU_IPC_H_ */