OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [ecos-2.0/] [packages/] [net/] [tcpip/] [v2_0/] [src/] [sys/] [kern/] [uipc_domain.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1254 phoenix
//==========================================================================
2
//
3
//      sys/kern/uipc_domain.c
4
//
5
//     
6
//
7
//==========================================================================
8
//####BSDCOPYRIGHTBEGIN####
9
//
10
// -------------------------------------------
11
//
12
// Portions of this software may have been derived from OpenBSD or other sources,
13
// and are covered by the appropriate copyright disclaimers included herein.
14
//
15
// -------------------------------------------
16
//
17
//####BSDCOPYRIGHTEND####
18
//==========================================================================
19
//#####DESCRIPTIONBEGIN####
20
//
21
// Author(s):    gthomas
22
// Contributors: gthomas
23
// Date:         2000-01-10
24
// Purpose:      
25
// Description:  
26
//              
27
//
28
//####DESCRIPTIONEND####
29
//
30
//==========================================================================
31
 
32
 
33
/*      $OpenBSD: uipc_domain.c,v 1.9 1999/12/08 06:50:17 itojun Exp $  */
34
/*      $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $        */
35
 
36
/*
37
 * Copyright (c) 1982, 1986, 1993
38
 *      The Regents of the University of California.  All rights reserved.
39
 *
40
 * Redistribution and use in source and binary forms, with or without
41
 * modification, are permitted provided that the following conditions
42
 * are met:
43
 * 1. Redistributions of source code must retain the above copyright
44
 *    notice, this list of conditions and the following disclaimer.
45
 * 2. Redistributions in binary form must reproduce the above copyright
46
 *    notice, this list of conditions and the following disclaimer in the
47
 *    documentation and/or other materials provided with the distribution.
48
 * 3. All advertising materials mentioning features or use of this software
49
 *    must display the following acknowledgement:
50
 *      This product includes software developed by the University of
51
 *      California, Berkeley and its contributors.
52
 * 4. Neither the name of the University nor the names of its contributors
53
 *    may be used to endorse or promote products derived from this software
54
 *    without specific prior written permission.
55
 *
56
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
57
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
60
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
62
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
64
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
65
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66
 * SUCH DAMAGE.
67
 *
68
 *      @(#)uipc_domain.c       8.2 (Berkeley) 10/18/93
69
 */
70
 
71
#include <sys/param.h>
72
#include <sys/socket.h>
73
#include <sys/protosw.h>
74
#include <sys/domain.h>
75
#include <sys/mbuf.h>
76
#include <sys/time.h>
77
#include <sys/kernel.h>
78
#ifndef __ECOS
79
#include <sys/systm.h>
80
#include <sys/proc.h>
81
 
82
#include <vm/vm.h>
83
#include <sys/sysctl.h>
84
#endif
85
 
86
void    pffasttimo __P((void *));
87
void    pfslowtimo __P((void *));
88
#if defined (KEY) || defined (IPSEC)
89
int pfkey_init __P((void));
90
#endif /* KEY || IPSEC */
91
 
92
#define ADDDOMAIN(x)    { \
93
        extern struct domain __CONCAT(x,domain); \
94
        __CONCAT(x,domain.dom_next) = domains; \
95
        domains = &__CONCAT(x,domain); \
96
}
97
 
98
void
99
domaininit()
100
{
101
        register struct domain *dp;
102
        register struct protosw *pr;
103
 
104
#undef unix
105
        /*
106
         * KAME NOTE: ADDDOMAIN(route) is moved to the last part so that
107
         * it will be initialized as the *first* element.  confusing!
108
         */
109
#ifndef lint
110
#ifndef __ECOS
111
        ADDDOMAIN(unix);
112
#endif
113
#ifdef INET
114
        ADDDOMAIN(inet);
115
#endif
116
#ifdef INET6
117
        ADDDOMAIN(inet6);
118
#endif /* INET6 */
119
#if defined (KEY) || defined (IPSEC)
120
        pfkey_init();
121
#endif /* KEY || IPSEC */
122
#ifdef IPX
123
        ADDDOMAIN(ipx);
124
#endif
125
#ifdef NETATALK
126
        ADDDOMAIN(atalk);
127
#endif
128
#ifdef NS
129
        ADDDOMAIN(ns);
130
#endif
131
#ifdef ISO
132
        ADDDOMAIN(iso);
133
#endif
134
#ifdef CCITT
135
        ADDDOMAIN(ccitt);
136
#endif
137
#ifdef notdef /* XXXX */
138
#include "imp.h"
139
#if NIMP > 0
140
        ADDDOMAIN(imp);
141
#endif
142
#endif
143
#ifdef IPSEC
144
#ifdef __KAME__
145
        ADDDOMAIN(key);
146
#endif
147
#endif
148
        ADDDOMAIN(route);
149
#endif
150
 
151
        for (dp = domains; dp; dp = dp->dom_next) {
152
                if (dp->dom_init)
153
                        (*dp->dom_init)();
154
                for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
155
                        if (pr->pr_init)
156
                                (*pr->pr_init)();
157
        }
158
 
159
if (max_linkhdr < 16)           /* XXX */
160
max_linkhdr = 16;
161
        max_hdr = max_linkhdr + max_protohdr;
162
        max_datalen = MHLEN - max_hdr;
163
        timeout(pffasttimo, NULL, 1);
164
        timeout(pfslowtimo, NULL, 1);
165
}
166
 
167
struct protosw *
168
pffindtype(family, type)
169
        int family, type;
170
{
171
        register struct domain *dp;
172
        register struct protosw *pr;
173
 
174
        for (dp = domains; dp; dp = dp->dom_next)
175
                if (dp->dom_family == family)
176
                        goto found;
177
        return (0);
178
found:
179
        for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
180
                if (pr->pr_type && pr->pr_type == type)
181
                        return (pr);
182
        return (0);
183
}
184
 
185
struct protosw *
186
pffindproto(family, protocol, type)
187
        int family, protocol, type;
188
{
189
        register struct domain *dp;
190
        register struct protosw *pr;
191
        struct protosw *maybe = 0;
192
 
193
        if (family == 0)
194
                return (0);
195
        for (dp = domains; dp; dp = dp->dom_next)
196
                if (dp->dom_family == family)
197
                        goto found;
198
        return (0);
199
found:
200
        for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
201
                if ((pr->pr_protocol == protocol) && (pr->pr_type == type))
202
                        return (pr);
203
 
204
                if (type == SOCK_RAW && pr->pr_type == SOCK_RAW &&
205
                    pr->pr_protocol == 0 && maybe == (struct protosw *)0)
206
                        maybe = pr;
207
        }
208
        return (maybe);
209
}
210
 
211
#ifndef __ECOS
212
int
213
net_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
214
        int *name;
215
        u_int namelen;
216
        void *oldp;
217
        size_t *oldlenp;
218
        void *newp;
219
        size_t newlen;
220
        struct proc *p;
221
{
222
        register struct domain *dp;
223
        register struct protosw *pr;
224
        int family, protocol;
225
 
226
        /*
227
         * All sysctl names at this level are nonterminal.
228
         * PF_KEY: next component is protocol family, and then at least one
229
         *      additional component.
230
         * usually: next two components are protocol family and protocol
231
         *      number, then at least one addition component.
232
         */
233
        if (namelen < 2)
234
                return (EISDIR);                /* overloaded */
235
        family = name[0];
236
 
237
        if (family == 0)
238
                return (0);
239
        for (dp = domains; dp; dp = dp->dom_next)
240
                if (dp->dom_family == family)
241
                        goto found;
242
        return (ENOPROTOOPT);
243
found:
244
        switch (family) {
245
#ifdef IPSEC
246
#ifdef __KAME__
247
        case PF_KEY:
248
                pr = dp->dom_protosw;
249
                if (pr->pr_sysctl)
250
                        return ((*pr->pr_sysctl)(name + 1, namelen - 1,
251
                                oldp, oldlenp, newp, newlen));
252
                return (ENOPROTOOPT);
253
#endif
254
#endif
255
        default:
256
                break;
257
        }
258
        if (namelen < 3)
259
                return (EISDIR);                /* overloaded */
260
        protocol = name[1];
261
        for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
262
                if (pr->pr_protocol == protocol && pr->pr_sysctl)
263
                        return ((*pr->pr_sysctl)(name + 2, namelen - 2,
264
                            oldp, oldlenp, newp, newlen));
265
        return (ENOPROTOOPT);
266
}
267
#endif
268
 
269
void
270
pfctlinput(cmd, sa)
271
        int cmd;
272
        struct sockaddr *sa;
273
{
274
        register struct domain *dp;
275
        register struct protosw *pr;
276
 
277
        for (dp = domains; dp; dp = dp->dom_next)
278
                for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
279
                        if (pr->pr_ctlinput)
280
                                (*pr->pr_ctlinput)(cmd, sa, NULL);
281
}
282
 
283
void
284
pfslowtimo(arg)
285
        void *arg;
286
{
287
        register struct domain *dp;
288
        register struct protosw *pr;
289
 
290
        for (dp = domains; dp; dp = dp->dom_next)
291
                for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
292
                    if (pr->pr_slowtimo) {
293
                                (*pr->pr_slowtimo)();
294
                    }
295
        timeout(pfslowtimo, NULL, hz/2);
296
}
297
 
298
void
299
pffasttimo(arg)
300
        void *arg;
301
{
302
        register struct domain *dp;
303
        register struct protosw *pr;
304
 
305
        for (dp = domains; dp; dp = dp->dom_next)
306
                for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
307
                    if (pr->pr_fasttimo) {
308
                                (*pr->pr_fasttimo)();
309
                    }
310
        timeout(pffasttimo, NULL, hz/5);
311
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.