123453Smckusick /* 2*61064Sbostic * Copyright (c) 1982, 1986, 1989, 1993 3*61064Sbostic * The Regents of the University of California. All rights reserved. 423453Smckusick * 544524Sbostic * %sccs.include.redist.c% 633290Sbostic * 7*61064Sbostic * @(#)unpcb.h 8.1 (Berkeley) 06/02/93 823453Smckusick */ 97622Sroot 107622Sroot /* 117622Sroot * Protocol control block for an active 127622Sroot * instance of a UNIX internal protocol. 137622Sroot * 1437723Smckusick * A socket may be associated with an vnode in the 1537723Smckusick * file system. If so, the unp_vnode pointer holds 1637723Smckusick * a reference count to this vnode, which should be irele'd 177622Sroot * when the socket goes away. 187622Sroot * 197622Sroot * A socket may be connected to another socket, in which 207622Sroot * case the control block of the socket to which it is connected 217622Sroot * is given by unp_conn. 227622Sroot * 237622Sroot * A socket may be referenced by a number of sockets (e.g. several 247622Sroot * sockets may be connected to a datagram socket.) These sockets 257622Sroot * are in a linked list starting with unp_refs, linked through 267622Sroot * unp_nextref and null-terminated. Note that a socket may be referenced 277622Sroot * by a number of other sockets and may also reference a socket (not 287622Sroot * necessarily one which is referencing it). This generates 297622Sroot * the need for unp_refs and unp_nextref to be separate fields. 3025594Skarels * 3125594Skarels * Stream sockets keep copies of receive sockbuf sb_cc and sb_mbcnt 3225594Skarels * so that changes in the sockbuf may be computed to modify 3325594Skarels * back pressure on the sender accordingly. 347622Sroot */ 357622Sroot struct unpcb { 367622Sroot struct socket *unp_socket; /* pointer back to socket */ 3737723Smckusick struct vnode *unp_vnode; /* if associated with file */ 3843445Skarels ino_t unp_ino; /* fake inode number */ 397622Sroot struct unpcb *unp_conn; /* control block of connected socket */ 407622Sroot struct unpcb *unp_refs; /* referencing socket linked list */ 417622Sroot struct unpcb *unp_nextref; /* link in unp_refs list */ 4225594Skarels struct mbuf *unp_addr; /* bound address of socket */ 4325594Skarels int unp_cc; /* copy of rcv.sb_cc */ 4425594Skarels int unp_mbcnt; /* copy of rcv.sb_mbcnt */ 457622Sroot }; 467643Sroot 477643Sroot #define sotounpcb(so) ((struct unpcb *)((so)->so_pcb)) 48