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