source: rtems/cpukit/libnetworking/netinet/tcp_var.h @ 0e16fa45

5
Last change on this file since 0e16fa45 was 65c6425, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 17:24:46

Remove CVS Id Strings (manual edits after script)

These modifications were required by hand after running the script.
In some cases, the file names did not match patterns. In others,
the format of the file did not match any common patterns.

  • Property mode set to 100644
File size: 16.3 KB
Line 
1/*
2 * Copyright (c) 1982, 1986, 1993, 1994, 1995
3 *      The Regents of the University of California.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 *    may be used to endorse or promote products derived from this software
15 *    without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 *      @(#)tcp_var.h   8.4 (Berkeley) 5/24/95
30 * $FreeBSD: src/sys/netinet/tcp_var.h,v 1.121 2005/04/21 20:11:01 ps Exp $
31 */
32 
33#ifndef _NETINET_TCP_VAR_H_
34#define _NETINET_TCP_VAR_H_
35
36#include <netinet/tcp.h>
37
38/*
39 * Kernel variables for tcp.
40 */
41
42#ifdef __BSD_VISIBLE
43#include <netinet/tcp_timer.h> /* TCPT_NTIMERS */
44
45/*
46 * Tcp control block, one per tcp; fields:
47 */
48struct tcpcb {
49        struct  tcpiphdr *seg_next;     /* sequencing queue */
50        struct  tcpiphdr *seg_prev;
51        int     t_state;                /* state of this connection */
52        u_int   t_flags;
53#define TF_ACKNOW       0x000001        /* ack peer immediately */
54#define TF_DELACK       0x000002        /* ack, but try to delay it */
55#define TF_NODELAY      0x000004        /* don't delay packets to coalesce */
56#define TF_NOOPT        0x000008        /* don't use tcp options */
57#define TF_SENTFIN      0x000010        /* have sent FIN */
58#define TF_REQ_SCALE    0x000020        /* have/will request window scaling */
59#define TF_RCVD_SCALE   0x000040        /* other side has requested scaling */
60#define TF_REQ_TSTMP    0x000080        /* have/will request timestamps */
61#define TF_RCVD_TSTMP   0x000100        /* a timestamp was received in SYN */
62#define TF_SACK_PERMIT  0x000200        /* other side said I could SACK */
63#define TF_NEEDSYN      0x000400        /* send SYN (implicit state) */
64#define TF_NEEDFIN      0x000800        /* send FIN (implicit state) */
65#define TF_NOPUSH       0x001000        /* don't push */
66#define TF_REQ_CC       0x002000        /* have/will request CC */
67#define TF_RCVD_CC      0x004000        /* a CC was received in SYN */
68#define TF_SENDCCNEW    0x008000        /* send CCnew instead of CC in SYN */
69#define TF_MORETOCOME   0x010000        /* More data to be appended to sock */
70#define TF_LQ_OVERFLOW  0x020000        /* listen queue overflow */
71#define TF_LASTIDLE     0x040000        /* connection was previously idle */
72#define TF_RXWIN0SENT   0x080000        /* sent a receiver win 0 in response */
73#define TF_FASTRECOVERY 0x100000        /* in NewReno Fast Recovery */
74#define TF_WASFRECOVERY 0x200000        /* was in NewReno Fast Recovery */
75#define TF_SIGNATURE    0x400000        /* require MD5 digests (RFC2385) */
76        int     t_force;                /* 1 if forcing out a byte */
77        int     t_timer[TCPT_NTIMERS];  /* tcp timers */
78        int     t_rxtshift;             /* log(2) of rexmt exp. backoff */
79        int     t_rxtcur;               /* current retransmit value */
80        int     t_dupacks;              /* consecutive dup acks recd */
81        u_int   t_maxseg;               /* maximum segment size */
82        u_int   t_maxopd;               /* mss plus options */
83        struct  tcpiphdr *t_template;   /* skeletal packet for transmit */
84        struct  inpcb *t_inpcb;         /* back pointer to internet pcb */
85/*
86 * The following fields are used as in the protocol specification.
87 * See RFC783, Dec. 1981, page 21.
88 */
89/* send sequence variables */
90        tcp_seq snd_una;                /* send unacknowledged */
91        tcp_seq snd_max;                /* highest sequence number sent;
92                                         * used to recognize retransmits
93                                         */
94        tcp_seq snd_nxt;                /* send next */
95        tcp_seq snd_up;                 /* send urgent pointer */
96
97        tcp_seq snd_wl1;                /* window update seg seq number */
98        tcp_seq snd_wl2;                /* window update seg ack number */
99        tcp_seq iss;                    /* initial send sequence number */
100        tcp_seq irs;                    /* initial receive sequence number */
101
102        tcp_seq rcv_nxt;                /* receive next */
103        tcp_seq rcv_adv;                /* advertised window */
104        u_long  rcv_wnd;                /* receive window */
105        tcp_seq rcv_up;                 /* receive urgent pointer */
106
107        u_long  snd_wnd;                /* send window */
108/*
109 * Additional variables for this implementation.
110 */
111/* congestion control (for slow start, source quench, retransmit after loss) */
112        u_long  snd_cwnd;               /* congestion-controlled window */
113        u_long  snd_ssthresh;           /* snd_cwnd size threshold for
114                                         * for slow start exponential to
115                                         * linear switch
116                                         */
117/*
118 * transmit timing stuff.  See below for scale of srtt and rttvar.
119 * "Variance" is actually smoothed difference.
120 */
121        u_int   t_idle;                 /* inactivity time */
122        int     t_rtt;                  /* round trip time */
123        tcp_seq t_rtseq;                /* sequence number being timed */
124        int     t_srtt;                 /* smoothed round-trip time */
125        int     t_rttvar;               /* variance in round-trip time */
126        u_int   t_rttmin;               /* minimum rtt allowed */
127        u_long  max_sndwnd;             /* largest window peer has offered */
128
129        int     t_softerror;            /* possible error not yet reported */
130/* out-of-band data */
131        char    t_oobflags;             /* have some */
132        char    t_iobc;                 /* input character */
133#define TCPOOB_HAVEDATA 0x01
134#define TCPOOB_HADDATA  0x02
135/* RFC 1323 variables */
136        u_char  snd_scale;              /* window scaling for send window */
137        u_char  rcv_scale;              /* window scaling for recv window */
138        u_char  request_r_scale;        /* pending window scaling */
139        u_char  requested_s_scale;
140        u_long  ts_recent;              /* timestamp echo data */
141
142        u_long  ts_recent_age;          /* when last updated */
143        tcp_seq last_ack_sent;
144/* RFC 1644 variables */
145        tcp_cc  cc_send;                /* send connection count */
146        tcp_cc  cc_recv;                /* receive connection count */
147        u_long  t_duration;             /* connection duration */
148
149/* TUBA stuff */
150        caddr_t t_tuba_pcb;             /* next level down pcb for TCP over z */
151/* More RTT stuff */
152        u_long  t_rttupdated;           /* number of times rtt sampled */
153};
154
155/*
156 * Structure to hold TCP options that are only used during segment
157 * processing (in tcp_input), but not held in the tcpcb.
158 * It's basically used to reduce the number of parameters
159 * to tcp_dooptions.
160 */
161struct tcpopt {
162        u_long          to_flags;       /* which options are present */
163#define TOF_TS          0x0001          /* timestamp */
164#define TOF_CC          0x0002          /* CC and CCnew are exclusive */
165#define TOF_CCNEW       0x0004
166#define TOF_CCECHO      0x0008
167#define TOF_MSS         0x0010
168#define TOF_SCALE       0x0020
169#define TOF_SIGNATURE   0x0040          /* signature option present */
170#define TOF_SIGLEN      0x0080          /* signature length valid (RFC2385) */
171#define TOF_SACK        0x0100          /* Peer sent SACK option */
172        u_int32_t       to_tsval;
173        u_int32_t       to_tsecr;
174        tcp_cc  to_cc;          /* holds CC or CCnew */
175        tcp_cc  to_ccecho;
176};
177
178/*
179 * The TAO cache entry which is stored in the protocol family specific
180 * portion of the route metrics.
181 */
182struct rmxp_tao {
183        tcp_cc  tao_cc;                 /* latest CC in valid SYN */
184        tcp_cc  tao_ccsent;             /* latest CC sent to peer */
185        u_short tao_mssopt;             /* peer's cached MSS */
186};
187#define rmx_taop(r)     ((struct rmxp_tao *)(r).rmx_filler)
188
189#define intotcpcb(ip)   ((struct tcpcb *)(ip)->inp_ppcb)
190#define intotw(ip)      ((struct tcptw *)(ip)->inp_ppcb)
191#define sototcpcb(so)   (intotcpcb(sotoinpcb(so)))
192#endif /* __BSD_VISIBLE */
193
194/*
195 * The smoothed round-trip time and estimated variance
196 * are stored as fixed point numbers scaled by the values below.
197 * For convenience, these scales are also used in smoothing the average
198 * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
199 * With these scales, srtt has 3 bits to the right of the binary point,
200 * and thus an "ALPHA" of 0.875.  rttvar has 2 bits to the right of the
201 * binary point, and is smoothed with an ALPHA of 0.75.
202 */
203#define TCP_RTT_SCALE           32      /* multiplier for srtt; 3 bits frac. */
204#define TCP_RTT_SHIFT           5       /* shift for srtt; 3 bits frac. */
205#define TCP_RTTVAR_SCALE        16      /* multiplier for rttvar; 2 bits */
206#define TCP_RTTVAR_SHIFT        4       /* shift for rttvar; 2 bits */
207#define TCP_DELTA_SHIFT         2       /* see tcp_input.c */
208
209/*
210 * The initial retransmission should happen at rtt + 4 * rttvar.
211 * Because of the way we do the smoothing, srtt and rttvar
212 * will each average +1/2 tick of bias.  When we compute
213 * the retransmit timer, we want 1/2 tick of rounding and
214 * 1 extra tick because of +-1/2 tick uncertainty in the
215 * firing of the timer.  The bias will give us exactly the
216 * 1.5 tick we need.  But, because the bias is
217 * statistical, we have to test that we don't drop below
218 * the minimum feasible timer (which is 2 ticks).
219 * This version of the macro adapted from a paper by Lawrence
220 * Brakmo and Larry Peterson which outlines a problem caused
221 * by insufficient precision in the original implementation,
222 * which results in inappropriately large RTO values for very
223 * fast networks.
224 */
225#define TCP_REXMTVAL(tp) \
226        ((((tp)->t_srtt >> (TCP_RTT_SHIFT - TCP_DELTA_SHIFT))  \
227          + (tp)->t_rttvar) >> TCP_DELTA_SHIFT)
228
229/* XXX
230 * We want to avoid doing m_pullup on incoming packets but that
231 * means avoiding dtom on the tcp reassembly code.  That in turn means
232 * keeping an mbuf pointer in the reassembly queue (since we might
233 * have a cluster).  As a quick hack, the source & destination
234 * port numbers (which are no longer needed once we've located the
235 * tcpcb) are overlayed with an mbuf pointer.
236 */
237#if (defined(__GNUC__) && (defined(__arm__) || defined(__mips__)))
238#define STR32_UNALGN(ti,m) \
239        (ti)->ti_sport = (unsigned short)(((unsigned int) m & 0xffff0000) >> 16); \
240         (ti)->ti_dport = (unsigned short) ((unsigned int) m & 0x0000ffff);
241#define LD32_UNALGN(ti,m) \
242        m = (struct mbuf *)((((unsigned int) (ti)->ti_sport) << 16) | ( (unsigned int)(ti)->ti_dport));
243
244#else
245#define REASS_MBUF(ti) (*(struct mbuf **)&((ti)->ti_t))
246#endif
247
248/*
249 * TCP statistics.
250 * Many of these should be kept per connection,
251 * but that's inconvenient at the moment.
252 */
253struct  tcpstat {
254        u_long  tcps_connattempt;       /* connections initiated */
255        u_long  tcps_accepts;           /* connections accepted */
256        u_long  tcps_connects;          /* connections established */
257        u_long  tcps_drops;             /* connections dropped */
258        u_long  tcps_conndrops;         /* embryonic connections dropped */
259        u_long  tcps_closed;            /* conn. closed (includes drops) */
260        u_long  tcps_segstimed;         /* segs where we tried to get rtt */
261        u_long  tcps_rttupdated;        /* times we succeeded */
262        u_long  tcps_delack;            /* delayed acks sent */
263        u_long  tcps_timeoutdrop;       /* conn. dropped in rxmt timeout */
264        u_long  tcps_rexmttimeo;        /* retransmit timeouts */
265        u_long  tcps_persisttimeo;      /* persist timeouts */
266        u_long  tcps_keeptimeo;         /* keepalive timeouts */
267        u_long  tcps_keepprobe;         /* keepalive probes sent */
268        u_long  tcps_keepdrops;         /* connections dropped in keepalive */
269
270        u_long  tcps_sndtotal;          /* total packets sent */
271        u_long  tcps_sndpack;           /* data packets sent */
272        u_long  tcps_sndbyte;           /* data bytes sent */
273        u_long  tcps_sndrexmitpack;     /* data packets retransmitted */
274        u_long  tcps_sndrexmitbyte;     /* data bytes retransmitted */
275        u_long  tcps_sndacks;           /* ack-only packets sent */
276        u_long  tcps_sndprobe;          /* window probes sent */
277        u_long  tcps_sndurg;            /* packets sent with URG only */
278        u_long  tcps_sndwinup;          /* window update-only packets sent */
279        u_long  tcps_sndctrl;           /* control (SYN|FIN|RST) packets sent */
280
281        u_long  tcps_rcvtotal;          /* total packets received */
282        u_long  tcps_rcvpack;           /* packets received in sequence */
283        u_long  tcps_rcvbyte;           /* bytes received in sequence */
284        u_long  tcps_rcvbadsum;         /* packets received with ccksum errs */
285        u_long  tcps_rcvbadoff;         /* packets received with bad offset */
286        u_long  tcps_rcvshort;          /* packets received too short */
287        u_long  tcps_rcvduppack;        /* duplicate-only packets received */
288        u_long  tcps_rcvdupbyte;        /* duplicate-only bytes received */
289        u_long  tcps_rcvpartduppack;    /* packets with some duplicate data */
290        u_long  tcps_rcvpartdupbyte;    /* dup. bytes in part-dup. packets */
291        u_long  tcps_rcvoopack;         /* out-of-order packets received */
292        u_long  tcps_rcvoobyte;         /* out-of-order bytes received */
293        u_long  tcps_rcvpackafterwin;   /* packets with data after window */
294        u_long  tcps_rcvbyteafterwin;   /* bytes rcvd after window */
295        u_long  tcps_rcvafterclose;     /* packets rcvd after "close" */
296        u_long  tcps_rcvwinprobe;       /* rcvd window probe packets */
297        u_long  tcps_rcvdupack;         /* rcvd duplicate acks */
298        u_long  tcps_rcvacktoomuch;     /* rcvd acks for unsent data */
299        u_long  tcps_rcvackpack;        /* rcvd ack packets */
300        u_long  tcps_rcvackbyte;        /* bytes acked by rcvd acks */
301        u_long  tcps_rcvwinupd;         /* rcvd window update packets */
302        u_long  tcps_pawsdrop;          /* segments dropped due to PAWS */
303        u_long  tcps_predack;           /* times hdr predict ok for acks */
304        u_long  tcps_preddat;           /* times hdr predict ok for data pkts */
305        u_long  tcps_pcbcachemiss;
306        u_long  tcps_cachedrtt;         /* times cached RTT in route updated */
307        u_long  tcps_cachedrttvar;      /* times cached rttvar updated */
308        u_long  tcps_cachedssthresh;    /* times cached ssthresh updated */
309        u_long  tcps_usedrtt;           /* times RTT initialized from route */
310        u_long  tcps_usedrttvar;        /* times RTTVAR initialized from rt */
311        u_long  tcps_usedssthresh;      /* times ssthresh initialized from rt*/
312        u_long  tcps_persistdrop;       /* timeout in persist state */
313        u_long  tcps_badsyn;            /* bogus SYN, e.g. premature ACK */
314        u_long  tcps_mturesent;         /* resends due to MTU discovery */
315        u_long  tcps_listendrop;        /* listen queue overflows */
316};
317
318/*
319 * TCB structure exported to user-land via sysctl(3).
320 * Evil hack: declare only if in_pcb.h and sys/socketvar.h have been
321 * included.  Not all of our clients do.
322 */
323#if defined(_NETINET_IN_PCB_H_) && defined(_SYS_SOCKETVAR_H_)
324struct  xtcpcb {
325        size_t  xt_len;
326        struct  inpcb   xt_inp;
327        struct  tcpcb   xt_tp;
328#if 0
329        struct  xsocket xt_socket;
330        u_quad_t        xt_alignment_hack;
331#endif
332};
333#endif
334
335/*
336 * Names for TCP sysctl objects
337 */
338#define TCPCTL_DO_RFC1323       1       /* use RFC-1323 extensions */
339#define TCPCTL_DO_RFC1644       2       /* use RFC-1644 extensions */
340#define TCPCTL_MSSDFLT          3       /* MSS default */
341#define TCPCTL_STATS            4       /* statistics (read-only) */
342#define TCPCTL_RTTDFLT          5       /* default RTT estimate */
343#define TCPCTL_KEEPIDLE         6       /* keepalive idle timer */
344#define TCPCTL_KEEPINTVL        7       /* interval to send keepalives */
345#define TCPCTL_SENDSPACE        8       /* send buffer space */
346#define TCPCTL_RECVSPACE        9       /* receive buffer space */
347#define TCPCTL_KEEPINIT         10      /* timeout for establishing syn */
348#define TCPCTL_PCBLIST          11      /* list of all outstanding PCBs */
349#define TCPCTL_MAXID            12
350
351#define TCPCTL_NAMES { \
352        { 0, 0 }, \
353        { "rfc1323", CTLTYPE_INT }, \
354        { "rfc1644", CTLTYPE_INT }, \
355        { "mssdflt", CTLTYPE_INT }, \
356        { "stats", CTLTYPE_STRUCT }, \
357        { "rttdflt", CTLTYPE_INT }, \
358        { "keepidle", CTLTYPE_INT }, \
359        { "keepintvl", CTLTYPE_INT }, \
360        { "sendspace", CTLTYPE_INT }, \
361        { "recvspace", CTLTYPE_INT }, \
362        { "keepinit", CTLTYPE_INT }, \
363}
364
365#ifdef _KERNEL
366#ifdef SYSCTL_DECL
367SYSCTL_DECL(_net_inet_tcp);
368#endif
369
370extern  struct inpcbhead tcb;           /* head of queue of active tcpcb's */
371extern  struct inpcbinfo tcbinfo;
372extern  struct tcpstat tcpstat; /* tcp statistics */
373extern  int tcp_mssdflt;        /* XXX */
374extern  u_long tcp_now;         /* for RFC 1323 timestamps */
375
376void     tcp_canceltimers(struct tcpcb *);
377struct tcpcb *
378         tcp_close(struct tcpcb *);
379void     tcp_ctlinput(int, struct sockaddr *, void *);
380int      tcp_ctloutput(int, struct socket *, int, int, struct mbuf **);
381struct tcpcb *
382         tcp_drop(struct tcpcb *, int);
383void     tcp_drain(void);
384void     tcp_fasttimo(void);
385struct rmxp_tao *
386         tcp_gettaocache(struct inpcb *);
387void     tcp_init(void);
388void     tcp_input(struct mbuf *, int);
389void     tcp_mss(struct tcpcb *, int);
390int      tcp_mssopt(struct tcpcb *);
391void     tcp_mtudisc(struct inpcb *, int);
392struct tcpcb *
393         tcp_newtcpcb(struct inpcb *);
394int      tcp_output(struct tcpcb *);
395void     tcp_quench(struct inpcb *, int);
396void     tcp_respond(struct tcpcb *,
397            struct tcpiphdr *, struct mbuf *, tcp_seq, tcp_seq, int);
398struct rtentry *
399         tcp_rtlookup(struct inpcb *);
400void     tcp_setpersist(struct tcpcb *);
401void     tcp_slowtimo(void);
402struct tcpiphdr *
403         tcp_template(struct tcpcb *);
404struct tcpcb *
405         tcp_timers(struct tcpcb *, int);
406void     tcp_trace(short, short, struct tcpcb *, struct tcpiphdr *, int);
407
408extern  struct pr_usrreqs tcp_usrreqs;
409extern  u_long tcp_sendspace;
410extern  u_long tcp_recvspace;
411
412#endif /* _KERNEL */
413
414#endif /* _NETINET_TCP_VAR_H_ */
Note: See TracBrowser for help on using the repository browser.