1 /*
2  * SPDX-License-Identifier: ISC
3  *
4  * Copyright (c) 2019-2020 Todd C. Miller <Todd.Miller@sudo.ws>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef SUDO_LOGSRV_UTIL_H
20 #define SUDO_LOGSRV_UTIL_H
21 
22 #include <netinet/in.h>		/* for INET_ADDRSTRLEN and INET6_ADDRSTRLEN */
23 
24 /* Default ports to listen on */
25 #define DEFAULT_PORT		"30343"
26 #define DEFAULT_PORT_TLS	"30344"
27 
28 /* Maximum message size (2Mb) */
29 #define MESSAGE_SIZE_MAX	(2 * 1024 * 1024)
30 
31 struct peer_info {
32     const char *name;
33 #if defined(HAVE_STRUCT_IN6_ADDR)
34     char ipaddr[INET6_ADDRSTRLEN];
35 #else
36     char ipaddr[INET_ADDRSTRLEN];
37 #endif
38 };
39 
40 struct connection_buffer {
41     TAILQ_ENTRY(connection_buffer) entries;
42     uint8_t *data;
43     unsigned int size;
44     unsigned int len;
45     unsigned int off;
46 };
47 TAILQ_HEAD(connection_buffer_list, connection_buffer);
48 
49 /* logsrv_util.c */
50 struct iolog_file;
51 bool expand_buf(struct connection_buffer *buf, unsigned int needed);
52 bool iolog_open_all(int dfd, const char *iolog_dir, struct iolog_file *iolog_files, const char *mode);
53 bool iolog_seekto(int iolog_dir_fd, const char *iolog_path, struct iolog_file *iolog_files, struct timespec *elapsed_time, const struct timespec *target);
54 
55 
56 #endif /* SUDO_LOGSRV_UTIL_H */
57