2 * Copyright (c) 1982, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * @(#)uipc_domain.c 8.2 (Berkeley) 10/18/93
36 #include <sys/param.h>
37 #include <sys/socket.h>
38 #include <sys/protosw.h>
39 #include <sys/domain.h>
42 #include <sys/kernel.h>
43 #include <sys/systm.h>
46 #include <sys/sysctl.h>
48 void pffasttimo
__P((void *));
49 void pfslowtimo
__P((void *));
51 struct domain
*domains
;
53 #define ADDDOMAIN(x) { \
54 extern struct domain __CONCAT(x,domain); \
55 __CONCAT(x,domain.dom_next) = domains; \
56 domains = &__CONCAT(x,domain); \
59 extern struct linker_set domain_set
;
64 register struct domain
*dp
, **dpp
;
65 register struct protosw
*pr
;
67 //printf("domaininit starting\n");
70 * NB - local domain is always present.
75 for (dpp
= (struct domain
**)domain_set
.ls_items
; *dpp
; dpp
++) {
76 //printf("(1) Domain %s counting\n", (**dpp).dom_name);
77 (**dpp
).dom_next
= domains
;
81 /* - not in our sources
86 for (dp
= domains
; dp
; dp
= dp
->dom_next
) {
87 //printf("(1) Domain %s initializing\n", dp->dom_name);
90 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++) {
91 //printf("Registering protocols for %s\n", dp->dom_name);
95 if( dp
->dom_next
&& !dp
->dom_next
->dom_name
)
99 if (max_linkhdr
< 16) /* XXX */
101 max_hdr
= max_linkhdr
+ max_protohdr
;
102 max_datalen
= MHLEN
- max_hdr
;
103 timeout(pffasttimo
, (void *)0, 1);
104 timeout(pfslowtimo
, (void *)0, 1);
106 //printf("Domaininit done\n");
110 pffindtype(family
, type
)
113 register struct domain
*dp
;
114 register struct protosw
*pr
;
116 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
117 if (dp
->dom_family
== family
)
121 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++)
122 if (pr
->pr_type
&& pr
->pr_type
== type
)
128 pffindproto(family
, protocol
, type
)
129 int family
, protocol
, type
;
131 register struct domain
*dp
;
132 register struct protosw
*pr
;
133 struct protosw
*maybe
= 0;
137 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
138 if (dp
->dom_family
== family
)
142 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++) {
143 if ((pr
->pr_protocol
== protocol
) && (pr
->pr_type
== type
))
146 if (type
== SOCK_RAW
&& pr
->pr_type
== SOCK_RAW
&&
147 pr
->pr_protocol
== 0 && maybe
== (struct protosw
*)0)
154 net_sysctl(name
, namelen
, oldp
, oldlenp
, newp
, newlen
, p
)
163 register struct domain
*dp
;
164 register struct protosw
*pr
;
165 int family
, protocol
;
168 * All sysctl names at this level are nonterminal;
169 * next two components are protocol family and protocol number,
170 * then at least one addition component.
173 return (EISDIR
); /* overloaded */
179 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
180 if (dp
->dom_family
== family
)
182 return (ENOPROTOOPT
);
184 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++)
185 if (pr
->pr_protocol
== protocol
&& pr
->pr_sysctl
)
186 return ((*pr
->pr_sysctl
)(name
+ 2, namelen
- 2,
187 oldp
, oldlenp
, newp
, newlen
));
188 return (ENOPROTOOPT
);
196 register struct domain
*dp
;
197 register struct protosw
*pr
;
199 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
200 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++)
202 (*pr
->pr_ctlinput
)(cmd
, sa
, (caddr_t
)0);
209 register struct domain
*dp
;
210 register struct protosw
*pr
;
212 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
213 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++)
215 (*pr
->pr_slowtimo
)();
216 timeout(pfslowtimo
, (void *)0, hz
/2);
223 register struct domain
*dp
;
224 register struct protosw
*pr
;
226 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
227 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++)
229 (*pr
->pr_fasttimo
)();
230 timeout(pffasttimo
, (void *)0, hz
/5);