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