xref: /csrg-svn/sys/sys/unpcb.h (revision 43445)
123453Smckusick /*
237723Smckusick  * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
333290Sbostic  * All rights reserved.
423453Smckusick  *
533290Sbostic  * Redistribution and use in source and binary forms are permitted
634837Sbostic  * provided that the above copyright notice and this paragraph are
734837Sbostic  * duplicated in all such forms and that any documentation,
834837Sbostic  * advertising materials, and other materials related to such
934837Sbostic  * distribution and use acknowledge that the software was developed
1034837Sbostic  * by the University of California, Berkeley.  The name of the
1134837Sbostic  * University may not be used to endorse or promote products derived
1234837Sbostic  * from this software without specific prior written permission.
1334837Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1434837Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1537723Smckusick  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1633290Sbostic  *
17*43445Skarels  *	@(#)unpcb.h	7.5 (Berkeley) 06/22/90
1823453Smckusick  */
197622Sroot 
207622Sroot /*
217622Sroot  * Protocol control block for an active
227622Sroot  * instance of a UNIX internal protocol.
237622Sroot  *
2437723Smckusick  * A socket may be associated with an vnode in the
2537723Smckusick  * file system.  If so, the unp_vnode pointer holds
2637723Smckusick  * a reference count to this vnode, 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 */
4737723Smckusick 	struct	vnode *unp_vnode;	/* if associated with file */
48*43445Skarels 	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