New Structures and Macros For T/TCP

include/linux/tcp.h

 /*      a global non-zero variable that's incremented
  * everytime a new connection has been started
  */
     
     _u32 ttcp_gen;
 /* a macro used to increment ttcp_gen and ensures ttcp_gen to be non-zero when it's rounded-up */
     
     #define CC_INC(c) (++(c) == 0 ? ++(c) : (c))
 
   

include/net/tcp.h

 /* constants used in TCP options      */
     
     #define TCPOLEN_CC 6
     #define TCPOLEN_CC_NEW 6
     #define TCPOLEN_CC_ECHO 6
     #define TCPOLEN_CC_ALIGNED 8


include/net/dst.h in struct dst_entry{}

 /*      the per-host cache 
  * tao_cc is the CC value contained in the last SYN (no ACK) packet received      from the remote host 
  * tao_ccsent is the CC value contained in the last SYN (no ACK) packet sent      to the remote host 
  */
     
     struct rt_tao {
     __u32 tao_cc;
     __u32 tao_ccsent;
     } tao;
 
    

include/net/sock.h in struct tcp_opt{}

 /* the per-connection cache 
  * t_duration shows how long this connection has been in existence since active open
  * cc_send is the CC value contained in every packet sent to the remote host on this connection
  * cc_recv is the CC value contained in every packet received from the remote host on this connection
  */

 struct tcp_opt_cc {
 unsigned long t_duration;
 __u32 cc_send;
 __u32 cc_recv;
 } cc_cache;

 /* two booleans for T/TCP states */ 

 char TTCP_SENDSYN, TTCP_SENDFIN;

 /* values of T/TCP options parsed from incoming packets */ 

 __u32 cc;
 __u32 cc_new;
 __u32 cc_echo;

 /* a per-connection flag to enable or disable T/TCP */ 

 int do_rfc1644;

 /* macros to set two booleans for T/TCP states */ 

 #define TTCP_SENDSYN_ON(sk)	((sk)->tp_pinfo.af_tcp.TTCP_SENDSYN = 1)
 #define TTCP_SENDFIN_ON(sk)	((sk)->tp_pinfo.af_tcp.TTCP_SENDFIN = 1)
 #define TTCP_SENDSYN_OFF(sk)	((sk)->tp_pinfo.af_tcp.TTCP_SENDSYN = 0)
 #define TTCP_SENDFIN_OFF(sk)	((sk)->tp_pinfo.af_tcp.TTCP_SENDFIN = 0)

 /* macros to test T/TCP states */ 

 #define TTCP_SYN_SENT(sk)	((sk)->state == TCP_SYN_SENT && (!(sk)->tp_pinfo.af_tcp.TTCP_SENDSYN) && (sk)->tp_pinfo.af_tcp.TTCP_SENDFIN) 
 #define TTCP_SYN_RECV(sk)	((sk)->state == TCP_SYN_RECV && (!(sk)->tp_pinfo.af_tcp.TTCP_SENDSYN) && (sk)->tp_pinfo.af_tcp.TTCP_SENDFIN) 
 #define TTCP_ESTABLISHED(sk)	((sk)->state == TCP_ESTABLISHED && (!(sk)->tp_pinfo.af_tcp.TTCP_SENDFIN) && (sk)->tp_pinfo.af_tcp.TTCP_SENDSYN) 
 #define TTCP_CLOSE_WAIT(sk)	((sk)->state == TCP_CLOSE_WAIT && (!(sk)->tp_pinfo.af_tcp.TTCP_SENDFIN) && (sk)->tp_pinfo.af_tcp.TTCP_SENDSYN) 
 #define TTCP_LAST_ACK(sk) ((sk)->state == TCP_LAST_ACK && (!(sk)->tp_pinfo.af_tcp.TTCP_SENDFIN) && (sk)->tp_pinfo.af_tcp.TTCP_SENDSYN) 
 #define TTCP_FIN_WAIT1(sk)	((sk)->state == TCP_FIN_WAIT1 && (!(sk)->tp_pinfo.af_tcp.TTCP_SENDFIN) && (sk)->tp_pinfo.af_tcp.TTCP_SENDSYN)
 #define TTCP_CLOSING(sk) ((sk)->state == TCP_CLOSING && (!(sk)->tp_pinfo.af_tcp.TTCP_SENDFIN) && (sk)->tp_pinfo.af_tcp.TTCP_SENDSYN)