2018-10-03 21:52:11 +02:00
|
|
|
#ifndef __IPC_MSG_H__
|
|
|
|
#define __IPC_MSG_H__
|
2016-12-21 01:26:47 +01:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2016-12-23 13:06:31 +01:00
|
|
|
#define MSG_TYPE_CLOSE 0
|
2016-12-23 01:33:52 +01:00
|
|
|
#define MSG_TYPE_CON 1
|
2016-12-23 13:06:31 +01:00
|
|
|
#define MSG_TYPE_ERR 2
|
|
|
|
#define MSG_TYPE_ACK 3
|
|
|
|
#define MSG_TYPE_DATA 4
|
2016-12-21 01:26:47 +01:00
|
|
|
|
2018-10-03 22:02:37 +02:00
|
|
|
struct ipc_message {
|
2016-12-21 01:26:47 +01:00
|
|
|
char type;
|
2016-12-22 21:48:35 +01:00
|
|
|
unsigned short valsize;
|
2016-12-21 01:26:47 +01:00
|
|
|
char *val;
|
|
|
|
};
|
|
|
|
|
|
|
|
// used to create msg structure from buffer
|
2018-10-03 22:02:37 +02:00
|
|
|
int ipc_message_format_read (struct ipc_message *m, const char *buf, size_t msize);
|
2016-12-21 01:26:47 +01:00
|
|
|
// used to create buffer from msg structure
|
2018-10-03 22:02:37 +02:00
|
|
|
int ipc_message_format_write (const struct ipc_message *m, char **buf, size_t *msize);
|
2016-12-21 01:26:47 +01:00
|
|
|
|
|
|
|
// read a structure msg from fd
|
2018-10-03 22:02:37 +02:00
|
|
|
int ipc_message_read (int fd, struct ipc_message *m);
|
2016-12-21 01:26:47 +01:00
|
|
|
// write a structure msg to fd
|
2018-10-03 22:02:37 +02:00
|
|
|
int ipc_message_write (int fd, const struct ipc_message *m);
|
2016-12-21 01:26:47 +01:00
|
|
|
|
2018-10-03 22:02:37 +02:00
|
|
|
int ipc_message_format_con (struct ipc_message *m, const char *val, size_t valsize);
|
|
|
|
int ipc_message_format_data (struct ipc_message *m, const char *val, size_t valsize);
|
|
|
|
int ipc_message_format_ack (struct ipc_message *m, const char *val, size_t valsize);
|
2016-12-21 01:26:47 +01:00
|
|
|
|
2018-10-03 22:02:37 +02:00
|
|
|
int ipc_message_free (struct ipc_message *m);
|
|
|
|
void ipc_message_print (const struct ipc_message *m);
|
2016-12-21 01:26:47 +01:00
|
|
|
|
|
|
|
#endif
|