2 * Copyright (C) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
3 * Helsinki University of Technology, Finland.
5 * Copyright (C) 2005 Neil Cafferkey
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24 * Copyright (c) 1982, 1986 Regents of the University of California.
25 * All rights reserved.
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgement:
37 * This product includes software developed by the University of
38 * California, Berkeley and its contributors.
39 * 4. Neither the name of the University nor the names of its contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
43 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * @(#)uipc_domain.c 7.9 (Berkeley) 3/4/91
60 #include <sys/param.h>
61 #include <sys/socket.h>
62 #include <sys/protosw.h>
63 #include <sys/domain.h>
65 #include <sys/kernel.h>
67 #include <kern/amiga_includes.h>
68 #include <kern/uipc_domain_protos.h>
70 /* --- start moved from sys/domain.h --- */
71 struct domain
*domains
= NULL
;
72 /* --- end moved from sys/domain.h --- */
74 static BOOL domain_initialized
= FALSE
;
76 #define ADDDOMAIN(x) { \
77 extern struct domain __CONCAT(x,domain); \
78 __CONCAT(x,domain.dom_next) = domains; \
79 domains = &__CONCAT(x,domain); \
85 register struct domain
*dp
;
86 register struct protosw
*pr
;
88 if (domain_initialized
)
115 for (dp
= domains
; dp
; dp
= dp
->dom_next
) {
118 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++)
124 * No space needed for the link header with SanaII drivers
128 if (max_linkhdr
< 16) /* XXX */
131 max_hdr
= max_linkhdr
+ max_protohdr
;
132 max_datalen
= MHLEN
- max_hdr
;
136 * Timeouts are scheduled from amiga_main.c in AmiTCP/IP
141 domain_initialized
= TRUE
;
146 pffindtype(family
, type
)
149 register struct domain
*dp
;
150 register struct protosw
*pr
;
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_type
&& pr
->pr_type
== type
)
164 pffindproto(family
, protocol
, type
)
165 int family
, protocol
, type
;
167 register struct domain
*dp
;
168 register struct protosw
*pr
;
169 struct protosw
*maybe
= 0;
173 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
174 if (dp
->dom_family
== family
)
178 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++) {
179 if ((pr
->pr_protocol
== protocol
) && (pr
->pr_type
== type
))
182 if (type
== SOCK_RAW
&& pr
->pr_type
== SOCK_RAW
&&
183 pr
->pr_protocol
== 0 && maybe
== (struct protosw
*)0)
194 register struct domain
*dp
;
195 register struct protosw
*pr
;
197 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
198 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++)
200 (*pr
->pr_ctlinput
)(cmd
, sa
, (caddr_t
) 0);
206 register struct domain
*dp
;
207 register struct protosw
*pr
;
209 for (dp
= domains
; dp
; dp
= dp
->dom_next
)
210 for (pr
= dp
->dom_protosw
; pr
< dp
->dom_protoswNPROTOSW
; pr
++)
212 (*pr
->pr_slowtimo
)();
215 * Timeouts are scheduled from amiga_main.c in AmiTCP/IP
217 timeout(pfslowtimo
, (caddr_t
)0, hz
/2);
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_fasttimo
)();
233 * Timeouts are scheduled from amiga_main.c in AmiTCP/IP
235 timeout(pffasttimo
, (caddr_t
)0, hz
/5);