1 /** $MirOS: src/sys/netinet/tcp_var.h,v 1.5 2008/02/22 22:50:46 tg Exp $ */
2 /* $OpenBSD: tcp_var.h,v 1.68 2004/11/25 15:32:08 markus Exp $ */
3 /* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
4
5 /*
6 * Copyright (c) 1982, 1986, 1993, 1994
7 * The Regents of the University of California. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)tcp_var.h 8.3 (Berkeley) 4/10/94
34 */
35
36 #ifndef _NETINET_TCP_VAR_H_
37 #define _NETINET_TCP_VAR_H_
38
39 struct sackblk {
40 tcp_seq start; /* start seq no. of sack block */
41 tcp_seq end; /* end seq no. */
42 };
43
44 struct sackhole {
45 tcp_seq start; /* start seq no. of hole */
46 tcp_seq end; /* end seq no. */
47 int dups; /* number of dup(s)acks for this hole */
48 tcp_seq rxmit; /* next seq. no in hole to be retransmitted */
49 struct sackhole *next; /* next in list */
50 };
51
52 /*
53 * Kernel variables for tcp.
54 */
55
56 /*
57 * Tcp control block, one per tcp; fields:
58 */
59 struct tcpcb {
60 struct ipqehead segq; /* sequencing queue */
61 struct timeout t_timer[TCPT_NTIMERS]; /* tcp timers */
62 short t_state; /* state of this connection */
63 short t_rxtshift; /* log(2) of rexmt exp. backoff */
64 short t_rxtcur; /* current retransmit value */
65 short t_dupacks; /* consecutive dup acks recd */
66 u_short t_maxseg; /* maximum segment size */
67 char t_force; /* 1 if forcing out a byte */
68 u_int t_flags;
69 #define TF_ACKNOW 0x0001 /* ack peer immediately */
70 #define TF_DELACK 0x0002 /* ack, but try to delay it */
71 #define TF_NODELAY 0x0004 /* don't delay packets to coalesce */
72 #define TF_NOOPT 0x0008 /* don't use tcp options */
73 #define TF_SENTFIN 0x0010 /* have sent FIN */
74 #define TF_REQ_SCALE 0x0020 /* have/will request window scaling */
75 #define TF_RCVD_SCALE 0x0040 /* other side has requested scaling */
76 #define TF_REQ_TSTMP 0x0080 /* have/will request timestamps */
77 #define TF_RCVD_TSTMP 0x0100 /* a timestamp was received in SYN */
78 #define TF_SACK_PERMIT 0x0200 /* other side said I could SACK */
79 #define TF_SIGNATURE 0x0400 /* require TCP MD5 signature */
80 #ifdef TCP_ECN
81 #define TF_ECN_PERMIT 0x00008000 /* other side said I could ECN */
82 #define TF_RCVD_CE 0x00010000 /* send ECE in subsequent segs */
83 #define TF_SEND_CWR 0x00020000 /* send CWR in next seg */
84 #define TF_DISABLE_ECN 0x00040000 /* disable ECN for this connection */
85 #endif
86 #define TF_REASSLOCK 0x00080000 /* reassembling or draining */
87 #define TF_LASTIDLE 0x00100000 /* no outstanding ACK on last send */
88 #define TF_DEAD 0x00200000 /* dead and to-be-released */
89 #define TF_PMTUD_PEND 0x00400000 /* Path MTU Discovery pending */
90
91 struct mbuf *t_template; /* skeletal packet for transmit */
92 struct inpcb *t_inpcb; /* back pointer to internet pcb */
93 struct timeout t_delack_to; /* delayed ACK callback */
94 /*
95 * The following fields are used as in the protocol specification.
96 * See RFC783, Dec. 1981, page 21.
97 */
98 /* send sequence variables */
99 tcp_seq snd_una; /* send unacknowledged */
100 tcp_seq snd_nxt; /* send next */
101 tcp_seq snd_up; /* send urgent pointer */
102 tcp_seq snd_wl1; /* window update seg seq number */
103 tcp_seq snd_wl2; /* window update seg ack number */
104 tcp_seq iss; /* initial send sequence number */
105 u_long snd_wnd; /* send window */
106 #if 1 /*def TCP_SACK*/
107 int sack_enable; /* enable SACK for this connection */
108 int snd_numholes; /* number of holes seen by sender */
109 struct sackhole *snd_holes; /* linked list of holes (sorted) */
110 #if 1 /*defined(TCP_SACK) && defined(TCP_FACK)*/
111 tcp_seq snd_fack; /* for FACK congestion control */
112 u_long snd_awnd; /* snd_nxt - snd_fack + */
113 /* retransmitted data */
114 int retran_data; /* amount of outstanding retx. data */
115 #endif /* TCP_FACK */
116 #endif /* TCP_SACK */
117 #if 1 /*defined(TCP_SACK) || defined(TCP_ECN)*/
118 tcp_seq snd_last; /* for use in fast recovery */
119 #endif
120 /* receive sequence variables */
121 u_long rcv_wnd; /* receive window */
122 tcp_seq rcv_nxt; /* receive next */
123 tcp_seq rcv_up; /* receive urgent pointer */
124 tcp_seq irs; /* initial receive sequence number */
125 #if 1 /*def TCP_SACK*/
126 tcp_seq rcv_laststart; /* start of last segment recd. */
127 tcp_seq rcv_lastend; /* end of ... */
128 tcp_seq rcv_lastsack; /* last seq number(+1) sack'd by rcv'r*/
129 int rcv_numsacks; /* # distinct sack blks present */
130 struct sackblk sackblks[MAX_SACK_BLKS]; /* seq nos. of sack blocks */
131 #endif
132
133 /*
134 * Additional variables for this implementation.
135 */
136 /* receive variables */
137 tcp_seq rcv_adv; /* advertised window */
138 /* retransmit variables */
139 tcp_seq snd_max; /* highest sequence number sent;
140 * used to recognize retransmits
141 */
142 /* congestion control (for slow start, source quench, retransmit after loss) */
143 u_long snd_cwnd; /* congestion-controlled window */
144 u_long snd_ssthresh; /* snd_cwnd size threshhold for
145 * for slow start exponential to
146 * linear switch
147 */
148 u_short t_maxopd; /* mss plus options */
149 u_short t_peermss; /* peer's maximum segment size */
150
151 /*
152 * transmit timing stuff. See below for scale of srtt and rttvar.
153 * "Variance" is actually smoothed difference.
154 */
155 uint32_t t_rcvtime; /* time last segment received */
156 uint32_t t_rtttime; /* time we started measuring rtt */
157 tcp_seq t_rtseq; /* sequence number being timed */
158 short t_srtt; /* smoothed round-trip time */
159 short t_rttvar; /* variance in round-trip time */
160 u_short t_rttmin; /* minimum rtt allowed */
161 u_long max_sndwnd; /* largest window peer has offered */
162
163 /* out-of-band data */
164 char t_oobflags; /* have some */
165 char t_iobc; /* input character */
166 #define TCPOOB_HAVEDATA 0x01
167 #define TCPOOB_HADDATA 0x02
168 short t_softerror; /* possible error not yet reported */
169
170 /* RFC 1323 variables */
171 u_char snd_scale; /* window scaling for send window */
172 u_char rcv_scale; /* window scaling for recv window */
173 u_char request_r_scale; /* pending window scaling */
174 u_char requested_s_scale;
175 u_int32_t ts_recent; /* timestamp echo data */
176 u_int32_t ts_recent_age; /* when last updated */
177 tcp_seq last_ack_sent;
178
179 /* pointer for syn cache entries*/
180 LIST_HEAD(, syn_cache) t_sc; /* list of entries by this tcb */
181
182 /* TUBA stuff */
183 caddr_t t_tuba_pcb; /* next level down pcb for TCP over z */
184
185 /* Path-MTU Discovery Information */
186 u_int t_pmtud_mss_acked; /* MSS acked, lower bound for MTU */
187 u_int t_pmtud_mtu_sent; /* MTU used, upper bound for MTU */
188 tcp_seq t_pmtud_th_seq; /* TCP SEQ from ICMP payload */
189 u_int t_pmtud_nextmtu; /* Advertised Next-Hop MTU from ICMP */
190 u_short t_pmtud_ip_len; /* IP length from ICMP payload */
191 u_short t_pmtud_ip_hl; /* IP header length from ICMP payload */
192
193 int pf;
194
195 struct timeout t_reap_to; /* delayed cleanup timeout */
196 };
197
198 #define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb)
199 #define sototcpcb(so) (intotcpcb(sotoinpcb(so)))
200
201 #ifdef _KERNEL
202 extern int tcp_delack_ticks;
203 void tcp_delack(void *);
204
205 #define TCP_INIT_DELACK(tp) \
206 timeout_set(&(tp)->t_delack_to, tcp_delack, tp)
207
208 #define TCP_RESTART_DELACK(tp) \
209 timeout_add(&(tp)->t_delack_to, tcp_delack_ticks)
210
211 #define TCP_SET_DELACK(tp) \
212 do { \
213 if (((tp)->t_flags & TF_DELACK) == 0) { \
214 (tp)->t_flags |= TF_DELACK; \
215 TCP_RESTART_DELACK(tp); \
216 } \
217 } while (/*CONSTCOND*/0)
218
219 #define TCP_CLEAR_DELACK(tp) \
220 do { \
221 if ((tp)->t_flags & TF_DELACK) { \
222 (tp)->t_flags &= ~TF_DELACK; \
223 timeout_del(&(tp)->t_delack_to); \
224 } \
225 } while (/*CONSTCOND*/0)
226
227 /*
228 * Handy way of passing around TCP option info.
229 */
230 struct tcp_opt_info {
231 int ts_present;
232 u_int32_t ts_val;
233 u_int32_t ts_ecr;
234 u_int16_t maxseg;
235 };
236
237 /*
238 * Data for the TCP compressed state engine.
239 */
240 union syn_cache_sa {
241 struct sockaddr sa;
242 struct sockaddr_in sin;
243 #if 1 /*def INET6*/
244 struct sockaddr_in6 sin6;
245 #endif
246 };
247
248 struct syn_cache {
249 TAILQ_ENTRY(syn_cache) sc_bucketq; /* link on bucket list */
250 struct timeout sc_timer; /* rexmt timer */
251 union { /* cached route */
252 struct route route4;
253 #ifdef INET6
254 struct route_in6 route6;
255 #endif
256 } sc_route_u;
257 #define sc_route4 sc_route_u.route4
258 #ifdef INET6
259 #define sc_route6 sc_route_u.route6
260 #endif
261 long sc_win; /* advertised window */
262 int sc_bucketidx; /* our bucket index */
263 u_int32_t sc_hash;
264 u_int32_t sc_timestamp; /* timestamp from SYN */
265 #if 0
266 u_int32_t sc_timebase; /* our local timebase */
267 #endif
268 union syn_cache_sa sc_src;
269 union syn_cache_sa sc_dst;
270 tcp_seq sc_irs;
271 tcp_seq sc_iss;
272 u_int sc_rxtcur; /* current rxt timeout */
273 u_int sc_rxttot; /* total time spend on queues */
274 u_short sc_rxtshift; /* for computing backoff */
275 u_short sc_flags;
276
277 #define SCF_UNREACH 0x0001 /* we've had an unreach error */
278 #define SCF_TIMESTAMP 0x0002 /* peer will do timestamps */
279 #define SCF_DEAD 0x0004 /* this entry to be released */
280 #define SCF_SACK_PERMIT 0x0008 /* permit sack */
281 #define SCF_ECN_PERMIT 0x0010 /* permit ecn */
282 #define SCF_SIGNATURE 0x0020 /* enforce tcp signatures */
283
284 struct mbuf *sc_ipopts; /* IP options */
285 u_int16_t sc_peermaxseg;
286 u_int16_t sc_ourmaxseg;
287 u_int8_t sc_request_r_scale : 4,
288 sc_requested_s_scale : 4;
289
290 struct tcpcb *sc_tp; /* tcb for listening socket */
291 LIST_ENTRY(syn_cache) sc_tpq; /* list of entries by same tp */
292 };
293
294 struct syn_cache_head {
295 TAILQ_HEAD(, syn_cache) sch_bucket; /* bucket entries */
296 u_short sch_length; /* # entries in bucket */
297 };
298
299 static __inline int tcp_reass_lock_try(struct tcpcb *);
300 static __inline void tcp_reass_unlock(struct tcpcb *);
301 #define tcp_reass_lock(tp) tcp_reass_lock_try(tp)
302
303 static __inline int
tcp_reass_lock_try(struct tcpcb * tp)304 tcp_reass_lock_try(struct tcpcb *tp)
305 {
306 int s;
307
308 s = splimp();
309 if (tp->t_flags & TF_REASSLOCK) {
310 splx(s);
311 return (0);
312 }
313 tp->t_flags |= TF_REASSLOCK;
314 splx(s);
315 return (1);
316 }
317
318 static __inline void
tcp_reass_unlock(struct tcpcb * tp)319 tcp_reass_unlock(struct tcpcb *tp)
320 {
321 int s;
322
323 s = splimp();
324 tp->t_flags &= ~TF_REASSLOCK;
325 splx(s);
326 }
327 #endif /* _KERNEL */
328
329 /*
330 * The smoothed round-trip time and estimated variance
331 * are stored as fixed point numbers scaled by the values below.
332 * For convenience, these scales are also used in smoothing the average
333 * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
334 * With these scales, srtt has 3 bits to the right of the binary point,
335 * and thus an "ALPHA" of 0.875. rttvar has 2 bits to the right of the
336 * binary point, and is smoothed with an ALPHA of 0.75.
337 */
338 #define TCP_RTT_SCALE 8 /* multiplier for srtt; 3 bits frac. */
339 #define TCP_RTT_SHIFT 3 /* shift for srtt; 3 bits frac. */
340 #define TCP_RTTVAR_SCALE 4 /* multiplier for rttvar; 2 bits */
341 #define TCP_RTTVAR_SHIFT 2 /* multiplier for rttvar; 2 bits */
342 #define TCP_RTT_MAX (1<<9) /* maximum rtt */
343
344 /*
345 * The initial retransmission should happen at rtt + 4 * rttvar.
346 * Because of the way we do the smoothing, srtt and rttvar
347 * will each average +1/2 tick of bias. When we compute
348 * the retransmit timer, we want 1/2 tick of rounding and
349 * 1 extra tick because of +-1/2 tick uncertainty in the
350 * firing of the timer. The bias will give us exactly the
351 * 1.5 tick we need. But, because the bias is
352 * statistical, we have to test that we don't drop below
353 * the minimum feasible timer (which is 2 ticks).
354 * This macro assumes that the value of TCP_RTTVAR_SCALE
355 * is the same as the multiplier for rttvar.
356 */
357 #define TCP_REXMTVAL(tp) \
358 ((((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar) >> 2)
359
360 /*
361 * TCP statistics.
362 * Many of these should be kept per connection,
363 * but that's inconvenient at the moment.
364 */
365 struct tcpstat {
366 u_int32_t tcps_connattempt; /* connections initiated */
367 u_int32_t tcps_accepts; /* connections accepted */
368 u_int32_t tcps_connects; /* connections established */
369 u_int32_t tcps_drops; /* connections dropped */
370 u_int32_t tcps_conndrops; /* embryonic connections dropped */
371 u_int32_t tcps_closed; /* conn. closed (includes drops) */
372 u_int32_t tcps_segstimed; /* segs where we tried to get rtt */
373 u_int32_t tcps_rttupdated; /* times we succeeded */
374 u_int32_t tcps_delack; /* delayed acks sent */
375 u_int32_t tcps_timeoutdrop; /* conn. dropped in rxmt timeout */
376 u_int32_t tcps_rexmttimeo; /* retransmit timeouts */
377 u_int32_t tcps_persisttimeo; /* persist timeouts */
378 u_int32_t tcps_persistdrop; /* connections dropped in persist */
379 u_int32_t tcps_keeptimeo; /* keepalive timeouts */
380 u_int32_t tcps_keepprobe; /* keepalive probes sent */
381 u_int32_t tcps_keepdrops; /* connections dropped in keepalive */
382
383 u_int32_t tcps_sndtotal; /* total packets sent */
384 u_int32_t tcps_sndpack; /* data packets sent */
385 u_int64_t tcps_sndbyte; /* data bytes sent */
386 u_int32_t tcps_sndrexmitpack; /* data packets retransmitted */
387 u_int64_t tcps_sndrexmitbyte; /* data bytes retransmitted */
388 u_int64_t tcps_sndrexmitfast; /* Fast retransmits */
389 u_int32_t tcps_sndacks; /* ack-only packets sent */
390 u_int32_t tcps_sndprobe; /* window probes sent */
391 u_int32_t tcps_sndurg; /* packets sent with URG only */
392 u_int32_t tcps_sndwinup; /* window update-only packets sent */
393 u_int32_t tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */
394
395 u_int32_t tcps_rcvtotal; /* total packets received */
396 u_int32_t tcps_rcvpack; /* packets received in sequence */
397 u_int64_t tcps_rcvbyte; /* bytes received in sequence */
398 u_int32_t tcps_rcvbadsum; /* packets received with ccksum errs */
399 u_int32_t tcps_rcvbadoff; /* packets received with bad offset */
400 u_int32_t tcps_rcvmemdrop; /* packets dropped for lack of memory */
401 u_int32_t tcps_rcvnosec; /* packets dropped for lack of ipsec */
402 u_int32_t tcps_rcvshort; /* packets received too short */
403 u_int32_t tcps_rcvduppack; /* duplicate-only packets received */
404 u_int64_t tcps_rcvdupbyte; /* duplicate-only bytes received */
405 u_int32_t tcps_rcvpartduppack; /* packets with some duplicate data */
406 u_int64_t tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */
407 u_int32_t tcps_rcvoopack; /* out-of-order packets received */
408 u_int64_t tcps_rcvoobyte; /* out-of-order bytes received */
409 u_int32_t tcps_rcvpackafterwin; /* packets with data after window */
410 u_int64_t tcps_rcvbyteafterwin; /* bytes rcvd after window */
411 u_int32_t tcps_rcvafterclose; /* packets rcvd after "close" */
412 u_int32_t tcps_rcvwinprobe; /* rcvd window probe packets */
413 u_int32_t tcps_rcvdupack; /* rcvd duplicate acks */
414 u_int32_t tcps_rcvacktoomuch; /* rcvd acks for unsent data */
415 u_int32_t tcps_rcvacktooold; /* rcvd acks for old data */
416 u_int32_t tcps_rcvackpack; /* rcvd ack packets */
417 u_int64_t tcps_rcvackbyte; /* bytes acked by rcvd acks */
418 u_int32_t tcps_rcvwinupd; /* rcvd window update packets */
419 u_int32_t tcps_pawsdrop; /* segments dropped due to PAWS */
420 u_int32_t tcps_predack; /* times hdr predict ok for acks */
421 u_int32_t tcps_preddat; /* times hdr predict ok for data pkts */
422
423 u_int32_t tcps_pcbhashmiss; /* input packets missing pcb hash */
424 u_int32_t tcps_noport; /* no socket on port */
425 u_int32_t tcps_badsyn; /* SYN packet with src==dst rcv'ed */
426
427 u_int32_t tcps_rcvbadsig; /* rcvd bad/missing TCP signatures */
428 u_int64_t tcps_rcvgoodsig; /* rcvd good TCP signatures */
429 u_int32_t tcps_inhwcsum; /* input hardware-checksummed packets */
430 u_int32_t tcps_outhwcsum; /* output hardware-checksummed packets */
431
432 /* ECN stats */
433 u_int32_t tcps_ecn_accepts; /* ecn connections accepted */
434 u_int32_t tcps_ecn_rcvece; /* # of rcvd ece */
435 u_int32_t tcps_ecn_rcvcwr; /* # of rcvd cwr */
436 u_int32_t tcps_ecn_rcvce; /* # of rcvd ce in ip header */
437 u_int32_t tcps_ecn_sndect; /* # of cwr sent */
438 u_int32_t tcps_ecn_sndece; /* # of ece sent */
439 u_int32_t tcps_ecn_sndcwr; /* # of cwr sent */
440 u_int32_t tcps_cwr_ecn; /* # of cwnd reduced by ecn */
441 u_int32_t tcps_cwr_frecovery; /* # of cwnd reduced by fastrecovery */
442 u_int32_t tcps_cwr_timeout; /* # of cwnd reduced by timeout */
443
444 /* These statistics deal with the SYN cache. */
445 u_int64_t tcps_sc_added; /* # of entries added */
446 u_int64_t tcps_sc_completed; /* # of connections completed */
447 u_int64_t tcps_sc_timed_out; /* # of entries timed out */
448 u_int64_t tcps_sc_overflowed; /* # dropped due to overflow */
449 u_int64_t tcps_sc_reset; /* # dropped due to RST */
450 u_int64_t tcps_sc_unreach; /* # dropped due to ICMP unreach */
451 u_int64_t tcps_sc_bucketoverflow;/* # dropped due to bucket overflow */
452 u_int64_t tcps_sc_aborted; /* # of entries aborted (no mem) */
453 u_int64_t tcps_sc_dupesyn; /* # of duplicate SYNs received */
454 u_int64_t tcps_sc_dropped; /* # of SYNs dropped (no route/mem) */
455 u_int64_t tcps_sc_collisions; /* # of hash collisions */
456 u_int64_t tcps_sc_retransmitted;/* # of retransmissions */
457
458 u_int64_t tcps_conndrained; /* # of connections drained */
459 };
460
461 /*
462 * Names for TCP sysctl objects.
463 */
464
465 #define TCPCTL_RFC1323 1 /* enable/disable RFC1323 timestamps/scaling */
466 #define TCPCTL_KEEPINITTIME 2 /* TCPT_KEEP value */
467 #define TCPCTL_KEEPIDLE 3 /* allow tcp_keepidle to be changed */
468 #define TCPCTL_KEEPINTVL 4 /* allow tcp_keepintvl to be changed */
469 #define TCPCTL_SLOWHZ 5 /* return kernel idea of PR_SLOWHZ */
470 #define TCPCTL_BADDYNAMIC 6 /* return bad dynamic port bitmap */
471 #define TCPCTL_RECVSPACE 7 /* receive buffer space */
472 #define TCPCTL_SENDSPACE 8 /* send buffer space */
473 #define TCPCTL_IDENT 9 /* get connection owner */
474 #define TCPCTL_SACK 10 /* selective acknowledgement, rfc 2018 */
475 #define TCPCTL_MSSDFLT 11 /* Default maximum segment size */
476 #define TCPCTL_RSTPPSLIMIT 12 /* RST pps limit */
477 #define TCPCTL_ACK_ON_PUSH 13 /* ACK immediately on PUSH */
478 #define TCPCTL_ECN 14 /* RFC3168 ECN */
479 #define TCPCTL_SYN_CACHE_LIMIT 15 /* max size of comp. state engine */
480 #define TCPCTL_SYN_BUCKET_LIMIT 16 /* max size of hash bucket */
481 #define TCPCTL_RFC3390 17 /* enable/disable RFC3390 increased cwnd */
482 #define TCPCTL_REASS_LIMIT 18 /* max entries for tcp reass queues */
483 #define TCPCTL_DROP 19 /* drop tcp connection */
484 #define TCPCTL_SACKHOLE_LIMIT 20 /* max entries for tcp sack queues */
485 #define TCPCTL_MAXID 21
486
487 #define TCPCTL_NAMES { \
488 { 0, 0 }, \
489 { "rfc1323", CTLTYPE_INT }, \
490 { "keepinittime", CTLTYPE_INT }, \
491 { "keepidle", CTLTYPE_INT }, \
492 { "keepintvl", CTLTYPE_INT }, \
493 { "slowhz", CTLTYPE_INT }, \
494 { "baddynamic", CTLTYPE_STRUCT }, \
495 { "recvspace", CTLTYPE_INT }, \
496 { "sendspace", CTLTYPE_INT }, \
497 { "ident", CTLTYPE_STRUCT }, \
498 { "sack", CTLTYPE_INT }, \
499 { "mssdflt", CTLTYPE_INT }, \
500 { "rstppslimit", CTLTYPE_INT }, \
501 { "ackonpush", CTLTYPE_INT }, \
502 { "ecn", CTLTYPE_INT }, \
503 { "syncachelimit", CTLTYPE_INT }, \
504 { "synbucketlimit", CTLTYPE_INT }, \
505 { "rfc3390", CTLTYPE_INT }, \
506 { "reasslimit", CTLTYPE_INT }, \
507 { "drop", CTLTYPE_STRUCT }, \
508 { "sackholelimit", CTLTYPE_INT }, \
509 }
510
511 #define TCPCTL_VARS { \
512 NULL, \
513 &tcp_do_rfc1323, \
514 &tcptv_keep_init, \
515 &tcp_keepidle, \
516 &tcp_keepintvl, \
517 NULL, \
518 NULL, \
519 &tcp_recvspace, \
520 &tcp_sendspace, \
521 NULL, \
522 NULL, \
523 &tcp_mssdflt, \
524 &tcp_rst_ppslim, \
525 &tcp_ack_on_push, \
526 NULL, \
527 &tcp_syn_cache_limit, \
528 &tcp_syn_bucket_limit, \
529 &tcp_do_rfc3390, \
530 NULL, \
531 NULL, \
532 NULL \
533 }
534
535 struct tcp_ident_mapping {
536 struct sockaddr_storage faddr, laddr;
537 int euid, ruid;
538 };
539
540 #ifdef _KERNEL
541 extern struct inpcbtable tcbtable; /* head of queue of active tcpcb's */
542 extern struct tcpstat tcpstat; /* tcp statistics */
543 extern u_int32_t tcp_now; /* for RFC 1323 timestamps */
544 extern int tcp_do_rfc1323; /* enabled/disabled? */
545 extern int tcp_mssdflt; /* default maximum segment size */
546 extern int tcp_ack_on_push; /* ACK immediately on PUSH */
547 #ifdef TCP_SACK
548 extern int tcp_do_sack; /* SACK enabled/disabled */
549 extern struct pool sackhl_pool;
550 extern int tcp_sackhole_limit; /* max entries for tcp sack queues */
551 #endif
552 extern int tcp_do_ecn; /* RFC3168 ECN enabled/disabled? */
553 extern int tcp_do_rfc3390; /* RFC3390 Increasing TCP's Initial Window */
554
555 extern struct pool tcpqe_pool;
556 extern int tcp_reass_limit; /* max entries for tcp reass queues */
557
558 extern int tcp_syn_cache_limit; /* max entries for compressed state engine */
559 extern int tcp_syn_bucket_limit;/* max entries per hash bucket */
560
561 extern int tcp_syn_cache_size;
562 extern struct syn_cache_head tcp_syn_cache[];
563 extern u_long syn_cache_count;
564
565 extern struct pool tcpqe_pool;
566 extern int tcp_reass_limit; /* max entries for tcp reass queues */
567
568 int tcp_attach(struct socket *);
569 void tcp_canceltimers(struct tcpcb *);
570 struct tcpcb *
571 tcp_close(struct tcpcb *);
572 void tcp_reaper(void *);
573 int tcp_freeq(struct tcpcb *);
574 #if defined(INET6) && !defined(TCP6)
575 void tcp6_ctlinput(int, struct sockaddr *, void *);
576 #endif
577 void *tcp_ctlinput(int, struct sockaddr *, void *);
578 int tcp_ctloutput(int, struct socket *, int, int, struct mbuf **);
579 struct tcpcb *
580 tcp_disconnect(struct tcpcb *);
581 struct tcpcb *
582 tcp_drop(struct tcpcb *, int);
583 int tcp_dooptions(struct tcpcb *, u_char *, int, struct tcphdr *,
584 struct mbuf *, int, struct tcp_opt_info *);
585 void tcp_drain(void);
586 void tcp_init(void);
587 #if defined(INET6) && !defined(TCP6)
588 int tcp6_input(struct mbuf **, int *, int);
589 #endif
590 void tcp_input(struct mbuf *, ...);
591 int tcp_mss(struct tcpcb *, int);
592 void tcp_mss_update(struct tcpcb *);
593 u_int tcp_hdrsz(struct tcpcb *);
594 void tcp_mtudisc(struct inpcb *, int);
595 void tcp_mtudisc_increase(struct inpcb *, int);
596 #ifdef INET6
597 void tcp6_mtudisc(struct inpcb *, int);
598 void tcp6_mtudisc_callback(struct in6_addr *);
599 #endif
600 struct tcpcb *
601 tcp_newtcpcb(struct inpcb *);
602 void tcp_notify(struct inpcb *, int);
603 int tcp_output(struct tcpcb *);
604 void tcp_pulloutofband(struct socket *, u_int, struct mbuf *, int);
605 void tcp_quench(struct inpcb *, int);
606 int tcp_reass(struct tcpcb *, struct tcphdr *, struct mbuf *, int *);
607 void tcp_rscale(struct tcpcb *, u_long);
608 void tcp_respond(struct tcpcb *, caddr_t, struct tcphdr *, tcp_seq,
609 tcp_seq, int);
610 void tcp_setpersist(struct tcpcb *);
611 void tcp_slowtimo(void);
612 struct mbuf *
613 tcp_template(struct tcpcb *);
614 void tcp_trace(int, int, struct tcpcb *, caddr_t, int, int);
615 struct tcpcb *
616 tcp_usrclosed(struct tcpcb *);
617 int tcp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
618 #if defined(INET6) && !defined(TCP6)
619 int tcp6_usrreq(struct socket *,
620 int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
621 #endif
622 int tcp_usrreq(struct socket *,
623 int, struct mbuf *, struct mbuf *, struct mbuf *);
624 void tcp_xmit_timer(struct tcpcb *, int);
625 void tcpdropoldhalfopen(struct tcpcb *, u_int16_t);
626 #ifdef TCP_SACK
627 void tcp_sack_option(struct tcpcb *,struct tcphdr *,u_char *,int);
628 void tcp_update_sack_list(struct tcpcb *tp);
629 void tcp_del_sackholes(struct tcpcb *, struct tcphdr *);
630 void tcp_clean_sackreport(struct tcpcb *tp);
631 void tcp_sack_adjust(struct tcpcb *tp);
632 struct sackhole *
633 tcp_sack_output(struct tcpcb *tp);
634 int tcp_sack_partialack(struct tcpcb *, struct tcphdr *);
635 #ifdef DEBUG
636 void tcp_print_holes(struct tcpcb *tp);
637 #endif
638 #endif /* TCP_SACK */
639 #if defined(TCP_SACK)
640 int tcp_newreno(struct tcpcb *, struct tcphdr *);
641 u_long tcp_seq_subtract(u_long, u_long );
642 #endif /* TCP_SACK */
643 #ifdef TCP_SIGNATURE
644 int tcp_signature_apply(caddr_t, caddr_t, unsigned int);
645 #endif /* TCP_SIGNATURE */
646 void tcp_rndiss_init(void);
647 tcp_seq tcp_rndiss_next(void);
648 u_int16_t
649 tcp_rndiss_encrypt(u_int16_t);
650
651 int syn_cache_add(struct sockaddr *, struct sockaddr *,
652 struct tcphdr *, unsigned int, struct socket *,
653 struct mbuf *, u_char *, int, struct tcp_opt_info *);
654 void syn_cache_unreach(struct sockaddr *, struct sockaddr *,
655 struct tcphdr *);
656 struct socket *syn_cache_get(struct sockaddr *, struct sockaddr *,
657 struct tcphdr *, unsigned int, unsigned int,
658 struct socket *so, struct mbuf *);
659 void syn_cache_init(void);
660 void syn_cache_insert(struct syn_cache *, struct tcpcb *);
661 struct syn_cache *syn_cache_lookup(struct sockaddr *, struct sockaddr *,
662 struct syn_cache_head **);
663 void syn_cache_reset(struct sockaddr *, struct sockaddr *,
664 struct tcphdr *);
665 int syn_cache_respond(struct syn_cache *, struct mbuf *);
666 void syn_cache_timer(void *);
667 void syn_cache_cleanup(struct tcpcb *);
668 void syn_cache_reaper(void *);
669
670 #endif /* _KERNEL */
671 #endif /* _NETINET_TCP_VAR_H_ */
672