123453Smckusick /* 229055Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 3*33290Sbostic * All rights reserved. 423453Smckusick * 5*33290Sbostic * Redistribution and use in source and binary forms are permitted 6*33290Sbostic * provided that this notice is preserved and that due credit is given 7*33290Sbostic * to the University of California at Berkeley. The name of the University 8*33290Sbostic * may not be used to endorse or promote products derived from this 9*33290Sbostic * software without specific prior written permission. This software 10*33290Sbostic * is provided ``as is'' without express or implied warranty. 11*33290Sbostic * 12*33290Sbostic * @(#)unpcb.h 7.2 (Berkeley) 01/07/88 1323453Smckusick */ 147622Sroot 157622Sroot /* 167622Sroot * Protocol control block for an active 177622Sroot * instance of a UNIX internal protocol. 187622Sroot * 197622Sroot * A socket may be associated with an inode in the 207622Sroot * file system. If so, the unp_inode pointer holds 217622Sroot * a reference count to this inode, which should be irele'd 227622Sroot * when the socket goes away. 237622Sroot * 247622Sroot * A socket may be connected to another socket, in which 257622Sroot * case the control block of the socket to which it is connected 267622Sroot * is given by unp_conn. 277622Sroot * 287622Sroot * A socket may be referenced by a number of sockets (e.g. several 297622Sroot * sockets may be connected to a datagram socket.) These sockets 307622Sroot * are in a linked list starting with unp_refs, linked through 317622Sroot * unp_nextref and null-terminated. Note that a socket may be referenced 327622Sroot * by a number of other sockets and may also reference a socket (not 337622Sroot * necessarily one which is referencing it). This generates 347622Sroot * the need for unp_refs and unp_nextref to be separate fields. 3525594Skarels * 3625594Skarels * Stream sockets keep copies of receive sockbuf sb_cc and sb_mbcnt 3725594Skarels * so that changes in the sockbuf may be computed to modify 3825594Skarels * back pressure on the sender accordingly. 397622Sroot */ 407622Sroot struct unpcb { 417622Sroot struct socket *unp_socket; /* pointer back to socket */ 427622Sroot struct inode *unp_inode; /* if associated with file */ 4325594Skarels ino_t unp_ino; /* fake inode number */ 447622Sroot struct unpcb *unp_conn; /* control block of connected socket */ 457622Sroot struct unpcb *unp_refs; /* referencing socket linked list */ 467622Sroot struct unpcb *unp_nextref; /* link in unp_refs list */ 4725594Skarels struct mbuf *unp_addr; /* bound address of socket */ 4825594Skarels int unp_cc; /* copy of rcv.sb_cc */ 4925594Skarels int unp_mbcnt; /* copy of rcv.sb_mbcnt */ 507622Sroot }; 517643Sroot 527643Sroot #define sotounpcb(so) ((struct unpcb *)((so)->so_pcb)) 53