1*0a6a1f1dSLionel Sambuc.\" $NetBSD: libblacklist.3,v 1.3 2015/01/25 23:09:28 wiz Exp $ 2*0a6a1f1dSLionel Sambuc.\" 3*0a6a1f1dSLionel Sambuc.\" Copyright (c) 2015 The NetBSD Foundation, Inc. 4*0a6a1f1dSLionel Sambuc.\" All rights reserved. 5*0a6a1f1dSLionel Sambuc.\" 6*0a6a1f1dSLionel Sambuc.\" This code is derived from software contributed to The NetBSD Foundation 7*0a6a1f1dSLionel Sambuc.\" by Christos Zoulas. 8*0a6a1f1dSLionel Sambuc.\" 9*0a6a1f1dSLionel Sambuc.\" Redistribution and use in source and binary forms, with or without 10*0a6a1f1dSLionel Sambuc.\" modification, are permitted provided that the following conditions 11*0a6a1f1dSLionel Sambuc.\" are met: 12*0a6a1f1dSLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright 13*0a6a1f1dSLionel Sambuc.\" notice, this list of conditions and the following disclaimer. 14*0a6a1f1dSLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright 15*0a6a1f1dSLionel Sambuc.\" notice, this list of conditions and the following disclaimer in the 16*0a6a1f1dSLionel Sambuc.\" documentation and/or other materials provided with the distribution. 17*0a6a1f1dSLionel Sambuc.\" 18*0a6a1f1dSLionel Sambuc.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19*0a6a1f1dSLionel Sambuc.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20*0a6a1f1dSLionel Sambuc.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21*0a6a1f1dSLionel Sambuc.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22*0a6a1f1dSLionel Sambuc.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*0a6a1f1dSLionel Sambuc.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*0a6a1f1dSLionel Sambuc.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*0a6a1f1dSLionel Sambuc.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*0a6a1f1dSLionel Sambuc.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*0a6a1f1dSLionel Sambuc.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*0a6a1f1dSLionel Sambuc.\" POSSIBILITY OF SUCH DAMAGE. 29*0a6a1f1dSLionel Sambuc.\" 30*0a6a1f1dSLionel Sambuc.Dd January 22, 2015 31*0a6a1f1dSLionel Sambuc.Dt LIBBLACKLIST 3 32*0a6a1f1dSLionel Sambuc.Os 33*0a6a1f1dSLionel Sambuc.Sh NAME 34*0a6a1f1dSLionel Sambuc.Nm blacklist_open , 35*0a6a1f1dSLionel Sambuc.Nm blacklist_close , 36*0a6a1f1dSLionel Sambuc.Nm blacklist_r , 37*0a6a1f1dSLionel Sambuc.Nm blacklist , 38*0a6a1f1dSLionel Sambuc.Nm blacklist_sa 39*0a6a1f1dSLionel Sambuc.Nm blacklist_sa_r , 40*0a6a1f1dSLionel Sambuc.Nd Blacklistd notification library 41*0a6a1f1dSLionel Sambuc.Sh LIBRARY 42*0a6a1f1dSLionel Sambuc.Lb libblacklist 43*0a6a1f1dSLionel Sambuc.Sh SYNOPSIS 44*0a6a1f1dSLionel Sambuc.In blacklist.h 45*0a6a1f1dSLionel Sambuc.Ft struct blacklist * 46*0a6a1f1dSLionel Sambuc.Fn blacklist_open "void" 47*0a6a1f1dSLionel Sambuc.Ft void 48*0a6a1f1dSLionel Sambuc.Fn blacklist_close "struct blacklist *cookie" 49*0a6a1f1dSLionel Sambuc.Ft int 50*0a6a1f1dSLionel Sambuc.Fn blacklist "int action" "int fd" "const char *msg" 51*0a6a1f1dSLionel Sambuc.Ft int 52*0a6a1f1dSLionel Sambuc.Fn blacklist_r "struct blacklist *cookie" "int action" "int fd" "const char *msg" 53*0a6a1f1dSLionel Sambuc.Ft int 54*0a6a1f1dSLionel Sambuc.Fn blacklist_sa "int action" "int fd" "const struct sockaddr *sa" "socklen_t salen" "const char *msg" 55*0a6a1f1dSLionel Sambuc.Ft int 56*0a6a1f1dSLionel Sambuc.Fn blacklist_sa_r "struct blacklist *cookie" "int action" "int fd" "const struct sockaddr *sa" "socklen_t salen" "const char *msg" 57*0a6a1f1dSLionel Sambuc.Sh DESCRIPTION 58*0a6a1f1dSLionel SambucThese functions can be used by daemons to notify 59*0a6a1f1dSLionel Sambuc.Xr blacklistd 8 60*0a6a1f1dSLionel Sambucabout successful and failed remote connections so that blacklistd can 61*0a6a1f1dSLionel Sambucblock or release port access to prevent Denial of Service attacks. 62*0a6a1f1dSLionel Sambuc.Pp 63*0a6a1f1dSLionel SambucThe function 64*0a6a1f1dSLionel Sambuc.Fn blacklist_open 65*0a6a1f1dSLionel Sambuccreates a the necessary state to communicate with 66*0a6a1f1dSLionel Sambuc.Xr blacklistd 8 67*0a6a1f1dSLionel Sambucand returns a pointer to it, or 68*0a6a1f1dSLionel Sambuc.Dv NULL 69*0a6a1f1dSLionel Sambucon failure. 70*0a6a1f1dSLionel Sambuc.Pp 71*0a6a1f1dSLionel SambucThe 72*0a6a1f1dSLionel Sambuc.Fn blacklist_close 73*0a6a1f1dSLionel Sambucfunction frees all memory and resources used. 74*0a6a1f1dSLionel Sambuc.Pp 75*0a6a1f1dSLionel SambucThe 76*0a6a1f1dSLionel Sambuc.Fn blacklist 77*0a6a1f1dSLionel Sambucfunction sends a message to 78*0a6a1f1dSLionel Sambuc.Xr blacklistd 8 , 79*0a6a1f1dSLionel Sambucwith an 80*0a6a1f1dSLionel Sambuc.Ar action 81*0a6a1f1dSLionel Sambucargument specifying 82*0a6a1f1dSLionel Sambuc.Dv 1 83*0a6a1f1dSLionel Sambucfor a failed connection or 84*0a6a1f1dSLionel Sambuc.Dv 0 85*0a6a1f1dSLionel Sambucfor a successful connection, 86*0a6a1f1dSLionel Sambuca file descriptor 87*0a6a1f1dSLionel Sambuc.Ar fd 88*0a6a1f1dSLionel Sambucspecifying the accepted file descriptor connected to the client, 89*0a6a1f1dSLionel Sambucand an optional message in the 90*0a6a1f1dSLionel Sambuc.Ar msg 91*0a6a1f1dSLionel Sambucargument. 92*0a6a1f1dSLionel Sambuc.Pp 93*0a6a1f1dSLionel SambucThe 94*0a6a1f1dSLionel Sambuc.Fn blacklist_r 95*0a6a1f1dSLionel Sambucfunction is more efficient because it keeps the blacklist state around. 96*0a6a1f1dSLionel Sambuc.Pp 97*0a6a1f1dSLionel SambucThe 98*0a6a1f1dSLionel Sambuc.Fn blacklist_sa 99*0a6a1f1dSLionel Sambucand 100*0a6a1f1dSLionel Sambuc.Fn blacklist_sa_r 101*0a6a1f1dSLionel Sambucfunctions can be used with unconnected sockets, where 102*0a6a1f1dSLionel Sambuc.Xr getpeername 2 103*0a6a1f1dSLionel Sambucwill not work, the server will pass the peer name in the message. 104*0a6a1f1dSLionel Sambuc.Pp 105*0a6a1f1dSLionel SambucAll functions log errors to 106*0a6a1f1dSLionel Sambuc.Xr syslogd 8 . 107*0a6a1f1dSLionel Sambuc.Sh RETURN VALUES 108*0a6a1f1dSLionel SambucThe function 109*0a6a1f1dSLionel Sambuc.Fn bl_open 110*0a6a1f1dSLionel Sambucreturns a cookie on success and 111*0a6a1f1dSLionel Sambuc.Dv NULL 112*0a6a1f1dSLionel Sambucon failure setting errno to an appropriate value. 113*0a6a1f1dSLionel Sambuc.Pp 114*0a6a1f1dSLionel SambucThe 115*0a6a1f1dSLionel Sambuc.Fn bl_send 116*0a6a1f1dSLionel Sambucfunction returns 117*0a6a1f1dSLionel Sambuc.Dv 0 118*0a6a1f1dSLionel Sambucon success and 119*0a6a1f1dSLionel Sambuc.Dv -1 120*0a6a1f1dSLionel Sambucon failure setting errno to an appropriate value. 121*0a6a1f1dSLionel Sambuc.Sh SEE ALSO 122*0a6a1f1dSLionel Sambuc.Xr blacklistd.conf 5 , 123*0a6a1f1dSLionel Sambuc.Xr blacklistd 8 124*0a6a1f1dSLionel Sambuc.Sh AUTHORS 125*0a6a1f1dSLionel Sambuc.An Christos Zoulas 126