home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
comm
/
amitcp-3.0ß2.lha
/
AmiTCP
/
src
/
amitcp
/
kern
/
uipc_socket2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-18
|
25KB
|
948 lines
RCS_ID_C="$Id: uipc_socket2.c,v 1.23 1993/12/18 15:28:09 jraja Exp $";
/*
* Copyright (c) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
* Helsinki University of Technology, Finland.
* All rights reserved.
*
* HISTORY
* $Log: uipc_socket2.c,v $
* Revision 1.23 1993/12/18 15:28:09 jraja
* Disabled code using M_EOR, unless USE_M_EOR is defined.
*
* Revision 1.22 1993/11/17 12:14:31 jraja
* Added check for the SB_SEL flag to the sowakeup() to prevent unnecessary
* calls to selwakeup().
*
* Revision 1.21 1993/11/17 09:21:47 jraja
* Added setting of SB_SEL to sbselqueue(), so that protocols would notify us.
* Added clearing of that flag in sowakeup() to prevent extra notifications.
*
* Revision 1.20 1993/06/04 11:16:15 jraja
* Fixes for first public release.
*
* Revision 1.19 1993/05/17 01:07:47 ppessi
* Changed RCS version.
*
* Revision 1.18 1993/04/26 11:54:52 too
* Changed include paths of amiga_api.h, amiga_libcallentry.h and amiga_raf.h
* from kern to api
*
* Revision 1.17 93/04/24 22:45:56 22:45:56 jraja (Jarno Tapio Rajahalme)
* Removed Define for USECLUSTERS
*
* Revision 1.16 93/04/24 17:52:35 17:52:35 jraja (Jarno Tapio Rajahalme)
* Changed MCLBYTES to mbconf.mclbytes.
*
* Revision 1.15 93/04/12 00:38:28 00:38:28 jraja (Jarno Tapio Rajahalme)
* Added #include <kern/amiga_includes.h> and <kern/amiga_api.h> for Signal().
*
* Revision 1.14 93/04/12 00:29:36 00:29:36 jraja (Jarno Tapio Rajahalme)
* Added signalling of the task (SIGIO).
*
* Revision 1.13 93/04/06 15:16:21 15:16:21 jraja (Jarno Tapio Rajahalme)
* Changed spl function return value storage to spl_t,
* changed bcopys and bzeros to aligned and/or const when possible,
* added inclusion of conf.h to every .c file.
*
* Revision 1.12 93/03/17 12:07:33 12:07:33 jraja (Jarno Tapio Rajahalme)
* Fixed tsleep() call to find socket base if necessary and to give NULL
* timeout if timeval is all zeroes.
*
* Revision 1.11 93/03/05 21:11:20 21:11:20 jraja (Jarno Tapio Rajahalme)
* Fixed includes (again).
*
* Revision 1.10 93/03/04 09:51:35 09:51:35 jraja (Jarno Tapio Rajahalme)
* Removed some redundant includes.
*
* Revision 1.9 93/03/03 16:12:10 16:12:10 jraja (Jarno Tapio Rajahalme)
* Changed sonewconn1() to sonewconn().
*
* Revision 1.8 93/03/02 17:35:07 17:35:07 too (Tomi Ollila)
* Changed some %d:s to %ld:s.. compiled when SOCKBUF_DEBUG is defined.
*
* Revision 1.7 93/02/27 11:04:08 11:04:08 too (Tomi Ollila)
* Added prototypes.
*
* Revision 1.6 93/02/25 13:02:06 13:02:06 too (Tomi Ollila)
* Added static inlines, sys/cdefs etc.
*
* Revision 1.5 93/02/24 16:33:56 16:33:56 too (Tomi Ollila)
* Compiles.
*
* Revision 1.4 93/02/23 11:39:45 11:39:45 too (Tomi Ollila)
* added SocketBase pointer to sbwait() and sblock(), now shoud work w/ AmiTCP
*
* Revision 1.3 93/01/09 12:57:35 12:57:35 jraja (Jarno Tapio Rajahalme)
* Added #ifdef USECLUSTERS to disable cluster dependant code.
*
* Revision 1.2 92/11/20 15:14:52 15:14:52 jraja (Jarno Tapio Rajahalme)
* Added #ifndef AMITCP's to make this compile.
*
* Revision 1.1 92/11/19 12:07:33 12:07:33 jraja (Jarno Tapio Rajahalme)
* Initial revision
*
*
*/
/*
* Mach Operating System
* Copyright (c) 1992 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
* HISTORY
* Log: uipc_socket2.c,v
* Revision 2.1 92/04/21 17:13:26 rwd
* BSDSS
*
*
*/
/*
* Copyright (c) 1982, 1986, 1988, 1990 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)uipc_socket2.c 7.17 (Berkeley) 5/4/91
*/
#include <conf.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/synch.h>
#include <api/amiga_api.h>
#include <kern/amiga_includes.h>
#include <kern/uipc_socket2_protos.h>
#include <kern/amiga_select_protos.h>
/*
* Primitive routines for operating on sockets and socket buffers
*/
/* strings for sleep message: */
char netio[] = "netio";
char netcon[] = "netcon";
char netcls[] = "netcls";
u_long sb_max = SB_MAX; /* patchable */
/*
* Procedures to manipulate state flags of socket
* and do appropriate wakeups. Normal sequence from the
* active (originating) side is that soisconnecting() is
* called during processing of connect() call,
* resulting in an eventual call to soisconnected() if/when the
* connection is established. When the connection is torn down
* soisdisconnecting() is called during processing of disconnect() call,
* and soisdisconnected() is called when the connection to the peer
* is totally severed. The semantics of these routines are such that
* connectionless protocols can call soisconnected() and soisdisconnected()
* only, bypassing the in-progress calls when setting up a ``connection''
* takes no time.
*
* From the passive side, a socket is created with
* two queues of sockets: so_q0 for connections in progress
* and so_q for connections already made and awaiting user acceptance.
* As a protocol is preparing incoming connections, it creates a socket
* structure queued on so_q0 by calling sonewconn(). When the connection
* is established, soisconnected() is called, and transfers the
* socket structure to so_q, making it available to accept().
*
* If a socket is closed with sockets on either
* so_q0 or so_q, these sockets are dropped.
*
* If