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
39 .Nd "network domain management"
46 .Fn net_add_domain "void *data"
48 .Fn pfctlinput "int cmd" "struct sockaddr *sa"
50 .Fn pfctlinput2 "int cmd" "struct sockaddr *sa" "void *ctlparam"
52 .Fn pffindproto "int family" "int protocol" "int type"
54 .Fn pffindtype "int family" "int type"
58 Network protocols installed in the system are maintained within what
66 int dom_family; /* AF_xxx */
68 void (*dom_init) /* initialize domain data structures */
70 int (*dom_externalize) /* externalize access rights */
71 (struct mbuf *, struct mbuf **);
72 void (*dom_dispose) /* dispose of internalized rights */
74 struct protosw *dom_protosw, *dom_protoswNPROTOSW;
75 struct domain *dom_next;
76 int (*dom_rtattach) /* initialize routing table */
78 int dom_rtoffset; /* an arg to rtattach, in bits */
79 int dom_maxrtkey; /* for routing layer */
83 Each domain contains an array of protocol switch structures
84 .Pq Vt "struct protosw *" ,
85 one for each socket type supported.
88 short pr_type; /* socket type used for */
89 struct domain *pr_domain; /* domain protocol a member of */
90 short pr_protocol; /* protocol number */
91 short pr_flags; /* see below */
92 /* protocol-protocol hooks */
93 pr_input_t *pr_input; /* input to protocol (from below) */
94 pr_output_t *pr_output; /* output to protocol (from above) */
95 pr_ctlinput_t *pr_ctlinput; /* control input (from below) */
96 pr_ctloutput_t *pr_ctloutput; /* control output (from above) */
99 pr_fasttimo_t *pr_fasttimo; /* fast timeout (200ms) */
100 pr_slowtimo_t *pr_slowtimo; /* slow timeout (500ms) */
101 pr_drain_t *pr_drain; /* flush any excess space possible */
103 struct pr_usrreqs *pr_usrreqs; /* supersedes pr_usrreq() */
107 The following functions handle the registration of a new domain,
108 lookups of specific protocols and protocol types within those domains,
109 and handle control messages from the system.
112 is called by the system whenever an event occurs that could affect every
114 Examples of those types of events are routing table changes, interface
120 calls the protocol specific
122 function for each protocol in that has defined one, in every domain.
125 provides that same functionality of
127 but with a few additional checks and a new
129 argument that is passed directly to the protocol's
139 and that only the protocol families that are the same as
146 adds a new protocol domain to the system.
150 .Vt "struct domain *"
151 within the function, but is declared
153 in order to prevent compiler warnings when new domains are registered with
157 is not called directly, instead
161 If the new domain has defined an initialization routine, it is called by
163 as well, each of the protocols within the domain that have defined an
164 initialization routine will have theirs called.
166 Once a domain is added it cannot be unloaded.
167 This is because there is
168 no reference counting system in place to determine if there are any
169 active references from sockets within that domain.
174 look up a protocol by its number or by its type.
175 In most cases, if the protocol or type cannot be found,
179 may return the default if the requested type is
181 a protocol switch type of
183 is found, and the domain has a default raw protocol.
185 Both functions are called by
187 in order to resolve the protocol for the socket currently being created.
190 is a macro that simplifies the registration of a domain via
192 The code resulting from the macro expects there to be a domain structure
194 .Dq Fa name Ns Li domain
200 struct domain localdomain =
201 { AF_LOCAL, "local", unp_init, unp_externalize, unp_dispose,
202 localsw, &localsw[sizeof(localsw)/sizeof(localsw[0])] };
212 .Vt "struct protosw *"
213 for the protocol requested.
214 If the protocol or socket type is not found,
219 the default protocol may be returned for
221 types if the domain has a default raw protocol.
225 This manual page was written by
226 .An Chad David Aq davidc@acns.ab.ca .