1180948Skmacy/*- 2180948Skmacy * Copyright (c) 1982, 1986, 1990, 1993 3180948Skmacy * The Regents of the University of California. All rights reserved. 4180948Skmacy * 5180948Skmacy * Redistribution and use in source and binary forms, with or without 6180948Skmacy * modification, are permitted provided that the following conditions 7180948Skmacy * are met: 8180948Skmacy * 1. Redistributions of source code must retain the above copyright 9180948Skmacy * notice, this list of conditions and the following disclaimer. 10180948Skmacy * 2. Redistributions in binary form must reproduce the above copyright 11180948Skmacy * notice, this list of conditions and the following disclaimer in the 12180948Skmacy * documentation and/or other materials provided with the distribution. 13180948Skmacy * 4. Neither the name of the University nor the names of its contributors 14180948Skmacy * may be used to endorse or promote products derived from this software 15180948Skmacy * without specific prior written permission. 16180948Skmacy * 17180948Skmacy * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18180948Skmacy * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19180948Skmacy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20180948Skmacy * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21180948Skmacy * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22180948Skmacy * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23180948Skmacy * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24180948Skmacy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25180948Skmacy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26180948Skmacy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27180948Skmacy * SUCH DAMAGE. 28180948Skmacy * 29180948Skmacy * @(#)socketvar.h 8.3 (Berkeley) 2/19/95 30180948Skmacy * 31180948Skmacy * $FreeBSD$ 32180948Skmacy */ 33180948Skmacy#ifndef _SYS_SOCKTATE_H_ 34180948Skmacy#define _SYS_SOCKTATE_H_ 35180948Skmacy 36180948Skmacy/* 37180948Skmacy * Socket state bits. 38180948Skmacy * 39180948Skmacy * Historically, this bits were all kept in the so_state field. For 40180948Skmacy * locking reasons, they are now in multiple fields, as they are 41180948Skmacy * locked differently. so_state maintains basic socket state protected 42180948Skmacy * by the socket lock. so_qstate holds information about the socket 43180948Skmacy * accept queues. Each socket buffer also has a state field holding 44180948Skmacy * information relevant to that socket buffer (can't send, rcv). Many 45180948Skmacy * fields will be read without locks to improve performance and avoid 46180948Skmacy * lock order issues. However, this approach must be used with caution. 47180948Skmacy */ 48180948Skmacy#define SS_NOFDREF 0x0001 /* no file table ref any more */ 49180948Skmacy#define SS_ISCONNECTED 0x0002 /* socket connected to a peer */ 50180948Skmacy#define SS_ISCONNECTING 0x0004 /* in process of connecting to peer */ 51180948Skmacy#define SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */ 52180948Skmacy#define SS_NBIO 0x0100 /* non-blocking ops */ 53180948Skmacy#define SS_ASYNC 0x0200 /* async i/o notify */ 54180948Skmacy#define SS_ISCONFIRMING 0x0400 /* deciding to accept connection req */ 55180948Skmacy#define SS_ISDISCONNECTED 0x2000 /* socket disconnected from peer */ 56180948Skmacy 57180948Skmacy/* 58180948Skmacy * Protocols can mark a socket as SS_PROTOREF to indicate that, following 59180948Skmacy * pru_detach, they still want the socket to persist, and will free it 60180948Skmacy * themselves when they are done. Protocols should only ever call sofree() 61180948Skmacy * following setting this flag in pru_detach(), and never otherwise, as 62180948Skmacy * sofree() bypasses socket reference counting. 63180948Skmacy */ 64180948Skmacy#define SS_PROTOREF 0x4000 /* strong protocol reference */ 65180948Skmacy 66180948Skmacy/* 67180948Skmacy * Socket state bits now stored in the socket buffer state field. 68180948Skmacy */ 69180948Skmacy#define SBS_CANTSENDMORE 0x0010 /* can't send more data to peer */ 70180948Skmacy#define SBS_CANTRCVMORE 0x0020 /* can't receive more data from peer */ 71180948Skmacy#define SBS_RCVATMARK 0x0040 /* at mark on input */ 72180948Skmacy 73180948Skmacystruct socket; 74180948Skmacy 75180948Skmacyvoid soisconnected(struct socket *so); 76180948Skmacyvoid soisconnecting(struct socket *so); 77180948Skmacyvoid soisdisconnected(struct socket *so); 78180948Skmacyvoid soisdisconnecting(struct socket *so); 79180948Skmacyvoid socantrcvmore(struct socket *so); 80180948Skmacyvoid socantrcvmore_locked(struct socket *so); 81180948Skmacyvoid socantsendmore(struct socket *so); 82180948Skmacyvoid socantsendmore_locked(struct socket *so); 83180948Skmacy#endif /* _SYS_SOCKTATE_H_ */ 84