2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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
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
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
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.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 * Copyright (c) 1982, 1986, 1993, 1994, 1995
32 * The Regents of the University of California. All rights reserved.
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
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.
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
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 $
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>
75 #define N_TIME_WAIT_SLOTS 128 /* must be power of 2 */
78 * Kernel variables for tcp.
81 /* TCP segment queue entry */
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 */
88 LIST_HEAD(tsegqe_head
, tseg_qent
);
89 extern int tcp_reass_maxseg
;
90 extern int tcp_reass_qsize
;
92 MALLOC_DECLARE(M_TSEGQ
);
96 tcp_seq start
; /* start seq no. of sack block */
97 tcp_seq end
; /* end seq no. */
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 */
108 struct sackhole
*nexthole
;
109 int sack_bytes_rexmit
;
113 u_char tt_ipgen
[40]; /* the size must be of max ip header, now IPv6 */
117 #define tcp6cb tcpcb /* for KAME src sync over BSD*'s */
120 * Tcp control block, one per tcp; fields:
121 * Organized for 16 byte cacheline efficiency.
124 struct tsegqe_head t_segq
;
125 int t_dupacks
; /* consecutive dup acks recd */
126 struct tcptemp
*unused
; /* unused now: was t_template */
128 int t_timer
[TCPT_NTIMERS
]; /* tcp timers */
130 struct inpcb
*t_inpcb
; /* back pointer to internet pcb */
131 int t_state
; /* state of this connection */
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 */
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 */
161 int t_force
; /* 1 if forcing out a byte */
163 tcp_seq snd_una
; /* send unacknowledged */
164 tcp_seq snd_max
; /* highest sequence number sent;
165 * used to recognize retransmits
167 tcp_seq snd_nxt
; /* send next */
168 tcp_seq snd_up
; /* send urgent pointer */
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 */
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 */
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
186 u_int t_maxopd
; /* mss plus options */
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 */
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 */
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 */
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 */
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 */
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 */
227 int t_keepidle
; /* keepalive idle timer (override global if > 0) */
228 int t_lastchain
; /* amount of packets chained last time around */
230 /* 3529618 MSS overload prevention */
234 tcp_seq snd_high
; /* for use in NewReno Fast Recovery */
235 tcp_seq snd_high_prev
; /* snd_high prior to retransmit */
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 */
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 */
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
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
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 */
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 */
284 * The TAO cache entry which is stored in the protocol family specific
285 * portion of the route metrics.
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 */
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 */
298 #define rmx_taop(r) ((struct rmxp_tao *)(r).rmx_filler)
300 #define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb)
301 #define sototcpcb(so) (intotcpcb(sotoinpcb(so)))
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.
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 */
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
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)
339 * Jaguar compatible TCP control block, for xtcpcb
340 * Does not have the old fields
345 LIST_HEAD(tsegqe_head
, tseg_qent
);
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 */
353 int t_timer
[TCPT_NTIMERS
]; /* tcp timers */
355 struct inpcb
*t_inpcb
; /* back pointer to internet pcb */
356 int t_state
; /* state of this connection */
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 */
379 int t_force
; /* 1 if forcing out a byte */
381 tcp_seq snd_una
; /* send unacknowledged */
382 tcp_seq snd_max
; /* highest sequence number sent;
383 * used to recognize retransmits
385 tcp_seq snd_nxt
; /* send next */
386 tcp_seq snd_up
; /* send urgent pointer */
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 */
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 */
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
404 u_int t_maxopd
; /* mss plus options */
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 */
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 */
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 */
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 */
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 */
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 */
448 * Many of these should be kept per connection,
449 * but that's inconvenient at the moment.
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 */
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 */
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 */
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 */
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.
533 #ifdef KERNEL_PRIVATE
534 struct inpcb_compat xt_inp
;
538 #ifdef KERNEL_PRIVATE
543 struct xsocket xt_socket
;
544 u_quad_t xt_alignment_hack
;
548 * Names for TCP sysctl objects
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
565 #ifdef KERNEL_PRIVATE
566 #define TCPCTL_NAMES { \
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 }, \
584 SYSCTL_DECL(_net_inet_tcp
);
585 #endif /* SYSCTL_DECL */
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
;
595 extern int ss_fltsz_local
;
597 extern u_long tcp_now
; /* for RFC 1323 timestamps */
598 extern int tcp_delack_enabled
;
599 #endif /* __APPLE__ */
601 extern int tcp_do_sack
; /* SACK enabled/disabled */
603 void tcp_canceltimers(struct tcpcb
*);
605 tcp_close(struct tcpcb
*);
606 void tcp_ctlinput(int, struct sockaddr
*, void *);
607 int tcp_ctloutput(struct socket
*, struct sockopt
*);
609 tcp_drop(struct tcpcb
*, int);
610 void tcp_drain(void);
611 void tcp_fasttimo(void);
613 tcp_gettaocache(struct inpcb
*);
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);
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);
627 tcp_rtlookup(struct inpcb
*);
628 void tcp_setpersist(struct tcpcb
*);
629 void tcp_slowtimo(void);
631 tcp_maketemplate(struct tcpcb
*);
632 void tcp_fillheaders(struct tcpcb
*, void *, void *);
634 tcp_timers(struct tcpcb
*, int);
635 void tcp_trace(int, int, struct tcpcb
*, void *, struct tcphdr
*, int);
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
);
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);
650 void * tcp_getlock (struct socket
*, int);
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
*);
659 #endif /* KERNEL_RPIVATE */
661 #endif /* _NETINET_TCP_VAR_H_ */