xref: /csrg-svn/sys/sys/unpcb.h (revision 25594)
123453Smckusick /*
223453Smckusick  * Copyright (c) 1982 Regents of the University of California.
323453Smckusick  * All rights reserved.  The Berkeley software License Agreement
423453Smckusick  * specifies the terms and conditions for redistribution.
523453Smckusick  *
6*25594Skarels  *	@(#)unpcb.h	6.3 (Berkeley) 12/11/85
723453Smckusick  */
87622Sroot 
97622Sroot /*
107622Sroot  * Protocol control block for an active
117622Sroot  * instance of a UNIX internal protocol.
127622Sroot  *
137622Sroot  * A socket may be associated with an inode in the
147622Sroot  * file system.  If so, the unp_inode pointer holds
157622Sroot  * a reference count to this inode, which should be irele'd
167622Sroot  * when the socket goes away.
177622Sroot  *
187622Sroot  * A socket may be connected to another socket, in which
197622Sroot  * case the control block of the socket to which it is connected
207622Sroot  * is given by unp_conn.
217622Sroot  *
227622Sroot  * A socket may be referenced by a number of sockets (e.g. several
237622Sroot  * sockets may be connected to a datagram socket.)  These sockets
247622Sroot  * are in a linked list starting with unp_refs, linked through
257622Sroot  * unp_nextref and null-terminated.  Note that a socket may be referenced
267622Sroot  * by a number of other sockets and may also reference a socket (not
277622Sroot  * necessarily one which is referencing it).  This generates
287622Sroot  * the need for unp_refs and unp_nextref to be separate fields.
29*25594Skarels  *
30*25594Skarels  * Stream sockets keep copies of receive sockbuf sb_cc and sb_mbcnt
31*25594Skarels  * so that changes in the sockbuf may be computed to modify
32*25594Skarels  * back pressure on the sender accordingly.
337622Sroot  */
347622Sroot struct	unpcb {
357622Sroot 	struct	socket *unp_socket;	/* pointer back to socket */
367622Sroot 	struct	inode *unp_inode;	/* if associated with file */
37*25594Skarels 	ino_t	unp_ino;		/* fake inode number */
387622Sroot 	struct	unpcb *unp_conn;	/* control block of connected socket */
397622Sroot 	struct	unpcb *unp_refs;	/* referencing socket linked list */
407622Sroot 	struct 	unpcb *unp_nextref;	/* link in unp_refs list */
41*25594Skarels 	struct	mbuf *unp_addr;		/* bound address of socket */
42*25594Skarels 	int	unp_cc;			/* copy of rcv.sb_cc */
43*25594Skarels 	int	unp_mbcnt;		/* copy of rcv.sb_mbcnt */
447622Sroot };
457643Sroot 
467643Sroot #define	sotounpcb(so)	((struct unpcb *)((so)->so_pcb))
47