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

Subversion Repositories openrisc

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      sys/net/raw_cb.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: raw_cb.c,v 1.2 1996/03/03 21:07:16 niklas Exp $       */
31
/*      $NetBSD: raw_cb.c,v 1.9 1996/02/13 22:00:39 christos Exp $      */
32
 
33
/*
34
 * Copyright (c) 1980, 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
 *      @(#)raw_cb.c    8.1 (Berkeley) 6/10/93
66
 */
67
 
68
#include <sys/param.h>
69
#ifndef __ECOS
70
#include <sys/systm.h>
71
#endif
72
#include <sys/mbuf.h>
73
#include <sys/socket.h>
74
#include <sys/socketvar.h>
75
#include <sys/domain.h>
76
#include <sys/protosw.h>
77
#include <sys/errno.h>
78
 
79
#include <net/if.h>
80
#include <net/route.h>
81
#include <net/raw_cb.h>
82
#include <netinet/in.h>
83
 
84
/*
85
 * Routines to manage the raw protocol control blocks.
86
 *
87
 * TODO:
88
 *      hash lookups by protocol family/protocol + address family
89
 *      take care of unique address problems per AF?
90
 *      redo address binding to allow wildcards
91
 */
92
 
93
u_long  raw_sendspace = RAWSNDQ;
94
u_long  raw_recvspace = RAWRCVQ;
95
 
96
/*
97
 * Allocate a control block and a nominal amount
98
 * of buffer space for the socket.
99
 */
100
int
101
raw_attach(so, proto)
102
        register struct socket *so;
103
        int proto;
104
{
105
        register struct rawcb *rp = sotorawcb(so);
106
        int error;
107
 
108
        /*
109
         * It is assumed that raw_attach is called
110
         * after space has been allocated for the
111
         * rawcb.
112
         */
113
        if (rp == 0)
114
                return (ENOBUFS);
115
        if ((error = soreserve(so, raw_sendspace, raw_recvspace)) != 0)
116
                return (error);
117
        rp->rcb_socket = so;
118
        rp->rcb_proto.sp_family = so->so_proto->pr_domain->dom_family;
119
        rp->rcb_proto.sp_protocol = proto;
120
        LIST_INSERT_HEAD(&rawcb, rp, rcb_list);
121
        return (0);
122
}
123
 
124
/*
125
 * Detach the raw connection block and discard
126
 * socket resources.
127
 */
128
void
129
raw_detach(rp)
130
        register struct rawcb *rp;
131
{
132
        struct socket *so = rp->rcb_socket;
133
 
134
        so->so_pcb = 0;
135
        sofree(so);
136
        LIST_REMOVE(rp, rcb_list);
137
#ifdef notdef
138
        if (rp->rcb_laddr)
139
                m_freem(dtom(rp->rcb_laddr));
140
        rp->rcb_laddr = 0;
141
#endif
142
        free((caddr_t)(rp), M_PCB);
143
}
144
 
145
/*
146
 * Disconnect and possibly release resources.
147
 */
148
void
149
raw_disconnect(rp)
150
        struct rawcb *rp;
151
{
152
 
153
#ifdef notdef
154
        if (rp->rcb_faddr)
155
                m_freem(dtom(rp->rcb_faddr));
156
        rp->rcb_faddr = 0;
157
#endif
158
        if (rp->rcb_socket->so_state & SS_NOFDREF)
159
                raw_detach(rp);
160
}
161
 
162
#ifdef notdef
163
int
164
raw_bind(so, nam)
165
        register struct socket *so;
166
        struct mbuf *nam;
167
{
168
        struct sockaddr *addr = mtod(nam, struct sockaddr *);
169
        register struct rawcb *rp;
170
 
171
        if (ifnet == 0)
172
                return (EADDRNOTAVAIL);
173
        rp = sotorawcb(so);
174
        nam = m_copym(nam, 0, M_COPYALL, M_WAITOK);
175
        rp->rcb_laddr = mtod(nam, struct sockaddr *);
176
        return (0);
177
}
178
#endif

powered by: WebSVN 2.1.0

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