1*72383174SJose Luis Duran /* $NetBSD: bl.h,v 1.2 2024/08/02 17:11:55 christos Exp $ */ 2*72383174SJose Luis Duran 3*72383174SJose Luis Duran /*- 4*72383174SJose Luis Duran * Copyright (c) 2014 The NetBSD Foundation, Inc. 5*72383174SJose Luis Duran * All rights reserved. 6*72383174SJose Luis Duran * 7*72383174SJose Luis Duran * This code is derived from software contributed to The NetBSD Foundation 8*72383174SJose Luis Duran * by Christos Zoulas. 9*72383174SJose Luis Duran * 10*72383174SJose Luis Duran * Redistribution and use in source and binary forms, with or without 11*72383174SJose Luis Duran * modification, are permitted provided that the following conditions 12*72383174SJose Luis Duran * are met: 13*72383174SJose Luis Duran * 1. Redistributions of source code must retain the above copyright 14*72383174SJose Luis Duran * notice, this list of conditions and the following disclaimer. 15*72383174SJose Luis Duran * 2. Redistributions in binary form must reproduce the above copyright 16*72383174SJose Luis Duran * notice, this list of conditions and the following disclaimer in the 17*72383174SJose Luis Duran * documentation and/or other materials provided with the distribution. 18*72383174SJose Luis Duran * 19*72383174SJose Luis Duran * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20*72383174SJose Luis Duran * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21*72383174SJose Luis Duran * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22*72383174SJose Luis Duran * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23*72383174SJose Luis Duran * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24*72383174SJose Luis Duran * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25*72383174SJose Luis Duran * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26*72383174SJose Luis Duran * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27*72383174SJose Luis Duran * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28*72383174SJose Luis Duran * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29*72383174SJose Luis Duran * POSSIBILITY OF SUCH DAMAGE. 30*72383174SJose Luis Duran */ 31*72383174SJose Luis Duran #ifndef _OLD_BL_H 32*72383174SJose Luis Duran #define _OLD_BL_H 33*72383174SJose Luis Duran 34*72383174SJose Luis Duran #include <stdbool.h> 35*72383174SJose Luis Duran #include <stdarg.h> 36*72383174SJose Luis Duran #include <sys/param.h> 37*72383174SJose Luis Duran #include <sys/socket.h> 38*72383174SJose Luis Duran #include "blacklist.h" 39*72383174SJose Luis Duran 40*72383174SJose Luis Duran typedef enum { 41*72383174SJose Luis Duran BL_INVALID, 42*72383174SJose Luis Duran BL_ADD, 43*72383174SJose Luis Duran BL_DELETE, 44*72383174SJose Luis Duran BL_ABUSE, 45*72383174SJose Luis Duran BL_BADUSER 46*72383174SJose Luis Duran } bl_type_t; 47*72383174SJose Luis Duran 48*72383174SJose Luis Duran typedef struct { 49*72383174SJose Luis Duran bl_type_t bi_type; 50*72383174SJose Luis Duran int bi_fd; 51*72383174SJose Luis Duran uid_t bi_uid; 52*72383174SJose Luis Duran gid_t bi_gid; 53*72383174SJose Luis Duran socklen_t bi_slen; 54*72383174SJose Luis Duran struct sockaddr_storage bi_ss; 55*72383174SJose Luis Duran char bi_msg[1024]; 56*72383174SJose Luis Duran } bl_info_t; 57*72383174SJose Luis Duran 58*72383174SJose Luis Duran #define bi_cred bi_u._bi_cred 59*72383174SJose Luis Duran 60*72383174SJose Luis Duran /* We want the new name */ 61*72383174SJose Luis Duran #ifndef _PATH_BLSOCK 62*72383174SJose Luis Duran #define _PATH_BLSOCK "/var/run/blocklistd.sock" 63*72383174SJose Luis Duran #endif 64*72383174SJose Luis Duran 65*72383174SJose Luis Duran __BEGIN_DECLS 66*72383174SJose Luis Duran 67*72383174SJose Luis Duran typedef struct blacklist *bl_t; 68*72383174SJose Luis Duran 69*72383174SJose Luis Duran bl_t bl_create(bool, const char *, 70*72383174SJose Luis Duran void (*)(int, struct syslog_data *, const char *, va_list)); 71*72383174SJose Luis Duran void bl_destroy(bl_t); 72*72383174SJose Luis Duran int bl_send(bl_t, bl_type_t, int, const struct sockaddr *, socklen_t, 73*72383174SJose Luis Duran const char *); 74*72383174SJose Luis Duran int bl_getfd(bl_t); 75*72383174SJose Luis Duran bl_info_t *bl_recv(bl_t); 76*72383174SJose Luis Duran bool bl_isconnected(bl_t); 77*72383174SJose Luis Duran 78*72383174SJose Luis Duran __END_DECLS 79*72383174SJose Luis Duran 80*72383174SJose Luis Duran #endif /* _OLD_BL_H */ 81