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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [tcpip/] [current/] [src/] [sys/] [kern/] [uipc_domain.c] - Blame information for rev 786

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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