Deleted Added
full compact
socketvar.h (95883) socketvar.h (95959)
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 * @(#)socketvar.h 8.3 (Berkeley) 2/19/95
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 * @(#)socketvar.h 8.3 (Berkeley) 2/19/95
34 * $FreeBSD: head/sys/sys/socketvar.h 95883 2002-05-01 20:44:46Z alfred $
34 * $FreeBSD: head/sys/sys/socketvar.h 95959 2002-05-02 22:03:19Z alfred $
35 */
36
37#ifndef _SYS_SOCKETVAR_H_
38#define _SYS_SOCKETVAR_H_
39
40#include <sys/queue.h> /* for TAILQ macros */
35 */
36
37#ifndef _SYS_SOCKETVAR_H_
38#define _SYS_SOCKETVAR_H_
39
40#include <sys/queue.h> /* for TAILQ macros */
41#include <sys/_lock.h>
42#include <sys/_mutex.h>
43#include <sys/selinfo.h> /* for struct selinfo */
41#include <sys/selinfo.h> /* for struct selinfo */
44#include <vm/uma.h>
45
46/*
47 * Kernel structure per socket.
48 * Contains send and receive buffer queues,
49 * handle on protocol and pointer to protocol
50 * private data and error information.
51 */
52typedef u_quad_t so_gen_t;
53
42
43/*
44 * Kernel structure per socket.
45 * Contains send and receive buffer queues,
46 * handle on protocol and pointer to protocol
47 * private data and error information.
48 */
49typedef u_quad_t so_gen_t;
50
54struct accept_filter;
55
56/*
57 * List of locks:
58 * (c) const, inited in either socreate() or sonewconn()
59 * (m) sb_mtx mutex
60 * (mr) so_rcv.sb_mtx mutex
61 * (sg) sigio_lock sx
62 * (sh) sohead_lock sx
63 *

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

90 TAILQ_HEAD(, socket) so_comp; /* queue of complete unaccepted connections */
91 TAILQ_ENTRY(socket) so_list; /* list of unaccepted connections */
92 short so_qlen; /* number of unaccepted connections */
93 short so_incqlen; /* number of unaccepted incomplete
94 connections */
95 short so_qlimit; /* max number queued connections */
96 short so_timeo; /* connection timeout */
97 u_short so_error; /* error affecting connection */
51/*
52 * List of locks:
53 * (c) const, inited in either socreate() or sonewconn()
54 * (m) sb_mtx mutex
55 * (mr) so_rcv.sb_mtx mutex
56 * (sg) sigio_lock sx
57 * (sh) sohead_lock sx
58 *

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

85 TAILQ_HEAD(, socket) so_comp; /* queue of complete unaccepted connections */
86 TAILQ_ENTRY(socket) so_list; /* list of unaccepted connections */
87 short so_qlen; /* number of unaccepted connections */
88 short so_incqlen; /* number of unaccepted incomplete
89 connections */
90 short so_qlimit; /* max number queued connections */
91 short so_timeo; /* connection timeout */
92 u_short so_error; /* error affecting connection */
98 struct sigio *so_sigio; /* [sg] information for async I/O or
93 struct sigio *so_sigio; /* [sg] information for async I/O or
99 out of band data (SIGURG) */
100 u_long so_oobmark; /* chars to oob mark */
101 TAILQ_HEAD(, aiocblist) so_aiojobq; /* AIO ops waiting on socket */
102/*
103 * Variables for socket buffering.
104 */
105 struct sockbuf {
106 u_long sb_cc; /* actual chars in buffer */

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

125#define SB_KNOTE 0x100 /* kernel note attached */
126
127 void (*so_upcall)(struct socket *, void *, int);
128 void *so_upcallarg;
129 struct ucred *so_cred; /* user credentials */
130 /* NB: generation count must not be first; easiest to make it last. */
131 so_gen_t so_gencnt; /* generation count */
132 void *so_emuldata; /* private data for emulators */
94 out of band data (SIGURG) */
95 u_long so_oobmark; /* chars to oob mark */
96 TAILQ_HEAD(, aiocblist) so_aiojobq; /* AIO ops waiting on socket */
97/*
98 * Variables for socket buffering.
99 */
100 struct sockbuf {
101 u_long sb_cc; /* actual chars in buffer */

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

120#define SB_KNOTE 0x100 /* kernel note attached */
121
122 void (*so_upcall)(struct socket *, void *, int);
123 void *so_upcallarg;
124 struct ucred *so_cred; /* user credentials */
125 /* NB: generation count must not be first; easiest to make it last. */
126 so_gen_t so_gencnt; /* generation count */
127 void *so_emuldata; /* private data for emulators */
133 struct so_accf {
128 struct so_accf {
134 struct accept_filter *so_accept_filter;
135 void *so_accept_filter_arg; /* saved filter args */
136 char *so_accept_filter_str; /* saved user args */
137 } *so_accf;
138};
139
140/*
141 * Socket state bits.

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

260 } \
261}
262
263/*
264 * soref()/sorele() ref-count the socket structure. Note that you must
265 * still explicitly close the socket, but the last ref count will free
266 * the structure.
267 */
129 struct accept_filter *so_accept_filter;
130 void *so_accept_filter_arg; /* saved filter args */
131 char *so_accept_filter_str; /* saved user args */
132 } *so_accf;
133};
134
135/*
136 * Socket state bits.

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

255 } \
256}
257
258/*
259 * soref()/sorele() ref-count the socket structure. Note that you must
260 * still explicitly close the socket, but the last ref count will free
261 * the structure.
262 */
268
269#define soref(so) do { \
270 ++(so)->so_count; \
271 } while (0)
272
273#define sorele(so) do { \
274 if ((so)->so_count <= 0) \
275 panic("sorele");\
276 if (--(so)->so_count == 0)\
277 sofree(so); \
278 } while (0)
279
280#define sotryfree(so) do { \
281 if ((so)->so_count == 0) \
282 sofree(so); \
283 } while(0)
284
263#define soref(so) do { \
264 ++(so)->so_count; \
265 } while (0)
266
267#define sorele(so) do { \
268 if ((so)->so_count <= 0) \
269 panic("sorele");\
270 if (--(so)->so_count == 0)\
271 sofree(so); \
272 } while (0)
273
274#define sotryfree(so) do { \
275 if ((so)->so_count == 0) \
276 sofree(so); \
277 } while(0)
278
285#define sorwakeup_locked(so) do { \
286 if (sb_notify(&(so)->so_rcv)) \
287 sowakeup((so), &(so)->so_rcv); \
279#define sorwakeup_locked(so) do { \
280 if (sb_notify(&(so)->so_rcv)) \
281 sowakeup((so), &(so)->so_rcv); \
288 } while (0)
289
282 } while (0)
283
290#define sorwakeup(so) do { \
291 sorwakeup_locked(so); \
284#define sorwakeup(so) do { \
285 sorwakeup_locked(so); \
292 } while (0)
293
286 } while (0)
287
294#define sowwakeup_locked(so) do { \
295 if (sb_notify(&(so)->so_snd)) \
296 sowakeup((so), &(so)->so_snd); \
288#define sowwakeup_locked(so) do { \
289 if (sb_notify(&(so)->so_snd)) \
290 sowakeup((so), &(so)->so_snd); \
297 } while (0)
298
291 } while (0)
292
299#define sowwakeup(so) do { \
300 sowwakeup_locked(so); \
293#define sowwakeup(so) do { \
294 sowwakeup_locked(so); \
301 } while (0)
302
303#ifdef _KERNEL
304
305/*
306 * Argument structure for sosetopt et seq. This is in the KERNEL
307 * section because it will never be visible to user code.
308 */
309enum sopt_dir { SOPT_GET, SOPT_SET };
310struct sockopt {
311 enum sopt_dir sopt_dir; /* is this a get or a set? */
312 int sopt_level; /* second arg of [gs]etsockopt */
313 int sopt_name; /* third arg of [gs]etsockopt */
314 void *sopt_val; /* fourth arg of [gs]etsockopt */
315 size_t sopt_valsize; /* (almost) fifth arg of [gs]etsockopt */
295 } while (0)
296
297#ifdef _KERNEL
298
299/*
300 * Argument structure for sosetopt et seq. This is in the KERNEL
301 * section because it will never be visible to user code.
302 */
303enum sopt_dir { SOPT_GET, SOPT_SET };
304struct sockopt {
305 enum sopt_dir sopt_dir; /* is this a get or a set? */
306 int sopt_level; /* second arg of [gs]etsockopt */
307 int sopt_name; /* third arg of [gs]etsockopt */
308 void *sopt_val; /* fourth arg of [gs]etsockopt */
309 size_t sopt_valsize; /* (almost) fifth arg of [gs]etsockopt */
316 struct thread *sopt_td; /* calling thread or null if kernel */
310 struct thread *sopt_td; /* calling thread or null if kernel */
317};
318
319struct sf_buf {
320 SLIST_ENTRY(sf_buf) free_list; /* list of free buffer slots */
321 struct vm_page *m; /* currently mapped page */
322 vm_offset_t kva; /* va of mapping */
323};
324
325struct accept_filter {
326 char accf_name[16];
327 void (*accf_callback)
328 (struct socket *so, void *arg, int waitflag);
329 void * (*accf_create)
330 (struct socket *so, char *arg);
331 void (*accf_destroy)
332 (struct socket *so);
311};
312
313struct sf_buf {
314 SLIST_ENTRY(sf_buf) free_list; /* list of free buffer slots */
315 struct vm_page *m; /* currently mapped page */
316 vm_offset_t kva; /* va of mapping */
317};
318
319struct accept_filter {
320 char accf_name[16];
321 void (*accf_callback)
322 (struct socket *so, void *arg, int waitflag);
323 void * (*accf_create)
324 (struct socket *so, char *arg);
325 void (*accf_destroy)
326 (struct socket *so);
333 SLIST_ENTRY(accept_filter) accf_next; /* next on the list */
327 SLIST_ENTRY(accept_filter) accf_next;
334};
335
336#ifdef MALLOC_DECLARE
328};
329
330#ifdef MALLOC_DECLARE
331MALLOC_DECLARE(M_ACCF);
337MALLOC_DECLARE(M_PCB);
338MALLOC_DECLARE(M_SONAME);
332MALLOC_DECLARE(M_PCB);
333MALLOC_DECLARE(M_SONAME);
339MALLOC_DECLARE(M_ACCF);
340#endif
341
334#endif
335
342extern int maxsockets;
336extern int maxsockets;
343extern u_long sb_max;
337extern u_long sb_max;
344extern uma_zone_t socket_zone;
338extern struct uma_zone *socket_zone;
345extern so_gen_t so_gencnt;
346
347struct file;
348struct filedesc;
339extern so_gen_t so_gencnt;
340
341struct file;
342struct filedesc;
343struct knote;
349struct mbuf;
350struct sockaddr;
351struct stat;
352struct ucred;
353struct uio;
344struct mbuf;
345struct sockaddr;
346struct stat;
347struct ucred;
348struct uio;
354struct knote;
355
356/*
357 * File operations on sockets.
358 */
359int soo_read(struct file *fp, struct uio *uio, struct ucred *cred,
360 int flags, struct thread *td);
361int soo_write(struct file *fp, struct uio *uio, struct ucred *cred,
362 int flags, struct thread *td);

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

391void sbrelease(struct sockbuf *sb, struct socket *so);
392int sbreserve(struct sockbuf *sb, u_long cc, struct socket *so,
393 struct thread *td);
394void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb);
395int sbwait(struct sockbuf *sb);
396int sb_lock(struct sockbuf *sb);
397int soabort(struct socket *so);
398int soaccept(struct socket *so, struct sockaddr **nam);
349
350/*
351 * File operations on sockets.
352 */
353int soo_read(struct file *fp, struct uio *uio, struct ucred *cred,
354 int flags, struct thread *td);
355int soo_write(struct file *fp, struct uio *uio, struct ucred *cred,
356 int flags, struct thread *td);

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

385void sbrelease(struct sockbuf *sb, struct socket *so);
386int sbreserve(struct sockbuf *sb, u_long cc, struct socket *so,
387 struct thread *td);
388void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb);
389int sbwait(struct sockbuf *sb);
390int sb_lock(struct sockbuf *sb);
391int soabort(struct socket *so);
392int soaccept(struct socket *so, struct sockaddr **nam);
393int socheckuid(struct socket *so, uid_t uid);
394int socheckproc(struct socket *so, struct proc *p);
399struct socket *soalloc(int waitok);
400int sobind(struct socket *so, struct sockaddr *nam, struct thread *td);
401void socantrcvmore(struct socket *so);
402void socantsendmore(struct socket *so);
403int soclose(struct socket *so);
404int soconnect(struct socket *so, struct sockaddr *nam, struct thread *td);
405int soconnect2(struct socket *so1, struct socket *so2);
406int socreate(int dom, struct socket **aso, int type, int proto,
407 struct ucred *cred, struct thread *td);
408int sodisconnect(struct socket *so);
395struct socket *soalloc(int waitok);
396int sobind(struct socket *so, struct sockaddr *nam, struct thread *td);
397void socantrcvmore(struct socket *so);
398void socantsendmore(struct socket *so);
399int soclose(struct socket *so);
400int soconnect(struct socket *so, struct sockaddr *nam, struct thread *td);
401int soconnect2(struct socket *so1, struct socket *so2);
402int socreate(int dom, struct socket **aso, int type, int proto,
403 struct ucred *cred, struct thread *td);
404int sodisconnect(struct socket *so);
405void soisconnected_locked(struct socket *so);
409void sofree(struct socket *so);
410int sogetopt(struct socket *so, struct sockopt *sopt);
411void sohasoutofband(struct socket *so);
412void soisconnected(struct socket *so);
406void sofree(struct socket *so);
407int sogetopt(struct socket *so, struct sockopt *sopt);
408void sohasoutofband(struct socket *so);
409void soisconnected(struct socket *so);
413void soisconnected_locked(struct socket *so);
414void soisconnecting(struct socket *so);
415void soisdisconnected(struct socket *so);
416void soisdisconnected_locked(struct socket *so);
417void soisdisconnecting(struct socket *so);
418int solisten(struct socket *so, int backlog, struct thread *td);
419struct socket *
420 sonewconn(struct socket *head, int connstatus);
421int sooptcopyin(struct sockopt *sopt, void *buf, size_t len, size_t minlen);

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

435int sosend(struct socket *so, struct sockaddr *addr, struct uio *uio,
436 struct mbuf *top, struct mbuf *control, int flags,
437 struct thread *td);
438int sosetopt(struct socket *so, struct sockopt *sopt);
439int soshutdown(struct socket *so, int how);
440void sotoxsocket(struct socket *so, struct xsocket *xso);
441void sowakeup(struct socket *so, struct sockbuf *sb);
442
410void soisconnecting(struct socket *so);
411void soisdisconnected(struct socket *so);
412void soisdisconnected_locked(struct socket *so);
413void soisdisconnecting(struct socket *so);
414int solisten(struct socket *so, int backlog, struct thread *td);
415struct socket *
416 sonewconn(struct socket *head, int connstatus);
417int sooptcopyin(struct sockopt *sopt, void *buf, size_t len, size_t minlen);

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

431int sosend(struct socket *so, struct sockaddr *addr, struct uio *uio,
432 struct mbuf *top, struct mbuf *control, int flags,
433 struct thread *td);
434int sosetopt(struct socket *so, struct sockopt *sopt);
435int soshutdown(struct socket *so, int how);
436void sotoxsocket(struct socket *so, struct xsocket *xso);
437void sowakeup(struct socket *so, struct sockbuf *sb);
438
443/* accept filter functions */
439/*
440 * Accept filter functions (duh).
441 */
444int accept_filt_add(struct accept_filter *filt);
445int accept_filt_del(char *name);
442int accept_filt_add(struct accept_filter *filt);
443int accept_filt_del(char *name);
446struct accept_filter * accept_filt_get(char *name);
444struct accept_filter *accept_filt_get(char *name);
447#ifdef ACCEPT_FILTER_MOD
445#ifdef ACCEPT_FILTER_MOD
448int accept_filt_generic_mod_event(module_t mod, int event, void *data);
446#ifdef SYSCTL_DECL
449SYSCTL_DECL(_net_inet_accf);
447SYSCTL_DECL(_net_inet_accf);
450#endif /* ACCEPT_FILTER_MOD */
448#endif
449int accept_filt_generic_mod_event(module_t mod, int event, void *data);
450#endif
451
451
452int socheckuid(struct socket *so, uid_t uid);
453int socheckproc(struct socket *so, struct proc *p);
454
455#endif /* _KERNEL */
456
457#endif /* !_SYS_SOCKETVAR_H_ */
452#endif /* _KERNEL */
453
454#endif /* !_SYS_SOCKETVAR_H_ */