xref: /csrg-svn/sys/sys/unpcb.h (revision 34837)
123453Smckusick /*
229055Smckusick  * Copyright (c) 1982, 1986 Regents of the University of California.
333290Sbostic  * All rights reserved.
423453Smckusick  *
533290Sbostic  * Redistribution and use in source and binary forms are permitted
6*34837Sbostic  * provided that the above copyright notice and this paragraph are
7*34837Sbostic  * duplicated in all such forms and that any documentation,
8*34837Sbostic  * advertising materials, and other materials related to such
9*34837Sbostic  * distribution and use acknowledge that the software was developed
10*34837Sbostic  * by the University of California, Berkeley.  The name of the
11*34837Sbostic  * University may not be used to endorse or promote products derived
12*34837Sbostic  * from this software without specific prior written permission.
13*34837Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*34837Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*34837Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1633290Sbostic  *
17*34837Sbostic  *	@(#)unpcb.h	7.3 (Berkeley) 06/27/88
1823453Smckusick  */
197622Sroot 
207622Sroot /*
217622Sroot  * Protocol control block for an active
227622Sroot  * instance of a UNIX internal protocol.
237622Sroot  *
247622Sroot  * A socket may be associated with an inode in the
257622Sroot  * file system.  If so, the unp_inode pointer holds
267622Sroot  * a reference count to this inode, which should be irele'd
277622Sroot  * when the socket goes away.
287622Sroot  *
297622Sroot  * A socket may be connected to another socket, in which
307622Sroot  * case the control block of the socket to which it is connected
317622Sroot  * is given by unp_conn.
327622Sroot  *
337622Sroot  * A socket may be referenced by a number of sockets (e.g. several
347622Sroot  * sockets may be connected to a datagram socket.)  These sockets
357622Sroot  * are in a linked list starting with unp_refs, linked through
367622Sroot  * unp_nextref and null-terminated.  Note that a socket may be referenced
377622Sroot  * by a number of other sockets and may also reference a socket (not
387622Sroot  * necessarily one which is referencing it).  This generates
397622Sroot  * the need for unp_refs and unp_nextref to be separate fields.
4025594Skarels  *
4125594Skarels  * Stream sockets keep copies of receive sockbuf sb_cc and sb_mbcnt
4225594Skarels  * so that changes in the sockbuf may be computed to modify
4325594Skarels  * back pressure on the sender accordingly.
447622Sroot  */
457622Sroot struct	unpcb {
467622Sroot 	struct	socket *unp_socket;	/* pointer back to socket */
477622Sroot 	struct	inode *unp_inode;	/* if associated with file */
4825594Skarels 	ino_t	unp_ino;		/* fake inode number */
497622Sroot 	struct	unpcb *unp_conn;	/* control block of connected socket */
507622Sroot 	struct	unpcb *unp_refs;	/* referencing socket linked list */
517622Sroot 	struct 	unpcb *unp_nextref;	/* link in unp_refs list */
5225594Skarels 	struct	mbuf *unp_addr;		/* bound address of socket */
5325594Skarels 	int	unp_cc;			/* copy of rcv.sb_cc */
5425594Skarels 	int	unp_mbcnt;		/* copy of rcv.sb_mbcnt */
557622Sroot };
567643Sroot 
577643Sroot #define	sotounpcb(so)	((struct unpcb *)((so)->so_pcb))
58