1 /* $Id: uipc_domain.c,v 1.1.1.1 2006/09/14 01:59:08 root Exp $ */
2 /* $OpenBSD: uipc_domain.c,v 1.8 1999/03/30 00:19:05 niklas Exp $ */
3 /* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */
6 * Copyright (c) 1982, 1986, 1993
7 * The Regents of the University of California. All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * @(#)uipc_domain.c 8.2 (Berkeley) 10/18/93
40 #include <sys/param.h>
41 #include <sys/socket.h>
42 #include <sys/protosw.h>
43 #include <sys/domain.h>
46 #include <sys/kernel.h>
47 #include <sys/systm.h>
50 #include <sys/sysctl.h>
52 void pffasttimo
__P((void *));
53 void pfslowtimo
__P((void *));
54 #if defined (KEY) || defined (IPSEC)
55 int pfkey_init
__P((void));
56 #endif /* KEY || IPSEC */
58 #define ADDDOMAIN(x) { \
59 extern struct domain __CONCAT(x,domain); \
60 __CONCAT(x,domain.dom_next) = domains; \
61 domains = &__CONCAT(x,domain); \
67 register struct domain
*dp
;
68 register struct protosw
*pr
;
82 #if defined (KEY) || defined (IPSEC)
84 #endif /* KEY || IPSEC */
100 #ifdef notdef /* XXXX */
108 for (dp
= domains
; dp
; dp
= dp
->dom_next
) {
111 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++)
116 if (max_linkhdr
< 16) /* XXX */
118 max_hdr
= max_linkhdr
+ max_protohdr
;
119 max_datalen
= MHLEN
- max_hdr
;
120 timeout(pffasttimo
, NULL
, 1);
121 timeout(pfslowtimo
, NULL
, 1);
125 pffindtype(family
, type
)
128 register struct domain
*dp
;
129 register struct protosw
*pr
;
131 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
132 if (dp
->dom_family
== family
)
136 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++)
137 if (pr
->pr_type
&& pr
->pr_type
== type
)
143 pffindproto(family
, protocol
, type
)
144 int family
, protocol
, type
;
146 register struct domain
*dp
;
147 register struct protosw
*pr
;
148 struct protosw
*maybe
= 0;
152 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
153 if (dp
->dom_family
== family
)
157 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++) {
158 if ((pr
->pr_protocol
== protocol
) && (pr
->pr_type
== type
))
161 if (type
== SOCK_RAW
&& pr
->pr_type
== SOCK_RAW
&&
162 pr
->pr_protocol
== 0 && maybe
== (struct protosw
*)0)
169 net_sysctl(name
, namelen
, oldp
, oldlenp
, newp
, newlen
, p
)
178 register struct domain
*dp
;
179 register struct protosw
*pr
;
180 int family
, protocol
;
183 * All sysctl names at this level are nonterminal;
184 * next two components are protocol family and protocol number,
185 * then at least one addition component.
188 return (EISDIR
); /* overloaded */
194 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
195 if (dp
->dom_family
== family
)
197 return (ENOPROTOOPT
);
199 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++)
200 if (pr
->pr_protocol
== protocol
&& pr
->pr_sysctl
)
201 return ((*pr
->pr_sysctl
)(name
+ 2, namelen
- 2,
202 oldp
, oldlenp
, newp
, newlen
));
203 return (ENOPROTOOPT
);
211 register struct domain
*dp
;
212 register struct protosw
*pr
;
214 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
215 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++)
217 (*pr
->pr_ctlinput
)(cmd
, sa
, NULL
);
224 register struct domain
*dp
;
225 register struct protosw
*pr
;
227 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
228 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++)
230 (*pr
->pr_slowtimo
)();
231 timeout(pfslowtimo
, NULL
, hz
/2);
238 register struct domain
*dp
;
239 register struct protosw
*pr
;
241 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
242 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++)
244 (*pr
->pr_fasttimo
)();
245 timeout(pffasttimo
, NULL
, hz
/5);