From 809c4e0b2f4ced53f48b092f43b37c08eae18b75 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Sun, 12 Jul 2020 22:34:18 +0200 Subject: Move main.c to minecproxy.c for consistency and better debug msgs --- minecproxy/minecproxy.h | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 minecproxy/minecproxy.h (limited to 'minecproxy/minecproxy.h') 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 +#include + +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 -- cgit v1.2.3