Deleted Added
sdiff udiff text old ( 183661 ) new ( 191816 )
full compact
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

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)sys_socket.c 8.1 (Berkeley) 6/10/93
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/kern/sys_socket.c 191816 2009-05-05 10:56:12Z zec $");
34
35#include "opt_mac.h"
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/file.h>
40#include <sys/filedesc.h>
41#include <sys/proc.h>
42#include <sys/protosw.h>
43#include <sys/sigio.h>
44#include <sys/signal.h>
45#include <sys/signalvar.h>
46#include <sys/socket.h>
47#include <sys/socketvar.h>
48#include <sys/filio.h> /* XXX */
49#include <sys/sockio.h>
50#include <sys/stat.h>
51#include <sys/uio.h>
52#include <sys/ucred.h>
53#include <sys/vimage.h>
54
55#include <net/if.h>
56#include <net/route.h>
57
58#include <security/mac/mac_framework.h>
59
60struct fileops socketops = {
61 .fo_read = soo_read,

--- 8 unchanged lines hidden (view full) ---

70};
71
72/* ARGSUSED */
73int
74soo_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
75 int flags, struct thread *td)
76{
77 struct socket *so = fp->f_data;
78 int error;
79
80#ifdef MAC
81 SOCK_LOCK(so);
82 error = mac_socket_check_receive(active_cred, so);
83 SOCK_UNLOCK(so);
84 if (error)
85 return (error);
86#endif
87 CURVNET_SET(so->so_vnet);
88 error = soreceive(so, 0, uio, 0, 0, 0);
89 CURVNET_RESTORE();
90 return (error);
91}
92
93/* ARGSUSED */
94int
95soo_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
96 int flags, struct thread *td)
97{
98 struct socket *so = fp->f_data;

--- 25 unchanged lines hidden (view full) ---

124
125int
126soo_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
127 struct thread *td)
128{
129 struct socket *so = fp->f_data;
130 int error = 0;
131
132 CURVNET_SET(so->so_vnet);
133 switch (cmd) {
134 case FIONBIO:
135 SOCK_LOCK(so);
136 if (*(int *)data)
137 so->so_state |= SS_NBIO;
138 else
139 so->so_state &= ~SS_NBIO;
140 SOCK_UNLOCK(so);

--- 64 unchanged lines hidden (view full) ---

205 error = ifioctl(so, cmd, data, td);
206 else if (IOCGROUP(cmd) == 'r')
207 error = rtioctl_fib(cmd, data, so->so_fibnum);
208 else
209 error = ((*so->so_proto->pr_usrreqs->pru_control)
210 (so, cmd, data, 0, td));
211 break;
212 }
213 CURVNET_RESTORE();
214 return (error);
215}
216
217int
218soo_poll(struct file *fp, int events, struct ucred *active_cred,
219 struct thread *td)
220{
221 struct socket *so = fp->f_data;

--- 69 unchanged lines hidden ---