source: rtems/cpukit/libnetworking/netinet/tcp_var.h @ 2acc6ee

4.104.114.95
Last change on this file since 2acc6ee was 2acc6ee, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/01/08 at 06:33:59

Fix broken declaration of tcp_trace().

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