2 * Copyright (c) 2000-2007 Apple 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>
72 #define _TCPCB_PTR(x) u_int32_t
73 #define _TCPCB_LIST_HEAD(name, type) \
78 #define _TCPCB_PTR(x) x
79 #define _TCPCB_LIST_HEAD(name, type) LIST_HEAD(name, type)
82 #define TCP_RETRANSHZ 10 /* tcp retrans timer (100ms) per hz */
85 #define N_TIME_WAIT_SLOTS 128 /* must be power of 2 */
88 * Kernel variables for tcp.
91 /* TCP segment queue entry */
93 LIST_ENTRY(tseg_qent
) tqe_q
;
94 int tqe_len
; /* TCP segment data length */
95 struct tcphdr
*tqe_th
; /* a pointer to tcp header */
96 struct mbuf
*tqe_m
; /* mbuf contains packet */
98 LIST_HEAD(tsegqe_head
, tseg_qent
);
99 extern int tcp_reass_maxseg
;
100 extern int tcp_reass_qsize
;
101 #ifdef MALLOC_DECLARE
102 MALLOC_DECLARE(M_TSEGQ
);
106 tcp_seq start
; /* start seq no. of sack block */
107 tcp_seq end
; /* end seq no. */
111 tcp_seq start
; /* start seq no. of hole */
112 tcp_seq end
; /* end seq no. */
113 tcp_seq rxmit
; /* next seq. no in hole to be retransmitted */
114 TAILQ_ENTRY(sackhole
) scblink
; /* scoreboard linkage */
118 struct sackhole
*nexthole
;
119 int sack_bytes_rexmit
;
123 u_char tt_ipgen
[40]; /* the size must be of max ip header, now IPv6 */
127 #define tcp6cb tcpcb /* for KAME src sync over BSD*'s */
130 * Tcp control block, one per tcp; fields:
131 * Organized for 16 byte cacheline efficiency.
134 struct tsegqe_head t_segq
;
135 int t_dupacks
; /* consecutive dup acks recd */
136 struct tcptemp
*unused
; /* unused now: was t_template */
138 int t_timer
[TCPT_NTIMERS
]; /* tcp timers */
140 struct inpcb
*t_inpcb
; /* back pointer to internet pcb */
141 int t_state
; /* state of this connection */
143 #define TF_ACKNOW 0x00001 /* ack peer immediately */
144 #define TF_DELACK 0x00002 /* ack, but try to delay it */
145 #define TF_NODELAY 0x00004 /* don't delay packets to coalesce */
146 #define TF_NOOPT 0x00008 /* don't use tcp options */
147 #define TF_SENTFIN 0x00010 /* have sent FIN */
148 #define TF_REQ_SCALE 0x00020 /* have/will request window scaling */
149 #define TF_RCVD_SCALE 0x00040 /* other side has requested scaling */
150 #define TF_REQ_TSTMP 0x00080 /* have/will request timestamps */
151 #define TF_RCVD_TSTMP 0x00100 /* a timestamp was received in SYN */
152 #define TF_SACK_PERMIT 0x00200 /* other side said I could SACK */
153 #define TF_NEEDSYN 0x00400 /* send SYN (implicit state) */
154 #define TF_NEEDFIN 0x00800 /* send FIN (implicit state) */
155 #define TF_NOPUSH 0x01000 /* don't push */
156 #define TF_REQ_CC 0x02000 /* have/will request CC */
157 #define TF_RCVD_CC 0x04000 /* a CC was received in SYN */
158 #define TF_SENDCCNEW 0x08000 /* send CCnew instead of CC in SYN */
159 #define TF_MORETOCOME 0x10000 /* More data to be appended to sock */
160 #define TF_LQ_OVERFLOW 0x20000 /* UNUSED listen queue overflow */
161 #define TF_RXWIN0SENT 0x40000 /* sent a receiver win 0 in response */
162 #define TF_SLOWLINK 0x80000 /* route is a on a modem speed link */
165 #define TF_LASTIDLE 0x100000 /* connection was previously idle */
166 #define TF_FASTRECOVERY 0x200000 /* in NewReno Fast Recovery */
167 #define TF_WASFRECOVERY 0x400000 /* was in NewReno Fast Recovery */
168 #define TF_SIGNATURE 0x800000 /* require MD5 digests (RFC2385) */
169 #define TF_MAXSEGSNT 0x1000000 /* last segment sent was a full segment */
170 #define TF_SENDINPROG 0x2000000 /* send is in progress */
171 #define TF_PMTUD 0x4000000 /* Perform Path MTU Discovery for this connection */
172 #define TF_CLOSING 0x8000000 /* pending tcp close */
174 int t_force
; /* 1 if forcing out a byte */
176 tcp_seq snd_una
; /* send unacknowledged */
177 tcp_seq snd_max
; /* highest sequence number sent;
178 * used to recognize retransmits
180 tcp_seq snd_nxt
; /* send next */
181 tcp_seq snd_up
; /* send urgent pointer */
183 tcp_seq snd_wl1
; /* window update seg seq number */
184 tcp_seq snd_wl2
; /* window update seg ack number */
185 tcp_seq iss
; /* initial send sequence number */
186 tcp_seq irs
; /* initial receive sequence number */
188 tcp_seq rcv_nxt
; /* receive next */
189 tcp_seq rcv_adv
; /* advertised window */
190 u_long rcv_wnd
; /* receive window */
191 tcp_seq rcv_up
; /* receive urgent pointer */
193 u_long snd_wnd
; /* send window */
194 u_long snd_cwnd
; /* congestion-controlled window */
195 u_long snd_bwnd
; /* bandwidth-controlled window */
196 u_long snd_ssthresh
; /* snd_cwnd size threshold for
197 * for slow start exponential to
200 u_long snd_bandwidth
; /* calculated bandwidth or 0 */
201 tcp_seq snd_recover
; /* for use in NewReno Fast Recovery */
203 u_int t_maxopd
; /* mss plus options */
205 u_long t_rcvtime
; /* inactivity time */
206 u_long t_starttime
; /* time connection was established */
207 int t_rtttime
; /* round trip time */
208 tcp_seq t_rtseq
; /* sequence number being timed */
210 int t_bw_rtttime
; /* used for bandwidth calculation */
211 tcp_seq t_bw_rtseq
; /* used for bandwidth calculation */
213 int t_rxtcur
; /* current retransmit value (ticks) */
214 u_int t_maxseg
; /* maximum segment size */
215 int t_srtt
; /* smoothed round-trip time */
216 int t_rttvar
; /* variance in round-trip time */
218 int t_rxtshift
; /* log(2) of rexmt exp. backoff */
219 u_int t_rttmin
; /* minimum rtt allowed */
220 u_int t_rttbest
; /* best rtt we've seen */
221 u_long t_rttupdated
; /* number of times rtt sampled */
222 u_long max_sndwnd
; /* largest window peer has offered */
224 int t_softerror
; /* possible error not yet reported */
225 /* out-of-band data */
226 char t_oobflags
; /* have some */
227 char t_iobc
; /* input character */
228 #define TCPOOB_HAVEDATA 0x01
229 #define TCPOOB_HADDATA 0x02
230 /* RFC 1323 variables */
231 u_char snd_scale
; /* window scaling for send window */
232 u_char rcv_scale
; /* window scaling for recv window */
233 u_char request_r_scale
; /* pending window scaling */
234 u_char requested_s_scale
;
235 u_long ts_recent
; /* timestamp echo data */
237 u_long ts_recent_age
; /* when last updated */
238 tcp_seq last_ack_sent
;
239 /* RFC 1644 variables */
240 tcp_cc cc_send
; /* send connection count */
241 tcp_cc cc_recv
; /* receive connection count */
242 /* RFC 3465 variables */
243 u_long t_bytes_acked
; /* ABC "bytes_acked" parameter */
245 u_long snd_cwnd_prev
; /* cwnd prior to retransmit */
246 u_long snd_ssthresh_prev
; /* ssthresh prior to retransmit */
247 u_long t_badrxtwin
; /* window for retransmit recovery */
249 int t_keepidle
; /* keepalive idle timer (override global if > 0) */
250 int t_lastchain
; /* amount of packets chained last time around */
251 int t_unacksegs
; /* received but unacked segments: used for delaying acks */
254 /* 3529618 MSS overload prevention */
259 tcp_seq snd_high
; /* for use in NewReno Fast Recovery */
260 tcp_seq snd_high_prev
; /* snd_high prior to retransmit */
262 tcp_seq snd_recover_prev
; /* snd_recover prior to retransmit */
263 u_char snd_limited
; /* segments limited transmitted */
264 /* anti DoS counters */
265 u_long rcv_second
; /* start of interval second */
266 /* SACK related state */
267 int sack_enable
; /* enable SACK for this connection */
268 int snd_numholes
; /* number of holes seen by sender */
270 TAILQ_HEAD(sackhole_head
, sackhole
) snd_holes
;
271 /* SACK scoreboard (sorted) */
272 tcp_seq snd_fack
; /* last seq number(+1) sack'd by rcv'r*/
273 int rcv_numsacks
; /* # distinct sack blks present */
274 struct sackblk sackblks
[MAX_SACK_BLKS
]; /* seq nos. of sack blocks */
275 tcp_seq sack_newdata
; /* New data xmitted in this recovery
276 episode starts at this seq number */
277 struct sackhint sackhint
; /* SACK scoreboard hint */
278 int t_rttlow
; /* smallest observerved RTT */
280 #define TE_SETUPSENT 0x01 /* Indicate we have sent ECN-SETUP SYN or SYN-ACK */
281 #define TE_SETUPRECEIVED 0x02 /* Indicate we have received ECN-SETUP SYN or SYN-ACK */
282 #define TE_SENDIPECT 0x04 /* Indicate we haven't sent or received non-ECN-setup SYN or SYN-ACK */
283 #define TE_SENDCWR 0x08 /* Indicate that the next non-retransmit should have the TCP CWR flag set */
284 #define TE_SENDECE 0x10 /* Indicate that the next packet should have the TCP ECE flag set */
287 u_int32_t tot_recv_snapshot
; /* snapshot of global total pkts received */
288 u_int32_t bg_recv_snapshot
; /* snapshot of global background pkts received */
289 #endif /* TRAFFIC_MGT */
290 u_int32_t t_pktlist_sentlen
; /* total bytes in transmit chain */
291 struct mbuf
*t_pktlist_head
; /* First packet in transmit chain */
292 struct mbuf
*t_pktlist_tail
; /* Last packet in transmit chain */
295 #define IN_FASTRECOVERY(tp) (tp->t_flags & TF_FASTRECOVERY)
296 #define ENTER_FASTRECOVERY(tp) tp->t_flags |= TF_FASTRECOVERY
297 #define EXIT_FASTRECOVERY(tp) tp->t_flags &= ~TF_FASTRECOVERY
301 * Structure to hold TCP options that are only used during segment
302 * processing (in tcp_input), but not held in the tcpcb.
303 * It's basically used to reduce the number of parameters
307 u_long to_flags
; /* which options are present */
308 #define TOF_TS 0x0001 /* timestamp */
309 #define TOF_MSS 0x0010
310 #define TOF_SCALE 0x0020
311 #define TOF_SIGNATURE 0x0040 /* signature option present */
312 #define TOF_SIGLEN 0x0080 /* signature length valid (RFC2385) */
313 #define TOF_SACK 0x0100 /* Peer sent SACK option */
317 u_int8_t to_requested_s_scale
;
318 u_int8_t to_nsacks
; /* number of SACK blocks */
319 u_char
*to_sacks
; /* pointer to the first SACK blocks */
323 * The TAO cache entry which is stored in the protocol family specific
324 * portion of the route metrics.
327 tcp_cc tao_cc
; /* latest CC in valid SYN */
328 tcp_cc tao_ccsent
; /* latest CC sent to peer */
329 u_short tao_mssopt
; /* peer's cached MSS */
331 u_short tao_flags
; /* cache status flags */
332 #define TAOF_DONT 0x0001 /* peer doesn't understand rfc1644 */
333 #define TAOF_OK 0x0002 /* peer does understand rfc1644 */
334 #define TAOF_UNDEF 0 /* we don't know yet */
337 #define rmx_taop(r) ((struct rmxp_tao *)(r).rmx_filler)
339 #define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb)
340 #define sototcpcb(so) (intotcpcb(sotoinpcb(so)))
343 * The smoothed round-trip time and estimated variance
344 * are stored as fixed point numbers scaled by the values below.
345 * For convenience, these scales are also used in smoothing the average
346 * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
347 * With these scales, srtt has 3 bits to the right of the binary point,
348 * and thus an "ALPHA" of 0.875. rttvar has 2 bits to the right of the
349 * binary point, and is smoothed with an ALPHA of 0.75.
351 #define TCP_RTT_SCALE 32 /* multiplier for srtt; 3 bits frac. */
352 #define TCP_RTT_SHIFT 5 /* shift for srtt; 3 bits frac. */
353 #define TCP_RTTVAR_SCALE 16 /* multiplier for rttvar; 2 bits */
354 #define TCP_RTTVAR_SHIFT 4 /* shift for rttvar; 2 bits */
355 #define TCP_DELTA_SHIFT 2 /* see tcp_input.c */
358 * The initial retransmission should happen at rtt + 4 * rttvar.
359 * Because of the way we do the smoothing, srtt and rttvar
360 * will each average +1/2 tick of bias. When we compute
361 * the retransmit timer, we want 1/2 tick of rounding and
362 * 1 extra tick because of +-1/2 tick uncertainty in the
363 * firing of the timer. The bias will give us exactly the
364 * 1.5 tick we need. But, because the bias is
365 * statistical, we have to test that we don't drop below
366 * the minimum feasible timer (which is 2 ticks).
367 * This version of the macro adapted from a paper by Lawrence
368 * Brakmo and Larry Peterson which outlines a problem caused
369 * by insufficient precision in the original implementation,
370 * which results in inappropriately large RTO values for very
373 #define TCP_REXMTVAL(tp) \
374 max((tp)->t_rttmin, (((tp)->t_srtt >> (TCP_RTT_SHIFT - TCP_DELTA_SHIFT)) \
375 + (tp)->t_rttvar) >> TCP_DELTA_SHIFT)
378 * Jaguar compatible TCP control block, for xtcpcb
379 * Does not have the old fields
384 _TCPCB_LIST_HEAD(tsegqe_head
, tseg_qent
);
387 #endif /* KERNEL_PRIVATE */
388 struct tsegqe_head t_segq
;
389 int t_dupacks
; /* consecutive dup acks recd */
390 u_int32_t unused
; /* unused now: was t_template */
392 int t_timer
[TCPT_NTIMERS
]; /* tcp timers */
394 _TCPCB_PTR(struct inpcb
*) t_inpcb
; /* back pointer to internet pcb */
395 int t_state
; /* state of this connection */
397 #define TF_ACKNOW 0x00001 /* ack peer immediately */
398 #define TF_DELACK 0x00002 /* ack, but try to delay it */
399 #define TF_NODELAY 0x00004 /* don't delay packets to coalesce */
400 #define TF_NOOPT 0x00008 /* don't use tcp options */
401 #define TF_SENTFIN 0x00010 /* have sent FIN */
402 #define TF_REQ_SCALE 0x00020 /* have/will request window scaling */
403 #define TF_RCVD_SCALE 0x00040 /* other side has requested scaling */
404 #define TF_REQ_TSTMP 0x00080 /* have/will request timestamps */
405 #define TF_RCVD_TSTMP 0x00100 /* a timestamp was received in SYN */
406 #define TF_SACK_PERMIT 0x00200 /* other side said I could SACK */
407 #define TF_NEEDSYN 0x00400 /* send SYN (implicit state) */
408 #define TF_NEEDFIN 0x00800 /* send FIN (implicit state) */
409 #define TF_NOPUSH 0x01000 /* don't push */
410 #define TF_REQ_CC 0x02000 /* have/will request CC */
411 #define TF_RCVD_CC 0x04000 /* a CC was received in SYN */
412 #define TF_SENDCCNEW 0x08000 /* send CCnew instead of CC in SYN */
413 #define TF_MORETOCOME 0x10000 /* More data to be appended to sock */
414 #define TF_LQ_OVERFLOW 0x20000 /* listen queue overflow */
415 #define TF_RXWIN0SENT 0x40000 /* sent a receiver win 0 in response */
416 #define TF_SLOWLINK 0x80000 /* route is a on a modem speed link */
418 int t_force
; /* 1 if forcing out a byte */
420 tcp_seq snd_una
; /* send unacknowledged */
421 tcp_seq snd_max
; /* highest sequence number sent;
422 * used to recognize retransmits
424 tcp_seq snd_nxt
; /* send next */
425 tcp_seq snd_up
; /* send urgent pointer */
427 tcp_seq snd_wl1
; /* window update seg seq number */
428 tcp_seq snd_wl2
; /* window update seg ack number */
429 tcp_seq iss
; /* initial send sequence number */
430 tcp_seq irs
; /* initial receive sequence number */
432 tcp_seq rcv_nxt
; /* receive next */
433 tcp_seq rcv_adv
; /* advertised window */
434 u_int32_t rcv_wnd
; /* receive window */
435 tcp_seq rcv_up
; /* receive urgent pointer */
437 u_int32_t snd_wnd
; /* send window */
438 u_int32_t snd_cwnd
; /* congestion-controlled window */
439 u_int32_t snd_ssthresh
; /* snd_cwnd size threshold for
440 * for slow start exponential to
443 u_int t_maxopd
; /* mss plus options */
445 u_int32_t t_rcvtime
; /* inactivity time */
446 u_int32_t t_starttime
; /* time connection was established */
447 int t_rtttime
; /* round trip time */
448 tcp_seq t_rtseq
; /* sequence number being timed */
450 int t_rxtcur
; /* current retransmit value (ticks) */
451 u_int t_maxseg
; /* maximum segment size */
452 int t_srtt
; /* smoothed round-trip time */
453 int t_rttvar
; /* variance in round-trip time */
455 int t_rxtshift
; /* log(2) of rexmt exp. backoff */
456 u_int t_rttmin
; /* minimum rtt allowed */
457 u_int32_t t_rttupdated
; /* number of times rtt sampled */
458 u_int32_t max_sndwnd
; /* largest window peer has offered */
460 int t_softerror
; /* possible error not yet reported */
461 /* out-of-band data */
462 char t_oobflags
; /* have some */
463 char t_iobc
; /* input character */
464 #define TCPOOB_HAVEDATA 0x01
465 #define TCPOOB_HADDATA 0x02
466 /* RFC 1323 variables */
467 u_char snd_scale
; /* window scaling for send window */
468 u_char rcv_scale
; /* window scaling for recv window */
469 u_char request_r_scale
; /* pending window scaling */
470 u_char requested_s_scale
;
471 u_int32_t ts_recent
; /* timestamp echo data */
473 u_int32_t ts_recent_age
; /* when last updated */
474 tcp_seq last_ack_sent
;
475 /* RFC 1644 variables */
476 tcp_cc cc_send
; /* send connection count */
477 tcp_cc cc_recv
; /* receive connection count */
478 tcp_seq snd_recover
; /* for use in fast recovery */
480 u_int32_t snd_cwnd_prev
; /* cwnd prior to retransmit */
481 u_int32_t snd_ssthresh_prev
; /* ssthresh prior to retransmit */
482 u_int32_t t_badrxtwin
; /* window for retransmit recovery */
487 * Many of these should be kept per connection,
488 * but that's inconvenient at the moment.
491 u_int32_t tcps_connattempt
; /* connections initiated */
492 u_int32_t tcps_accepts
; /* connections accepted */
493 u_int32_t tcps_connects
; /* connections established */
494 u_int32_t tcps_drops
; /* connections dropped */
495 u_int32_t tcps_conndrops
; /* embryonic connections dropped */
496 u_int32_t tcps_closed
; /* conn. closed (includes drops) */
497 u_int32_t tcps_segstimed
; /* segs where we tried to get rtt */
498 u_int32_t tcps_rttupdated
; /* times we succeeded */
499 u_int32_t tcps_delack
; /* delayed acks sent */
500 u_int32_t tcps_timeoutdrop
; /* conn. dropped in rxmt timeout */
501 u_int32_t tcps_rexmttimeo
; /* retransmit timeouts */
502 u_int32_t tcps_persisttimeo
; /* persist timeouts */
503 u_int32_t tcps_keeptimeo
; /* keepalive timeouts */
504 u_int32_t tcps_keepprobe
; /* keepalive probes sent */
505 u_int32_t tcps_keepdrops
; /* connections dropped in keepalive */
507 u_int32_t tcps_sndtotal
; /* total packets sent */
508 u_int32_t tcps_sndpack
; /* data packets sent */
509 u_int32_t tcps_sndbyte
; /* data bytes sent */
510 u_int32_t tcps_sndrexmitpack
; /* data packets retransmitted */
511 u_int32_t tcps_sndrexmitbyte
; /* data bytes retransmitted */
512 u_int32_t tcps_sndacks
; /* ack-only packets sent */
513 u_int32_t tcps_sndprobe
; /* window probes sent */
514 u_int32_t tcps_sndurg
; /* packets sent with URG only */
515 u_int32_t tcps_sndwinup
; /* window update-only packets sent */
516 u_int32_t tcps_sndctrl
; /* control (SYN|FIN|RST) packets sent */
518 u_int32_t tcps_rcvtotal
; /* total packets received */
519 u_int32_t tcps_rcvpack
; /* packets received in sequence */
520 u_int32_t tcps_rcvbyte
; /* bytes received in sequence */
521 u_int32_t tcps_rcvbadsum
; /* packets received with ccksum errs */
522 u_int32_t tcps_rcvbadoff
; /* packets received with bad offset */
523 u_int32_t tcps_rcvmemdrop
; /* packets dropped for lack of memory */
524 u_int32_t tcps_rcvshort
; /* packets received too short */
525 u_int32_t tcps_rcvduppack
; /* duplicate-only packets received */
526 u_int32_t tcps_rcvdupbyte
; /* duplicate-only bytes received */
527 u_int32_t tcps_rcvpartduppack
; /* packets with some duplicate data */
528 u_int32_t tcps_rcvpartdupbyte
; /* dup. bytes in part-dup. packets */
529 u_int32_t tcps_rcvoopack
; /* out-of-order packets received */
530 u_int32_t tcps_rcvoobyte
; /* out-of-order bytes received */
531 u_int32_t tcps_rcvpackafterwin
; /* packets with data after window */
532 u_int32_t tcps_rcvbyteafterwin
; /* bytes rcvd after window */
533 u_int32_t tcps_rcvafterclose
; /* packets rcvd after "close" */
534 u_int32_t tcps_rcvwinprobe
; /* rcvd window probe packets */
535 u_int32_t tcps_rcvdupack
; /* rcvd duplicate acks */
536 u_int32_t tcps_rcvacktoomuch
; /* rcvd acks for unsent data */
537 u_int32_t tcps_rcvackpack
; /* rcvd ack packets */
538 u_int32_t tcps_rcvackbyte
; /* bytes acked by rcvd acks */
539 u_int32_t tcps_rcvwinupd
; /* rcvd window update packets */
540 u_int32_t tcps_pawsdrop
; /* segments dropped due to PAWS */
541 u_int32_t tcps_predack
; /* times hdr predict ok for acks */
542 u_int32_t tcps_preddat
; /* times hdr predict ok for data pkts */
543 u_int32_t tcps_pcbcachemiss
;
544 u_int32_t tcps_cachedrtt
; /* times cached RTT in route updated */
545 u_int32_t tcps_cachedrttvar
; /* times cached rttvar updated */
546 u_int32_t tcps_cachedssthresh
; /* times cached ssthresh updated */
547 u_int32_t tcps_usedrtt
; /* times RTT initialized from route */
548 u_int32_t tcps_usedrttvar
; /* times RTTVAR initialized from rt */
549 u_int32_t tcps_usedssthresh
; /* times ssthresh initialized from rt*/
550 u_int32_t tcps_persistdrop
; /* timeout in persist state */
551 u_int32_t tcps_badsyn
; /* bogus SYN, e.g. premature ACK */
552 u_int32_t tcps_mturesent
; /* resends due to MTU discovery */
553 u_int32_t tcps_listendrop
; /* listen queue overflows */
555 /* new stats from FreeBSD 5.4 sync up */
556 u_int32_t tcps_minmssdrops
; /* average minmss too low drops */
557 u_int32_t tcps_sndrexmitbad
; /* unnecessary packet retransmissions */
558 u_int32_t tcps_badrst
; /* ignored RSTs in the window */
560 u_int32_t tcps_sc_added
; /* entry added to syncache */
561 u_int32_t tcps_sc_retransmitted
; /* syncache entry was retransmitted */
562 u_int32_t tcps_sc_dupsyn
; /* duplicate SYN packet */
563 u_int32_t tcps_sc_dropped
; /* could not reply to packet */
564 u_int32_t tcps_sc_completed
; /* successful extraction of entry */
565 u_int32_t tcps_sc_bucketoverflow
; /* syncache per-bucket limit hit */
566 u_int32_t tcps_sc_cacheoverflow
; /* syncache cache limit hit */
567 u_int32_t tcps_sc_reset
; /* RST removed entry from syncache */
568 u_int32_t tcps_sc_stale
; /* timed out or listen socket gone */
569 u_int32_t tcps_sc_aborted
; /* syncache entry aborted */
570 u_int32_t tcps_sc_badack
; /* removed due to bad ACK */
571 u_int32_t tcps_sc_unreach
; /* ICMP unreachable received */
572 u_int32_t tcps_sc_zonefail
; /* zalloc() failed */
573 u_int32_t tcps_sc_sendcookie
; /* SYN cookie sent */
574 u_int32_t tcps_sc_recvcookie
; /* SYN cookie received */
576 u_int32_t tcps_hc_added
; /* entry added to hostcache */
577 u_int32_t tcps_hc_bucketoverflow
; /* hostcache per bucket limit hit */
579 /* SACK related stats */
580 u_int32_t tcps_sack_recovery_episode
; /* SACK recovery episodes */
581 u_int32_t tcps_sack_rexmits
; /* SACK rexmit segments */
582 u_int32_t tcps_sack_rexmit_bytes
; /* SACK rexmit bytes */
583 u_int32_t tcps_sack_rcv_blocks
; /* SACK blocks (options) received */
584 u_int32_t tcps_sack_send_blocks
; /* SACK blocks (options) sent */
585 u_int32_t tcps_sack_sboverflow
; /* SACK sendblock overflow */
588 u_int32_t tcps_bg_rcvtotal
; /* total background packets received */
589 #endif /* TRAFFIC_MGT */
595 * TCB structure exported to user-land via sysctl(3).
596 * Evil hack: declare only if in_pcb.h and sys/socketvar.h have been
597 * included. Not all of our clients do.
601 #ifdef KERNEL_PRIVATE
602 struct inpcb_compat xt_inp
;
606 #ifdef KERNEL_PRIVATE
611 struct xsocket xt_socket
;
612 u_quad_t xt_alignment_hack
;
618 * Names for TCP sysctl objects
620 #define TCPCTL_DO_RFC1323 1 /* use RFC-1323 extensions */
621 #define TCPCTL_DO_RFC1644 2 /* use RFC-1644 extensions */
622 #define TCPCTL_MSSDFLT 3 /* MSS default */
623 #define TCPCTL_STATS 4 /* statistics (read-only) */
624 #define TCPCTL_RTTDFLT 5 /* default RTT estimate */
625 #define TCPCTL_KEEPIDLE 6 /* keepalive idle timer */
626 #define TCPCTL_KEEPINTVL 7 /* interval to send keepalives */
627 #define TCPCTL_SENDSPACE 8 /* send buffer space */
628 #define TCPCTL_RECVSPACE 9 /* receive buffer space */
629 #define TCPCTL_KEEPINIT 10 /* timeout for establishing syn */
630 #define TCPCTL_PCBLIST 11 /* list of all outstanding PCBs */
631 #define TCPCTL_DELACKTIME 12 /* time before sending delayed ACK */
632 #define TCPCTL_V6MSSDFLT 13 /* MSS default for IPv6 */
633 #define TCPCTL_MAXID 14
635 #ifdef KERNEL_PRIVATE
636 #define TCP_PKTLIST_CLEAR(tp) { \
637 (tp)->t_pktlist_head = (tp)->t_pktlist_tail = NULL; \
638 (tp)->t_lastchain = (tp)->t_pktlist_sentlen = 0; \
641 #define TCPCTL_NAMES { \
643 { "rfc1323", CTLTYPE_INT }, \
644 { "rfc1644", CTLTYPE_INT }, \
645 { "mssdflt", CTLTYPE_INT }, \
646 { "stats", CTLTYPE_STRUCT }, \
647 { "rttdflt", CTLTYPE_INT }, \
648 { "keepidle", CTLTYPE_INT }, \
649 { "keepintvl", CTLTYPE_INT }, \
650 { "sendspace", CTLTYPE_INT }, \
651 { "recvspace", CTLTYPE_INT }, \
652 { "keepinit", CTLTYPE_INT }, \
653 { "pcblist", CTLTYPE_STRUCT }, \
654 { "delacktime", CTLTYPE_INT }, \
655 { "v6mssdflt", CTLTYPE_INT }, \
659 SYSCTL_DECL(_net_inet_tcp
);
660 #endif /* SYSCTL_DECL */
662 extern struct inpcbhead tcb
; /* head of queue of active tcpcb's */
663 extern struct inpcbinfo tcbinfo
;
664 extern struct tcpstat tcpstat
; /* tcp statistics */
665 extern int tcp_mssdflt
; /* XXX */
666 extern int tcp_minmss
;
667 extern int tcp_minmssoverload
;
668 extern int tcp_do_newreno
;
670 extern int ss_fltsz_local
;
672 extern u_long tcp_now
; /* for RFC 1323 timestamps */
673 extern int tcp_delack_enabled
;
674 #endif /* __APPLE__ */
676 extern int tcp_do_sack
; /* SACK enabled/disabled */
678 void tcp_canceltimers(struct tcpcb
*);
680 tcp_close(struct tcpcb
*);
681 void tcp_ctlinput(int, struct sockaddr
*, void *);
682 int tcp_ctloutput(struct socket
*, struct sockopt
*);
684 tcp_drop(struct tcpcb
*, int);
685 void tcp_drain(void);
686 void tcp_fasttimo(void);
688 tcp_gettaocache(struct inpcb
*);
689 void tcp_init(void) __attribute__((section("__TEXT, initcode")));
690 void tcp_input(struct mbuf
*, int);
691 void tcp_mss(struct tcpcb
*, int);
692 int tcp_mssopt(struct tcpcb
*);
693 void tcp_drop_syn_sent(struct inpcb
*, int);
694 void tcp_mtudisc(struct inpcb
*, int);
696 tcp_newtcpcb(struct inpcb
*);
697 int tcp_output(struct tcpcb
*);
698 void tcp_quench(struct inpcb
*, int);
699 void tcp_respond(struct tcpcb
*, void *,
700 struct tcphdr
*, struct mbuf
*, tcp_seq
, tcp_seq
, int, ifnet_t
);
702 tcp_rtlookup(struct inpcb
*);
703 void tcp_setpersist(struct tcpcb
*);
704 void tcp_slowtimo(void);
706 tcp_maketemplate(struct tcpcb
*);
707 void tcp_fillheaders(struct tcpcb
*, void *, void *);
709 tcp_timers(struct tcpcb
*, int);
710 void tcp_trace(int, int, struct tcpcb
*, void *, struct tcphdr
*, int);
712 void tcp_sack_doack(struct tcpcb
*, struct tcpopt
*, tcp_seq
);
713 void tcp_update_sack_list(struct tcpcb
*tp
, tcp_seq rcv_laststart
, tcp_seq rcv_lastend
);
714 void tcp_clean_sackreport(struct tcpcb
*tp
);
715 void tcp_sack_adjust(struct tcpcb
*tp
);
716 struct sackhole
*tcp_sack_output(struct tcpcb
*tp
, int *sack_bytes_rexmt
);
717 void tcp_sack_partialack(struct tcpcb
*, struct tcphdr
*);
718 void tcp_free_sackholes(struct tcpcb
*tp
);
719 long tcp_sbspace(struct tcpcb
*tp
);
722 int tcp_lock (struct socket
*, int, int);
723 int tcp_unlock (struct socket
*, int, int);
724 #ifdef _KERN_LOCKS_H_
725 lck_mtx_t
* tcp_getlock (struct socket
*, int);
727 void * tcp_getlock (struct socket
*, int);
731 extern struct pr_usrreqs tcp_usrreqs
;
732 extern u_long tcp_sendspace
;
733 extern u_long tcp_recvspace
;
734 tcp_seq
tcp_new_isn(struct tcpcb
*);
736 #endif /* KERNEL_RPIVATE */
738 #endif /* _NETINET_TCP_VAR_H_ */