2 .\" Copyright (c) 2000 Alfred Perlstein
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
16 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 .Nm accept_filt_generic_mod_event ,
37 .Nd filter incoming connections
42 .Fd #define ACCEPT_FILTER_MOD
45 .Fn accept_filt_add "struct accept_filter *filt"
47 .Fn accept_filt_del "char *name"
49 .Fn accept_filt_generic_mod_event "module_t mod" "int event" "void *data"
50 .Ft struct accept_filter *
51 .Fn accept_filt_get "char *name"
53 Accept filters allow an application to request
54 that the kernel pre-process incoming connections.
55 An accept filter is requested via the
57 system call, passing in an
61 .Sh IMPLEMENTATION NOTES
62 A module that wants to be an accept filter
63 must provide a struct accept_filter to the system:
65 struct accept_filter {
67 void (*accf_callback)(struct socket *so, void *arg, int waitflag);
68 void * (*accf_create)(struct socket *so, char *arg);
69 void (*accf_destroy)(struct socket *so);
70 SLIST_ENTRY(accept_filter) accf_next; /* next on the list */
74 The module should register it with the function
76 passing a pointer to a struct accept_filter, allocated with
80 .Fa struct accept_filter
82 .Bl -tag -width accf_callbackXXX
85 this is how it will be accessed from userland.
87 The callback that the kernel will do
88 once the connection is established.
89 It is the same as a socket upcall
90 and will be called when the connection is established
91 and whenever new data arrives on the socket,
92 unless the callback modifies the socket's flags.
96 installs the filter onto
99 Called whenever the user removes the accept filter on the socket.
103 passed the same string used in accept_filter.accf_name during registration
105 .Fn accept_filt_add ,
106 the kernel will then disallow and further userland use of the filter.
109 is used internally to locate which accept filter to use via the
113 .Fn accept_filt_generic_mod_event
114 provides a simple way to avoid duplicate
115 code for accept filters which don't use
116 argument field to load and unload
117 themselves. It is a function that can be
118 put in the load/unload struct
128 The accept filter mechanism was introduced in
131 This manual page was written by
132 .An Alfred Perlstein ,
133 Sheldon Hearn and Jeroen Ruigrok van der Werven.
134 The accept filter concept was pioneered by David Filo at Yahoo!
135 and refined to be a loadable module system by Alfred Perlstein.