xref: /original-bsd/sys/sys/unpcb.h (revision c3e32dec)
1 /*
2  * Copyright (c) 1982, 1986, 1989, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)unpcb.h	8.1 (Berkeley) 06/02/93
8  */
9 
10 /*
11  * Protocol control block for an active
12  * instance of a UNIX internal protocol.
13  *
14  * A socket may be associated with an vnode in the
15  * file system.  If so, the unp_vnode pointer holds
16  * a reference count to this vnode, which should be irele'd
17  * when the socket goes away.
18  *
19  * A socket may be connected to another socket, in which
20  * case the control block of the socket to which it is connected
21  * is given by unp_conn.
22  *
23  * A socket may be referenced by a number of sockets (e.g. several
24  * sockets may be connected to a datagram socket.)  These sockets
25  * are in a linked list starting with unp_refs, linked through
26  * unp_nextref and null-terminated.  Note that a socket may be referenced
27  * by a number of other sockets and may also reference a socket (not
28  * necessarily one which is referencing it).  This generates
29  * the need for unp_refs and unp_nextref to be separate fields.
30  *
31  * Stream sockets keep copies of receive sockbuf sb_cc and sb_mbcnt
32  * so that changes in the sockbuf may be computed to modify
33  * back pressure on the sender accordingly.
34  */
35 struct	unpcb {
36 	struct	socket *unp_socket;	/* pointer back to socket */
37 	struct	vnode *unp_vnode;	/* if associated with file */
38 	ino_t	unp_ino;		/* fake inode number */
39 	struct	unpcb *unp_conn;	/* control block of connected socket */
40 	struct	unpcb *unp_refs;	/* referencing socket linked list */
41 	struct 	unpcb *unp_nextref;	/* link in unp_refs list */
42 	struct	mbuf *unp_addr;		/* bound address of socket */
43 	int	unp_cc;			/* copy of rcv.sb_cc */
44 	int	unp_mbcnt;		/* copy of rcv.sb_mbcnt */
45 };
46 
47 #define	sotounpcb(so)	((struct unpcb *)((so)->so_pcb))
48