root/include/net/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
  4. tcp_connected

   1 /*
   2  * INET         An implementation of the TCP/IP protocol suite for the LINUX
   3  *              operating system.  INET is implemented using the  BSD Socket
   4  *              interface as the means of communication with the user level.
   5  *
   6  *              Definitions for the TCP module.
   7  *
   8  * Version:     @(#)tcp.h       1.0.5   05/23/93
   9  *
  10  * Authors:     Ross Biro, <bir7@leland.Stanford.Edu>
  11  *              Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  12  *
  13  *              This program is free software; you can redistribute it and/or
  14  *              modify it under the terms of the GNU General Public License
  15  *              as published by the Free Software Foundation; either version
  16  *              2 of the License, or (at your option) any later version.
  17  */
  18 #ifndef _TCP_H
  19 #define _TCP_H
  20 
  21 #include <linux/tcp.h>
  22 
  23 #define MAX_SYN_SIZE    44 + MAX_HEADER + 15
  24 #define MAX_FIN_SIZE    40 + MAX_HEADER + 15
  25 #define MAX_ACK_SIZE    40 + MAX_HEADER + 15
  26 #define MAX_RESET_SIZE  40 + MAX_HEADER + 15
  27 #define MAX_WINDOW      16384
  28 #define MIN_WINDOW      2048
  29 #define MAX_ACK_BACKLOG 2
  30 #define MIN_WRITE_SPACE 2048
  31 #define TCP_WINDOW_DIFF 2048
  32 
  33 /* urg_data states */
  34 #define URG_VALID       0x0100
  35 #define URG_NOTYET      0x0200
  36 #define URG_READ        0x0400
  37 
  38 #define TCP_RETR1       7       /*
  39                                  * This is how many retries it does before it
  40                                  * tries to figure out if the gateway is
  41                                  * down.
  42                                  */
  43 
  44 #define TCP_RETR2       15      /*
  45                                  * This should take at least
  46                                  * 90 minutes to time out.
  47                                  */
  48 
  49 #define TCP_TIMEOUT_LEN (15*60*HZ) /* should be about 15 mins           */
  50 #define TCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to successfully 
  51                                   * close the socket, about 60 seconds  */
  52 #define TCP_FIN_TIMEOUT (3*60*HZ) /* BSD style FIN_WAIT2 deadlock breaker */                              
  53 #define TCP_ACK_TIME    (3*HZ)  /* time to delay before sending an ACK  */
  54 #define TCP_DONE_TIME   250     /* maximum time to wait before actually
  55                                  * destroying a socket                  */
  56 #define TCP_WRITE_TIME  3000    /* initial time to wait for an ACK,
  57                                  * after last transmit                  */
  58 #define TCP_TIMEOUT_INIT (3*HZ) /* RFC 1122 initial timeout value       */
  59 #define TCP_SYN_RETRIES  10     /* number of times to retry opening a
  60                                  * connection   (TCP_RETR2-....)        */
  61 #define TCP_PROBEWAIT_LEN 100   /* time to wait between probes when
  62                                  * I've got something to write and
  63                                  * there is no window                   */
  64 
  65 #define TCP_NO_CHECK    0       /* turn to one if you want the default
  66                                  * to be no checksum                    */
  67 
  68 
  69 /*
  70  *      TCP option
  71  */
  72  
  73 #define TCPOPT_NOP              1       /* Padding */
  74 #define TCPOPT_EOL              0       /* End of options */
  75 #define TCPOPT_MSS              2       /* Segment size negotiating */
  76 /*
  77  *      We don't use these yet, but they are for PAWS and big windows
  78  */
  79 #define TCPOPT_WINDOW           3       /* Window scaling */
  80 #define TCPOPT_TIMESTAMP        8       /* Better RTT estimations/PAWS */
  81 
  82 
  83 /*
  84  * The next routines deal with comparing 32 bit unsigned ints
  85  * and worry about wraparound (automatic with unsigned arithmetic).
  86  */
  87 
  88 extern __inline int before(__u32 seq1, __u32 seq2)
     /* [previous][next][first][last][top][bottom][index][help] */
  89 {
  90         return (__s32)(seq1-seq2) < 0;
  91 }
  92 
  93 extern __inline int after(__u32 seq1, __u32 seq2)
     /* [previous][next][first][last][top][bottom][index][help] */
  94 {
  95         return (__s32)(seq1-seq2) > 0;
  96 }
  97 
  98 
  99 /* is s2<=s1<=s3 ? */
 100 extern __inline int between(__u32 seq1, __u32 seq2, __u32 seq3)
     /* [previous][next][first][last][top][bottom][index][help] */
 101 {
 102         return (after(seq1+1, seq2) && before(seq1, seq3+1));
 103 }
 104 
 105 
 106 /*
 107  * List all states of a TCP socket that can be viewed as a "connected"
 108  * state.  This now includes TCP_SYN_RECV, although I am not yet fully
 109  * convinced that this is the solution for the 'getpeername(2)'
 110  * problem. Thanks to Stephen A. Wood <saw@cebaf.gov>  -FvK
 111  */
 112 extern __inline const int
 113 tcp_connected(const int state)
     /* [previous][next][first][last][top][bottom][index][help] */
 114 {
 115   return(state == TCP_ESTABLISHED || state == TCP_CLOSE_WAIT ||
 116          state == TCP_FIN_WAIT1   || state == TCP_FIN_WAIT2 ||
 117          state == TCP_SYN_RECV);
 118 }
 119 
 120 
 121 extern struct proto tcp_prot;
 122 
 123 
 124 extern void     tcp_err(int err, unsigned char *header, unsigned long daddr,
 125                         unsigned long saddr, struct inet_protocol *protocol);
 126 extern void     tcp_shutdown (struct sock *sk, int how);
 127 extern int      tcp_rcv(struct sk_buff *skb, struct device *dev,
 128                         struct options *opt, unsigned long daddr,
 129                         unsigned short len, unsigned long saddr, int redo,
 130                         struct inet_protocol *protocol);
 131 
 132 extern int      tcp_ioctl(struct sock *sk, int cmd, unsigned long arg);
 133 
 134 extern int tcp_select_window(struct sock *sk);
 135 extern void tcp_send_check(struct tcphdr *th, unsigned long saddr, 
 136                 unsigned long daddr, int len, struct sock *sk);
 137 extern void tcp_send_probe0(struct sock *sk);
 138 extern void tcp_enqueue_partial(struct sk_buff *, struct sock *);
 139 extern struct sk_buff * tcp_dequeue_partial(struct sock *);
 140 extern void tcp_cache_zap(void);
 141 
 142 #endif  /* _TCP_H */

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