1 /*- 2 * SSLsplit - transparent SSL/TLS interception 3 * https://www.roe.ch/SSLsplit 4 * 5 * Copyright (c) 2009-2019, Daniel Roethlisberger <daniel@roe.ch>. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are met: 10 * 1. Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef LOGBUF_H 30 #define LOGBUF_H 31 32 #include "attrib.h" 33 34 #include <stdlib.h> 35 #include <unistd.h> 36 37 typedef struct logbuf { 38 int prio; 39 unsigned char *buf; 40 ssize_t sz; 41 void *fh; 42 unsigned long ctl; 43 struct logbuf *next; 44 } logbuf_t; 45 46 typedef ssize_t (*writefunc_t)(int, void *, unsigned long, const void *, size_t); 47 48 logbuf_t * logbuf_new(int, void *, size_t, logbuf_t *) MALLOC; 49 logbuf_t * logbuf_new_alloc(size_t, logbuf_t *) MALLOC; 50 logbuf_t * logbuf_new_copy(const void *, size_t, logbuf_t *) MALLOC; 51 logbuf_t * logbuf_new_printf(logbuf_t *, const char *, ...) MALLOC PRINTF(2,3); 52 logbuf_t * logbuf_new_deepcopy(logbuf_t *, int) MALLOC; 53 logbuf_t * logbuf_make_contiguous(logbuf_t *) WUNRES; 54 ssize_t logbuf_size(logbuf_t *) NONNULL(1) WUNRES; 55 ssize_t logbuf_write_free(logbuf_t *, writefunc_t) NONNULL(1); 56 void logbuf_free(logbuf_t *) NONNULL(1); 57 58 #define logbuf_ctl_clear(x) (x)->ctl = 0 59 #define logbuf_ctl_set(x, y) (x)->ctl |= (y) 60 #define logbuf_ctl_unset(x, y) (x)->ctl &= ~(y) 61 #define logbuf_ctl_isset(x, y) (!!((x)->ctl & (y))) 62 63 #define LBFLAG_REOPEN (1 << 0) /* logger */ 64 #define LBFLAG_OPEN (1 << 1) /* logger */ 65 #define LBFLAG_CLOSE (1 << 2) /* logger */ 66 #define LBFLAG_IS_REQ (1 << 3) /* pcap/mirror content log */ 67 #define LBFLAG_IS_RESP (1 << 4) /* pcap/mirror content log */ 68 69 #endif /* !LOGBUF_H */ 70 71 /* vim: set noet ft=c: */ 72