1139827Simp/*-
2132043Srwatson * Copyright (c) 2004 Robert N. M. Watson
3165891Srwatson * All rights reserved.
4165891Srwatson *
5165891Srwatson * Redistribution and use in source and binary forms, with or without
6165891Srwatson * modification, are permitted provided that the following conditions
7165891Srwatson * are met:
8165891Srwatson * 1. Redistributions of source code must retain the above copyright
9165891Srwatson *    notice, this list of conditions and the following disclaimer.
10165891Srwatson * 2. Redistributions in binary form must reproduce the above copyright
11165891Srwatson *    notice, this list of conditions and the following disclaimer in the
12165891Srwatson *    documentation and/or other materials provided with the distribution.
13165891Srwatson *
14165891Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15165891Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16165891Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17165891Srwatson * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18165891Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19165891Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20165891Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21165891Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22165891Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23165891Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24165891Srwatson * SUCH DAMAGE.
25165891Srwatson *
26165974Srwatson * Copyright (c) 1990, 1994 Regents of The University of Michigan.
27139827Simp * All Rights Reserved.
28127195Srwatson *
29139827Simp * Permission to use, copy, modify, and distribute this software and
30139827Simp * its documentation for any purpose and without fee is hereby granted,
31139827Simp * provided that the above copyright notice appears in all copies and
32139827Simp * that both that copyright notice and this permission notice appear
33139827Simp * in supporting documentation, and that the name of The University
34139827Simp * of Michigan not be used in advertising or publicity pertaining to
35139827Simp * distribution of the software without specific, written prior
36139827Simp * permission. This software is supplied as is without expressed or
37139827Simp * implied warranties of any kind.
38139827Simp *
39139827Simp * This product includes software developed by the University of
40139827Simp * California, Berkeley and its contributors.
41139827Simp *
42139827Simp *	Research Systems Unix Group
43139827Simp *	The University of Michigan
44139827Simp *	c/o Wesley Craig
45139827Simp *	535 W. William Street
46139827Simp *	Ann Arbor, Michigan
47139827Simp *	+1-313-764-2278
48139827Simp *	netatalk@umich.edu
49139827Simp *
50127195Srwatson * $FreeBSD$
51127195Srwatson */
52127195Srwatson
53127195Srwatson#ifndef _NETATALK_DDP_PCB_H_
54127195Srwatson#define	_NETATALK_DDP_PCB_H_
55127195Srwatson
56127195Srwatsonint	at_pcballoc(struct socket *so);
57127195Srwatsonint	at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr,
58127195Srwatson	    struct thread *td);
59127195Srwatsonvoid	at_pcbdetach(struct socket *so, struct ddpcb *ddp);
60127195Srwatsonvoid	at_pcbdisconnect(struct ddpcb *ddp);
61127195Srwatsonint	at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr,
62127195Srwatson	    struct thread *td);
63127195Srwatsonvoid	at_sockaddr(struct ddpcb *ddp, struct sockaddr **addr);
64127195Srwatson
65132043Srwatson/* Lock macros for per-pcb locks. */
66132043Srwatson#define	DDP_LOCK_INIT(ddp)	mtx_init(&(ddp)->ddp_mtx, "ddp_mtx",	\
67132043Srwatson				    NULL, MTX_DEF)
68132043Srwatson#define	DDP_LOCK_DESTROY(ddp)	mtx_destroy(&(ddp)->ddp_mtx)
69132043Srwatson#define	DDP_LOCK(ddp)		mtx_lock(&(ddp)->ddp_mtx)
70132043Srwatson#define	DDP_UNLOCK(ddp)		mtx_unlock(&(ddp)->ddp_mtx)
71132043Srwatson#define	DDP_LOCK_ASSERT(ddp)	mtx_assert(&(ddp)->ddp_mtx, MA_OWNED)
72132043Srwatson
73132043Srwatson/* Lock macros for global pcb list lock. */
74132043Srwatson#define	DDP_LIST_LOCK_INIT()	mtx_init(&ddp_list_mtx, "ddp_list_mtx",	\
75132043Srwatson				    NULL, MTX_DEF)
76132043Srwatson#define	DDP_LIST_LOCK_DESTROY()	mtx_destroy(&ddp_list_mtx)
77132043Srwatson#define	DDP_LIST_XLOCK()	mtx_lock(&ddp_list_mtx)
78132043Srwatson#define	DDP_LIST_XUNLOCK()	mtx_unlock(&ddp_list_mtx)
79132043Srwatson#define	DDP_LIST_XLOCK_ASSERT()	mtx_assert(&ddp_list_mtx, MA_OWNED)
80132043Srwatson#define	DDP_LIST_SLOCK()	mtx_lock(&ddp_list_mtx)
81132043Srwatson#define	DDP_LIST_SUNLOCK()	mtx_unlock(&ddp_list_mtx)
82132043Srwatson#define	DDP_LIST_SLOCK_ASSERT()	mtx_assert(&ddp_list_mtx, MA_OWNED)
83132043Srwatson
84165974Srwatson#endif /* !_NETATALK_DDP_PCB_H_ */
85