1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#ifndef AVREMU_IPC_H_
#define AVREMU_IPC_H_
#include "util.h"
#include <unistd.h>
/* 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_ */
|