marc's changes: malloc uio if too large, ktrace
[unix-history] / usr / src / sys / kern / uipc_domain.c
CommitLineData
da7c5cc6 1/*
0880b18e 2 * Copyright (c) 1982, 1986 Regents of the University of California.
5b519e94 3 * All rights reserved.
da7c5cc6 4 *
5b519e94 5 * Redistribution and use in source and binary forms are permitted
616d42db
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
5b519e94 16 *
616d42db 17 * @(#)uipc_domain.c 7.3 (Berkeley) %G%
da7c5cc6 18 */
2f6bcc97 19
94368568
JB
20#include "param.h"
21#include "socket.h"
22#include "protosw.h"
23#include "domain.h"
24#include "time.h"
25#include "kernel.h"
d0d50a86
BJ
26
27#define ADDDOMAIN(x) { \
28 extern struct domain x/**/domain; \
29 x/**/domain.dom_next = domains; \
30 domains = &x/**/domain; \
31}
32
33domaininit()
34{
4f083fd7
SL
35 register struct domain *dp;
36 register struct protosw *pr;
d0d50a86 37
4f083fd7 38#ifndef lint
d0d50a86 39 ADDDOMAIN(unix);
2a04df10 40#ifdef INET
d0d50a86
BJ
41 ADDDOMAIN(inet);
42#endif
6e8408aa
KS
43#ifdef NS
44 ADDDOMAIN(ns);
45#endif
bd65e3c4
SL
46#include "imp.h"
47#if NIMP > 0
d0d50a86
BJ
48 ADDDOMAIN(imp);
49#endif
4f083fd7 50#endif
d0d50a86 51
261a8548
MK
52 for (dp = domains; dp; dp = dp->dom_next) {
53 if (dp->dom_init)
54 (*dp->dom_init)();
d0d50a86
BJ
55 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
56 if (pr->pr_init)
57 (*pr->pr_init)();
261a8548 58 }
79058dbc 59 null_init();
4f083fd7
SL
60 pffasttimo();
61 pfslowtimo();
d0d50a86
BJ
62}
63
64struct protosw *
65pffindtype(family, type)
66 int family, type;
67{
68 register struct domain *dp;
69 register struct protosw *pr;
70
71 for (dp = domains; dp; dp = dp->dom_next)
72 if (dp->dom_family == family)
73 goto found;
74 return (0);
75found:
76 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
6cd6d0de 77 if (pr->pr_type && pr->pr_type == type)
d0d50a86
BJ
78 return (pr);
79 return (0);
80}
81
82struct protosw *
9f773c40
MK
83pffindproto(family, protocol, type)
84 int family, protocol, type;
d0d50a86
BJ
85{
86 register struct domain *dp;
87 register struct protosw *pr;
9f773c40 88 struct protosw *maybe = 0;
d0d50a86
BJ
89
90 if (family == 0)
91 return (0);
92 for (dp = domains; dp; dp = dp->dom_next)
93 if (dp->dom_family == family)
94 goto found;
95 return (0);
96found:
9f773c40 97 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
c76325fe 98 if ((pr->pr_protocol == protocol) && (pr->pr_type == type))
d0d50a86 99 return (pr);
c76325fe 100
9f773c40
MK
101 if (type == SOCK_RAW && pr->pr_type == SOCK_RAW &&
102 pr->pr_protocol == 0 && maybe == (struct protosw *)0)
103 maybe = pr;
104 }
105 return (maybe);
d0d50a86
BJ
106}
107
122d5d84 108pfctlinput(cmd, sa)
d0d50a86 109 int cmd;
122d5d84 110 struct sockaddr *sa;
d0d50a86
BJ
111{
112 register struct domain *dp;
113 register struct protosw *pr;
114
115 for (dp = domains; dp; dp = dp->dom_next)
116 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
117 if (pr->pr_ctlinput)
122d5d84 118 (*pr->pr_ctlinput)(cmd, sa);
d0d50a86
BJ
119}
120
121pfslowtimo()
122{
123 register struct domain *dp;
124 register struct protosw *pr;
125
126 for (dp = domains; dp; dp = dp->dom_next)
127 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
128 if (pr->pr_slowtimo)
129 (*pr->pr_slowtimo)();
4f083fd7 130 timeout(pfslowtimo, (caddr_t)0, hz/2);
d0d50a86
BJ
131}
132
133pffasttimo()
4147b3f6 134{
d0d50a86
BJ
135 register struct domain *dp;
136 register struct protosw *pr;
4147b3f6 137
d0d50a86
BJ
138 for (dp = domains; dp; dp = dp->dom_next)
139 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
140 if (pr->pr_fasttimo)
141 (*pr->pr_fasttimo)();
4f083fd7 142 timeout(pffasttimo, (caddr_t)0, hz/5);
4147b3f6 143}