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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      src/sys/kern/uipc_accf.c
4
//
5
//==========================================================================
6
// ####BSDCOPYRIGHTBEGIN####                                    
7
// -------------------------------------------                  
8
// This file is part of eCos, the Embedded Configurable Operating System.
9
//
10
// Portions of this software may have been derived from FreeBSD 
11
// or other sources, and if so are covered by the appropriate copyright
12
// and license included herein.                                 
13
//
14
// Portions created by the Free Software Foundation are         
15
// Copyright (C) 2002 Free Software Foundation, Inc.            
16
// -------------------------------------------                  
17
// ####BSDCOPYRIGHTEND####                                      
18
//==========================================================================
19
 
20
/*
21
 * Copyright (c) 2000 Paycounter, Inc.
22
 * Author: Alfred Perlstein <alfred@paycounter.com>, <alfred@FreeBSD.org>
23
 * All rights reserved.
24
 *
25
 * Redistribution and use in source and binary forms, with or without
26
 * modification, are permitted provided that the following conditions
27
 * are met:
28
 * 1. Redistributions of source code must retain the above copyright
29
 *    notice, this list of conditions and the following disclaimer.
30
 * 2. Redistributions in binary form must reproduce the above copyright
31
 *    notice, this list of conditions and the following disclaimer in the
32
 *    documentation and/or other materials provided with the distribution.
33
 *
34
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
35
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
38
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
43
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44
 * SUCH DAMAGE.
45
 *
46
 *      $FreeBSD: src/sys/kern/uipc_accf.c,v 1.2.2.2 2000/09/20 21:19:21 ps Exp $
47
 */
48
 
49
#include <sys/param.h>
50
#include <sys/domain.h>
51
#include <sys/malloc.h>
52
#include <sys/mbuf.h>
53
#include <sys/protosw.h>
54
#include <sys/socket.h>
55
#include <sys/socketvar.h>
56
#include <sys/queue.h>
57
 
58
static SLIST_HEAD(, accept_filter) accept_filtlsthd =
59
        SLIST_HEAD_INITIALIZER(&accept_filtlsthd);
60
 
61
#ifdef ACCEPT_FILTER_MOD
62
static int unloadable = 0;
63
#endif
64
 
65
/*
66
 * must be passed a malloc'd structure so we don't explode if the kld
67
 * is unloaded, we leak the struct on deallocation to deal with this,
68
 * but if a filter is loaded with the same name as a leaked one we re-use
69
 * the entry.
70
 */
71
int
72
accept_filt_add(struct accept_filter *filt)
73
{
74
        struct accept_filter *p;
75
 
76
        SLIST_FOREACH(p, &accept_filtlsthd, accf_next)
77
                if (strcmp(p->accf_name, filt->accf_name) == 0)  {
78
                        if (p->accf_callback != NULL) {
79
                                return (EEXIST);
80
                        } else {
81
                                p->accf_callback = filt->accf_callback;
82
                                FREE(filt, M_ACCF);
83
                                return (0);
84
                        }
85
                }
86
 
87
        if (p == NULL)
88
                SLIST_INSERT_HEAD(&accept_filtlsthd, filt, accf_next);
89
        return (0);
90
}
91
 
92
int
93
accept_filt_del(char *name)
94
{
95
        struct accept_filter *p;
96
 
97
        p = accept_filt_get(name);
98
        if (p == NULL)
99
                return (ENOENT);
100
 
101
        p->accf_callback = NULL;
102
        return (0);
103
}
104
 
105
struct accept_filter *
106
accept_filt_get(char *name)
107
{
108
        struct accept_filter *p;
109
 
110
        SLIST_FOREACH(p, &accept_filtlsthd, accf_next)
111
                if (strcmp(p->accf_name, name) == 0)
112
                        return (p);
113
 
114
        return (NULL);
115
}
116
 
117
#ifdef ACCEPT_FILTER_MOD
118
int
119
accept_filt_generic_mod_event(module_t mod, int event, void *data)
120
{
121
        struct accept_filter *p;
122
        struct accept_filter *accfp = (struct accept_filter *) data;
123
        int     s, error;
124
 
125
        switch (event) {
126
        case MOD_LOAD:
127
                MALLOC(p, struct accept_filter *, sizeof(*p), M_ACCF, M_WAITOK);
128
                bcopy(accfp, p, sizeof(*p));
129
                s = splnet();
130
                error = accept_filt_add(p);
131
                splx(s);
132
                break;
133
 
134
        case MOD_UNLOAD:
135
                /*
136
                 * Do not support unloading yet. we don't keep track of refcounts
137
                 * and unloading an accept filter callback and then having it called
138
                 * is a bad thing.  A simple fix would be to track the refcount
139
                 * in the struct accept_filter.
140
                 */
141
                if (unloadable != 0) {
142
                        s = splnet();
143
                        error = accept_filt_del(accfp->accf_name);
144
                        splx(s);
145
                } else
146
                        error = EOPNOTSUPP;
147
                break;
148
 
149
        case MOD_SHUTDOWN:
150
                error = 0;
151
                break;
152
 
153
        default:
154
                error = EOPNOTSUPP;
155
                break;
156
        }
157
 
158
        return (error);
159
}
160
#endif

powered by: WebSVN 2.1.0

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