/*1* SPDX-License-Identifier: ISC2*3* Copyright (c) 2019-2020 Todd C. Miller <[email protected]>4*5* Permission to use, copy, modify, and distribute this software for any6* purpose with or without fee is hereby granted, provided that the above7* copyright notice and this permission notice appear in all copies.8*9* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES10* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF11* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR12* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES13* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN14* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF15* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.16*/1718#ifndef SUDO_LOGSRV_UTIL_H19#define SUDO_LOGSRV_UTIL_H2021#include <netinet/in.h> /* for INET_ADDRSTRLEN and INET6_ADDRSTRLEN */2223#ifndef INET_ADDRSTRLEN24# define INET_ADDRSTRLEN 1625#endif26#ifndef INET6_ADDRSTRLEN27# define INET6_ADDRSTRLEN 4628#endif2930/* Default ports to listen on */31#define DEFAULT_PORT "30343"32#define DEFAULT_PORT_TLS "30344"3334/* Maximum message size (2Mb) */35#define MESSAGE_SIZE_MAX (2 * 1024 * 1024)3637struct peer_info {38const char *name;39#if defined(HAVE_STRUCT_IN6_ADDR)40char ipaddr[INET6_ADDRSTRLEN];41#else42char ipaddr[INET_ADDRSTRLEN];43#endif44};4546struct connection_buffer {47TAILQ_ENTRY(connection_buffer) entries;48uint8_t *data;49size_t size;50size_t len;51size_t off;52};53TAILQ_HEAD(connection_buffer_list, connection_buffer);5455/* dotdot.c */56bool contains_dot_dot(const char *str);5758/* logsrv_util.c */59struct iolog_file;60bool expand_buf(struct connection_buffer *buf, size_t needed);61bool iolog_open_all(int dfd, const char *iolog_dir, struct iolog_file *iolog_files, const char *mode);62bool iolog_seekto(int iolog_dir_fd, const char *iolog_path, struct iolog_file *iolog_files, struct timespec *elapsed_time, const struct timespec *target);636465#endif /* SUDO_LOGSRV_UTIL_H */666768