tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / workbench / network / stacks / AROSTCP / bsdsocket / net / raw_cb.c
blobafb284bc66e0923c9c1c42f3d9e9aa6cbe40cf32
1 /*
2 * Copyright (C) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
3 * Helsinki University of Technology, Finland.
4 * All rights reserved.
5 * Copyright (C) 2005 Neil Cafferkey
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19 * MA 02111-1307, USA.
23 /*
24 * Mach Operating System
25 * Copyright (c) 1992 Carnegie Mellon University
26 * All Rights Reserved.
28 * Permission to use, copy, modify and distribute this software and its
29 * documentation is hereby granted, provided that both the copyright
30 * notice and this permission notice appear in all copies of the
31 * software, derivative works or modified versions, and any portions
32 * thereof, and that both notices appear in supporting documentation.
34 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
35 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
36 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
38 * Carnegie Mellon requests users of this software to return to
40 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
41 * School of Computer Science
42 * Carnegie Mellon University
43 * Pittsburgh PA 15213-3890
45 * any improvements or extensions that they make and grant Carnegie Mellon
46 * the rights to redistribute these changes.
50 * Copyright (c) 1980, 1986 Regents of the University of California.
51 * All rights reserved.
53 * Redistribution and use in source and binary forms, with or without
54 * modification, are permitted provided that the following conditions
55 * are met:
56 * 1. Redistributions of source code must retain the above copyright
57 * notice, this list of conditions and the following disclaimer.
58 * 2. Redistributions in binary form must reproduce the above copyright
59 * notice, this list of conditions and the following disclaimer in the
60 * documentation and/or other materials provided with the distribution.
61 * 3. All advertising materials mentioning features or use of this software
62 * must display the following acknowledgement:
63 * This product includes software developed by the University of
64 * California, Berkeley and its contributors.
65 * 4. Neither the name of the University nor the names of its contributors
66 * may be used to endorse or promote products derived from this software
67 * without specific prior written permission.
69 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
70 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
71 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
72 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
73 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
74 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
75 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
76 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
77 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
78 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
79 * SUCH DAMAGE.
81 * @(#)raw_cb.c 7.11 (Berkeley) 6/28/90
84 #include <conf.h>
86 #include <sys/param.h>
87 #include <sys/systm.h>
88 #include <sys/malloc.h>
89 #include <sys/mbuf.h>
90 #include <sys/socket.h>
91 #include <sys/socketvar.h>
92 #include <sys/domain.h>
93 #include <sys/protosw.h>
94 #include <sys/errno.h>
96 #include <net/if.h>
97 #include <net/route.h>
98 #include <net/raw_cb.h>
99 #include <netinet/in.h>
101 #include <protos/kern/uipc_socket_protos.h>
102 #include <protos/kern/uipc_socket2_protos.h>
104 /* --- start moved from raw_cb.h --- */
105 struct rawcb rawcb = {0}; /* head of list */
106 /* --- end moved from raw_cb.h --- */
109 * Routines to manage the raw protocol control blocks.
111 * TODO:
112 * hash lookups by protocol family/protocol + address family
113 * take care of unique address problems per AF?
114 * redo address binding to allow wildcards
117 u_long raw_sendspace = RAWSNDQ;
118 u_long raw_recvspace = RAWRCVQ;
121 * Allocate a control block and a nominal amount
122 * of buffer space for the socket.
125 raw_attach(register struct socket *so,
126 int proto)
128 register struct rawcb *rp = sotorawcb(so);
129 int error;
132 * It is assumed that raw_attach is called
133 * after space has been allocated for the
134 * rawcb.
136 if (rp == 0)
137 return (ENOBUFS);
138 if (error = soreserve(so, raw_sendspace, raw_recvspace))
139 return (error);
140 rp->rcb_socket = so;
141 rp->rcb_proto.sp_family = so->so_proto->pr_domain->dom_family;
142 rp->rcb_proto.sp_protocol = proto;
143 insque(rp, &rawcb);
144 return (0);
148 * Detach the raw connection block and discard
149 * socket resources.
151 void
152 raw_detach(register struct rawcb *rp)
154 struct socket *so = rp->rcb_socket;
156 so->so_pcb = 0;
157 sofree(so);
158 remque(rp);
159 #ifdef notdef
160 if (rp->rcb_laddr)
161 m_freem(dtom(rp->rcb_laddr));
162 rp->rcb_laddr = 0;
163 #endif
164 bsd_free((caddr_t)(rp), M_PCB);
168 * Disconnect and possibly release resources.
170 void
171 raw_disconnect(struct rawcb *rp)
174 #ifdef notdef
175 if (rp->rcb_faddr)
176 m_freem(dtom(rp->rcb_faddr));
177 rp->rcb_faddr = 0;
178 #endif
179 if (rp->rcb_socket->so_state & SS_NOFDREF)
180 raw_detach(rp);
183 #ifdef notdef
184 raw_bind(so, nam)
185 register struct socket *so;
186 struct mbuf *nam;
188 struct sockaddr *addr = mtod(nam, struct sockaddr *);
189 register struct rawcb *rp;
191 if (ifnet == 0)
192 return (EADDRNOTAVAIL);
193 rp = sotorawcb(so);
194 nam = m_copym(nam, 0, M_COPYALL, M_WAITOK);
195 rp->rcb_laddr = mtod(nam, struct sockaddr *);
196 return (0);
198 #endif