33 #ifndef _SYS_SOCKETVAR_H_ 34 #define _SYS_SOCKETVAR_H_ 36 #include <sys/queue.h> 46 typedef u_quad_t so_gen_t;
67 TAILQ_HEAD(,
socket) so_incomp;
68 TAILQ_HEAD(,
socket) so_comp;
69 TAILQ_ENTRY(
socket) so_list;
91 void (*sb_wakeup)(
struct socket *,
void *);
94 #define SB_MAX (256L*1024L) 100 #define SB_NOTIFY (SB_WAIT|SB_SEL|SB_ASYNC) 101 #define SB_NOINTR 0x40 104 void (*so_upcall)(
struct socket *,
void *arg, int);
111 #define SS_NOFDREF 0x0001 112 #define SS_ISCONNECTED 0x0002 113 #define SS_ISCONNECTING 0x0004 114 #define SS_ISDISCONNECTING 0x0008 115 #define SS_CANTSENDMORE 0x0010 116 #define SS_CANTRCVMORE 0x0020 117 #define SS_RCVATMARK 0x0040 119 #define SS_PRIV 0x0080 120 #define SS_NBIO 0x0100 121 #define SS_ASYNC 0x0200 122 #define SS_ISCONFIRMING 0x0400 124 #define SS_INCOMP 0x0800 125 #define SS_COMP 0x1000 138 #define sbspace(sb) \ 139 ((long) imin((int)((sb)->sb_hiwat - (sb)->sb_cc), \ 140 (int)((sb)->sb_mbmax - (sb)->sb_mbcnt))) 143 #define sosendallatonce(so) \ 144 ((so)->so_proto->pr_flags & PR_ATOMIC) 147 #define soreadable(so) \ 148 ((so)->so_rcv.sb_cc >= (so)->so_rcv.sb_lowat || \ 149 ((so)->so_state & SS_CANTRCVMORE) || \ 150 (so)->so_comp.tqh_first || (so)->so_error) 153 #define sowriteable(so) \ 154 ((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \ 155 (((so)->so_state&SS_ISCONNECTED) || \ 156 ((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0)) || \ 157 ((so)->so_state & SS_CANTSENDMORE) || \ 161 #define sballoc(sb, m) { \ 162 (sb)->sb_cc += (m)->m_len; \ 163 (sb)->sb_mbcnt += MSIZE; \ 164 if ((m)->m_flags & M_EXT) \ 165 (sb)->sb_mbcnt += (m)->m_ext.ext_size; \ 169 #define sbfree(sb, m) { \ 170 (sb)->sb_cc -= (m)->m_len; \ 171 (sb)->sb_mbcnt -= MSIZE; \ 172 if ((m)->m_flags & M_EXT) \ 173 (sb)->sb_mbcnt -= (m)->m_ext.ext_size; \ 181 #define sblock(sb, wf) ((sb)->sb_flags & SB_LOCK ? \ 182 (((wf) == M_WAITOK) ? sb_lock(sb) : EWOULDBLOCK) : \ 183 ((sb)->sb_flags |= SB_LOCK), 0) 186 #define sbunlock(sb) { \ 187 (sb)->sb_flags &= ~SB_LOCK; \ 188 if ((sb)->sb_flags & SB_WANT) { \ 189 (sb)->sb_flags &= ~SB_WANT; \ 190 wakeup((caddr_t)&(sb)->sb_flags); \ 194 #define sorwakeup(so) { sowakeup((so), &(so)->so_rcv); \ 195 if ((so)->so_upcall) \ 196 (*((so)->so_upcall))((so), (so)->so_upcallarg, M_DONTWAIT); \ 199 #define sowwakeup(so) sowakeup((so), &(so)->so_snd) 202 extern u_long sb_max;
205 #define sonewconn(head, connstatus) sonewconn1((head), (connstatus)) 215 int sockargs(
struct mbuf **mp, caddr_t buf,
int buflen,
int type);
218 struct mbuf *m0,
struct mbuf *control);
219 int sbappendcontrol(
struct sockbuf *sb,
struct mbuf *m0,
220 struct mbuf *control);
221 void sbappendrecord(
struct sockbuf *sb,
struct mbuf *m0);
222 void sbcheck(
struct sockbuf *sb);
225 sbcreatecontrol(caddr_t p,
int size,
int type,
int level);
226 void sbdrop(
struct sockbuf *sb,
int len);
227 void sbdroprecord(
struct sockbuf *sb);
228 void sbflush(
struct sockbuf *sb);
229 void sbinsertoob(
struct sockbuf *sb,
struct mbuf *m0);
230 void sbrelease(
struct sockbuf *sb);
231 int sbreserve(
struct sockbuf *sb, u_long cc);
232 int sbwait(
struct sockbuf *sb);
233 int sb_lock(
struct sockbuf *sb);
234 int soabort(
struct socket *so);
235 int soaccept(
struct socket *so,
struct mbuf *nam);
236 int sobind(
struct socket *so,
struct mbuf *nam);
237 void socantrcvmore(
struct socket *so);
238 void socantsendmore(
struct socket *so);
239 int soclose(
struct socket *so);
240 int soconnect(
struct socket *so,
struct mbuf *nam);
242 int socreate(
int dom,
struct socket **aso,
int type,
int proto,
244 int sodisconnect(
struct socket *so);
245 void sofree(
struct socket *so);
246 int sogetopt(
struct socket *so,
int level,
int optname,
248 void sohasoutofband(
struct socket *so);
249 void soisconnected(
struct socket *so);
250 void soisconnecting(
struct socket *so);
251 void soisdisconnected(
struct socket *so);
252 void soisdisconnecting(
struct socket *so);
253 int solisten(
struct socket *so,
int backlog);
255 sodropablereq(
struct socket *head);
257 sonewconn1(
struct socket *head,
int connstatus);
258 int soreceive(
struct socket *so,
struct mbuf **paddr,
struct uio *uio,
259 struct mbuf **mp0,
struct mbuf **controlp,
int *flagsp);
260 int soreserve(
struct socket *so, u_long sndcc, u_long rcvcc);
261 void sorflush(
struct socket *so);
262 int sosend(
struct socket *so,
struct mbuf *addr,
struct uio *uio,
263 struct mbuf *top,
struct mbuf *control,
int flags);
264 int sosetopt(
struct socket *so,
int level,
int optname,
266 int soshutdown(
struct socket *so,
int how);
Definition: socketvar.h:49
Definition: socketvar.h:82