root/net/tcp/tcp.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. before
  2. after
  3. between

   1 /* tcp.h */
   2 /*
   3     Copyright (C) 1992  Ross Biro
   4 
   5     This program is free software; you can redistribute it and/or modify
   6     it under the terms of the GNU General Public License as published by
   7     the Free Software Foundation; either version 2, or (at your option)
   8     any later version.
   9 
  10     This program is distributed in the hope that it will be useful,
  11     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13     GNU General Public License for more details.
  14 
  15     You should have received a copy of the GNU General Public License
  16     along with this program; if not, write to the Free Software
  17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
  18 
  19     The Author may be reached as bir7@leland.stanford.edu or
  20     C/O Department of Mathematics; Stanford University; Stanford, CA 94305
  21 */
  22 /* $Id: tcp.h,v 0.8.4.1 1992/11/10 00:17:18 bir7 Exp $ */
  23 /* $Log: tcp.h,v $
  24  * Revision 0.8.4.1  1992/11/10  00:17:18  bir7
  25  * version change only.
  26  *
  27  * Revision 0.8.3.2  1992/11/10  00:14:47  bir7
  28  * Changed malloc to kmalloc and added $iId$ and $Log: tcp.h,v $
  29  * Revision 0.8.4.1  1992/11/10  00:17:18  bir7
  30  * version change only.
  31  *.
  32  * */
  33 
  34 #ifndef _TCP_TCP_H
  35 #define _TCP_TCP_H
  36 
  37 struct tcp_header
  38 {
  39   unsigned short source;
  40   unsigned short dest;
  41   unsigned long seq;
  42   unsigned long ack_seq;
  43   unsigned short res1:4, doff:4, fin:1, syn:1, rst:1, psh:1,
  44                  ack:1, urg:1,res2:2;
  45   unsigned short window;
  46   unsigned short check;
  47   unsigned short urg_ptr;
  48 };
  49 
  50 enum {
  51   TCP_ESTABLISHED=1,
  52   TCP_SYN_SENT,
  53   TCP_SYN_RECV,
  54   TCP_CLOSING, /* not a valid state, just a seperator so we can use
  55                   < tcp_closing or > tcp_closing for checks. */
  56   TCP_FIN_WAIT1,
  57   TCP_FIN_WAIT2,
  58   TCP_TIME_WAIT,
  59   TCP_CLOSE,
  60   TCP_LAST_ACK,
  61   TCP_LISTEN
  62 };
  63 
  64 #define MAX_SYN_SIZE 44 + sizeof (struct sk_buff) + MAX_HEADER
  65 #define MAX_FIN_SIZE 40 + sizeof (struct sk_buff) + MAX_HEADER
  66 #define MAX_ACK_SIZE 40 + sizeof (struct sk_buff) + MAX_HEADER
  67 #define MAX_RESET_SIZE 40 + sizeof (struct sk_buff) + MAX_HEADER
  68 #define MAX_WINDOW  12000
  69 #define MIN_WINDOW   2048
  70 #define MAX_ACK_BACKLOG 2
  71 #define MIN_WRITE_SPACE 2048
  72 #define TCP_WINDOW_DIFF 2048
  73 
  74 #define TCP_RETR1       7       /* this is howmany retries it does
  75                                    before it tries to figure out
  76                                    if the gateway is down. */
  77 
  78 #define TCP_RETR2      10       /* this should take between 3 and
  79                                    ten minutes ( 1024 * rtt). */
  80 
  81 
  82 #define TCP_TIMEOUT_LEN 720000 /* should be about 2 hrs. */
  83 #define TCP_TIMEWAIT_LEN 6000 /* How long to wait to sucessfully 
  84                                  close the socket, about 60 seconds. */
  85 #define TCP_ACK_TIME 35 /* time to delay before sending an ack. */
  86 #define TCP_DONE_TIME 2500 /* maximum time to wait before actually destroying
  87                              a socket. */
  88 #define TCP_WRITE_TIME 100 /* initial time to wait for an ack,
  89                               after last transmit. */
  90 #define TCP_CONNECT_TIME 200 /* time to retransmit first syn. */
  91 #define TCP_SYN_RETRIES 30 /* number of times to retry openning a connection.
  92                               */
  93 
  94 #define TCP_NO_CHECK 0 /* turn to one if you want the default to be no
  95                           checksum . */
  96 
  97 void print_th (struct tcp_header *);
  98 #define HEADER_SIZE 100
  99 
 100 
 101  /* this next routines deal with comparing 32 bit unsigned ints and
 102     worry about wrap around. The general strategy is to do a normal
 103     compare so long as neither of the numbers is within 4k of wrapping.
 104     Otherwise we must check for the wrap. */
 105 
 106  static inline int
 107  before (unsigned long seq1, unsigned long seq2)
     /* [previous][next][first][last][top][bottom][index][help] */
 108  {
 109    /* this inequality is strict. */
 110    if (seq1 == seq2) return (0);
 111    if (seq1 < seq2) 
 112      {
 113        if ((unsigned long)seq2-(unsigned long)seq1 < 32767UL) 
 114          {
 115            return (1);
 116          }
 117        else
 118          {
 119            return (0);
 120          }
 121      }
 122    /* now we know seq1 > seq2.  So all we need to do is check to see
 123       if seq1 has wrapped. */
 124    if (seq2 < 4096UL && seq1 > (0xffffffUL - 4096UL))
 125      {
 126        return (1);
 127      }
 128    return (0);
 129 
 130  }
 131 
 132  static inline int
 133  after (unsigned long seq1, unsigned long seq2)
     /* [previous][next][first][last][top][bottom][index][help] */
 134  {
 135    return (before (seq2, seq1));
 136  }
 137 
 138  /* is s2<=s1<=s3 ? */
 139  static inline int
 140  between (unsigned long seq1, unsigned long seq2, unsigned long seq3)
     /* [previous][next][first][last][top][bottom][index][help] */
 141  {
 142    return (after (seq1+1, seq2) && before (seq1, seq3+1));
 143  }
 144 
 145 #endif

/* [previous][next][first][last][top][bottom][index][help] */