summaryrefslogtreecommitdiff
path: root/minecproxy/minecproxy.h
diff options
context:
space:
mode:
Diffstat (limited to 'minecproxy/minecproxy.h')
-rw-r--r--minecproxy/minecproxy.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/minecproxy/minecproxy.h b/minecproxy/minecproxy.h
new file mode 100644
index 0000000..adb82c6
--- /dev/null
+++ b/minecproxy/minecproxy.h
@@ -0,0 +1,88 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef foominecproxyhfoo
+#define foominecproxyhfoo
+
+#include <sys/socket.h>
+#include <netinet/ip.h>
+
+struct cfg;
+struct uring_task;
+
+#include "misc.h"
+#include "shared/utils.h"
+
+extern struct cfg *cfg;
+extern bool exiting;
+
+void dump_tree();
+
+/* To save typing in all the function definitions below */
+typedef void (*utask_cb_t)(struct uring_task *, int res);
+typedef int (*rutask_cb_t)(struct uring_task *, int res);
+
+struct uring_task_buf {
+ char buf[4096];
+ size_t len;
+ size_t done;
+ struct iovec iov;
+ struct msghdr msg;
+};
+
+struct uring_task {
+ const char *name;
+ int refcount; /* signed to catch refcount bugs */
+ int fd;
+ struct uring_task *parent;
+ void (*free)(struct uring_task *);
+ bool dead;
+ struct uring_task_buf *tbuf;
+
+ /* called once or repeatedly until is_complete_cb is satisfied */
+ utask_cb_t cb;
+
+ /* returns: 0 = not complete; < 0 = error; > 0 = complete */
+ rutask_cb_t is_complete_cb;
+
+ /* called once tbuf processing is done */
+ utask_cb_t final_cb;
+
+ /* used for recvmsg/sendmsg */
+ struct saddr saddr;
+ void *priv;
+};
+
+struct cfg {
+ /* Options */
+ const char *cfg_path;
+ char *cfg_real_path;
+ DIR *cfg_dir;
+ const char *data_path;
+ char *data_real_path;
+ DIR *data_dir;
+ uid_t uid;
+ gid_t gid;
+ bool do_igmp;
+ char *igmp_iface;
+ bool splice_supported;
+ uint16_t announce_interval;
+ uint16_t proxy_connection_interval;
+ uint16_t proxy_connection_attempts;
+ bool socket_defer;
+ bool socket_freebind;
+ bool socket_keepalive;
+ bool socket_iptos;
+ bool socket_nodelay;
+
+ /* Bookkeeping */
+ struct uring_ev *uring;
+ struct server_cfg_monitor *server_cfg_monitor;
+ struct signal_ev *signal;
+ struct announce *announce;
+ struct ptimer *ptimer;
+ struct igmp *igmp;
+ struct idle *idle;
+ struct uring_task task;
+ struct list_head servers;
+};
+
+#endif