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