2 .\" Copyright (C) 2001 Chad David <davidc@acns.ab.ca>. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice(s), this list of conditions and the following disclaimer as
9 .\" the first lines of this file unmodified other than the possible
10 .\" addition of one or more copyright notices.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice(s), 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 COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
16 .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 .\" DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
19 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 .\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
40 .Nd "network domain management"
47 .Fn domain_add "void *data"
49 .Fn pfctlinput "int cmd" "struct sockaddr *sa"
51 .Fn pfctlinput2 "int cmd" "struct sockaddr *sa" "void *ctlparam"
53 .Fn pffinddomain "int family"
55 .Fn pffindproto "int family" "int protocol" "int type"
57 .Fn pffindtype "int family" "int type"
61 Network protocols installed in the system are maintained within what
69 int dom_family; /* AF_xxx */
71 void (*dom_init) /* initialize domain data structures */
73 void (*dom_destroy) /* cleanup structures / state */
75 int (*dom_externalize) /* externalize access rights */
76 (struct mbuf *, struct mbuf **);
77 void (*dom_dispose) /* dispose of internalized rights */
79 struct protosw *dom_protosw, *dom_protoswNPROTOSW;
80 struct domain *dom_next;
81 int (*dom_rtattach) /* initialize routing table */
83 int (*dom_rtdetach) /* clean up routing table */
85 void *(*dom_ifattach)(struct ifnet *);
86 void (*dom_ifdetach)(struct ifnet *, void *);
87 int (*dom_ifmtu)(struct ifnet *);
88 /* af-dependent data on ifnet */
92 Each domain contains an array of protocol switch structures
93 .Pq Vt "struct protosw *" ,
94 one for each socket type supported.
97 short pr_type; /* socket type used for */
98 struct domain *pr_domain; /* domain protocol a member of */
99 short pr_protocol; /* protocol number */
100 short pr_flags; /* see below */
101 /* protocol-protocol hooks */
102 pr_input_t *pr_input; /* input to protocol (from below) */
103 pr_output_t *pr_output; /* output to protocol (from above) */
104 pr_ctlinput_t *pr_ctlinput; /* control input (from below) */
105 pr_ctloutput_t *pr_ctloutput; /* control output (from above) */
108 pr_fasttimo_t *pr_fasttimo; /* fast timeout (200ms) */
109 pr_slowtimo_t *pr_slowtimo; /* slow timeout (500ms) */
110 pr_drain_t *pr_drain; /* flush any excess space possible */
112 struct pr_usrreqs *pr_usrreqs; /* user-protocol hook */
116 The following functions handle the registration of a new domain,
117 lookups of specific protocols and protocol types within those domains,
118 and handle control messages from the system.
121 is called by the system whenever an event occurs that could affect every
123 Examples of those types of events are routing table changes, interface
129 calls the protocol specific
131 function for each protocol in that has defined one, in every domain.
134 provides that same functionality of
136 but with a few additional checks and a new
138 argument that is passed directly to the protocol's
148 and that only the protocol families that are the same as
155 adds a new protocol domain to the system.
159 .Vt "struct domain *"
160 within the function, but is declared
162 in order to prevent compiler warnings when new domains are registered with
166 is not called directly, instead
170 If the new domain has defined an initialization routine, it is called by
172 as well, each of the protocols within the domain that have defined an
173 initialization routine will have theirs called.
175 Once a domain is added it cannot be unloaded.
176 This is because there is
177 no reference counting system in place to determine if there are any
178 active references from sockets within that domain.
181 finds a domain by family.
182 If the domain cannot be found,
189 look up a protocol by its number or by its type.
190 In most cases, if the protocol or type cannot be found,
194 may return the default if the requested type is
196 a protocol switch type of
198 is found, and the domain has a default raw protocol.
200 Both functions are called by
202 in order to resolve the protocol for the socket currently being created.
205 is a macro that simplifies the registration of a domain via
207 The code resulting from the macro expects there to be a domain structure
209 .Dq Fa name Ns Li domain
215 struct domain localdomain =
216 { AF_LOCAL, "local", unp_init, unp_externalize, unp_dispose,
217 localsw, &localsw[sizeof(localsw)/sizeof(localsw[0])] };
227 .Vt "struct protosw *"
228 for the protocol requested.
229 If the protocol or socket type is not found,
234 the default protocol may be returned for
236 types if the domain has a default raw protocol.
252 This manual page was written by
253 .An Chad David Aq Mt davidc@acns.ab.ca .