home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / bsd / netinet / tcp_var.h < prev    next >
Text File  |  1992-07-29  |  9KB  |  229 lines

  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.  *    @(#)tcp_var.h    7.7 (Berkeley) 2/27/88
  13.  */
  14.  
  15. /*
  16.  * TCP configuration:  This is a half-assed attempt to make TCP
  17.  * self-configure for a few varieties of 4.2 and 4.3-based unixes.
  18.  * If you don't have a) a 4.3bsd vax or b) a 3.x Sun (x<6), check
  19.  * this carefully (it's probably not right).  Please send me mail
  20.  * if you run into configuration problems.
  21.  *  - Van Jacobson (van@lbl-csam.arpa)
  22.  */
  23.  
  24. #ifndef BSD
  25. #define BSD 42    /* if we're not 4.3, pretend we're 4.2 */
  26. #define OLDSTAT    /* set if we have to use old netstat binaries */
  27. #endif
  28.  
  29. /* #define OLDSTAT    /* set if we have to use old netstat binaries */
  30.  
  31. #if sun || BSD < 43
  32. #define TCP_COMPAT_42    /* set if we have to interop w/4.2 systems */
  33. #endif
  34.  
  35. #ifndef SB_MAX
  36. #ifdef    SB_MAXCOUNT
  37. #define    SB_MAX    SB_MAXCOUNT    /* Sun has to be a little bit different... */
  38. #else
  39. #define SB_MAX    32767        /* XXX */
  40. #endif    SB_MAXCOUNT
  41. #endif    SB_MAX
  42.  
  43. #ifndef IP_MAXPACKET
  44. #define    IP_MAXPACKET    65535        /* maximum packet size */
  45. #endif
  46.  
  47. /*
  48.  * Bill Nowicki pointed out that the page size (CLBYTES) has
  49.  * nothing to do with the mbuf cluster size.  So, we followed
  50.  * Sun's lead and made the new define MCLBYTES stand for the mbuf
  51.  * cluster size.  The following define makes up backwards compatible
  52.  * with 4.3 and 4.2.  If CLBYTES is >1024 on your machine, check
  53.  * this against the mbuf cluster definitions in /usr/include/sys/mbuf.h.
  54.  */
  55. #ifndef MCLBYTES
  56. #define    MCLBYTES CLBYTES    /* XXX */
  57. #endif
  58.  
  59. /*
  60.  * The routine in@'aladdr is broken in Sun's 3.4.  We redefine ours
  61.  * (in tcp_input.c) so we use can it but won't have a name conflict.
  62.  */
  63. #ifdef sun
  64. #define in_localaddr tcp_in_localaddr
  65. #endif
  66.  
  67. /* --------------- end of TCP config ---------------- */
  68.  
  69. /*
  70.  * Kernel variables for tcp.
  71.  */
  72.  
  73. /*
  74.  * Tcp control block, one per tcp; fields:
  75.  */
  76. struct tcpcb {
  77.     struct    tcpiphdr *seg_next;    /* sequencing queue */
  78.     struct    tcpiphdr *seg_prev;
  79.     short    t_state;        /* state of this connection */
  80.     short    t_timer[TCPT_NTIMERS];    /* tcp timers */
  81.     short    t_rxtshift;        /* log(2) of rexmt exp. backoff */
  82.     short    t_rxtcur;        /* current retransmit value */
  83.     short    t_dupacks;        /* consecutive dup acks recd */
  84.     u_short    t_maxseg;        /* maximum segment size */
  85.     char    t_force;        /* 1 if forcing out a byte */
  86.     u_char    t_flags;
  87. #define    TF_ACKNOW    0x01        /* ack peer immediately */
  88. #define    TF_DELACK    0x02        /* ack, but try to delay it */
  89. #define    TF_NODELAY    0x04        /* don't delay packets to coalesce */
  90. #define    TF_NOOPT    0x08        /* don't use tcp options */
  91. #define    TF_SENTFIN    0x10        /* have sent FIN */
  92.     struct    tcpiphdr *t_template;    /* skeletal packet for transmit */
  93.     struct    inpcb *t_inpcb;        /* back pointer to internet pcb */
  94. /*
  95.  * The following fields are used as in the protocol specification.
  96.  * See RFC783, Dec. 1981, page 21.
  97.  */
  98. /* send sequence variables */
  99.     tcp_seq    snd_una;        /* send unacknowledged */
  100.     tcp_seq    snd_nxt;        /* send next */
  101.     tcp_seq    snd_up;            /* send urgent pointer */
  102.     tcp_seq    snd_wl1;        /* window update seg seq number */
  103.     tcp_seq    snd_wl2;        /* window update seg ack number */
  104.     tcp_seq    iss;            /* initial send sequence number */
  105.     u_short    snd_wnd;        /* send window */
  106. /* receive sequence variables */
  107.     u_short    rcv_wnd;        /* receive window */
  108.     tcp_seq    rcv_nxt;        /* receive next */
  109.     tcp_seq    rcv_up;            /* receive urgent pointer */
  110.     tcp_seq    irs;            /* initial receive sequence number */
  111. /*
  112.  * Additional variables for this implementation.
  113.  */
  114. /* receive variables */
  115.     tcp_seq    rcv_adv;        /* advertised window */
  116. /* retransmit variables */
  117.     tcp_seq    snd_max;        /* highest sequence number sent
  118.                      * used to recognize retransmits
  119.                      */
  120. /* congestion control (for slow start, source quench, retransmit after loss) */
  121.     u_short    snd_cwnd;        /* congestion-controlled window */
  122.     u_short snd_ssthresh;        /* snd_cwnd size threshhold for
  123.                      * for slow start exponential to
  124.                      * linear switch */
  125. /*
  126.  *@(nsmit timing stuff.
  127.  * srtt and rttvar are stored as fixed point; for convenience in smoothing,
  128.  * srtt has 3 bits to the right of the binary point, rttvar has 2.
  129.  * "Variance" is actually smoothed difference.
  130.  */
  131.     short    t_idle;            /* inactivity time */
  132.     short    t_rtt;            /* round trip time */
  133.     tcp_seq    t_rtseq;        /* sequence number being timed */
  134.     short    t_srtt;            /* smoothed round-trip time */
  135.     short    t_rttvar;        /* variance in round-trip time */
  136.     u_short max_rcvd;        /* most peer has sent into window */
  137.     u_short    max_sndwnd;        /* largest window peer has offered */
  138. /* out-of-band data */
  139.     char    t_oobflags;        /* have some */
  140.     char    t_iobc;            /* input character */
  141. #define    TCPOOB_HAVEDATA    0x01
  142. #define    TCPOOB_HADDATA    0x02
  143. };
  144.  
  145. #define    intotcpcb(ip)    ((struct tcpcb *)(ip)->inp_ppcb)
  146. #define    sototcpcb(so)    (intotcpcb(sotoinpcb(so)))
  147.  
  148. /*
  149.  * TCP statistics.
  150.  * Many of these should be kept per connection,
  151.  * but that's inconvenient at the moment.
  152.  */
  153. struct    tcpstat {
  154. #ifdef OLDSTAT
  155.     /*
  156.      * Declare statistics the same as in 4.3
  157.      * at the start of tcpstat (same size and
  158.      * position) for netstat.
  159.      */
  160.     int    tcps_rcvbadsum;
  161.     int    tcps_rcvbadoff;
  162.     int    tcps_rcvshort;
  163.     int    tcps_badsegs;
  164.     int    tcps_unack;
  165. #define    tcps_badsum    tcps_rcvbadsum
  166. #define    tcps_badoff    tcps_rcvbadoff
  167. #define    tcps_hdrops    tcps_rcvshort
  168.  
  169. #endif OLDSTAT
  170.     u_long    tcps_connattempt;    /* connections initiated */
  171.     u_long    tcps_accepts;        /* connections accepted */
  172.     u_long    tcps_connects;        /* connections established */
  173.     u_long    tcps_drops;        /* connections dropped */
  174.     u_long    tcps_conndrops;        /* embryonic connections dropped */
  175.     u_long    tcps_closed;        /* conn. closed (includes drops) */
  176.     u_long    tcps_segstimed;        /* segs where we tried to get rtt */
  177.     u_long    tcps_rttupdated;    /* times we succeeded */
  178.     u_long    tcps_delack;        /* delayed acks sent */
  179.     u_long    tcps_timeoutdrop;    /* conn. dropped in rxmt timeout */
  180.     u_long    tcps_rexmttimeo;    /* retransmit timeouts */
  181.     u_long    tcps_persisttimeo;    /* persist timeouts */
  182.     u_long    tcps_keeptimeo;        /* keepalive timeouts */
  183.     u_long    tcps_keepprobe;        /* keepalive probes sent */
  184.     u_long    tcps_keepdrops;        /* connections dropped in keepalive */
  185.  
  186.     u_long    tcps_sndtotal;        /* total packets sent */
  187.     u_long    tcps_sndpack;        /* data packets sent */
  188.     u_long    tcps_sndbyte;        /* data bytes sent */
  189.     u_long    tcps_sndrexmitpack;    /* data packets retransmitted */
  190.     u_long    tcps_sndrexmitb@)    /* data bytes retransmitted */
  191.     u_long    tcps_sndacks;        /* ack-only packets sent */
  192.     u_long    tcps_sndprobe;        /* window probes sent */
  193.     u_long    tcps_sndurg;        /* packets sent with URG only */
  194.     u_long    tcps_sndwinup;        /* window update-only packets sent */
  195.     u_long    tcps_sndctrl;        /* control (SYN|FIN|RST) packets sent */
  196.  
  197.     u_long    tcps_rcvtotal;        /* total packets received */
  198.     u_long    tcps_rcvpack;        /* packets received in sequence */
  199.     u_long    tcps_rcvbyte;        /* bytes received in sequence */
  200. #ifndef OLDSTAT
  201.     u_long    tcps_rcvbadsum;        /* packets received with ccksum errs */
  202.     u_long    tcps_rcvbadoff;        /* packets received with bad offset */
  203.     u_long    tcps_rcvshort;        /* packets received too short */
  204. #endif
  205.     u_long    tcps_rcvduppack;    /* duplicate-only packets received */
  206.     u_long    tcps_rcvdupbyte;    /* duplicate-only bytes received */
  207.     u_long    tcps_rcvpartduppack;    /* packets with some duplicate data */
  208.     u_long    tcps_rcvpartdupbyte;    /* dup. bytes in part-dup. packets */
  209.     u_long    tcps_rcvoopack;        /* out-of-order packets received */
  210.     u_long    tcps_rcvoobyte;        /* out-of-order bytes received */
  211.     u_long    tcps_rcvpackafterwin;    /* packets with data after window */
  212.     u_long    tcps_rcvbyteafterwin;    /* bytes rcvd after window */
  213.     u_long    tcps_rcvafterclose;    /* packets rcvd after "close" */
  214.     u_long    tcps_rcvwinprobe;    /* rcvd window probe packets */
  215.     u_long    tcps_rcvdupack;        /* rcvd duplicate acks */
  216.     u_long    tcps_rcvacktoomuch;    /* rcvd acks for unsent data */
  217.     u_long    tcps_rcvackpack;    /* rcvd ack packets */
  218.     u_long    tcps_rcvackbyte;    /* bytes acked by rcvd acks */
  219.     u_long    tcps_rcvwinupd;        /* rcvd window update packets */
  220. };
  221.  
  222. #ifdef KERNEL
  223. struct    inpcb tcb;        /* head of queue of active tcpcb's */
  224. struct    tcpstat tcpstat;    /* tcp statistics */
  225. struct    tcpiphdr *tcp_template();
  226. struct    tcpcb *tcp_close(), *tcp_drop();
  227. struct    tcpcb *tcp_timers(), *tcp_disconnect(), *tcp_usrclosed();
  228. #endif
  229.