]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
5d5c5d0d A |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. |
3 | * | |
6601e61a | 4 | * @APPLE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
6601e61a A |
6 | * The contents of this file constitute Original Code as defined in and |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
8f6c56a5 | 11 | * |
6601e61a A |
12 | * This Original Code and all software distributed under the License are |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
6601e61a A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
8f6c56a5 | 19 | * |
6601e61a | 20 | * @APPLE_LICENSE_HEADER_END@ |
1c79356b A |
21 | */ |
22 | /* | |
23 | * Copyright (c) 1982, 1986, 1993, 1994, 1995 | |
24 | * The Regents of the University of California. All rights reserved. | |
25 | * | |
26 | * Redistribution and use in source and binary forms, with or without | |
27 | * modification, are permitted provided that the following conditions | |
28 | * are met: | |
29 | * 1. Redistributions of source code must retain the above copyright | |
30 | * notice, this list of conditions and the following disclaimer. | |
31 | * 2. Redistributions in binary form must reproduce the above copyright | |
32 | * notice, this list of conditions and the following disclaimer in the | |
33 | * documentation and/or other materials provided with the distribution. | |
34 | * 3. All advertising materials mentioning features or use of this software | |
35 | * must display the following acknowledgement: | |
36 | * This product includes software developed by the University of | |
37 | * California, Berkeley and its contributors. | |
38 | * 4. Neither the name of the University nor the names of its contributors | |
39 | * may be used to endorse or promote products derived from this software | |
40 | * without specific prior written permission. | |
41 | * | |
42 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
43 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
44 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
45 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
46 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
47 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
48 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
49 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
50 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
51 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
52 | * SUCH DAMAGE. | |
53 | * | |
54 | * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95 | |
9bccf70c | 55 | * $FreeBSD: src/sys/netinet/tcp_var.h,v 1.56.2.8 2001/08/22 00:59:13 silby Exp $ |
1c79356b A |
56 | */ |
57 | ||
58 | #ifndef _NETINET_TCP_VAR_H_ | |
59 | #define _NETINET_TCP_VAR_H_ | |
9bccf70c | 60 | #include <sys/appleapiopts.h> |
91447636 A |
61 | #include <sys/queue.h> |
62 | #include <netinet/in_pcb.h> | |
9bccf70c | 63 | #include <netinet/tcp_timer.h> |
91447636 A |
64 | |
65 | #ifdef KERNEL_PRIVATE | |
9bccf70c | 66 | |
1c79356b A |
67 | #define N_TIME_WAIT_SLOTS 128 /* must be power of 2 */ |
68 | ||
69 | /* | |
9bccf70c | 70 | * Kernel variables for tcp. |
1c79356b | 71 | */ |
9bccf70c A |
72 | |
73 | /* TCP segment queue entry */ | |
74 | struct tseg_qent { | |
75 | LIST_ENTRY(tseg_qent) tqe_q; | |
76 | int tqe_len; /* TCP segment data length */ | |
77 | struct tcphdr *tqe_th; /* a pointer to tcp header */ | |
78 | struct mbuf *tqe_m; /* mbuf contains packet */ | |
1c79356b | 79 | }; |
9bccf70c | 80 | LIST_HEAD(tsegqe_head, tseg_qent); |
e5568f75 A |
81 | extern int tcp_reass_maxseg; |
82 | extern int tcp_reass_qsize; | |
9bccf70c A |
83 | #ifdef MALLOC_DECLARE |
84 | MALLOC_DECLARE(M_TSEGQ); | |
1c79356b | 85 | #endif |
9bccf70c | 86 | |
8ad349bb A |
87 | struct sackblk { |
88 | tcp_seq start; /* start seq no. of sack block */ | |
89 | tcp_seq end; /* end seq no. */ | |
90 | }; | |
91 | ||
92 | struct sackhole { | |
93 | tcp_seq start; /* start seq no. of hole */ | |
94 | tcp_seq end; /* end seq no. */ | |
95 | tcp_seq rxmit; /* next seq. no in hole to be retransmitted */ | |
96 | TAILQ_ENTRY(sackhole) scblink; /* scoreboard linkage */ | |
97 | }; | |
98 | ||
99 | struct sackhint { | |
100 | struct sackhole *nexthole; | |
101 | int sack_bytes_rexmit; | |
102 | }; | |
103 | ||
9bccf70c A |
104 | struct tcptemp { |
105 | u_char tt_ipgen[40]; /* the size must be of max ip header, now IPv6 */ | |
106 | struct tcphdr tt_t; | |
107 | }; | |
108 | ||
1c79356b A |
109 | #define tcp6cb tcpcb /* for KAME src sync over BSD*'s */ |
110 | ||
1c79356b A |
111 | /* |
112 | * Tcp control block, one per tcp; fields: | |
113 | * Organized for 16 byte cacheline efficiency. | |
114 | */ | |
115 | struct tcpcb { | |
9bccf70c | 116 | struct tsegqe_head t_segq; |
1c79356b | 117 | int t_dupacks; /* consecutive dup acks recd */ |
9bccf70c | 118 | struct tcptemp *unused; /* unused now: was t_template */ |
1c79356b A |
119 | |
120 | int t_timer[TCPT_NTIMERS]; /* tcp timers */ | |
121 | ||
122 | struct inpcb *t_inpcb; /* back pointer to internet pcb */ | |
123 | int t_state; /* state of this connection */ | |
124 | u_int t_flags; | |
125 | #define TF_ACKNOW 0x00001 /* ack peer immediately */ | |
126 | #define TF_DELACK 0x00002 /* ack, but try to delay it */ | |
127 | #define TF_NODELAY 0x00004 /* don't delay packets to coalesce */ | |
128 | #define TF_NOOPT 0x00008 /* don't use tcp options */ | |
129 | #define TF_SENTFIN 0x00010 /* have sent FIN */ | |
130 | #define TF_REQ_SCALE 0x00020 /* have/will request window scaling */ | |
131 | #define TF_RCVD_SCALE 0x00040 /* other side has requested scaling */ | |
132 | #define TF_REQ_TSTMP 0x00080 /* have/will request timestamps */ | |
133 | #define TF_RCVD_TSTMP 0x00100 /* a timestamp was received in SYN */ | |
134 | #define TF_SACK_PERMIT 0x00200 /* other side said I could SACK */ | |
135 | #define TF_NEEDSYN 0x00400 /* send SYN (implicit state) */ | |
136 | #define TF_NEEDFIN 0x00800 /* send FIN (implicit state) */ | |
137 | #define TF_NOPUSH 0x01000 /* don't push */ | |
138 | #define TF_REQ_CC 0x02000 /* have/will request CC */ | |
139 | #define TF_RCVD_CC 0x04000 /* a CC was received in SYN */ | |
140 | #define TF_SENDCCNEW 0x08000 /* send CCnew instead of CC in SYN */ | |
141 | #define TF_MORETOCOME 0x10000 /* More data to be appended to sock */ | |
9bccf70c A |
142 | #define TF_LQ_OVERFLOW 0x20000 /* listen queue overflow */ |
143 | #define TF_RXWIN0SENT 0x40000 /* sent a receiver win 0 in response */ | |
d12e1678 | 144 | #define TF_SLOWLINK 0x80000 /* route is a on a modem speed link */ |
9bccf70c | 145 | |
8ad349bb A |
146 | |
147 | #define TF_LASTIDLE 0x100000 /* connection was previously idle */ | |
148 | #define TF_FASTRECOVERY 0x200000 /* in NewReno Fast Recovery */ | |
149 | #define TF_WASFRECOVERY 0x400000 /* was in NewReno Fast Recovery */ | |
150 | #define TF_SIGNATURE 0x800000 /* require MD5 digests (RFC2385) */ | |
151 | #define TF_MAXSEGSNT 0x1000000 /* last segment sent was a full segment */ | |
152 | ||
1c79356b A |
153 | int t_force; /* 1 if forcing out a byte */ |
154 | ||
155 | tcp_seq snd_una; /* send unacknowledged */ | |
156 | tcp_seq snd_max; /* highest sequence number sent; | |
157 | * used to recognize retransmits | |
158 | */ | |
159 | tcp_seq snd_nxt; /* send next */ | |
160 | tcp_seq snd_up; /* send urgent pointer */ | |
161 | ||
162 | tcp_seq snd_wl1; /* window update seg seq number */ | |
163 | tcp_seq snd_wl2; /* window update seg ack number */ | |
164 | tcp_seq iss; /* initial send sequence number */ | |
165 | tcp_seq irs; /* initial receive sequence number */ | |
166 | ||
167 | tcp_seq rcv_nxt; /* receive next */ | |
168 | tcp_seq rcv_adv; /* advertised window */ | |
169 | u_long rcv_wnd; /* receive window */ | |
170 | tcp_seq rcv_up; /* receive urgent pointer */ | |
171 | ||
172 | u_long snd_wnd; /* send window */ | |
173 | u_long snd_cwnd; /* congestion-controlled window */ | |
174 | u_long snd_ssthresh; /* snd_cwnd size threshold for | |
175 | * for slow start exponential to | |
176 | * linear switch | |
177 | */ | |
178 | u_int t_maxopd; /* mss plus options */ | |
179 | ||
9bccf70c A |
180 | u_long t_rcvtime; /* inactivity time */ |
181 | u_long t_starttime; /* time connection was established */ | |
182 | int t_rtttime; /* round trip time */ | |
1c79356b A |
183 | tcp_seq t_rtseq; /* sequence number being timed */ |
184 | ||
9bccf70c | 185 | int t_rxtcur; /* current retransmit value (ticks) */ |
1c79356b A |
186 | u_int t_maxseg; /* maximum segment size */ |
187 | int t_srtt; /* smoothed round-trip time */ | |
188 | int t_rttvar; /* variance in round-trip time */ | |
189 | ||
190 | int t_rxtshift; /* log(2) of rexmt exp. backoff */ | |
191 | u_int t_rttmin; /* minimum rtt allowed */ | |
192 | u_long t_rttupdated; /* number of times rtt sampled */ | |
193 | u_long max_sndwnd; /* largest window peer has offered */ | |
194 | ||
195 | int t_softerror; /* possible error not yet reported */ | |
196 | /* out-of-band data */ | |
197 | char t_oobflags; /* have some */ | |
198 | char t_iobc; /* input character */ | |
199 | #define TCPOOB_HAVEDATA 0x01 | |
200 | #define TCPOOB_HADDATA 0x02 | |
201 | /* RFC 1323 variables */ | |
202 | u_char snd_scale; /* window scaling for send window */ | |
203 | u_char rcv_scale; /* window scaling for recv window */ | |
204 | u_char request_r_scale; /* pending window scaling */ | |
205 | u_char requested_s_scale; | |
206 | u_long ts_recent; /* timestamp echo data */ | |
207 | ||
208 | u_long ts_recent_age; /* when last updated */ | |
209 | tcp_seq last_ack_sent; | |
210 | /* RFC 1644 variables */ | |
211 | tcp_cc cc_send; /* send connection count */ | |
212 | tcp_cc cc_recv; /* receive connection count */ | |
91447636 | 213 | tcp_seq snd_recover; /* for use in NewReno Fast Recovery */ |
9bccf70c A |
214 | /* experimental */ |
215 | u_long snd_cwnd_prev; /* cwnd prior to retransmit */ | |
216 | u_long snd_ssthresh_prev; /* ssthresh prior to retransmit */ | |
217 | u_long t_badrxtwin; /* window for retransmit recovery */ | |
55e303ae A |
218 | |
219 | int t_keepidle; /* keepalive idle timer (override global if > 0) */ | |
91447636 A |
220 | int t_lastchain; /* amount of packets chained last time around */ |
221 | ||
222 | /* 3529618 MSS overload prevention */ | |
223 | u_long rcv_reset; | |
224 | u_long rcv_pps; | |
225 | u_long rcv_byps; | |
226 | tcp_seq snd_high; /* for use in NewReno Fast Recovery */ | |
227 | tcp_seq snd_high_prev; /* snd_high prior to retransmit */ | |
228 | ||
8ad349bb A |
229 | tcp_seq snd_recover_prev; /* snd_recover prior to retransmit */ |
230 | u_char snd_limited; /* segments limited transmitted */ | |
231 | /* anti DoS counters */ | |
232 | u_long rcv_second; /* start of interval second */ | |
233 | /* SACK related state */ | |
234 | int sack_enable; /* enable SACK for this connection */ | |
235 | int snd_numholes; /* number of holes seen by sender */ | |
236 | ||
237 | TAILQ_HEAD(sackhole_head, sackhole) snd_holes; | |
238 | /* SACK scoreboard (sorted) */ | |
239 | tcp_seq snd_fack; /* last seq number(+1) sack'd by rcv'r*/ | |
240 | int rcv_numsacks; /* # distinct sack blks present */ | |
241 | struct sackblk sackblks[MAX_SACK_BLKS]; /* seq nos. of sack blocks */ | |
242 | tcp_seq sack_newdata; /* New data xmitted in this recovery | |
243 | episode starts at this seq number */ | |
244 | struct sackhint sackhint; /* SACK scoreboard hint */ | |
245 | int t_rttlow; /* smallest observerved RTT */ | |
55e303ae | 246 | }; |
55e303ae | 247 | |
8ad349bb A |
248 | #define IN_FASTRECOVERY(tp) (tp->t_flags & TF_FASTRECOVERY) |
249 | #define ENTER_FASTRECOVERY(tp) tp->t_flags |= TF_FASTRECOVERY | |
250 | #define EXIT_FASTRECOVERY(tp) tp->t_flags &= ~TF_FASTRECOVERY | |
251 | ||
252 | ||
91447636 A |
253 | /* |
254 | * Structure to hold TCP options that are only used during segment | |
255 | * processing (in tcp_input), but not held in the tcpcb. | |
256 | * It's basically used to reduce the number of parameters | |
257 | * to tcp_dooptions. | |
258 | */ | |
259 | struct tcpopt { | |
8ad349bb | 260 | u_long to_flags; /* which options are present */ |
91447636 | 261 | #define TOF_TS 0x0001 /* timestamp */ |
8ad349bb A |
262 | #define TOF_MSS 0x0010 |
263 | #define TOF_SCALE 0x0020 | |
264 | #define TOF_SIGNATURE 0x0040 /* signature option present */ | |
265 | #define TOF_SIGLEN 0x0080 /* signature length valid (RFC2385) */ | |
266 | #define TOF_SACK 0x0100 /* Peer sent SACK option */ | |
267 | u_long to_tsval; | |
268 | u_long to_tsecr; | |
269 | u_int16_t to_mss; | |
270 | u_int8_t to_requested_s_scale; | |
271 | u_int8_t to_nsacks; /* number of SACK blocks */ | |
272 | u_char *to_sacks; /* pointer to the first SACK blocks */ | |
91447636 | 273 | }; |
55e303ae | 274 | |
91447636 A |
275 | /* |
276 | * The TAO cache entry which is stored in the protocol family specific | |
277 | * portion of the route metrics. | |
278 | */ | |
279 | struct rmxp_tao { | |
280 | tcp_cc tao_cc; /* latest CC in valid SYN */ | |
281 | tcp_cc tao_ccsent; /* latest CC sent to peer */ | |
282 | u_short tao_mssopt; /* peer's cached MSS */ | |
283 | #ifdef notyet | |
284 | u_short tao_flags; /* cache status flags */ | |
285 | #define TAOF_DONT 0x0001 /* peer doesn't understand rfc1644 */ | |
286 | #define TAOF_OK 0x0002 /* peer does understand rfc1644 */ | |
287 | #define TAOF_UNDEF 0 /* we don't know yet */ | |
288 | #endif /* notyet */ | |
289 | }; | |
290 | #define rmx_taop(r) ((struct rmxp_tao *)(r).rmx_filler) | |
291 | ||
292 | #define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb) | |
293 | #define sototcpcb(so) (intotcpcb(sotoinpcb(so))) | |
55e303ae | 294 | |
91447636 A |
295 | /* |
296 | * The smoothed round-trip time and estimated variance | |
297 | * are stored as fixed point numbers scaled by the values below. | |
298 | * For convenience, these scales are also used in smoothing the average | |
299 | * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed). | |
300 | * With these scales, srtt has 3 bits to the right of the binary point, | |
301 | * and thus an "ALPHA" of 0.875. rttvar has 2 bits to the right of the | |
302 | * binary point, and is smoothed with an ALPHA of 0.75. | |
303 | */ | |
304 | #define TCP_RTT_SCALE 32 /* multiplier for srtt; 3 bits frac. */ | |
305 | #define TCP_RTT_SHIFT 5 /* shift for srtt; 3 bits frac. */ | |
306 | #define TCP_RTTVAR_SCALE 16 /* multiplier for rttvar; 2 bits */ | |
307 | #define TCP_RTTVAR_SHIFT 4 /* shift for rttvar; 2 bits */ | |
308 | #define TCP_DELTA_SHIFT 2 /* see tcp_input.c */ | |
309 | ||
310 | /* | |
311 | * The initial retransmission should happen at rtt + 4 * rttvar. | |
312 | * Because of the way we do the smoothing, srtt and rttvar | |
313 | * will each average +1/2 tick of bias. When we compute | |
314 | * the retransmit timer, we want 1/2 tick of rounding and | |
315 | * 1 extra tick because of +-1/2 tick uncertainty in the | |
316 | * firing of the timer. The bias will give us exactly the | |
317 | * 1.5 tick we need. But, because the bias is | |
318 | * statistical, we have to test that we don't drop below | |
319 | * the minimum feasible timer (which is 2 ticks). | |
320 | * This version of the macro adapted from a paper by Lawrence | |
321 | * Brakmo and Larry Peterson which outlines a problem caused | |
322 | * by insufficient precision in the original implementation, | |
323 | * which results in inappropriately large RTO values for very | |
324 | * fast networks. | |
325 | */ | |
326 | #define TCP_REXMTVAL(tp) \ | |
327 | max((tp)->t_rttmin, (((tp)->t_srtt >> (TCP_RTT_SHIFT - TCP_DELTA_SHIFT)) \ | |
328 | + (tp)->t_rttvar) >> TCP_DELTA_SHIFT) | |
55e303ae A |
329 | |
330 | /* | |
331 | * Jaguar compatible TCP control block, for xtcpcb | |
332 | * Does not have the old fields | |
333 | */ | |
334 | struct otcpcb { | |
91447636 A |
335 | #else |
336 | struct tseg_qent; | |
337 | LIST_HEAD(tsegqe_head, tseg_qent); | |
338 | ||
339 | struct tcpcb { | |
340 | #endif /* KERNEL_PRIVATE */ | |
55e303ae A |
341 | struct tsegqe_head t_segq; |
342 | int t_dupacks; /* consecutive dup acks recd */ | |
343 | struct tcptemp *unused; /* unused now: was t_template */ | |
344 | ||
345 | int t_timer[TCPT_NTIMERS]; /* tcp timers */ | |
346 | ||
347 | struct inpcb *t_inpcb; /* back pointer to internet pcb */ | |
348 | int t_state; /* state of this connection */ | |
349 | u_int t_flags; | |
350 | #define TF_ACKNOW 0x00001 /* ack peer immediately */ | |
351 | #define TF_DELACK 0x00002 /* ack, but try to delay it */ | |
352 | #define TF_NODELAY 0x00004 /* don't delay packets to coalesce */ | |
353 | #define TF_NOOPT 0x00008 /* don't use tcp options */ | |
354 | #define TF_SENTFIN 0x00010 /* have sent FIN */ | |
355 | #define TF_REQ_SCALE 0x00020 /* have/will request window scaling */ | |
356 | #define TF_RCVD_SCALE 0x00040 /* other side has requested scaling */ | |
357 | #define TF_REQ_TSTMP 0x00080 /* have/will request timestamps */ | |
358 | #define TF_RCVD_TSTMP 0x00100 /* a timestamp was received in SYN */ | |
359 | #define TF_SACK_PERMIT 0x00200 /* other side said I could SACK */ | |
360 | #define TF_NEEDSYN 0x00400 /* send SYN (implicit state) */ | |
361 | #define TF_NEEDFIN 0x00800 /* send FIN (implicit state) */ | |
362 | #define TF_NOPUSH 0x01000 /* don't push */ | |
363 | #define TF_REQ_CC 0x02000 /* have/will request CC */ | |
364 | #define TF_RCVD_CC 0x04000 /* a CC was received in SYN */ | |
365 | #define TF_SENDCCNEW 0x08000 /* send CCnew instead of CC in SYN */ | |
366 | #define TF_MORETOCOME 0x10000 /* More data to be appended to sock */ | |
367 | #define TF_LQ_OVERFLOW 0x20000 /* listen queue overflow */ | |
368 | #define TF_RXWIN0SENT 0x40000 /* sent a receiver win 0 in response */ | |
369 | #define TF_SLOWLINK 0x80000 /* route is a on a modem speed link */ | |
370 | ||
371 | int t_force; /* 1 if forcing out a byte */ | |
372 | ||
373 | tcp_seq snd_una; /* send unacknowledged */ | |
374 | tcp_seq snd_max; /* highest sequence number sent; | |
375 | * used to recognize retransmits | |
376 | */ | |
377 | tcp_seq snd_nxt; /* send next */ | |
378 | tcp_seq snd_up; /* send urgent pointer */ | |
379 | ||
380 | tcp_seq snd_wl1; /* window update seg seq number */ | |
381 | tcp_seq snd_wl2; /* window update seg ack number */ | |
382 | tcp_seq iss; /* initial send sequence number */ | |
383 | tcp_seq irs; /* initial receive sequence number */ | |
384 | ||
385 | tcp_seq rcv_nxt; /* receive next */ | |
386 | tcp_seq rcv_adv; /* advertised window */ | |
387 | u_long rcv_wnd; /* receive window */ | |
388 | tcp_seq rcv_up; /* receive urgent pointer */ | |
389 | ||
390 | u_long snd_wnd; /* send window */ | |
391 | u_long snd_cwnd; /* congestion-controlled window */ | |
392 | u_long snd_ssthresh; /* snd_cwnd size threshold for | |
393 | * for slow start exponential to | |
394 | * linear switch | |
395 | */ | |
396 | u_int t_maxopd; /* mss plus options */ | |
397 | ||
398 | u_long t_rcvtime; /* inactivity time */ | |
399 | u_long t_starttime; /* time connection was established */ | |
400 | int t_rtttime; /* round trip time */ | |
401 | tcp_seq t_rtseq; /* sequence number being timed */ | |
402 | ||
403 | int t_rxtcur; /* current retransmit value (ticks) */ | |
404 | u_int t_maxseg; /* maximum segment size */ | |
405 | int t_srtt; /* smoothed round-trip time */ | |
406 | int t_rttvar; /* variance in round-trip time */ | |
407 | ||
408 | int t_rxtshift; /* log(2) of rexmt exp. backoff */ | |
409 | u_int t_rttmin; /* minimum rtt allowed */ | |
410 | u_long t_rttupdated; /* number of times rtt sampled */ | |
411 | u_long max_sndwnd; /* largest window peer has offered */ | |
412 | ||
413 | int t_softerror; /* possible error not yet reported */ | |
414 | /* out-of-band data */ | |
415 | char t_oobflags; /* have some */ | |
416 | char t_iobc; /* input character */ | |
417 | #define TCPOOB_HAVEDATA 0x01 | |
418 | #define TCPOOB_HADDATA 0x02 | |
419 | /* RFC 1323 variables */ | |
420 | u_char snd_scale; /* window scaling for send window */ | |
421 | u_char rcv_scale; /* window scaling for recv window */ | |
422 | u_char request_r_scale; /* pending window scaling */ | |
423 | u_char requested_s_scale; | |
424 | u_long ts_recent; /* timestamp echo data */ | |
425 | ||
426 | u_long ts_recent_age; /* when last updated */ | |
427 | tcp_seq last_ack_sent; | |
428 | /* RFC 1644 variables */ | |
429 | tcp_cc cc_send; /* send connection count */ | |
430 | tcp_cc cc_recv; /* receive connection count */ | |
91447636 | 431 | tcp_seq snd_recover; /* for use in fast recovery */ |
55e303ae A |
432 | /* experimental */ |
433 | u_long snd_cwnd_prev; /* cwnd prior to retransmit */ | |
434 | u_long snd_ssthresh_prev; /* ssthresh prior to retransmit */ | |
435 | u_long t_badrxtwin; /* window for retransmit recovery */ | |
1c79356b A |
436 | }; |
437 | ||
1c79356b A |
438 | /* |
439 | * TCP statistics. | |
440 | * Many of these should be kept per connection, | |
441 | * but that's inconvenient at the moment. | |
442 | */ | |
443 | struct tcpstat { | |
444 | u_long tcps_connattempt; /* connections initiated */ | |
445 | u_long tcps_accepts; /* connections accepted */ | |
446 | u_long tcps_connects; /* connections established */ | |
447 | u_long tcps_drops; /* connections dropped */ | |
448 | u_long tcps_conndrops; /* embryonic connections dropped */ | |
449 | u_long tcps_closed; /* conn. closed (includes drops) */ | |
450 | u_long tcps_segstimed; /* segs where we tried to get rtt */ | |
451 | u_long tcps_rttupdated; /* times we succeeded */ | |
452 | u_long tcps_delack; /* delayed acks sent */ | |
453 | u_long tcps_timeoutdrop; /* conn. dropped in rxmt timeout */ | |
454 | u_long tcps_rexmttimeo; /* retransmit timeouts */ | |
455 | u_long tcps_persisttimeo; /* persist timeouts */ | |
456 | u_long tcps_keeptimeo; /* keepalive timeouts */ | |
457 | u_long tcps_keepprobe; /* keepalive probes sent */ | |
458 | u_long tcps_keepdrops; /* connections dropped in keepalive */ | |
459 | ||
460 | u_long tcps_sndtotal; /* total packets sent */ | |
461 | u_long tcps_sndpack; /* data packets sent */ | |
462 | u_long tcps_sndbyte; /* data bytes sent */ | |
463 | u_long tcps_sndrexmitpack; /* data packets retransmitted */ | |
464 | u_long tcps_sndrexmitbyte; /* data bytes retransmitted */ | |
465 | u_long tcps_sndacks; /* ack-only packets sent */ | |
466 | u_long tcps_sndprobe; /* window probes sent */ | |
467 | u_long tcps_sndurg; /* packets sent with URG only */ | |
468 | u_long tcps_sndwinup; /* window update-only packets sent */ | |
469 | u_long tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */ | |
470 | ||
471 | u_long tcps_rcvtotal; /* total packets received */ | |
472 | u_long tcps_rcvpack; /* packets received in sequence */ | |
473 | u_long tcps_rcvbyte; /* bytes received in sequence */ | |
474 | u_long tcps_rcvbadsum; /* packets received with ccksum errs */ | |
475 | u_long tcps_rcvbadoff; /* packets received with bad offset */ | |
476 | u_long tcps_rcvmemdrop; /* packets dropped for lack of memory */ | |
477 | u_long tcps_rcvshort; /* packets received too short */ | |
478 | u_long tcps_rcvduppack; /* duplicate-only packets received */ | |
479 | u_long tcps_rcvdupbyte; /* duplicate-only bytes received */ | |
480 | u_long tcps_rcvpartduppack; /* packets with some duplicate data */ | |
481 | u_long tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */ | |
482 | u_long tcps_rcvoopack; /* out-of-order packets received */ | |
483 | u_long tcps_rcvoobyte; /* out-of-order bytes received */ | |
484 | u_long tcps_rcvpackafterwin; /* packets with data after window */ | |
485 | u_long tcps_rcvbyteafterwin; /* bytes rcvd after window */ | |
486 | u_long tcps_rcvafterclose; /* packets rcvd after "close" */ | |
487 | u_long tcps_rcvwinprobe; /* rcvd window probe packets */ | |
488 | u_long tcps_rcvdupack; /* rcvd duplicate acks */ | |
489 | u_long tcps_rcvacktoomuch; /* rcvd acks for unsent data */ | |
490 | u_long tcps_rcvackpack; /* rcvd ack packets */ | |
491 | u_long tcps_rcvackbyte; /* bytes acked by rcvd acks */ | |
492 | u_long tcps_rcvwinupd; /* rcvd window update packets */ | |
493 | u_long tcps_pawsdrop; /* segments dropped due to PAWS */ | |
494 | u_long tcps_predack; /* times hdr predict ok for acks */ | |
495 | u_long tcps_preddat; /* times hdr predict ok for data pkts */ | |
496 | u_long tcps_pcbcachemiss; | |
497 | u_long tcps_cachedrtt; /* times cached RTT in route updated */ | |
498 | u_long tcps_cachedrttvar; /* times cached rttvar updated */ | |
499 | u_long tcps_cachedssthresh; /* times cached ssthresh updated */ | |
500 | u_long tcps_usedrtt; /* times RTT initialized from route */ | |
501 | u_long tcps_usedrttvar; /* times RTTVAR initialized from rt */ | |
502 | u_long tcps_usedssthresh; /* times ssthresh initialized from rt*/ | |
503 | u_long tcps_persistdrop; /* timeout in persist state */ | |
504 | u_long tcps_badsyn; /* bogus SYN, e.g. premature ACK */ | |
505 | u_long tcps_mturesent; /* resends due to MTU discovery */ | |
506 | u_long tcps_listendrop; /* listen queue overflows */ | |
8ad349bb A |
507 | |
508 | /* SACK related stats */ | |
509 | u_long tcps_sack_recovery_episode; /* SACK recovery episodes */ | |
510 | u_long tcps_sack_rexmits; /* SACK rexmit segments */ | |
511 | u_long tcps_sack_rexmit_bytes; /* SACK rexmit bytes */ | |
512 | u_long tcps_sack_rcv_blocks; /* SACK blocks (options) received */ | |
513 | u_long tcps_sack_send_blocks; /* SACK blocks (options) sent */ | |
514 | u_long tcps_sack_sboverflow; /* SACK sendblock overflow */ | |
515 | ||
1c79356b A |
516 | }; |
517 | ||
518 | /* | |
519 | * TCB structure exported to user-land via sysctl(3). | |
520 | * Evil hack: declare only if in_pcb.h and sys/socketvar.h have been | |
521 | * included. Not all of our clients do. | |
522 | */ | |
1c79356b A |
523 | struct xtcpcb { |
524 | size_t xt_len; | |
91447636 A |
525 | #ifdef KERNEL_PRIVATE |
526 | struct inpcb_compat xt_inp; | |
527 | #else | |
1c79356b | 528 | struct inpcb xt_inp; |
91447636 A |
529 | #endif |
530 | #ifdef KERNEL_PRIVATE | |
55e303ae A |
531 | struct otcpcb xt_tp; |
532 | #else | |
533 | struct tcpcb xt_tp; | |
534 | #endif | |
1c79356b A |
535 | struct xsocket xt_socket; |
536 | u_quad_t xt_alignment_hack; | |
537 | }; | |
1c79356b A |
538 | |
539 | /* | |
540 | * Names for TCP sysctl objects | |
541 | */ | |
542 | #define TCPCTL_DO_RFC1323 1 /* use RFC-1323 extensions */ | |
543 | #define TCPCTL_DO_RFC1644 2 /* use RFC-1644 extensions */ | |
544 | #define TCPCTL_MSSDFLT 3 /* MSS default */ | |
545 | #define TCPCTL_STATS 4 /* statistics (read-only) */ | |
546 | #define TCPCTL_RTTDFLT 5 /* default RTT estimate */ | |
547 | #define TCPCTL_KEEPIDLE 6 /* keepalive idle timer */ | |
548 | #define TCPCTL_KEEPINTVL 7 /* interval to send keepalives */ | |
549 | #define TCPCTL_SENDSPACE 8 /* send buffer space */ | |
550 | #define TCPCTL_RECVSPACE 9 /* receive buffer space */ | |
9bccf70c | 551 | #define TCPCTL_KEEPINIT 10 /* timeout for establishing syn */ |
1c79356b | 552 | #define TCPCTL_PCBLIST 11 /* list of all outstanding PCBs */ |
9bccf70c A |
553 | #define TCPCTL_DELACKTIME 12 /* time before sending delayed ACK */ |
554 | #define TCPCTL_V6MSSDFLT 13 /* MSS default for IPv6 */ | |
555 | #define TCPCTL_MAXID 14 | |
1c79356b | 556 | |
91447636 | 557 | #ifdef KERNEL_PRIVATE |
1c79356b A |
558 | #define TCPCTL_NAMES { \ |
559 | { 0, 0 }, \ | |
560 | { "rfc1323", CTLTYPE_INT }, \ | |
561 | { "rfc1644", CTLTYPE_INT }, \ | |
562 | { "mssdflt", CTLTYPE_INT }, \ | |
563 | { "stats", CTLTYPE_STRUCT }, \ | |
564 | { "rttdflt", CTLTYPE_INT }, \ | |
565 | { "keepidle", CTLTYPE_INT }, \ | |
566 | { "keepintvl", CTLTYPE_INT }, \ | |
567 | { "sendspace", CTLTYPE_INT }, \ | |
568 | { "recvspace", CTLTYPE_INT }, \ | |
569 | { "keepinit", CTLTYPE_INT }, \ | |
570 | { "pcblist", CTLTYPE_STRUCT }, \ | |
9bccf70c | 571 | { "delacktime", CTLTYPE_INT }, \ |
1c79356b A |
572 | { "v6mssdflt", CTLTYPE_INT }, \ |
573 | } | |
574 | ||
1c79356b A |
575 | #ifdef SYSCTL_DECL |
576 | SYSCTL_DECL(_net_inet_tcp); | |
91447636 | 577 | #endif /* SYSCTL_DECL */ |
1c79356b A |
578 | |
579 | extern struct inpcbhead tcb; /* head of queue of active tcpcb's */ | |
580 | extern struct inpcbinfo tcbinfo; | |
581 | extern struct tcpstat tcpstat; /* tcp statistics */ | |
582 | extern int tcp_mssdflt; /* XXX */ | |
e5568f75 | 583 | extern int tcp_minmss; |
91447636 | 584 | extern int tcp_minmssoverload; |
9bccf70c A |
585 | extern int tcp_do_newreno; |
586 | extern int ss_fltsz; | |
587 | extern int ss_fltsz_local; | |
588 | #ifdef __APPLE__ | |
589 | extern u_long tcp_now; /* for RFC 1323 timestamps */ | |
590 | extern int tcp_delack_enabled; | |
91447636 | 591 | #endif /* __APPLE__ */ |
9bccf70c | 592 | |
8ad349bb | 593 | extern int tcp_do_sack; /* SACK enabled/disabled */ |
1c79356b | 594 | |
91447636 | 595 | void tcp_canceltimers(struct tcpcb *); |
1c79356b | 596 | struct tcpcb * |
91447636 A |
597 | tcp_close(struct tcpcb *); |
598 | void tcp_ctlinput(int, struct sockaddr *, void *); | |
599 | int tcp_ctloutput(struct socket *, struct sockopt *); | |
1c79356b | 600 | struct tcpcb * |
91447636 A |
601 | tcp_drop(struct tcpcb *, int); |
602 | void tcp_drain(void); | |
603 | void tcp_fasttimo(void); | |
1c79356b | 604 | struct rmxp_tao * |
91447636 A |
605 | tcp_gettaocache(struct inpcb *); |
606 | void tcp_init(void); | |
607 | void tcp_input(struct mbuf *, int); | |
608 | void tcp_mss(struct tcpcb *, int); | |
609 | int tcp_mssopt(struct tcpcb *); | |
610 | void tcp_drop_syn_sent(struct inpcb *, int); | |
611 | void tcp_mtudisc(struct inpcb *, int); | |
1c79356b | 612 | struct tcpcb * |
91447636 A |
613 | tcp_newtcpcb(struct inpcb *); |
614 | int tcp_output(struct tcpcb *); | |
615 | void tcp_quench(struct inpcb *, int); | |
616 | void tcp_respond(struct tcpcb *, void *, | |
617 | struct tcphdr *, struct mbuf *, tcp_seq, tcp_seq, int); | |
1c79356b | 618 | struct rtentry * |
91447636 A |
619 | tcp_rtlookup(struct inpcb *); |
620 | void tcp_setpersist(struct tcpcb *); | |
621 | void tcp_slowtimo(void); | |
1c79356b | 622 | struct tcptemp * |
91447636 A |
623 | tcp_maketemplate(struct tcpcb *); |
624 | void tcp_fillheaders(struct tcpcb *, void *, void *); | |
1c79356b | 625 | struct tcpcb * |
91447636 A |
626 | tcp_timers(struct tcpcb *, int); |
627 | void tcp_trace(int, int, struct tcpcb *, void *, struct tcphdr *, int); | |
8ad349bb A |
628 | |
629 | void tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_laststart, tcp_seq rcv_lastend); | |
630 | void tcp_clean_sackreport(struct tcpcb *tp); | |
631 | void tcp_sack_adjust(struct tcpcb *tp); | |
632 | struct sackhole *tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt); | |
633 | void tcp_sack_partialack(struct tcpcb *, struct tcphdr *); | |
634 | void tcp_free_sackholes(struct tcpcb *tp); | |
635 | ||
636 | ||
91447636 A |
637 | int tcp_lock (struct socket *, int, int); |
638 | int tcp_unlock (struct socket *, int, int); | |
639 | #ifdef _KERN_LOCKS_H_ | |
640 | lck_mtx_t * tcp_getlock (struct socket *, int); | |
641 | #else | |
642 | void * tcp_getlock (struct socket *, int); | |
643 | #endif | |
644 | ||
1c79356b A |
645 | |
646 | extern struct pr_usrreqs tcp_usrreqs; | |
1c79356b A |
647 | extern u_long tcp_sendspace; |
648 | extern u_long tcp_recvspace; | |
91447636 | 649 | tcp_seq tcp_new_isn(struct tcpcb *); |
1c79356b | 650 | |
91447636 | 651 | #endif /* KERNEL_RPIVATE */ |
1c79356b A |
652 | |
653 | #endif /* _NETINET_TCP_VAR_H_ */ |