summaryrefslogtreecommitdiff
path: root/draft/mcastseed/src/dgrambuf.h
diff options
context:
space:
mode:
Diffstat (limited to 'draft/mcastseed/src/dgrambuf.h')
-rw-r--r--draft/mcastseed/src/dgrambuf.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/draft/mcastseed/src/dgrambuf.h b/draft/mcastseed/src/dgrambuf.h
new file mode 100644
index 0000000..a83647b
--- /dev/null
+++ b/draft/mcastseed/src/dgrambuf.h
@@ -0,0 +1,41 @@
+#ifndef DGRAMBUF_H
+#define DGRAMBUF_H
+/*
+ * dgrambuf.c - C datagrams buffer.
+ *
+ * Copyright 2016 by Ludovic Pouzenc <ludovic@pouzenc.fr>
+ */
+#include <stdlib.h> /* size_t */
+
+#define DGRAMBUF_RECV_OVERWRITE 1 << 1
+#define DGRAMBUF_RECV_EINTR 1 << 2
+#define DGRAMBUF_RECV_IOVEC_FULL 1 << 3
+#define DGRAMBUF_RECV_FINALIZE 1 << 4
+#define DGRAMBUF_RECV_FUTURE_DGRAM 1 << 5
+#define DGRAMBUF_RECV_DUPLICATE_DGRAM 1 << 6
+#define DGRAMBUF_RECV_VALID_DGRAM 1 << 6
+
+#define DGRAMBUF_WRITE_PARTIAL 1 << 1
+#define DGRAMBUF_WRITE_EWOULDBLOCK_OR_EINTR 1 << 2
+#define DGRAMBUF_WRITE_IOVEC_FULL 1 << 3
+#define DGRAMBUF_WRITE_SUCCESS 1 << 4
+
+typedef struct dgrambuf_t *dgrambuf_t;
+
+dgrambuf_t dgrambuf_new(size_t dgram_slots, size_t dgram_max_size, size_t dgram_header_size, size_t iovec_slots);
+void dgrambuf_free(dgrambuf_t *);
+
+void dgrambuf_set_validate_func(dgrambuf_t dbuf, int (*validate_func)(unsigned int, void *, unsigned int *));
+
+size_t dgrambuf_get_free_count(const dgrambuf_t);
+size_t dgrambuf_get_used_count(const dgrambuf_t);
+int dgrambuf_have_data_ready_to_write(const dgrambuf_t);
+int dgrambuf_have_received_everything(const dgrambuf_t);
+
+int dgrambuf_stats(dgrambuf_t dbuf, char **allocated_string);
+
+/* Warning : dgrambuf_recvmmsg sets and restore SIGALRM handler if timeout != 0 */
+ssize_t dgrambuf_recvmmsg(dgrambuf_t dbuf, int sockfd, int timeout, int *info);
+ssize_t dgrambuf_write(dgrambuf_t dbuf, int fd, int *info);
+
+#endif /* DGRAMBUF_H */