1301169Slidl/* $NetBSD: bl.h,v 1.13 2016/03/11 17:16:40 christos Exp $ */ 2301169Slidl 3301169Slidl/*- 4301169Slidl * Copyright (c) 2014 The NetBSD Foundation, Inc. 5301169Slidl * All rights reserved. 6301169Slidl * 7301169Slidl * This code is derived from software contributed to The NetBSD Foundation 8301169Slidl * by Christos Zoulas. 9301169Slidl * 10301169Slidl * Redistribution and use in source and binary forms, with or without 11301169Slidl * modification, are permitted provided that the following conditions 12301169Slidl * are met: 13301169Slidl * 1. Redistributions of source code must retain the above copyright 14301169Slidl * notice, this list of conditions and the following disclaimer. 15301169Slidl * 2. Redistributions in binary form must reproduce the above copyright 16301169Slidl * notice, this list of conditions and the following disclaimer in the 17301169Slidl * documentation and/or other materials provided with the distribution. 18301169Slidl * 19301169Slidl * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20301169Slidl * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21301169Slidl * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22301169Slidl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23301169Slidl * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24301169Slidl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25301169Slidl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26301169Slidl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27301169Slidl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28301169Slidl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29301169Slidl * POSSIBILITY OF SUCH DAMAGE. 30301169Slidl */ 31301169Slidl#ifndef _BL_H 32301169Slidl#define _BL_H 33301169Slidl 34301169Slidl#include <stdbool.h> 35301169Slidl#include <stdarg.h> 36301169Slidl#include <sys/param.h> 37301169Slidl#include <sys/socket.h> 38301169Slidl#include "blacklist.h" 39301169Slidl 40301169Slidltypedef enum { 41301169Slidl BL_INVALID, 42301169Slidl BL_ADD, 43318950Slidl BL_DELETE, 44318950Slidl BL_ABUSE, 45318950Slidl BL_BADUSER 46301169Slidl} bl_type_t; 47301169Slidl 48301169Slidltypedef struct { 49301169Slidl bl_type_t bi_type; 50301169Slidl int bi_fd; 51301169Slidl uid_t bi_uid; 52301169Slidl gid_t bi_gid; 53301169Slidl socklen_t bi_slen; 54301169Slidl struct sockaddr_storage bi_ss; 55301169Slidl char bi_msg[1024]; 56301169Slidl} bl_info_t; 57301169Slidl 58301169Slidl#define bi_cred bi_u._bi_cred 59301169Slidl 60301169Slidl#ifndef _PATH_BLSOCK 61301169Slidl#define _PATH_BLSOCK "/var/run/blacklistd.sock" 62301169Slidl#endif 63301169Slidl 64301169Slidl__BEGIN_DECLS 65301169Slidl 66301169Slidltypedef struct blacklist *bl_t; 67301169Slidl 68301169Slidlbl_t bl_create(bool, const char *, void (*)(int, const char *, va_list)); 69301169Slidlvoid bl_destroy(bl_t); 70301169Slidlint bl_send(bl_t, bl_type_t, int, const struct sockaddr *, socklen_t, 71301169Slidl const char *); 72301169Slidlint bl_getfd(bl_t); 73301169Slidlbl_info_t *bl_recv(bl_t); 74301169Slidlbool bl_isconnected(bl_t); 75301169Slidl 76301169Slidl__END_DECLS 77301169Slidl 78301169Slidl#endif /* _BL_H */ 79