xref: /original-bsd/sys/sys/unpcb.h (revision e74403ba)
1 /*	unpcb.h	6.1	83/07/29	*/
2 
3 /*
4  * Protocol control block for an active
5  * instance of a UNIX internal protocol.
6  *
7  * A socket may be associated with an inode in the
8  * file system.  If so, the unp_inode pointer holds
9  * a reference count to this inode, which should be irele'd
10  * when the socket goes away.
11  *
12  * A socket may be connected to another socket, in which
13  * case the control block of the socket to which it is connected
14  * is given by unp_conn.
15  *
16  * A socket may be referenced by a number of sockets (e.g. several
17  * sockets may be connected to a datagram socket.)  These sockets
18  * are in a linked list starting with unp_refs, linked through
19  * unp_nextref and null-terminated.  Note that a socket may be referenced
20  * by a number of other sockets and may also reference a socket (not
21  * necessarily one which is referencing it).  This generates
22  * the need for unp_refs and unp_nextref to be separate fields.
23  */
24 struct	unpcb {
25 	struct	socket *unp_socket;	/* pointer back to socket */
26 	struct	inode *unp_inode;	/* if associated with file */
27 	struct	unpcb *unp_conn;	/* control block of connected socket */
28 	struct	unpcb *unp_refs;	/* referencing socket linked list */
29 	struct 	unpcb *unp_nextref;	/* link in unp_refs list */
30 	struct	mbuf *unp_remaddr;	/* address of connected socket */
31 };
32 
33 #define	sotounpcb(so)	((struct unpcb *)((so)->so_pcb))
34