ddp_pcb.h revision 139827
1/*-
2 * Copyright (c) 2004 Robert N. M. Watson
3 * Copyright (c) 1990,1994 Regents of The University of Michigan.
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify, and distribute this software and
7 * its documentation for any purpose and without fee is hereby granted,
8 * provided that the above copyright notice appears in all copies and
9 * that both that copyright notice and this permission notice appear
10 * in supporting documentation, and that the name of The University
11 * of Michigan not be used in advertising or publicity pertaining to
12 * distribution of the software without specific, written prior
13 * permission. This software is supplied as is without expressed or
14 * implied warranties of any kind.
15 *
16 * This product includes software developed by the University of
17 * California, Berkeley and its contributors.
18 *
19 *	Research Systems Unix Group
20 *	The University of Michigan
21 *	c/o Wesley Craig
22 *	535 W. William Street
23 *	Ann Arbor, Michigan
24 *	+1-313-764-2278
25 *	netatalk@umich.edu
26 *
27 * $FreeBSD: head/sys/netatalk/ddp_pcb.h 139827 2005-01-07 02:35:34Z imp $
28 */
29
30#ifndef _NETATALK_DDP_PCB_H_
31#define	_NETATALK_DDP_PCB_H_
32
33int	at_pcballoc(struct socket *so);
34int	at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr,
35	    struct thread *td);
36void	at_pcbdetach(struct socket *so, struct ddpcb *ddp);
37void	at_pcbdisconnect(struct ddpcb *ddp);
38int	at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr,
39	    struct thread *td);
40void	at_sockaddr(struct ddpcb *ddp, struct sockaddr **addr);
41
42/* Lock macros for per-pcb locks. */
43#define	DDP_LOCK_INIT(ddp)	mtx_init(&(ddp)->ddp_mtx, "ddp_mtx",	\
44				    NULL, MTX_DEF)
45#define	DDP_LOCK_DESTROY(ddp)	mtx_destroy(&(ddp)->ddp_mtx)
46#define	DDP_LOCK(ddp)		mtx_lock(&(ddp)->ddp_mtx)
47#define	DDP_UNLOCK(ddp)		mtx_unlock(&(ddp)->ddp_mtx)
48#define	DDP_LOCK_ASSERT(ddp)	mtx_assert(&(ddp)->ddp_mtx, MA_OWNED)
49
50/* Lock macros for global pcb list lock. */
51#define	DDP_LIST_LOCK_INIT()	mtx_init(&ddp_list_mtx, "ddp_list_mtx",	\
52				    NULL, MTX_DEF)
53#define	DDP_LIST_LOCK_DESTROY()	mtx_destroy(&ddp_list_mtx)
54#define	DDP_LIST_XLOCK()	mtx_lock(&ddp_list_mtx)
55#define	DDP_LIST_XUNLOCK()	mtx_unlock(&ddp_list_mtx)
56#define	DDP_LIST_XLOCK_ASSERT()	mtx_assert(&ddp_list_mtx, MA_OWNED)
57#define	DDP_LIST_SLOCK()	mtx_lock(&ddp_list_mtx)
58#define	DDP_LIST_SUNLOCK()	mtx_unlock(&ddp_list_mtx)
59#define	DDP_LIST_SLOCK_ASSERT()	mtx_assert(&ddp_list_mtx, MA_OWNED)
60
61#endif
62