/* SPDX-License-Identifier: GPL-2.0 */ #ifndef foomainhfoo #define foomainhfoo #include #include struct cfg; struct uring_task; #include "misc.h" #include "shared/utils.h" extern struct cfg *cfg; extern bool exiting; /* enum debug_lvl { DBG_ERROR = (0x1 << 1), DBG_INFO = (0x1 << 2), DBG_VERBOSE = (0x1 << 3), DBG_CFG = (0x1 << 4), DBG_REF = (0x1 << 5), DBG_MALLOC = (0x1 << 6), DBG_ANN = (0x1 << 7), DBG_SIG = (0x1 << 8), DBG_UR = (0x1 << 9), DBG_SRV = (0x1 << 10), DBG_PROXY = (0x1 << 11), DBG_RCON = (0x1 << 12), DBG_IDLE = (0x1 << 13), DBG_IGMP = (0x1 << 14), DBG_SYSD = (0x1 << 15), DBG_DNS = (0x1 << 16), DBG_TIMER = (0x1 << 17), }; */ 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 */ uid_t uid; gid_t gid; const char *cfg_dir; const char *cfg_file; 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