1/* 2 * Copyright (c) 1982, 1986, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)sys_socket.c 8.1 (Berkeley) 6/10/93 |
34 * $Id: sys_socket.c,v 1.5 1995/05/30 08:05:59 rgrimes Exp $ |
35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/proc.h> 40#include <sys/file.h> 41#include <sys/mbuf.h> 42#include <sys/protosw.h> 43#include <sys/socket.h> 44#include <sys/stat.h> 45#include <sys/socketvar.h> 46#include <sys/ioctl.h> 47#include <sys/stat.h> 48 49#include <net/if.h> 50#include <net/route.h> 51 |
52static int soo_read __P((struct file *fp, struct uio *uio, 53 struct ucred *cred)); 54static int soo_write __P((struct file *fp, struct uio *uio, 55 struct ucred *cred)); 56static int soo_close __P((struct file *fp, struct proc *p)); 57 |
58struct fileops socketops = 59 { soo_read, soo_write, soo_ioctl, soo_select, soo_close }; 60 61/* ARGSUSED */ |
62static int |
63soo_read(fp, uio, cred) 64 struct file *fp; 65 struct uio *uio; 66 struct ucred *cred; 67{ 68 69 return (soreceive((struct socket *)fp->f_data, (struct mbuf **)0, 70 uio, (struct mbuf **)0, (struct mbuf **)0, (int *)0)); 71} 72 73/* ARGSUSED */ |
74static int |
75soo_write(fp, uio, cred) 76 struct file *fp; 77 struct uio *uio; 78 struct ucred *cred; 79{ 80 81 return (sosend((struct socket *)fp->f_data, (struct mbuf *)0, 82 uio, (struct mbuf *)0, (struct mbuf *)0, 0)); --- 109 unchanged lines hidden (view full) --- 192 bzero((caddr_t)ub, sizeof (*ub)); 193 ub->st_mode = S_IFSOCK; 194 return ((*so->so_proto->pr_usrreq)(so, PRU_SENSE, 195 (struct mbuf *)ub, (struct mbuf *)0, 196 (struct mbuf *)0)); 197} 198 199/* ARGSUSED */ |
200static int |
201soo_close(fp, p) 202 struct file *fp; 203 struct proc *p; 204{ 205 int error = 0; 206 207 if (fp->f_data) 208 error = soclose((struct socket *)fp->f_data); 209 fp->f_data = 0; 210 return (error); 211} |