# 2.11BSD#431 - /usr/src/sys/h/socketvar.h

##### Macros

    SB_COLL           X
    SB_LOCK           X
    SB_MAX            X
    SB_SEL            X
    SB_WAIT           X
    SB_WANT           X
    SS_ASYNC          X
    SS_CANTRCVMORE    X
    SS_CANTSENDMORE   X
    SS_ISCONNECTED    X
    SS_ISCONNECTING   X
    SS_ISDISCONNECTINGX
    SS_NBIO           X
    SS_NOFDREF        X
    SS_PRIV           X
    SS_RCVATMARK      X
    sballoc           X
    sbfree            X
    sblock            X
    sbspace           X
    sbunlock          X
    soreadable        X
    sorwakeup         X
    sosendallatonce   X
    sowriteable       X
    sowwakeup         X

##### struct's

    sockbuf           X
    socket            X

       1: /*
       2:  * Copyright (c) 1982, 1986 Regents of the University of California.
       3:  * All rights reserved.
       4:  *
       5:  * Redistribution and use in source and binary forms are permitted
       6:  * provided that this notice is preserved and that due credit is given
       7:  * to the University of California at Berkeley. The name of the University
       8:  * may not be used to endorse or promote products derived from this
       9:  * software without specific prior written permission. This software
      10:  * is provided ``as is'' without express or implied warranty.
      11:  *
      12:  *	@(#)socketvar.h	7.3.1 (2.11BSD GTE) 12/31/93
      13:  */
      14:
      15: /*
      16:  * Kernel structure per socket.
      17:  * Contains send and receive buffer queues,
      18:  * handle on protocol and pointer to protocol
      19:  * private data and error information.
      20:  */
      21: struct socket {
      22:     short   so_type;        /* generic type, see socket.h */
      23:     short   so_options;     /* from socket call, see socket.h */
      24:     short   so_linger;      /* time to linger while closing */
      25:     short   so_state;       /* internal state flags SS_*, below */
      26:     caddr_t so_pcb;         /* protocol control block */
      27:     struct  protosw *so_proto;  /* protocol handle */
      28: /*
      29:  * Variables for connection queueing.
      30:  * Socket where accepts occur is so_head in all subsidiary sockets.
      31:  * If so_head is 0, socket is not related to an accept.
      32:  * For head socket so_q0 queues partially completed connections,
      33:  * while so_q is a queue of connections ready to be accepted.
      34:  * If a connection is aborted and it has so_head set, then
      35:  * it has to be pulled out of either so_q0 or so_q.
      36:  * We allow connections to queue up based on current queue lengths
      37:  * and limit on number of queued connections for this socket.
      38:  */
      39:     struct  socket *so_head;    /* back pointer to accept socket */
      40:     struct  socket *so_q0;      /* queue of partial connections */
      41:     struct  socket *so_q;       /* queue of incoming connections */
      42:     short   so_q0len;       /* partials on so_q0 */
      43:     short   so_qlen;        /* number of connections on so_q */
      44:     short   so_qlimit;      /* max number queued connections */
      45:     short   so_timeo;       /* connection timeout */
      46:     u_short so_error;       /* error affecting connection */
      47:     short   so_pgrp;        /* pgrp for signals */
      48:     u_short so_oobmark;     /* chars to oob mark */
      49: /*
      50:  * Variables for socket buffering.
      51:  */
      52:     struct  sockbuf {
      53:         u_short sb_cc;      /* actual chars in buffer */
      54:         u_short sb_hiwat;   /* max actual char count */
      55:         u_short sb_mbcnt;   /* chars of mbufs used */
      56:         u_short sb_mbmax;   /* max chars of mbufs to use */
      57:         u_short sb_lowat;   /* low water mark (not used yet) */
      58:         struct  mbuf *sb_mb;    /* the mbuf chain */
      59:         struct  proc *sb_sel;   /* process selecting read/write */
      60:         short   sb_timeo;   /* timeout (not used yet) */
      61:         short   sb_flags;   /* flags, see below */
      62:     } so_rcv, so_snd;
      63: #ifdef pdp11
      64: #define SB_MAX      8192        /* max chars in sockbuf */
      65: #else
      66: #define SB_MAX      (64*1024)   /* max chars in sockbuf */
      67: #endif
      68: #define SB_LOCK     0x01        /* lock on data queue (so_rcv only) */
      69: #define SB_WANT     0x02        /* someone is waiting to lock */
      70: #define SB_WAIT     0x04        /* someone is waiting for data/space */
      71: #define SB_SEL      0x08        /* buffer is selected */
      72: #define SB_COLL     0x10        /* collision selecting */
      73: };
      74:
      75: /*
      76:  * Socket state bits.
      77:  */
      78: #define SS_NOFDREF      0x001   /* no file table ref any more */
      79: #define SS_ISCONNECTED      0x002   /* socket connected to a peer */
      80: #define SS_ISCONNECTING     0x004   /* in process of connecting to peer */
      81: #define SS_ISDISCONNECTING  0x008   /* in process of disconnecting */
      82: #define SS_CANTSENDMORE     0x010   /* can't send more data to peer */
      83: #define SS_CANTRCVMORE      0x020   /* can't receive more data from peer */
      84: #define SS_RCVATMARK        0x040   /* at mark on input */
      85:
      86: #define SS_PRIV         0x080   /* privileged for broadcast, raw... */
      87: #define SS_NBIO         0x100   /* non-blocking ops */
      88: #define SS_ASYNC        0x200   /* async i/o notify */
      89:
      90:
      91: /*
      92:  * Macros for sockets and socket buffering.
      93:  */
      94:
      95: /* how much space is there in a socket buffer (so->so_snd or so->so_rcv) */
      96: #define sbspace(sb) \
      97:     (MIN((int)((sb)->sb_hiwat - (sb)->sb_cc),\
      98:      (int)((sb)->sb_mbmax - (sb)->sb_mbcnt)))
      99:
     100: /* do we have to send all at once on a socket? */
     101: #define sosendallatonce(so) \
     102:     ((so)->so_proto->pr_flags & PR_ATOMIC)
     103:
     104: /* can we read something from so? */
     105: #define soreadable(so) \
     106:     ((so)->so_rcv.sb_cc || ((so)->so_state & SS_CANTRCVMORE) || \
     107:     (so)->so_qlen || (so)->so_error)
     108:
     109: /* can we write something to so? */
     110: #define sowriteable(so) \
     111:     (sbspace(&(so)->so_snd) > 0 && \
     112:     (((so)->so_state&SS_ISCONNECTED) || \
     113:       ((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0) || \
     114:      ((so)->so_state & SS_CANTSENDMORE) || \
     115:      (so)->so_error)
     116:
     117: /* adjust counters in sb reflecting allocation of m */
     118: #define sballoc(sb, m) { \
     119:     (sb)->sb_cc += (m)->m_len; \
     120:     (sb)->sb_mbcnt += MSIZE; \
     121:     if ((m)->m_off > MMAXOFF) \
     122:         (sb)->sb_mbcnt += CLBYTES; \
     123: }
     124:
     125: /* adjust counters in sb reflecting freeing of m */
     126: #define sbfree(sb, m) { \
     127:     (sb)->sb_cc -= (m)->m_len; \
     128:     (sb)->sb_mbcnt -= MSIZE; \
     129:     if ((m)->m_off > MMAXOFF) \
     130:         (sb)->sb_mbcnt -= CLBYTES; \
     131: }
     132:
     133: /* set lock on sockbuf sb */
     134: #define sblock(sb) { \
     135:     while ((sb)->sb_flags & SB_LOCK) { \
     136:         (sb)->sb_flags |= SB_WANT; \
     137:         SLEEP((caddr_t)&(sb)->sb_flags, PZERO+1); \
     138:     } \
     139:     (sb)->sb_flags |= SB_LOCK; \
     140: }
     141:
     142: /* release lock on sockbuf sb */
     143: #define sbunlock(sb) { \
     144:     (sb)->sb_flags &= ~SB_LOCK; \
     145:     if ((sb)->sb_flags & SB_WANT) { \
     146:         (sb)->sb_flags &= ~SB_WANT; \
     147:         WAKEUP((caddr_t)&(sb)->sb_flags); \
     148:     } \
     149: }
     150:
     151: #define sorwakeup(so)   sowakeup((so), &(so)->so_rcv)
     152: #define sowwakeup(so)   sowakeup((so), &(so)->so_snd)
     153:
     154: #ifdef SUPERVISOR
     155: struct  socket *sonewconn();
     156: #endif

#### Defined struct's

sockbuf defined in line 52; used 40 times

- in /usr/src/sys/netns/spp_usrreq.c line 602(2), 649(2), 1186(2), 1444(2)
- in /usr/src/sys/sys/uipc_socket.c line 620-623(4)
- in /usr/src/sys/sys/uipc_socket2.c line 229(2), 244(2), 255(2), 276(2), 344(2), 363(2), 402(2), 423(2), 453(2), 494(2), 528(2), 563(2), 578(2), 621(2)

socket defined in line 21; used 280 times

- in line 39-41(6), 155(2)
- in /usr/src/libexec/identd/src/kernel/2.11bsd.c line 155(2), 197(2), 296(2)
- in /usr/src/new/crash/dispnet.c line 290(2), 317(2), 323-325(4), 532(2)
- in /usr/src/new/crash/inet.c line 60(2), 101(2), 107-112(6)
- in /usr/src/sys/net/if.c line 255(2)
- in /usr/src/sys/net/raw_cb.c line 43(2), 78(2), 103(2)
- in /usr/src/sys/net/raw_usrreq.c line 92(2), 159(2)
- in /usr/src/sys/netimp/raw_imp.c line 40(2)
- in /usr/src/sys/netinet/in.c line 198(2)
- in /usr/src/sys/netinet/in_pcb.c line 35(2), 56(2), 227(2)
- in /usr/src/sys/netinet/ip_output.c line 342(2)
- in /usr/src/sys/netinet/raw_ip.c line 58(2), 133(2)
- in /usr/src/sys/netinet/tcp_input.c line 75(2), 188(2), 1213(2)
- in /usr/src/sys/netinet/tcp_output.c line 51(2)
- in /usr/src/sys/netinet/tcp_subr.c line 206(2), 230(2)
- in /usr/src/sys/netinet/tcp_usrreq.c line 54(2), 323(2), 388(2), 426(2)
- in /usr/src/sys/netinet/udp_usrreq.c line 284(2)
- in /usr/src/sys/netns/idp_usrreq.c line 86(2), 100(2), 123(2), 248(2), 361(2), 521(2)
- in /usr/src/sys/netns/ns.c line 64(2)
- in /usr/src/sys/netns/ns_ip.c line 357-360(4)
- in /usr/src/sys/netns/ns_pcb.c line 33(2), 191(2)
- in /usr/src/sys/netns/spp_usrreq.c line 62(2), 94(2), 276(2), 646(2), 1062(2), 1177(2), 1419(2), 1472(2), 1516(2)
- in /usr/src/sys/sys/sys_kern.c line 93(2), 129(2)
- in /usr/src/sys/sys/sys_socket.c line 32(2), 85(2), 123(2)
- in /usr/src/sys/sys/uipc_socket.c line 41-46(4), 59(2), 79(2), 93(2), 118(2), 139(2), 187(2), 196(2), 212(2), 257-258(4), 270(2), 300(2), 425(2), 603(2), 618(2), 638(2), 731(2), 809(2), 833(2), 863-868(6), 882(2), 894(2), 901(2)
- in /usr/src/sys/sys/uipc_socket2.c line 62(2), 71-73(4), 90(2), 101(2), 118-122(6), 130(2), 147-151(4), 168-171(4), 206(2), 214(2), 275(2), 323(2)
- in /usr/src/sys/sys/uipc_syscalls.c line 56(2), 128(2), 165(2), 193-197(4), 246(2), 551(2)
- in /usr/src/sys/sys/uipc_usrreq.c line 38-43(4), 84(2), 282(2), 351(2), 357(2), 384-385(4), 470(2), 557(2)
- in /usr/src/ucb/PORT/systat/netstat.c line 124(2), 179(2)
- in /usr/src/ucb/netstat/inet.c line 51(2)
- in /usr/src/ucb/netstat/ns.c line 50(2)
- in /usr/src/ucb/netstat/unix.c line 40(2), 94(2)
- in /usr/src/usr.bin/fstat/fstat.c line 370(2), 407(2), 418(2), 429-434(6)

#### Defined macros

SB_COLL defined in line 72; used 5 times

- in /usr/src/sys/sys/uipc_socket.c line 820-822(2)
- in /usr/src/sys/sys/uipc_socket2.c line 235, 259-261(2)

SB_LOCK defined in line 68; used 5 times

- in line 135-144(3)
- in /usr/src/sys/sys/uipc_socket2.c line 566
- in /usr/src/sys/sys/uipc_usrreq.c line 588

SB_MAX defined in line 66; used 3 times

- in /usr/src/sys/sys/uipc_socket2.c line 348-355(3)

SB_SEL defined in line 71; never used
SB_WAIT defined in line 70; used 5 times

- in /usr/src/sys/netinet/tcp_input.c line 876
- in /usr/src/sys/netns/spp_usrreq.c line 393
- in /usr/src/sys/sys/uipc_socket2.c line 247, 263-264(2)

SB_WANT defined in line 69; used 3 times

- in line 136, 145-146(2)

SS_ASYNC defined in line 88; used 3 times

- in /usr/src/sys/sys/sys_socket.c line 49-51(2)
- in /usr/src/sys/sys/uipc_socket2.c line 281

SS_CANTRCVMORE defined in line 83; used 9 times

- in line 106
- in /usr/src/sys/netinet/tcp_input.c line 162, 898
- in /usr/src/sys/sys/uipc_socket.c line 471, 842
- in /usr/src/sys/sys/uipc_socket2.c line 94, 105, 217
- in /usr/src/usr.bin/fstat/fstat.c line 544

SS_CANTSENDMORE defined in line 82; used 7 times

- in line 114
- in /usr/src/sys/sys/uipc_socket.c line 325
- in /usr/src/sys/sys/uipc_socket2.c line 94, 105, 209
- in /usr/src/sys/sys/uipc_usrreq.c line 187
- in /usr/src/usr.bin/fstat/fstat.c line 547

SS_ISCONNECTED defined in line 79; used 13 times

- in line 112
- in /usr/src/sys/netinet/udp_usrreq.c line 363
- in /usr/src/sys/sys/uipc_socket.c line 152, 162, 233, 275, 333, 473, 905
- in /usr/src/sys/sys/uipc_socket2.c line 65, 83, 104
- in /usr/src/sys/sys/uipc_usrreq.c line 439

SS_ISCONNECTING defined in line 80; used 10 times

- in /usr/src/sys/sys/uipc_socket.c line 224, 233, 247-251(2), 885-889(2)
- in /usr/src/sys/sys/uipc_socket2.c line 66, 82, 93, 104

SS_ISDISCONNECTING defined in line 81; used 7 times

- in /usr/src/sys/sys/uipc_socket.c line 153, 159, 279
- in /usr/src/sys/sys/uipc_socket2.c line 65, 82, 94, 104

SS_NBIO defined in line 87; used 9 times

- in /usr/src/sys/sys/sys_socket.c line 42-44(2)
- in /usr/src/sys/sys/uipc_socket.c line 160, 224, 246, 348-349(2), 480, 838

SS_NOFDREF defined in line 78; used 13 times

- in /usr/src/sys/net/raw_cb.c line 98
- in /usr/src/sys/netinet/in_pcb.c line 220
- in /usr/src/sys/netinet/tcp_input.c line 575
- in /usr/src/sys/netinet/tcp_usrreq.c line 403-405(2)
- in /usr/src/sys/netns/ns_pcb.c line 184
- in /usr/src/sys/sys/uipc_socket.c line 70, 121, 175-177(2), 202-204(2)
- in /usr/src/sys/sys/uipc_socket2.c line 134

SS_PRIV defined in line 86; used 2 times

- in /usr/src/sys/net/raw_usrreq.c line 184
- in /usr/src/sys/sys/uipc_socket.c line 64

SS_RCVATMARK defined in line 84; used 8 times

- in /usr/src/sys/netinet/tcp_input.c line 1001
- in /usr/src/sys/netinet/tcp_usrreq.c line 255
- in /usr/src/sys/netns/spp_usrreq.c line 499, 1367
- in /usr/src/sys/sys/sys_socket.c line 67, 110
- in /usr/src/sys/sys/uipc_socket.c line 544, 577

sballoc defined in line 118; used 5 times

- in /usr/src/sys/sys/uipc_socket2.c line 437, 477-479(2), 510, 547

sbfree defined in line 126; used 6 times

- in /usr/src/sys/sys/uipc_socket.c line 502, 524, 558
- in /usr/src/sys/sys/uipc_socket2.c line 600-605(2), 629

sblock defined in line 134; used 3 times

- in /usr/src/sys/sys/uipc_socket.c line 322, 462, 625

sbspace defined in line 96; used 14 times

- in line 111
- in /usr/src/sys/netinet/tcp_input.c line 355
- in /usr/src/sys/netinet/tcp_output.c line 114
- in /usr/src/sys/netinet/tcp_subr.c line 116, 190
- in /usr/src/sys/netinet/tcp_usrreq.c line 274
- in /usr/src/sys/netns/spp_usrreq.c line 809, 1241, 1376, 1452
- in /usr/src/sys/sys/uipc_socket.c line 342
- in /usr/src/sys/sys/uipc_socket2.c line 464, 505
- in /usr/src/sys/sys/uipc_usrreq.c line 173

sbunlock defined in line 143; used 5 times

- in /usr/src/sys/sys/uipc_socket.c line 355, 404, 484, 597, 628

soreadable defined in line 105; used 1 times

- in /usr/src/sys/sys/sys_socket.c line 93

sorwakeup defined in line 151; used 16 times

- in /usr/src/sys/net/raw_usrreq.c line 129, 139
- in /usr/src/sys/netinet/tcp_input.c line 65, 167
- in /usr/src/sys/netinet/tcp_subr.c line 284
- in /usr/src/sys/netinet/udp_usrreq.c line 154, 170
- in /usr/src/sys/netns/idp_usrreq.c line 77
- in /usr/src/sys/netns/spp_usrreq.c line 516
- in /usr/src/sys/sys/uipc_socket2.c line 79, 85, 97, 108, 218
- in /usr/src/sys/sys/uipc_usrreq.c line 175, 208

sosendallatonce defined in line 101; used 2 times

- in /usr/src/sys/sys/uipc_socket.c line 311, 344

sowriteable defined in line 110; used 1 times

- in /usr/src/sys/sys/sys_socket.c line 101

sowwakeup defined in line 152; used 9 times

- in /usr/src/sys/netinet/tcp_input.c line 877
- in /usr/src/sys/netinet/tcp_subr.c line 285
- in /usr/src/sys/netinet/udp_usrreq.c line 171
- in /usr/src/sys/netns/spp_usrreq.c line 394
- in /usr/src/sys/sys/uipc_socket2.c line 86, 96, 107, 210
- in /usr/src/sys/sys/uipc_usrreq.c line 133

#### Usage of this include

socketvar.h used 43 times

- in /usr/src/libexec/identd/src/kernel/2.11bsd.c line 22
- in /usr/src/new/crash/dispnet.c line 16
- in /usr/src/new/crash/inet.c line 13
- in /usr/src/new/kermit5.188/ckcnet.h line 101
- in /usr/src/sys/net/af.c line 19
- in /usr/src/sys/net/if.c line 19
- in /usr/src/sys/net/raw_cb.c line 19
- in /usr/src/sys/net/raw_usrreq.c line 20
- in /usr/src/sys/netimp/raw_imp.c line 17
- in /usr/src/sys/netinet/in.c line 21
- in /usr/src/sys/netinet/in_pcb.c line 20
- in /usr/src/sys/netinet/ip_output.c line 20
- in /usr/src/sys/netinet/raw_ip.c line 19
- in /usr/src/sys/netinet/tcp_debug.c line 26
- in /usr/src/sys/netinet/tcp_input.c line 20
- in /usr/src/sys/netinet/tcp_output.c line 20
- in /usr/src/sys/netinet/tcp_subr.c line 19
- in /usr/src/sys/netinet/tcp_timer.c line 19
- in /usr/src/sys/netinet/tcp_usrreq.c line 19
- in /usr/src/sys/netinet/udp_usrreq.c line 20
- in /usr/src/sys/netns/idp_usrreq.c line 21
- in /usr/src/sys/netns/ns.c line 21
- in /usr/src/sys/netns/ns_input.c line 22
- in /usr/src/sys/netns/ns_ip.c line 24
- in /usr/src/sys/netns/ns_output.c line 20
- in /usr/src/sys/netns/ns_pcb.c line 21
- in /usr/src/sys/netns/spp_debug.c line 20
- in /usr/src/sys/netns/spp_usrreq.c line 22
- in /usr/src/sys/sys/kern_descrip.c line 20
- in /usr/src/sys/sys/sys_kern.c line 14
- in /usr/src/sys/sys/sys_socket.c line 23
- in /usr/src/sys/sys/uipc_socket.c line 24
- in /usr/src/sys/sys/uipc_socket2.c line 25
- in /usr/src/sys/sys/uipc_syscalls.c line 23
- in /usr/src/sys/sys/uipc_usrreq.c line 15
- in /usr/src/ucb/PORT/systat/netcmds.c line 18
- in /usr/src/ucb/PORT/systat/netstat.c line 17
- in /usr/src/ucb/netstat/inet.c line 22
- in /usr/src/ucb/netstat/ns.c line 23
- in /usr/src/ucb/netstat/unix.c line 23
- in /usr/src/usr.bin/fstat/fstat.c line 31
- in /usr/src/usr.sbin/trpt/trpt.c line 19
- in /usr/src/usr.sbin/trsp/trsp.c line 19

Last modified: 1994-01-11 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1005 |