]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
6d2010ae | 2 | * Copyright (c) 2000-2011 Apple Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
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. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * Copyright (c) 1982, 1986, 1993, 1994, 1995 | |
30 | * The Regents of the University of California. All rights reserved. | |
31 | * | |
32 | * Redistribution and use in source and binary forms, with or without | |
33 | * modification, are permitted provided that the following conditions | |
34 | * are met: | |
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. | |
47 | * | |
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 | |
58 | * SUCH DAMAGE. | |
59 | * | |
60 | * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95 | |
9bccf70c | 61 | * $FreeBSD: src/sys/netinet/tcp_var.h,v 1.56.2.8 2001/08/22 00:59:13 silby Exp $ |
1c79356b A |
62 | */ |
63 | ||
64 | #ifndef _NETINET_TCP_VAR_H_ | |
65 | #define _NETINET_TCP_VAR_H_ | |
9bccf70c | 66 | #include <sys/appleapiopts.h> |
91447636 A |
67 | #include <sys/queue.h> |
68 | #include <netinet/in_pcb.h> | |
9bccf70c | 69 | #include <netinet/tcp_timer.h> |
91447636 | 70 | |
2d21ac55 A |
71 | #if defined(__LP64__) |
72 | #define _TCPCB_PTR(x) u_int32_t | |
73 | #define _TCPCB_LIST_HEAD(name, type) \ | |
74 | struct name { \ | |
75 | u_int32_t lh_first; \ | |
76 | }; | |
77 | #else | |
78 | #define _TCPCB_PTR(x) x | |
79 | #define _TCPCB_LIST_HEAD(name, type) LIST_HEAD(name, type) | |
80 | #endif | |
81 | ||
6d2010ae A |
82 | #define TCP_RETRANSHZ 1000 /* granularity of TCP timestamps, 1ms */ |
83 | #define TCP_TIMERHZ 100 /* frequency of TCP fast timer, 100 ms */ | |
84 | ||
85 | /* Minimum time quantum within which the timers are coalesced */ | |
86 | #define TCP_FASTTIMER_QUANTUM TCP_TIMERHZ /* fast mode, once every 100ms */ | |
87 | #define TCP_SLOWTIMER_QUANTUM TCP_RETRANSHZ / PR_SLOWHZ /* slow mode, once every 500ms */ | |
88 | ||
89 | #define TCP_RETRANSHZ_TO_USEC 1000 | |
9bccf70c | 90 | |
2d21ac55 A |
91 | #ifdef KERNEL_PRIVATE |
92 | #define N_TIME_WAIT_SLOTS 128 /* must be power of 2 */ | |
1c79356b | 93 | |
6d2010ae A |
94 | /* Base RTT is stored for N_MIN_RTT_HISTORY slots. This is used to |
95 | * estimate expected minimum RTT for delay based congestion control | |
96 | * algorithms. | |
97 | */ | |
98 | #define N_RTT_BASE 5 | |
99 | ||
100 | /* Always allow at least 4 packets worth of recv window when adjusting | |
101 | * recv window using inter-packet arrival jitter. | |
102 | */ | |
103 | #define MIN_IAJ_WIN 4 | |
104 | ||
105 | /* A variation in delay of this many milliseconds is tolerable. This limit has to | |
106 | * be low but greater than zero. We also use standard deviation on jitter to adjust | |
107 | * this limit for different link and connection types. | |
108 | */ | |
109 | #define ALLOWED_IAJ 5 | |
110 | ||
111 | /* Ignore the first few packets on a connection until the ACK clock gets going | |
112 | */ | |
113 | #define IAJ_IGNORE_PKTCNT 40 | |
114 | ||
115 | /* Let the accumulated IAJ value increase by this threshold at most. This limit | |
116 | * will control how many ALLOWED_IAJ measurements a receiver will have to see | |
117 | * before opening the receive window | |
118 | */ | |
119 | #define ACC_IAJ_HIGH_THRESH 100 | |
120 | ||
121 | /* When accumulated IAJ reaches this value, the receiver starts to react by | |
122 | * closing the window | |
123 | */ | |
124 | #define ACC_IAJ_REACT_LIMIT 200 | |
125 | ||
126 | /* If the number of small packets (smaller than IAJ packet size) seen on a | |
127 | * connection is more than this threshold, reset the size and learn it again. | |
128 | * This is needed because the sender might send smaller segments after PMTU | |
129 | * discovery and the receiver has to learn the new size. | |
130 | */ | |
131 | #define RESET_IAJ_SIZE_THRESH 20 | |
132 | ||
1c79356b | 133 | /* |
9bccf70c | 134 | * Kernel variables for tcp. |
1c79356b | 135 | */ |
9bccf70c A |
136 | |
137 | /* TCP segment queue entry */ | |
138 | struct tseg_qent { | |
139 | LIST_ENTRY(tseg_qent) tqe_q; | |
140 | int tqe_len; /* TCP segment data length */ | |
141 | struct tcphdr *tqe_th; /* a pointer to tcp header */ | |
142 | struct mbuf *tqe_m; /* mbuf contains packet */ | |
1c79356b | 143 | }; |
9bccf70c | 144 | LIST_HEAD(tsegqe_head, tseg_qent); |
e5568f75 A |
145 | extern int tcp_reass_maxseg; |
146 | extern int tcp_reass_qsize; | |
9bccf70c A |
147 | #ifdef MALLOC_DECLARE |
148 | MALLOC_DECLARE(M_TSEGQ); | |
1c79356b | 149 | #endif |
9bccf70c | 150 | |
8ad349bb A |
151 | struct sackblk { |
152 | tcp_seq start; /* start seq no. of sack block */ | |
153 | tcp_seq end; /* end seq no. */ | |
154 | }; | |
155 | ||
156 | struct sackhole { | |
157 | tcp_seq start; /* start seq no. of hole */ | |
158 | tcp_seq end; /* end seq no. */ | |
159 | tcp_seq rxmit; /* next seq. no in hole to be retransmitted */ | |
160 | TAILQ_ENTRY(sackhole) scblink; /* scoreboard linkage */ | |
161 | }; | |
162 | ||
163 | struct sackhint { | |
164 | struct sackhole *nexthole; | |
165 | int sack_bytes_rexmit; | |
166 | }; | |
167 | ||
9bccf70c A |
168 | struct tcptemp { |
169 | u_char tt_ipgen[40]; /* the size must be of max ip header, now IPv6 */ | |
170 | struct tcphdr tt_t; | |
171 | }; | |
172 | ||
1c79356b A |
173 | #define tcp6cb tcpcb /* for KAME src sync over BSD*'s */ |
174 | ||
1c79356b A |
175 | /* |
176 | * Tcp control block, one per tcp; fields: | |
177 | * Organized for 16 byte cacheline efficiency. | |
178 | */ | |
179 | struct tcpcb { | |
9bccf70c | 180 | struct tsegqe_head t_segq; |
1c79356b | 181 | int t_dupacks; /* consecutive dup acks recd */ |
6d2010ae A |
182 | uint32_t t_timer[TCPT_NTIMERS]; /* tcp timers */ |
183 | struct tcptimerentry tentry; /* entry in timer list */ | |
1c79356b A |
184 | |
185 | struct inpcb *t_inpcb; /* back pointer to internet pcb */ | |
186 | int t_state; /* state of this connection */ | |
187 | u_int t_flags; | |
188 | #define TF_ACKNOW 0x00001 /* ack peer immediately */ | |
189 | #define TF_DELACK 0x00002 /* ack, but try to delay it */ | |
190 | #define TF_NODELAY 0x00004 /* don't delay packets to coalesce */ | |
191 | #define TF_NOOPT 0x00008 /* don't use tcp options */ | |
192 | #define TF_SENTFIN 0x00010 /* have sent FIN */ | |
193 | #define TF_REQ_SCALE 0x00020 /* have/will request window scaling */ | |
194 | #define TF_RCVD_SCALE 0x00040 /* other side has requested scaling */ | |
195 | #define TF_REQ_TSTMP 0x00080 /* have/will request timestamps */ | |
196 | #define TF_RCVD_TSTMP 0x00100 /* a timestamp was received in SYN */ | |
197 | #define TF_SACK_PERMIT 0x00200 /* other side said I could SACK */ | |
198 | #define TF_NEEDSYN 0x00400 /* send SYN (implicit state) */ | |
199 | #define TF_NEEDFIN 0x00800 /* send FIN (implicit state) */ | |
200 | #define TF_NOPUSH 0x01000 /* don't push */ | |
201 | #define TF_REQ_CC 0x02000 /* have/will request CC */ | |
202 | #define TF_RCVD_CC 0x04000 /* a CC was received in SYN */ | |
203 | #define TF_SENDCCNEW 0x08000 /* send CCnew instead of CC in SYN */ | |
204 | #define TF_MORETOCOME 0x10000 /* More data to be appended to sock */ | |
6d2010ae | 205 | #define TF_LOCAL 0x20000 /* connection to a host on local link */ |
9bccf70c | 206 | #define TF_RXWIN0SENT 0x40000 /* sent a receiver win 0 in response */ |
d12e1678 | 207 | #define TF_SLOWLINK 0x80000 /* route is a on a modem speed link */ |
2d21ac55 | 208 | #define TF_LASTIDLE 0x100000 /* connection was previously idle */ |
8ad349bb A |
209 | #define TF_FASTRECOVERY 0x200000 /* in NewReno Fast Recovery */ |
210 | #define TF_WASFRECOVERY 0x400000 /* was in NewReno Fast Recovery */ | |
211 | #define TF_SIGNATURE 0x800000 /* require MD5 digests (RFC2385) */ | |
212 | #define TF_MAXSEGSNT 0x1000000 /* last segment sent was a full segment */ | |
2d21ac55 A |
213 | #define TF_SENDINPROG 0x2000000 /* send is in progress */ |
214 | #define TF_PMTUD 0x4000000 /* Perform Path MTU Discovery for this connection */ | |
215 | #define TF_CLOSING 0x8000000 /* pending tcp close */ | |
b0d623f7 A |
216 | #define TF_TSO 0x10000000 /* TCP Segment Offloading is enable on this connection */ |
217 | #define TF_BLACKHOLE 0x20000000 /* Path MTU Discovery Black Hole detection */ | |
6d2010ae A |
218 | #define TF_TIMER_ONLIST 0x40000000 /* pcb is on tcp_timer_list */ |
219 | #define TF_STRETCHACK 0x80000000 /* receiver is going to delay acks */ | |
8ad349bb | 220 | |
1c79356b A |
221 | int t_force; /* 1 if forcing out a byte */ |
222 | ||
223 | tcp_seq snd_una; /* send unacknowledged */ | |
224 | tcp_seq snd_max; /* highest sequence number sent; | |
225 | * used to recognize retransmits | |
226 | */ | |
227 | tcp_seq snd_nxt; /* send next */ | |
228 | tcp_seq snd_up; /* send urgent pointer */ | |
229 | ||
230 | tcp_seq snd_wl1; /* window update seg seq number */ | |
231 | tcp_seq snd_wl2; /* window update seg ack number */ | |
232 | tcp_seq iss; /* initial send sequence number */ | |
233 | tcp_seq irs; /* initial receive sequence number */ | |
234 | ||
235 | tcp_seq rcv_nxt; /* receive next */ | |
236 | tcp_seq rcv_adv; /* advertised window */ | |
b0d623f7 | 237 | u_int32_t rcv_wnd; /* receive window */ |
1c79356b A |
238 | tcp_seq rcv_up; /* receive urgent pointer */ |
239 | ||
b0d623f7 A |
240 | u_int32_t snd_wnd; /* send window */ |
241 | u_int32_t snd_cwnd; /* congestion-controlled window */ | |
242 | u_int32_t snd_bwnd; /* bandwidth-controlled window */ | |
243 | u_int32_t snd_ssthresh; /* snd_cwnd size threshold for | |
1c79356b A |
244 | * for slow start exponential to |
245 | * linear switch | |
246 | */ | |
6d2010ae | 247 | u_int32_t snd_bandwidth; /* calculated bandwidth or 0 */ |
2d21ac55 A |
248 | tcp_seq snd_recover; /* for use in NewReno Fast Recovery */ |
249 | ||
1c79356b A |
250 | u_int t_maxopd; /* mss plus options */ |
251 | ||
6d2010ae A |
252 | u_int32_t t_rcvtime; /* time at which a packet was received */ |
253 | u_int32_t t_starttime; /* time connection was established */ | |
254 | int t_rtttime; /* tcp clock when rtt calculation was started */ | |
1c79356b A |
255 | tcp_seq t_rtseq; /* sequence number being timed */ |
256 | ||
2d21ac55 A |
257 | int t_bw_rtttime; /* used for bandwidth calculation */ |
258 | tcp_seq t_bw_rtseq; /* used for bandwidth calculation */ | |
259 | ||
9bccf70c | 260 | int t_rxtcur; /* current retransmit value (ticks) */ |
1c79356b A |
261 | u_int t_maxseg; /* maximum segment size */ |
262 | int t_srtt; /* smoothed round-trip time */ | |
263 | int t_rttvar; /* variance in round-trip time */ | |
264 | ||
265 | int t_rxtshift; /* log(2) of rexmt exp. backoff */ | |
266 | u_int t_rttmin; /* minimum rtt allowed */ | |
2d21ac55 | 267 | u_int t_rttbest; /* best rtt we've seen */ |
6d2010ae | 268 | u_int t_rttcur; /* most recent value of rtt */ |
b0d623f7 | 269 | u_int32_t t_rttupdated; /* number of times rtt sampled */ |
6d2010ae A |
270 | u_int32_t rxt_conndroptime; /* retxmt conn gets dropped after this time, when set */ |
271 | u_int32_t rxt_start; /* time at a connection starts retransmitting */ | |
b0d623f7 | 272 | u_int32_t max_sndwnd; /* largest window peer has offered */ |
1c79356b A |
273 | |
274 | int t_softerror; /* possible error not yet reported */ | |
275 | /* out-of-band data */ | |
276 | char t_oobflags; /* have some */ | |
277 | char t_iobc; /* input character */ | |
278 | #define TCPOOB_HAVEDATA 0x01 | |
279 | #define TCPOOB_HADDATA 0x02 | |
280 | /* RFC 1323 variables */ | |
281 | u_char snd_scale; /* window scaling for send window */ | |
282 | u_char rcv_scale; /* window scaling for recv window */ | |
283 | u_char request_r_scale; /* pending window scaling */ | |
284 | u_char requested_s_scale; | |
6d2010ae | 285 | u_int16_t tcp_cc_index; /* index of congestion control algorithm */ |
b0d623f7 | 286 | u_int32_t ts_recent; /* timestamp echo data */ |
1c79356b | 287 | |
b0d623f7 | 288 | u_int32_t ts_recent_age; /* when last updated */ |
1c79356b A |
289 | tcp_seq last_ack_sent; |
290 | /* RFC 1644 variables */ | |
291 | tcp_cc cc_send; /* send connection count */ | |
292 | tcp_cc cc_recv; /* receive connection count */ | |
2d21ac55 | 293 | /* RFC 3465 variables */ |
b0d623f7 | 294 | u_int32_t t_bytes_acked; /* ABC "bytes_acked" parameter */ |
9bccf70c | 295 | /* experimental */ |
b0d623f7 A |
296 | u_int32_t snd_cwnd_prev; /* cwnd prior to retransmit */ |
297 | u_int32_t snd_ssthresh_prev; /* ssthresh prior to retransmit */ | |
298 | u_int32_t t_badrxtwin; /* window for retransmit recovery */ | |
55e303ae A |
299 | |
300 | int t_keepidle; /* keepalive idle timer (override global if > 0) */ | |
91447636 | 301 | int t_lastchain; /* amount of packets chained last time around */ |
2d21ac55 | 302 | int t_unacksegs; /* received but unacked segments: used for delaying acks */ |
6d2010ae A |
303 | u_int32_t t_persist_timeout; /* ZWP persistence limit as set by PERSIST_TIMEOUT */ |
304 | u_int32_t t_persist_stop; /* persistence limit deadline if triggered by ZWP */ | |
2d21ac55 | 305 | |
91447636 A |
306 | |
307 | /* 3529618 MSS overload prevention */ | |
b0d623f7 A |
308 | u_int32_t rcv_reset; |
309 | u_int32_t rcv_pps; | |
310 | u_int32_t rcv_byps; | |
6d2010ae A |
311 | u_int32_t rcv_maxbyps; |
312 | ||
313 | /* Receiver state for stretch-ack algorithm */ | |
314 | u_int32_t rcv_unackwin; /* to measure win for stretching acks */ | |
315 | u_int32_t rcv_by_unackwin; /* bytes seen during the last ack-stretching win */ | |
316 | u_int16_t rcv_waitforss; /* wait for packets during slow-start */ | |
317 | u_int16_t ecn_flags; | |
318 | #define TE_SETUPSENT 0x01 /* Indicate we have sent ECN-SETUP SYN or SYN-ACK */ | |
319 | #define TE_SETUPRECEIVED 0x02 /* Indicate we have received ECN-SETUP SYN or SYN-ACK */ | |
320 | #define TE_SENDIPECT 0x04 /* Indicate we haven't sent or received non-ECN-setup SYN or SYN-ACK */ | |
321 | #define TE_SENDCWR 0x08 /* Indicate that the next non-retransmit should have the TCP CWR flag set */ | |
322 | #define TE_SENDECE 0x10 /* Indicate that the next packet should have the TCP ECE flag set */ | |
91447636 A |
323 | tcp_seq snd_high; /* for use in NewReno Fast Recovery */ |
324 | tcp_seq snd_high_prev; /* snd_high prior to retransmit */ | |
8ad349bb A |
325 | tcp_seq snd_recover_prev; /* snd_recover prior to retransmit */ |
326 | u_char snd_limited; /* segments limited transmitted */ | |
327 | /* anti DoS counters */ | |
b0d623f7 | 328 | u_int32_t rcv_second; /* start of interval second */ |
6d2010ae | 329 | |
8ad349bb A |
330 | /* SACK related state */ |
331 | int sack_enable; /* enable SACK for this connection */ | |
332 | int snd_numholes; /* number of holes seen by sender */ | |
8ad349bb A |
333 | TAILQ_HEAD(sackhole_head, sackhole) snd_holes; |
334 | /* SACK scoreboard (sorted) */ | |
335 | tcp_seq snd_fack; /* last seq number(+1) sack'd by rcv'r*/ | |
336 | int rcv_numsacks; /* # distinct sack blks present */ | |
337 | struct sackblk sackblks[MAX_SACK_BLKS]; /* seq nos. of sack blocks */ | |
338 | tcp_seq sack_newdata; /* New data xmitted in this recovery | |
339 | episode starts at this seq number */ | |
340 | struct sackhint sackhint; /* SACK scoreboard hint */ | |
2d21ac55 | 341 | |
2d21ac55 A |
342 | u_int32_t t_pktlist_sentlen; /* total bytes in transmit chain */ |
343 | struct mbuf *t_pktlist_head; /* First packet in transmit chain */ | |
344 | struct mbuf *t_pktlist_tail; /* Last packet in transmit chain */ | |
b0d623f7 A |
345 | |
346 | int t_keepinit; /* connection timeout, i.e. idle time in SYN_SENT or SYN_RECV state */ | |
347 | u_int32_t tso_max_segment_size; /* TCP Segment Offloading maximum segment unit for NIC */ | |
348 | u_int t_pmtud_saved_maxopd; /* MSS saved before performing PMTU-D BlackHole detection */ | |
6d2010ae A |
349 | |
350 | struct | |
351 | { | |
352 | u_int32_t rxduplicatebytes; | |
353 | u_int32_t rxoutoforderbytes; | |
354 | u_int32_t txretransmitbytes; | |
355 | u_int32_t unused_pad_to_8; | |
356 | } t_stat; | |
357 | ||
358 | /* Background congestion related state */ | |
359 | uint32_t rtt_hist[N_RTT_BASE]; /* history of minimum RTT */ | |
360 | uint32_t rtt_count; /* Number of RTT samples in recent base history */ | |
361 | uint32_t bg_ssthresh; /* Slow start threshold until delay increases */ | |
362 | uint32_t t_flagsext; /* Another field to accommodate more flags */ | |
363 | #define TF_RXTFINDROP 0x1 /* Drop conn after retransmitting FIN 3 times */ | |
364 | #define TF_RCVUNACK_WAITSS 0x2 /* set when the receiver should not stretch acks */ | |
365 | ||
366 | #if TRAFFIC_MGT | |
367 | /* Inter-arrival jitter related state */ | |
368 | uint32_t iaj_rcv_ts; /* tcp clock when the first packet was received */ | |
369 | uint16_t iaj_size; /* Size of packet for iaj measurement */ | |
370 | uint16_t iaj_small_pkt; /* Count of packets smaller than iaj_size */ | |
371 | uint16_t iaj_pktcnt; /* packet count, to avoid throttling initially */ | |
372 | uint16_t acc_iaj; /* Accumulated iaj */ | |
373 | tcp_seq iaj_rwintop; /* recent max advertised window */ | |
374 | uint32_t avg_iaj; /* Mean */ | |
375 | uint32_t std_dev_iaj; /* Standard deviation */ | |
376 | #endif /* TRAFFIC_MGT */ | |
55e303ae | 377 | }; |
55e303ae | 378 | |
8ad349bb A |
379 | #define IN_FASTRECOVERY(tp) (tp->t_flags & TF_FASTRECOVERY) |
380 | #define ENTER_FASTRECOVERY(tp) tp->t_flags |= TF_FASTRECOVERY | |
381 | #define EXIT_FASTRECOVERY(tp) tp->t_flags &= ~TF_FASTRECOVERY | |
382 | ||
6d2010ae A |
383 | #if CONFIG_DTRACE |
384 | enum tcp_cc_event { | |
385 | TCP_CC_CWND_INIT, | |
386 | TCP_CC_INSEQ_ACK_RCVD, | |
387 | TCP_CC_ACK_RCVD, | |
388 | TCP_CC_ENTER_FASTRECOVERY, | |
389 | TCP_CC_IN_FASTRECOVERY, | |
390 | TCP_CC_EXIT_FASTRECOVERY, | |
391 | TCP_CC_PARTIAL_ACK, | |
392 | TCP_CC_IDLE_TIMEOUT, | |
393 | TCP_CC_REXMT_TIMEOUT, | |
394 | TCP_CC_ECN_RCVD, | |
395 | TCP_CC_BAD_REXMT_RECOVERY, | |
396 | TCP_CC_OUTPUT_ERROR, | |
397 | TCP_CC_CHANGE_ALGO | |
398 | }; | |
399 | #endif /* CONFIG_DTRACE */ | |
8ad349bb | 400 | |
91447636 A |
401 | /* |
402 | * Structure to hold TCP options that are only used during segment | |
403 | * processing (in tcp_input), but not held in the tcpcb. | |
404 | * It's basically used to reduce the number of parameters | |
405 | * to tcp_dooptions. | |
406 | */ | |
407 | struct tcpopt { | |
b0d623f7 | 408 | u_int32_t to_flags; /* which options are present */ |
91447636 | 409 | #define TOF_TS 0x0001 /* timestamp */ |
8ad349bb A |
410 | #define TOF_MSS 0x0010 |
411 | #define TOF_SCALE 0x0020 | |
412 | #define TOF_SIGNATURE 0x0040 /* signature option present */ | |
413 | #define TOF_SIGLEN 0x0080 /* signature length valid (RFC2385) */ | |
414 | #define TOF_SACK 0x0100 /* Peer sent SACK option */ | |
b0d623f7 A |
415 | u_int32_t to_tsval; |
416 | u_int32_t to_tsecr; | |
8ad349bb A |
417 | u_int16_t to_mss; |
418 | u_int8_t to_requested_s_scale; | |
419 | u_int8_t to_nsacks; /* number of SACK blocks */ | |
420 | u_char *to_sacks; /* pointer to the first SACK blocks */ | |
91447636 | 421 | }; |
55e303ae | 422 | |
91447636 A |
423 | /* |
424 | * The TAO cache entry which is stored in the protocol family specific | |
425 | * portion of the route metrics. | |
426 | */ | |
427 | struct rmxp_tao { | |
428 | tcp_cc tao_cc; /* latest CC in valid SYN */ | |
429 | tcp_cc tao_ccsent; /* latest CC sent to peer */ | |
430 | u_short tao_mssopt; /* peer's cached MSS */ | |
431 | #ifdef notyet | |
432 | u_short tao_flags; /* cache status flags */ | |
433 | #define TAOF_DONT 0x0001 /* peer doesn't understand rfc1644 */ | |
434 | #define TAOF_OK 0x0002 /* peer does understand rfc1644 */ | |
435 | #define TAOF_UNDEF 0 /* we don't know yet */ | |
436 | #endif /* notyet */ | |
437 | }; | |
438 | #define rmx_taop(r) ((struct rmxp_tao *)(r).rmx_filler) | |
439 | ||
440 | #define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb) | |
441 | #define sototcpcb(so) (intotcpcb(sotoinpcb(so))) | |
55e303ae | 442 | |
91447636 | 443 | /* |
6d2010ae A |
444 | * The rtt measured is in milliseconds as the timestamp granularity is |
445 | * a millisecond. The smoothed round-trip time and estimated variance | |
91447636 A |
446 | * are stored as fixed point numbers scaled by the values below. |
447 | * For convenience, these scales are also used in smoothing the average | |
448 | * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed). | |
6d2010ae A |
449 | * With these scales, srtt has 5 bits to the right of the binary point, |
450 | * and thus an "ALPHA" of 0.875. rttvar has 4 bits to the right of the | |
91447636 A |
451 | * binary point, and is smoothed with an ALPHA of 0.75. |
452 | */ | |
453 | #define TCP_RTT_SCALE 32 /* multiplier for srtt; 3 bits frac. */ | |
6d2010ae A |
454 | #define TCP_RTT_SHIFT 5 /* shift for srtt; 5 bits frac. */ |
455 | #define TCP_RTTVAR_SCALE 16 /* multiplier for rttvar; 4 bits */ | |
456 | #define TCP_RTTVAR_SHIFT 4 /* shift for rttvar; 4 bits */ | |
91447636 A |
457 | #define TCP_DELTA_SHIFT 2 /* see tcp_input.c */ |
458 | ||
459 | /* | |
460 | * The initial retransmission should happen at rtt + 4 * rttvar. | |
461 | * Because of the way we do the smoothing, srtt and rttvar | |
462 | * will each average +1/2 tick of bias. When we compute | |
463 | * the retransmit timer, we want 1/2 tick of rounding and | |
464 | * 1 extra tick because of +-1/2 tick uncertainty in the | |
465 | * firing of the timer. The bias will give us exactly the | |
466 | * 1.5 tick we need. But, because the bias is | |
467 | * statistical, we have to test that we don't drop below | |
468 | * the minimum feasible timer (which is 2 ticks). | |
469 | * This version of the macro adapted from a paper by Lawrence | |
470 | * Brakmo and Larry Peterson which outlines a problem caused | |
471 | * by insufficient precision in the original implementation, | |
472 | * which results in inappropriately large RTO values for very | |
473 | * fast networks. | |
474 | */ | |
475 | #define TCP_REXMTVAL(tp) \ | |
476 | max((tp)->t_rttmin, (((tp)->t_srtt >> (TCP_RTT_SHIFT - TCP_DELTA_SHIFT)) \ | |
477 | + (tp)->t_rttvar) >> TCP_DELTA_SHIFT) | |
55e303ae A |
478 | |
479 | /* | |
480 | * Jaguar compatible TCP control block, for xtcpcb | |
481 | * Does not have the old fields | |
482 | */ | |
483 | struct otcpcb { | |
91447636 A |
484 | #else |
485 | struct tseg_qent; | |
2d21ac55 | 486 | _TCPCB_LIST_HEAD(tsegqe_head, tseg_qent); |
91447636 A |
487 | |
488 | struct tcpcb { | |
489 | #endif /* KERNEL_PRIVATE */ | |
b0d623f7 A |
490 | #if defined(KERNEL_PRIVATE) |
491 | u_int32_t t_segq; | |
492 | #else | |
55e303ae | 493 | struct tsegqe_head t_segq; |
b0d623f7 | 494 | #endif /* KERNEL_PRIVATE */ |
55e303ae | 495 | int t_dupacks; /* consecutive dup acks recd */ |
2d21ac55 | 496 | u_int32_t unused; /* unused now: was t_template */ |
55e303ae | 497 | |
6d2010ae | 498 | int t_timer[TCPT_NTIMERS_EXT]; /* tcp timers */ |
55e303ae | 499 | |
2d21ac55 | 500 | _TCPCB_PTR(struct inpcb *) t_inpcb; /* back pointer to internet pcb */ |
55e303ae A |
501 | int t_state; /* state of this connection */ |
502 | u_int t_flags; | |
503 | #define TF_ACKNOW 0x00001 /* ack peer immediately */ | |
504 | #define TF_DELACK 0x00002 /* ack, but try to delay it */ | |
505 | #define TF_NODELAY 0x00004 /* don't delay packets to coalesce */ | |
506 | #define TF_NOOPT 0x00008 /* don't use tcp options */ | |
507 | #define TF_SENTFIN 0x00010 /* have sent FIN */ | |
508 | #define TF_REQ_SCALE 0x00020 /* have/will request window scaling */ | |
509 | #define TF_RCVD_SCALE 0x00040 /* other side has requested scaling */ | |
510 | #define TF_REQ_TSTMP 0x00080 /* have/will request timestamps */ | |
511 | #define TF_RCVD_TSTMP 0x00100 /* a timestamp was received in SYN */ | |
512 | #define TF_SACK_PERMIT 0x00200 /* other side said I could SACK */ | |
513 | #define TF_NEEDSYN 0x00400 /* send SYN (implicit state) */ | |
514 | #define TF_NEEDFIN 0x00800 /* send FIN (implicit state) */ | |
515 | #define TF_NOPUSH 0x01000 /* don't push */ | |
516 | #define TF_REQ_CC 0x02000 /* have/will request CC */ | |
517 | #define TF_RCVD_CC 0x04000 /* a CC was received in SYN */ | |
518 | #define TF_SENDCCNEW 0x08000 /* send CCnew instead of CC in SYN */ | |
519 | #define TF_MORETOCOME 0x10000 /* More data to be appended to sock */ | |
520 | #define TF_LQ_OVERFLOW 0x20000 /* listen queue overflow */ | |
521 | #define TF_RXWIN0SENT 0x40000 /* sent a receiver win 0 in response */ | |
522 | #define TF_SLOWLINK 0x80000 /* route is a on a modem speed link */ | |
523 | ||
524 | int t_force; /* 1 if forcing out a byte */ | |
525 | ||
526 | tcp_seq snd_una; /* send unacknowledged */ | |
527 | tcp_seq snd_max; /* highest sequence number sent; | |
528 | * used to recognize retransmits | |
529 | */ | |
530 | tcp_seq snd_nxt; /* send next */ | |
531 | tcp_seq snd_up; /* send urgent pointer */ | |
532 | ||
533 | tcp_seq snd_wl1; /* window update seg seq number */ | |
534 | tcp_seq snd_wl2; /* window update seg ack number */ | |
535 | tcp_seq iss; /* initial send sequence number */ | |
536 | tcp_seq irs; /* initial receive sequence number */ | |
537 | ||
538 | tcp_seq rcv_nxt; /* receive next */ | |
539 | tcp_seq rcv_adv; /* advertised window */ | |
2d21ac55 | 540 | u_int32_t rcv_wnd; /* receive window */ |
55e303ae A |
541 | tcp_seq rcv_up; /* receive urgent pointer */ |
542 | ||
2d21ac55 A |
543 | u_int32_t snd_wnd; /* send window */ |
544 | u_int32_t snd_cwnd; /* congestion-controlled window */ | |
545 | u_int32_t snd_ssthresh; /* snd_cwnd size threshold for | |
55e303ae A |
546 | * for slow start exponential to |
547 | * linear switch | |
548 | */ | |
549 | u_int t_maxopd; /* mss plus options */ | |
550 | ||
6d2010ae | 551 | u_int32_t t_rcvtime; /* time at which a packet was received */ |
2d21ac55 | 552 | u_int32_t t_starttime; /* time connection was established */ |
55e303ae A |
553 | int t_rtttime; /* round trip time */ |
554 | tcp_seq t_rtseq; /* sequence number being timed */ | |
555 | ||
556 | int t_rxtcur; /* current retransmit value (ticks) */ | |
557 | u_int t_maxseg; /* maximum segment size */ | |
558 | int t_srtt; /* smoothed round-trip time */ | |
559 | int t_rttvar; /* variance in round-trip time */ | |
560 | ||
561 | int t_rxtshift; /* log(2) of rexmt exp. backoff */ | |
562 | u_int t_rttmin; /* minimum rtt allowed */ | |
2d21ac55 A |
563 | u_int32_t t_rttupdated; /* number of times rtt sampled */ |
564 | u_int32_t max_sndwnd; /* largest window peer has offered */ | |
55e303ae A |
565 | |
566 | int t_softerror; /* possible error not yet reported */ | |
567 | /* out-of-band data */ | |
568 | char t_oobflags; /* have some */ | |
569 | char t_iobc; /* input character */ | |
570 | #define TCPOOB_HAVEDATA 0x01 | |
571 | #define TCPOOB_HADDATA 0x02 | |
572 | /* RFC 1323 variables */ | |
573 | u_char snd_scale; /* window scaling for send window */ | |
574 | u_char rcv_scale; /* window scaling for recv window */ | |
575 | u_char request_r_scale; /* pending window scaling */ | |
576 | u_char requested_s_scale; | |
2d21ac55 | 577 | u_int32_t ts_recent; /* timestamp echo data */ |
55e303ae | 578 | |
2d21ac55 | 579 | u_int32_t ts_recent_age; /* when last updated */ |
55e303ae A |
580 | tcp_seq last_ack_sent; |
581 | /* RFC 1644 variables */ | |
582 | tcp_cc cc_send; /* send connection count */ | |
583 | tcp_cc cc_recv; /* receive connection count */ | |
2d21ac55 | 584 | tcp_seq snd_recover; /* for use in fast recovery */ |
55e303ae | 585 | /* experimental */ |
2d21ac55 A |
586 | u_int32_t snd_cwnd_prev; /* cwnd prior to retransmit */ |
587 | u_int32_t snd_ssthresh_prev; /* ssthresh prior to retransmit */ | |
588 | u_int32_t t_badrxtwin; /* window for retransmit recovery */ | |
1c79356b A |
589 | }; |
590 | ||
b0d623f7 | 591 | |
1c79356b A |
592 | /* |
593 | * TCP statistics. | |
594 | * Many of these should be kept per connection, | |
595 | * but that's inconvenient at the moment. | |
596 | */ | |
597 | struct tcpstat { | |
2d21ac55 A |
598 | u_int32_t tcps_connattempt; /* connections initiated */ |
599 | u_int32_t tcps_accepts; /* connections accepted */ | |
600 | u_int32_t tcps_connects; /* connections established */ | |
601 | u_int32_t tcps_drops; /* connections dropped */ | |
602 | u_int32_t tcps_conndrops; /* embryonic connections dropped */ | |
603 | u_int32_t tcps_closed; /* conn. closed (includes drops) */ | |
604 | u_int32_t tcps_segstimed; /* segs where we tried to get rtt */ | |
605 | u_int32_t tcps_rttupdated; /* times we succeeded */ | |
606 | u_int32_t tcps_delack; /* delayed acks sent */ | |
607 | u_int32_t tcps_timeoutdrop; /* conn. dropped in rxmt timeout */ | |
608 | u_int32_t tcps_rexmttimeo; /* retransmit timeouts */ | |
609 | u_int32_t tcps_persisttimeo; /* persist timeouts */ | |
610 | u_int32_t tcps_keeptimeo; /* keepalive timeouts */ | |
611 | u_int32_t tcps_keepprobe; /* keepalive probes sent */ | |
612 | u_int32_t tcps_keepdrops; /* connections dropped in keepalive */ | |
613 | ||
614 | u_int32_t tcps_sndtotal; /* total packets sent */ | |
615 | u_int32_t tcps_sndpack; /* data packets sent */ | |
616 | u_int32_t tcps_sndbyte; /* data bytes sent */ | |
617 | u_int32_t tcps_sndrexmitpack; /* data packets retransmitted */ | |
618 | u_int32_t tcps_sndrexmitbyte; /* data bytes retransmitted */ | |
619 | u_int32_t tcps_sndacks; /* ack-only packets sent */ | |
620 | u_int32_t tcps_sndprobe; /* window probes sent */ | |
621 | u_int32_t tcps_sndurg; /* packets sent with URG only */ | |
622 | u_int32_t tcps_sndwinup; /* window update-only packets sent */ | |
623 | u_int32_t tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */ | |
624 | ||
625 | u_int32_t tcps_rcvtotal; /* total packets received */ | |
626 | u_int32_t tcps_rcvpack; /* packets received in sequence */ | |
627 | u_int32_t tcps_rcvbyte; /* bytes received in sequence */ | |
628 | u_int32_t tcps_rcvbadsum; /* packets received with ccksum errs */ | |
629 | u_int32_t tcps_rcvbadoff; /* packets received with bad offset */ | |
630 | u_int32_t tcps_rcvmemdrop; /* packets dropped for lack of memory */ | |
631 | u_int32_t tcps_rcvshort; /* packets received too short */ | |
632 | u_int32_t tcps_rcvduppack; /* duplicate-only packets received */ | |
633 | u_int32_t tcps_rcvdupbyte; /* duplicate-only bytes received */ | |
634 | u_int32_t tcps_rcvpartduppack; /* packets with some duplicate data */ | |
635 | u_int32_t tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */ | |
636 | u_int32_t tcps_rcvoopack; /* out-of-order packets received */ | |
637 | u_int32_t tcps_rcvoobyte; /* out-of-order bytes received */ | |
638 | u_int32_t tcps_rcvpackafterwin; /* packets with data after window */ | |
639 | u_int32_t tcps_rcvbyteafterwin; /* bytes rcvd after window */ | |
640 | u_int32_t tcps_rcvafterclose; /* packets rcvd after "close" */ | |
641 | u_int32_t tcps_rcvwinprobe; /* rcvd window probe packets */ | |
642 | u_int32_t tcps_rcvdupack; /* rcvd duplicate acks */ | |
643 | u_int32_t tcps_rcvacktoomuch; /* rcvd acks for unsent data */ | |
644 | u_int32_t tcps_rcvackpack; /* rcvd ack packets */ | |
645 | u_int32_t tcps_rcvackbyte; /* bytes acked by rcvd acks */ | |
646 | u_int32_t tcps_rcvwinupd; /* rcvd window update packets */ | |
647 | u_int32_t tcps_pawsdrop; /* segments dropped due to PAWS */ | |
648 | u_int32_t tcps_predack; /* times hdr predict ok for acks */ | |
649 | u_int32_t tcps_preddat; /* times hdr predict ok for data pkts */ | |
650 | u_int32_t tcps_pcbcachemiss; | |
651 | u_int32_t tcps_cachedrtt; /* times cached RTT in route updated */ | |
652 | u_int32_t tcps_cachedrttvar; /* times cached rttvar updated */ | |
653 | u_int32_t tcps_cachedssthresh; /* times cached ssthresh updated */ | |
654 | u_int32_t tcps_usedrtt; /* times RTT initialized from route */ | |
655 | u_int32_t tcps_usedrttvar; /* times RTTVAR initialized from rt */ | |
656 | u_int32_t tcps_usedssthresh; /* times ssthresh initialized from rt*/ | |
657 | u_int32_t tcps_persistdrop; /* timeout in persist state */ | |
658 | u_int32_t tcps_badsyn; /* bogus SYN, e.g. premature ACK */ | |
659 | u_int32_t tcps_mturesent; /* resends due to MTU discovery */ | |
660 | u_int32_t tcps_listendrop; /* listen queue overflows */ | |
661 | ||
662 | /* new stats from FreeBSD 5.4 sync up */ | |
663 | u_int32_t tcps_minmssdrops; /* average minmss too low drops */ | |
664 | u_int32_t tcps_sndrexmitbad; /* unnecessary packet retransmissions */ | |
665 | u_int32_t tcps_badrst; /* ignored RSTs in the window */ | |
666 | ||
667 | u_int32_t tcps_sc_added; /* entry added to syncache */ | |
668 | u_int32_t tcps_sc_retransmitted; /* syncache entry was retransmitted */ | |
669 | u_int32_t tcps_sc_dupsyn; /* duplicate SYN packet */ | |
670 | u_int32_t tcps_sc_dropped; /* could not reply to packet */ | |
671 | u_int32_t tcps_sc_completed; /* successful extraction of entry */ | |
672 | u_int32_t tcps_sc_bucketoverflow; /* syncache per-bucket limit hit */ | |
673 | u_int32_t tcps_sc_cacheoverflow; /* syncache cache limit hit */ | |
674 | u_int32_t tcps_sc_reset; /* RST removed entry from syncache */ | |
675 | u_int32_t tcps_sc_stale; /* timed out or listen socket gone */ | |
676 | u_int32_t tcps_sc_aborted; /* syncache entry aborted */ | |
677 | u_int32_t tcps_sc_badack; /* removed due to bad ACK */ | |
678 | u_int32_t tcps_sc_unreach; /* ICMP unreachable received */ | |
679 | u_int32_t tcps_sc_zonefail; /* zalloc() failed */ | |
680 | u_int32_t tcps_sc_sendcookie; /* SYN cookie sent */ | |
681 | u_int32_t tcps_sc_recvcookie; /* SYN cookie received */ | |
682 | ||
683 | u_int32_t tcps_hc_added; /* entry added to hostcache */ | |
684 | u_int32_t tcps_hc_bucketoverflow; /* hostcache per bucket limit hit */ | |
8ad349bb A |
685 | |
686 | /* SACK related stats */ | |
2d21ac55 A |
687 | u_int32_t tcps_sack_recovery_episode; /* SACK recovery episodes */ |
688 | u_int32_t tcps_sack_rexmits; /* SACK rexmit segments */ | |
689 | u_int32_t tcps_sack_rexmit_bytes; /* SACK rexmit bytes */ | |
690 | u_int32_t tcps_sack_rcv_blocks; /* SACK blocks (options) received */ | |
691 | u_int32_t tcps_sack_send_blocks; /* SACK blocks (options) sent */ | |
692 | u_int32_t tcps_sack_sboverflow; /* SACK sendblock overflow */ | |
693 | ||
2d21ac55 | 694 | u_int32_t tcps_bg_rcvtotal; /* total background packets received */ |
6d2010ae | 695 | u_int32_t tcps_rxtfindrop; /* drop conn after retransmitting FIN */ |
1c79356b A |
696 | }; |
697 | ||
2d21ac55 A |
698 | #pragma pack(4) |
699 | ||
1c79356b A |
700 | /* |
701 | * TCB structure exported to user-land via sysctl(3). | |
702 | * Evil hack: declare only if in_pcb.h and sys/socketvar.h have been | |
703 | * included. Not all of our clients do. | |
704 | */ | |
b0d623f7 A |
705 | |
706 | struct xtcpcb { | |
707 | u_int32_t xt_len; | |
91447636 | 708 | #ifdef KERNEL_PRIVATE |
b0d623f7 | 709 | struct inpcb_compat xt_inp; |
91447636 | 710 | #else |
b0d623f7 | 711 | struct inpcb xt_inp; |
91447636 A |
712 | #endif |
713 | #ifdef KERNEL_PRIVATE | |
b0d623f7 | 714 | struct otcpcb xt_tp; |
55e303ae | 715 | #else |
b0d623f7 | 716 | struct tcpcb xt_tp; |
55e303ae | 717 | #endif |
b0d623f7 A |
718 | struct xsocket xt_socket; |
719 | u_quad_t xt_alignment_hack; | |
720 | }; | |
721 | ||
722 | #if !CONFIG_EMBEDDED | |
723 | ||
724 | struct xtcpcb64 { | |
725 | u_int32_t xt_len; | |
726 | struct xinpcb64 xt_inpcb; | |
727 | ||
728 | u_int64_t t_segq; | |
729 | int t_dupacks; /* consecutive dup acks recd */ | |
730 | ||
6d2010ae | 731 | int t_timer[TCPT_NTIMERS_EXT]; /* tcp timers */ |
b0d623f7 A |
732 | |
733 | int t_state; /* state of this connection */ | |
734 | u_int t_flags; | |
735 | ||
736 | int t_force; /* 1 if forcing out a byte */ | |
737 | ||
738 | tcp_seq snd_una; /* send unacknowledged */ | |
739 | tcp_seq snd_max; /* highest sequence number sent; | |
740 | * used to recognize retransmits | |
741 | */ | |
742 | tcp_seq snd_nxt; /* send next */ | |
743 | tcp_seq snd_up; /* send urgent pointer */ | |
744 | ||
745 | tcp_seq snd_wl1; /* window update seg seq number */ | |
746 | tcp_seq snd_wl2; /* window update seg ack number */ | |
747 | tcp_seq iss; /* initial send sequence number */ | |
748 | tcp_seq irs; /* initial receive sequence number */ | |
749 | ||
750 | tcp_seq rcv_nxt; /* receive next */ | |
751 | tcp_seq rcv_adv; /* advertised window */ | |
752 | u_int32_t rcv_wnd; /* receive window */ | |
753 | tcp_seq rcv_up; /* receive urgent pointer */ | |
754 | ||
755 | u_int32_t snd_wnd; /* send window */ | |
756 | u_int32_t snd_cwnd; /* congestion-controlled window */ | |
757 | u_int32_t snd_ssthresh; /* snd_cwnd size threshold for | |
758 | * for slow start exponential to | |
759 | * linear switch | |
760 | */ | |
761 | u_int t_maxopd; /* mss plus options */ | |
762 | ||
6d2010ae | 763 | u_int32_t t_rcvtime; /* time at which a packet was received */ |
b0d623f7 A |
764 | u_int32_t t_starttime; /* time connection was established */ |
765 | int t_rtttime; /* round trip time */ | |
766 | tcp_seq t_rtseq; /* sequence number being timed */ | |
767 | ||
768 | int t_rxtcur; /* current retransmit value (ticks) */ | |
769 | u_int t_maxseg; /* maximum segment size */ | |
770 | int t_srtt; /* smoothed round-trip time */ | |
771 | int t_rttvar; /* variance in round-trip time */ | |
772 | ||
773 | int t_rxtshift; /* log(2) of rexmt exp. backoff */ | |
774 | u_int t_rttmin; /* minimum rtt allowed */ | |
775 | u_int32_t t_rttupdated; /* number of times rtt sampled */ | |
776 | u_int32_t max_sndwnd; /* largest window peer has offered */ | |
777 | ||
778 | int t_softerror; /* possible error not yet reported */ | |
779 | /* out-of-band data */ | |
780 | char t_oobflags; /* have some */ | |
781 | char t_iobc; /* input character */ | |
782 | /* RFC 1323 variables */ | |
783 | u_char snd_scale; /* window scaling for send window */ | |
784 | u_char rcv_scale; /* window scaling for recv window */ | |
785 | u_char request_r_scale; /* pending window scaling */ | |
786 | u_char requested_s_scale; | |
787 | u_int32_t ts_recent; /* timestamp echo data */ | |
788 | ||
789 | u_int32_t ts_recent_age; /* when last updated */ | |
790 | tcp_seq last_ack_sent; | |
791 | /* RFC 1644 variables */ | |
792 | tcp_cc cc_send; /* send connection count */ | |
793 | tcp_cc cc_recv; /* receive connection count */ | |
794 | tcp_seq snd_recover; /* for use in fast recovery */ | |
795 | /* experimental */ | |
796 | u_int32_t snd_cwnd_prev; /* cwnd prior to retransmit */ | |
797 | u_int32_t snd_ssthresh_prev; /* ssthresh prior to retransmit */ | |
798 | u_int32_t t_badrxtwin; /* window for retransmit recovery */ | |
799 | ||
800 | u_quad_t xt_alignment_hack; | |
1c79356b | 801 | }; |
1c79356b | 802 | |
b0d623f7 A |
803 | #endif /* !CONFIG_EMBEDDED */ |
804 | ||
6d2010ae A |
805 | #ifdef PRIVATE |
806 | ||
807 | struct xtcpcb_n { | |
808 | u_int32_t xt_len; | |
809 | u_int32_t xt_kind; /* XSO_TCPCB */ | |
810 | ||
811 | u_int64_t t_segq; | |
812 | int t_dupacks; /* consecutive dup acks recd */ | |
813 | ||
814 | int t_timer[TCPT_NTIMERS_EXT]; /* tcp timers */ | |
815 | ||
816 | int t_state; /* state of this connection */ | |
817 | u_int t_flags; | |
818 | ||
819 | int t_force; /* 1 if forcing out a byte */ | |
820 | ||
821 | tcp_seq snd_una; /* send unacknowledged */ | |
822 | tcp_seq snd_max; /* highest sequence number sent; | |
823 | * used to recognize retransmits | |
824 | */ | |
825 | tcp_seq snd_nxt; /* send next */ | |
826 | tcp_seq snd_up; /* send urgent pointer */ | |
827 | ||
828 | tcp_seq snd_wl1; /* window update seg seq number */ | |
829 | tcp_seq snd_wl2; /* window update seg ack number */ | |
830 | tcp_seq iss; /* initial send sequence number */ | |
831 | tcp_seq irs; /* initial receive sequence number */ | |
832 | ||
833 | tcp_seq rcv_nxt; /* receive next */ | |
834 | tcp_seq rcv_adv; /* advertised window */ | |
835 | u_int32_t rcv_wnd; /* receive window */ | |
836 | tcp_seq rcv_up; /* receive urgent pointer */ | |
837 | ||
838 | u_int32_t snd_wnd; /* send window */ | |
839 | u_int32_t snd_cwnd; /* congestion-controlled window */ | |
840 | u_int32_t snd_ssthresh; /* snd_cwnd size threshold for | |
841 | * for slow start exponential to | |
842 | * linear switch | |
843 | */ | |
844 | u_int t_maxopd; /* mss plus options */ | |
845 | ||
846 | u_int32_t t_rcvtime; /* time at which a packet was received */ | |
847 | u_int32_t t_starttime; /* time connection was established */ | |
848 | int t_rtttime; /* round trip time */ | |
849 | tcp_seq t_rtseq; /* sequence number being timed */ | |
850 | ||
851 | int t_rxtcur; /* current retransmit value (ticks) */ | |
852 | u_int t_maxseg; /* maximum segment size */ | |
853 | int t_srtt; /* smoothed round-trip time */ | |
854 | int t_rttvar; /* variance in round-trip time */ | |
855 | ||
856 | int t_rxtshift; /* log(2) of rexmt exp. backoff */ | |
857 | u_int t_rttmin; /* minimum rtt allowed */ | |
858 | u_int32_t t_rttupdated; /* number of times rtt sampled */ | |
859 | u_int32_t max_sndwnd; /* largest window peer has offered */ | |
860 | ||
861 | int t_softerror; /* possible error not yet reported */ | |
862 | /* out-of-band data */ | |
863 | char t_oobflags; /* have some */ | |
864 | char t_iobc; /* input character */ | |
865 | /* RFC 1323 variables */ | |
866 | u_char snd_scale; /* window scaling for send window */ | |
867 | u_char rcv_scale; /* window scaling for recv window */ | |
868 | u_char request_r_scale; /* pending window scaling */ | |
869 | u_char requested_s_scale; | |
870 | u_int32_t ts_recent; /* timestamp echo data */ | |
871 | ||
872 | u_int32_t ts_recent_age; /* when last updated */ | |
873 | tcp_seq last_ack_sent; | |
874 | /* RFC 1644 variables */ | |
875 | tcp_cc cc_send; /* send connection count */ | |
876 | tcp_cc cc_recv; /* receive connection count */ | |
877 | tcp_seq snd_recover; /* for use in fast recovery */ | |
878 | /* experimental */ | |
879 | u_int32_t snd_cwnd_prev; /* cwnd prior to retransmit */ | |
880 | u_int32_t snd_ssthresh_prev; /* ssthresh prior to retransmit */ | |
881 | u_int32_t t_badrxtwin; /* window for retransmit recovery */ | |
882 | }; | |
883 | ||
884 | #endif /* PRIVATE */ | |
885 | ||
2d21ac55 A |
886 | #pragma pack() |
887 | ||
1c79356b A |
888 | /* |
889 | * Names for TCP sysctl objects | |
890 | */ | |
891 | #define TCPCTL_DO_RFC1323 1 /* use RFC-1323 extensions */ | |
892 | #define TCPCTL_DO_RFC1644 2 /* use RFC-1644 extensions */ | |
893 | #define TCPCTL_MSSDFLT 3 /* MSS default */ | |
894 | #define TCPCTL_STATS 4 /* statistics (read-only) */ | |
895 | #define TCPCTL_RTTDFLT 5 /* default RTT estimate */ | |
896 | #define TCPCTL_KEEPIDLE 6 /* keepalive idle timer */ | |
897 | #define TCPCTL_KEEPINTVL 7 /* interval to send keepalives */ | |
898 | #define TCPCTL_SENDSPACE 8 /* send buffer space */ | |
899 | #define TCPCTL_RECVSPACE 9 /* receive buffer space */ | |
9bccf70c | 900 | #define TCPCTL_KEEPINIT 10 /* timeout for establishing syn */ |
1c79356b | 901 | #define TCPCTL_PCBLIST 11 /* list of all outstanding PCBs */ |
9bccf70c A |
902 | #define TCPCTL_DELACKTIME 12 /* time before sending delayed ACK */ |
903 | #define TCPCTL_V6MSSDFLT 13 /* MSS default for IPv6 */ | |
904 | #define TCPCTL_MAXID 14 | |
1c79356b | 905 | |
91447636 | 906 | #ifdef KERNEL_PRIVATE |
2d21ac55 A |
907 | #define TCP_PKTLIST_CLEAR(tp) { \ |
908 | (tp)->t_pktlist_head = (tp)->t_pktlist_tail = NULL; \ | |
909 | (tp)->t_lastchain = (tp)->t_pktlist_sentlen = 0; \ | |
910 | } | |
911 | ||
1c79356b A |
912 | #define TCPCTL_NAMES { \ |
913 | { 0, 0 }, \ | |
914 | { "rfc1323", CTLTYPE_INT }, \ | |
915 | { "rfc1644", CTLTYPE_INT }, \ | |
916 | { "mssdflt", CTLTYPE_INT }, \ | |
917 | { "stats", CTLTYPE_STRUCT }, \ | |
918 | { "rttdflt", CTLTYPE_INT }, \ | |
919 | { "keepidle", CTLTYPE_INT }, \ | |
920 | { "keepintvl", CTLTYPE_INT }, \ | |
921 | { "sendspace", CTLTYPE_INT }, \ | |
922 | { "recvspace", CTLTYPE_INT }, \ | |
923 | { "keepinit", CTLTYPE_INT }, \ | |
924 | { "pcblist", CTLTYPE_STRUCT }, \ | |
9bccf70c | 925 | { "delacktime", CTLTYPE_INT }, \ |
1c79356b A |
926 | { "v6mssdflt", CTLTYPE_INT }, \ |
927 | } | |
928 | ||
1c79356b A |
929 | #ifdef SYSCTL_DECL |
930 | SYSCTL_DECL(_net_inet_tcp); | |
91447636 | 931 | #endif /* SYSCTL_DECL */ |
1c79356b A |
932 | |
933 | extern struct inpcbhead tcb; /* head of queue of active tcpcb's */ | |
934 | extern struct inpcbinfo tcbinfo; | |
935 | extern struct tcpstat tcpstat; /* tcp statistics */ | |
936 | extern int tcp_mssdflt; /* XXX */ | |
e5568f75 | 937 | extern int tcp_minmss; |
91447636 | 938 | extern int tcp_minmssoverload; |
9bccf70c A |
939 | extern int ss_fltsz; |
940 | extern int ss_fltsz_local; | |
6d2010ae | 941 | extern int tcp_do_rfc3390; /* Calculate ss_fltsz according to RFC 3390 */ |
9bccf70c | 942 | #ifdef __APPLE__ |
b0d623f7 | 943 | extern u_int32_t tcp_now; /* for RFC 1323 timestamps */ |
6d2010ae A |
944 | extern struct timeval tcp_uptime; |
945 | extern lck_spin_t *tcp_uptime_lock; | |
946 | ||
9bccf70c | 947 | extern int tcp_delack_enabled; |
91447636 | 948 | #endif /* __APPLE__ */ |
9bccf70c | 949 | |
8ad349bb | 950 | extern int tcp_do_sack; /* SACK enabled/disabled */ |
1c79356b | 951 | |
b0d623f7 A |
952 | #if CONFIG_IFEF_NOWINDOWSCALE |
953 | extern int tcp_obey_ifef_nowindowscale; | |
954 | #endif | |
955 | ||
91447636 | 956 | void tcp_canceltimers(struct tcpcb *); |
1c79356b | 957 | struct tcpcb * |
91447636 A |
958 | tcp_close(struct tcpcb *); |
959 | void tcp_ctlinput(int, struct sockaddr *, void *); | |
960 | int tcp_ctloutput(struct socket *, struct sockopt *); | |
1c79356b | 961 | struct tcpcb * |
91447636 A |
962 | tcp_drop(struct tcpcb *, int); |
963 | void tcp_drain(void); | |
1c79356b | 964 | struct rmxp_tao * |
91447636 | 965 | tcp_gettaocache(struct inpcb *); |
2d21ac55 | 966 | void tcp_init(void) __attribute__((section("__TEXT, initcode"))); |
91447636 | 967 | void tcp_input(struct mbuf *, int); |
c910b4d9 | 968 | void tcp_mss(struct tcpcb *, int, unsigned int); |
91447636 A |
969 | int tcp_mssopt(struct tcpcb *); |
970 | void tcp_drop_syn_sent(struct inpcb *, int); | |
971 | void tcp_mtudisc(struct inpcb *, int); | |
1c79356b | 972 | struct tcpcb * |
91447636 A |
973 | tcp_newtcpcb(struct inpcb *); |
974 | int tcp_output(struct tcpcb *); | |
91447636 | 975 | void tcp_respond(struct tcpcb *, void *, |
c910b4d9 | 976 | struct tcphdr *, struct mbuf *, tcp_seq, tcp_seq, int, |
6d2010ae | 977 | unsigned int, unsigned int); |
c910b4d9 | 978 | struct rtentry *tcp_rtlookup(struct inpcb *, unsigned int); |
91447636 A |
979 | void tcp_setpersist(struct tcpcb *); |
980 | void tcp_slowtimo(void); | |
6d2010ae A |
981 | void tcp_check_timer_state(struct tcpcb *tp); |
982 | void tcp_run_timerlist(void *arg1, void *arg2); | |
983 | ||
1c79356b | 984 | struct tcptemp * |
91447636 A |
985 | tcp_maketemplate(struct tcpcb *); |
986 | void tcp_fillheaders(struct tcpcb *, void *, void *); | |
1c79356b | 987 | struct tcpcb * |
91447636 A |
988 | tcp_timers(struct tcpcb *, int); |
989 | void tcp_trace(int, int, struct tcpcb *, void *, struct tcphdr *, int); | |
8ad349bb | 990 | |
2d21ac55 | 991 | void tcp_sack_doack(struct tcpcb *, struct tcpopt *, tcp_seq); |
8ad349bb A |
992 | void tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_laststart, tcp_seq rcv_lastend); |
993 | void tcp_clean_sackreport(struct tcpcb *tp); | |
994 | void tcp_sack_adjust(struct tcpcb *tp); | |
995 | struct sackhole *tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt); | |
996 | void tcp_sack_partialack(struct tcpcb *, struct tcphdr *); | |
997 | void tcp_free_sackholes(struct tcpcb *tp); | |
b0d623f7 A |
998 | int32_t tcp_sbspace(struct tcpcb *tp); |
999 | void tcp_set_tso(struct tcpcb *tp, struct ifnet *ifp); | |
6d2010ae | 1000 | void tcp_reset_stretch_ack(struct tcpcb *tp); |
8ad349bb | 1001 | |
6d2010ae A |
1002 | #if TRAFFIC_MGT |
1003 | void reset_acc_iaj(struct tcpcb *tp); | |
1004 | #endif /* TRAFFIC_MGT */ | |
8ad349bb | 1005 | |
b0d623f7 A |
1006 | int tcp_lock (struct socket *, int, void *); |
1007 | int tcp_unlock (struct socket *, int, void *); | |
6d2010ae A |
1008 | void calculate_tcp_clock(void); |
1009 | ||
91447636 A |
1010 | #ifdef _KERN_LOCKS_H_ |
1011 | lck_mtx_t * tcp_getlock (struct socket *, int); | |
1012 | #else | |
1013 | void * tcp_getlock (struct socket *, int); | |
1014 | #endif | |
1015 | ||
1c79356b A |
1016 | |
1017 | extern struct pr_usrreqs tcp_usrreqs; | |
b0d623f7 A |
1018 | extern u_int32_t tcp_sendspace; |
1019 | extern u_int32_t tcp_recvspace; | |
91447636 | 1020 | tcp_seq tcp_new_isn(struct tcpcb *); |
1c79356b | 1021 | |
91447636 | 1022 | #endif /* KERNEL_RPIVATE */ |
1c79356b A |
1023 | |
1024 | #endif /* _NETINET_TCP_VAR_H_ */ |