Deleted Added
full compact
socketvar.h (130818) socketvar.h (130831)
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

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

22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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 * @(#)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

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

22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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 * @(#)socketvar.h 8.3 (Berkeley) 2/19/95
30 * $FreeBSD: head/sys/sys/socketvar.h 130818 2004-06-20 21:39:46Z rwatson $
30 * $FreeBSD: head/sys/sys/socketvar.h 130831 2004-06-21 00:20:43Z rwatson $
31 */
32
33#ifndef _SYS_SOCKETVAR_H_
34#define _SYS_SOCKETVAR_H_
35
36#include <sys/queue.h> /* for TAILQ macros */
37#include <sys/selinfo.h> /* for struct selinfo */
38#include <sys/_lock.h>

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

314 * Unless SB_NOINTR is set on sockbuf, sleep is interruptible.
315 * Returns error without lock if sleep is interrupted.
316 */
317#define sblock(sb, wf) ((sb)->sb_flags & SB_LOCK ? \
318 (((wf) == M_WAITOK) ? sb_lock(sb) : EWOULDBLOCK) : \
319 ((sb)->sb_flags |= SB_LOCK), 0)
320
321/* release lock on sockbuf sb */
31 */
32
33#ifndef _SYS_SOCKETVAR_H_
34#define _SYS_SOCKETVAR_H_
35
36#include <sys/queue.h> /* for TAILQ macros */
37#include <sys/selinfo.h> /* for struct selinfo */
38#include <sys/_lock.h>

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

314 * Unless SB_NOINTR is set on sockbuf, sleep is interruptible.
315 * Returns error without lock if sleep is interrupted.
316 */
317#define sblock(sb, wf) ((sb)->sb_flags & SB_LOCK ? \
318 (((wf) == M_WAITOK) ? sb_lock(sb) : EWOULDBLOCK) : \
319 ((sb)->sb_flags |= SB_LOCK), 0)
320
321/* release lock on sockbuf sb */
322#define sbunlock(sb) { \
322#define sbunlock(sb) do { \
323 SOCKBUF_LOCK_ASSERT(sb); \
323 (sb)->sb_flags &= ~SB_LOCK; \
324 if ((sb)->sb_flags & SB_WANT) { \
325 (sb)->sb_flags &= ~SB_WANT; \
326 wakeup(&(sb)->sb_flags); \
327 } \
324 (sb)->sb_flags &= ~SB_LOCK; \
325 if ((sb)->sb_flags & SB_WANT) { \
326 (sb)->sb_flags &= ~SB_WANT; \
327 wakeup(&(sb)->sb_flags); \
328 } \
328}
329} while (0)
329
330/*
331 * soref()/sorele() ref-count the socket structure. Note that you must
332 * still explicitly close the socket, but the last ref count will free
333 * the structure.
334 */
335#define soref(so) do { \
336 SOCK_LOCK_ASSERT(so); \

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

350#define sotryfree(so) do { \
351 SOCK_LOCK_ASSERT(so); \
352 if ((so)->so_count == 0) \
353 sofree(so); \
354 else \
355 SOCK_UNLOCK(so); \
356} while(0)
357
330
331/*
332 * soref()/sorele() ref-count the socket structure. Note that you must
333 * still explicitly close the socket, but the last ref count will free
334 * the structure.
335 */
336#define soref(so) do { \
337 SOCK_LOCK_ASSERT(so); \

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

351#define sotryfree(so) do { \
352 SOCK_LOCK_ASSERT(so); \
353 if ((so)->so_count == 0) \
354 sofree(so); \
355 else \
356 SOCK_UNLOCK(so); \
357} while(0)
358
358#define sorwakeup(so) do { \
359/*
360 * In sorwakeup() and sowwakeup(), acquire the socket buffer lock to
361 * avoid a non-atomic test-and-wakeup. However, sowakeup is
362 * responsible for releasing the lock if it is called. We unlock only
363 * if we don't call into sowakeup. If any code is introduced that
364 * directly invokes the underlying sowakeup() primitives, it must
365 * maintain the same semantics.
366 */
367#define sorwakeup_locked(so) do { \
368 SOCKBUF_LOCK_ASSERT(&(so)->so_rcv); \
359 if (sb_notify(&(so)->so_rcv)) \
369 if (sb_notify(&(so)->so_rcv)) \
360 sowakeup((so), &(so)->so_rcv); \
370 sowakeup((so), &(so)->so_rcv); \
371 else \
372 SOCKBUF_UNLOCK(&(so)->so_rcv); \
361} while (0)
362
373} while (0)
374
363#define sowwakeup(so) do { \
375#define sorwakeup(so) do { \
376 SOCKBUF_LOCK(&(so)->so_rcv); \
377 sorwakeup_locked(so); \
378} while (0)
379
380#define sowwakeup_locked(so) do { \
364 if (sb_notify(&(so)->so_snd)) \
365 sowakeup((so), &(so)->so_snd); \
381 if (sb_notify(&(so)->so_snd)) \
382 sowakeup((so), &(so)->so_snd); \
383 else \
384 SOCKBUF_UNLOCK(&(so)->so_snd); \
366} while (0)
367
385} while (0)
386
387#define sowwakeup(so) do { \
388 SOCKBUF_LOCK(&(so)->so_snd); \
389 sowwakeup_locked(so); \
390} while (0)
391
368/*
369 * Argument structure for sosetopt et seq. This is in the KERNEL
370 * section because it will never be visible to user code.
371 */
372enum sopt_dir { SOPT_GET, SOPT_SET };
373struct sockopt {
374 enum sopt_dir sopt_dir; /* is this a get or a set? */
375 int sopt_level; /* second arg of [gs]etsockopt */

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

407struct uio;
408
409/*
410 * From uipc_socket and friends
411 */
412int sockargs(struct mbuf **mp, caddr_t buf, int buflen, int type);
413int getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len);
414void sbappend(struct sockbuf *sb, struct mbuf *m);
392/*
393 * Argument structure for sosetopt et seq. This is in the KERNEL
394 * section because it will never be visible to user code.
395 */
396enum sopt_dir { SOPT_GET, SOPT_SET };
397struct sockopt {
398 enum sopt_dir sopt_dir; /* is this a get or a set? */
399 int sopt_level; /* second arg of [gs]etsockopt */

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

431struct uio;
432
433/*
434 * From uipc_socket and friends
435 */
436int sockargs(struct mbuf **mp, caddr_t buf, int buflen, int type);
437int getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len);
438void sbappend(struct sockbuf *sb, struct mbuf *m);
439void sbappend_locked(struct sockbuf *sb, struct mbuf *m);
415void sbappendstream(struct sockbuf *sb, struct mbuf *m);
440void sbappendstream(struct sockbuf *sb, struct mbuf *m);
441void sbappendstream_locked(struct sockbuf *sb, struct mbuf *m);
416int sbappendaddr(struct sockbuf *sb, const struct sockaddr *asa,
417 struct mbuf *m0, struct mbuf *control);
442int sbappendaddr(struct sockbuf *sb, const struct sockaddr *asa,
443 struct mbuf *m0, struct mbuf *control);
444int sbappendaddr_locked(struct sockbuf *sb, const struct sockaddr *asa,
445 struct mbuf *m0, struct mbuf *control);
418int sbappendcontrol(struct sockbuf *sb, struct mbuf *m0,
419 struct mbuf *control);
446int sbappendcontrol(struct sockbuf *sb, struct mbuf *m0,
447 struct mbuf *control);
448int sbappendcontrol_locked(struct sockbuf *sb, struct mbuf *m0,
449 struct mbuf *control);
420void sbappendrecord(struct sockbuf *sb, struct mbuf *m0);
450void sbappendrecord(struct sockbuf *sb, struct mbuf *m0);
451void sbappendrecord_locked(struct sockbuf *sb, struct mbuf *m0);
421void sbcheck(struct sockbuf *sb);
422void sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n);
423struct mbuf *
424 sbcreatecontrol(caddr_t p, int size, int type, int level);
425void sbdrop(struct sockbuf *sb, int len);
452void sbcheck(struct sockbuf *sb);
453void sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n);
454struct mbuf *
455 sbcreatecontrol(caddr_t p, int size, int type, int level);
456void sbdrop(struct sockbuf *sb, int len);
457void sbdrop_locked(struct sockbuf *sb, int len);
426void sbdroprecord(struct sockbuf *sb);
458void sbdroprecord(struct sockbuf *sb);
459void sbdroprecord_locked(struct sockbuf *sb);
427void sbflush(struct sockbuf *sb);
460void sbflush(struct sockbuf *sb);
461void sbflush_locked(struct sockbuf *sb);
428void sbinsertoob(struct sockbuf *sb, struct mbuf *m0);
462void sbinsertoob(struct sockbuf *sb, struct mbuf *m0);
463void sbinsertoob_locked(struct sockbuf *sb, struct mbuf *m0);
429void sbrelease(struct sockbuf *sb, struct socket *so);
464void sbrelease(struct sockbuf *sb, struct socket *so);
465void sbrelease_locked(struct sockbuf *sb, struct socket *so);
430int sbreserve(struct sockbuf *sb, u_long cc, struct socket *so,
431 struct thread *td);
432void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb);
433int sbwait(struct sockbuf *sb);
434int sb_lock(struct sockbuf *sb);
435int soabort(struct socket *so);
436int soaccept(struct socket *so, struct sockaddr **nam);
437struct socket *soalloc(int mflags);
438int socheckuid(struct socket *so, uid_t uid);
439int sobind(struct socket *so, struct sockaddr *nam, struct thread *td);
440void socantrcvmore(struct socket *so);
466int sbreserve(struct sockbuf *sb, u_long cc, struct socket *so,
467 struct thread *td);
468void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb);
469int sbwait(struct sockbuf *sb);
470int sb_lock(struct sockbuf *sb);
471int soabort(struct socket *so);
472int soaccept(struct socket *so, struct sockaddr **nam);
473struct socket *soalloc(int mflags);
474int socheckuid(struct socket *so, uid_t uid);
475int sobind(struct socket *so, struct sockaddr *nam, struct thread *td);
476void socantrcvmore(struct socket *so);
477void socantrcvmore_locked(struct socket *so);
441void socantsendmore(struct socket *so);
478void socantsendmore(struct socket *so);
479void socantsendmore_locked(struct socket *so);
442int soclose(struct socket *so);
443int soconnect(struct socket *so, struct sockaddr *nam, struct thread *td);
444int soconnect2(struct socket *so1, struct socket *so2);
445int socow_setup(struct mbuf *m0, struct uio *uio);
446int socreate(int dom, struct socket **aso, int type, int proto,
447 struct ucred *cred, struct thread *td);
448void sodealloc(struct socket *so);
449int sodisconnect(struct socket *so);

--- 60 unchanged lines hidden ---
480int soclose(struct socket *so);
481int soconnect(struct socket *so, struct sockaddr *nam, struct thread *td);
482int soconnect2(struct socket *so1, struct socket *so2);
483int socow_setup(struct mbuf *m0, struct uio *uio);
484int socreate(int dom, struct socket **aso, int type, int proto,
485 struct ucred *cred, struct thread *td);
486void sodealloc(struct socket *so);
487int sodisconnect(struct socket *so);

--- 60 unchanged lines hidden ---