FreeBSD/Linux Kernel Cross Reference
sys/sys/unpcb.h
1 /* $NetBSD: unpcb.h,v 1.13 2003/11/29 10:02:42 matt Exp $ */
2
3 /*
4 * Copyright (c) 1982, 1986, 1989, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)unpcb.h 8.1 (Berkeley) 6/2/93
32 */
33
34 #ifndef _SYS_UNPCB_H_
35 #define _SYS_UNPCB_H_
36
37 /*
38 * Protocol control block for an active
39 * instance of a UNIX internal protocol.
40 *
41 * A socket may be associated with an vnode in the
42 * file system. If so, the unp_vnode pointer holds
43 * a reference count to this vnode, which should be irele'd
44 * when the socket goes away.
45 *
46 * A socket may be connected to another socket, in which
47 * case the control block of the socket to which it is connected
48 * is given by unp_conn.
49 *
50 * A socket may be referenced by a number of sockets (e.g. several
51 * sockets may be connected to a datagram socket.) These sockets
52 * are in a linked list starting with unp_refs, linked through
53 * unp_nextref and null-terminated. Note that a socket may be referenced
54 * by a number of other sockets and may also reference a socket (not
55 * necessarily one which is referencing it). This generates
56 * the need for unp_refs and unp_nextref to be separate fields.
57 *
58 * Stream sockets keep copies of receive sockbuf sb_cc and sb_mbcnt
59 * so that changes in the sockbuf may be computed to modify
60 * back pressure on the sender accordingly.
61 *
62 * The unp_ctime holds the creation time of the socket: it might be part of
63 * a socketpair created by pipe(2), and POSIX requires pipe(2) to initialize
64 * a stat structure's st_[acm]time members with the pipe's creation time.
65 * N.B.: updating st_[am]time when reading/writing the pipe is not required,
66 * so we just use a single timespec and do not implement that.
67 */
68 struct unpcb {
69 struct socket *unp_socket; /* pointer back to socket */
70 struct vnode *unp_vnode; /* if associated with file */
71 ino_t unp_ino; /* fake inode number */
72 struct unpcb *unp_conn; /* control block of connected socket */
73 struct unpcb *unp_refs; /* referencing socket linked list */
74 struct unpcb *unp_nextref; /* link in unp_refs list */
75 struct sockaddr_un *unp_addr; /* bound address of socket */
76 size_t unp_addrlen; /* size of socket address */
77 int unp_cc; /* copy of rcv.sb_cc */
78 int unp_mbcnt; /* copy of rcv.sb_mbcnt */
79 struct timespec unp_ctime; /* holds creation time */
80 int unp_flags; /* misc flags; see below*/
81 };
82
83 /* unp_flags */
84 #define UNP_WANTCRED 0x0001 /* credentials wanted */
85 #define UNP_CONNWAIT 0x0002 /* connect blocks until accepted */
86
87 #define sotounpcb(so) ((struct unpcb *)((so)->so_pcb))
88
89 #endif /* !_SYS_UNPCB_H_ */
Cache object: c64d40f3fbf44f1e34b03fb4a2b7d483
|