/* copdefs.h */ #include "coplinux.h" #include "copuser.h" // #define DPRINTK #ifdef DPRINTK #define dprintk(format,args...) printk(format, ##args) #else #define dprintk(format,args...) #endif /* Header flag bits */ #define CPF_CONNECT 1 /* Connect request or connect ACK */ #define CPF_ACK 2 /* ACK number is valid */ #define CPF_FIN1 4 /* Close request or close ACK */ #define CPF_FIN2 8 /* Close request or close ACK */ #define CPF_WUP 16 /* Window update probe */ #define CPF_RESET 32 #define CPF_SUPV 64 /* Connection state flags */ #define CPS_UAD 1 /* Unacked datagram. */ #define CPS_AD 2 /* Acked datagram */ #define CPS_FCD 4 /* Flow controlled datagram */ #define CPS_TBF 8 #if 0 enum { TCP_ESTABLISHED = 1, TCP_SYN_SENT, TCP_SYN_RECV, TCP_FIN_WAIT1, TCP_FIN_WAIT2, TCP_TIME_WAIT, TCP_CLOSE, TCP_CLOSE_WAIT, TCP_LAST_ACK, TCP_LISTEN, TCP_CLOSING, /* Now a valid state */ TCP_MAX_STATES /* Leave at the end! */ } #endif #define COP_STATES 11 #define COP_PTYPES 8 /* Token bucket parameters */ #define TB_MAX_CREDIT 1000 /* packets */ #define WUP_DELAY 300 /* jiffiies*/ #define RESEND_DELAY 100 /* Received packet type codes */ #define CPT_RESET 0 #define CPT_SYN1 1 // Control packets #define CPT_SYN2 2 #define CPT_ACK 3 #define CPT_WUP 4 #define CPT_FIN1 5 #define CPT_FIN2 6 #define CPT_DATA 7 // Data packets #define CPT_UAD 10 #define CPT_FCD 11 #define CPT_AD 12 typedef struct cop_hdr { unsigned long cid; /* Connection ID */ unsigned short sport; /* src and dest ports */ unsigned short dport; unsigned short len; /* packet length */ unsigned char flags; unsigned char seq; unsigned char ack; unsigned char win; /* Window */ unsigned char cstate; /* CPS_UAD, etc */ unsigned char resvd; } cop_hdr_t; #define SEQ_SPACE_SIZE 256 #define COP_CONN_TIMEOUT 1000 #define COP_SEND_TIMEOUT 1000 /* 1000 jiffies = 1 secs */ #define COP_CONN_RETRIES 3 #define COP_SEND_DROP_THRESH 10 #define COP_MAX_TIMEOUTS 3 extern struct timespec xtime; typedef struct cop_oqe_type { struct sk_buff *skb; unsigned long txtime; } cop_oqe_t; typedef struct cop_sock { struct inet_sock inet; struct sock *sk; unsigned long cid; /* Connection id */ unsigned int state; /* CPS_UAD, etc... */ /* Network and transport headers */ struct iphdr iph; struct cop_hdr coph; /* Connection state data */ unsigned char nxtsnd; /* Next send seq num */ unsigned char nxtrcv; /* Next expected pkt */ unsigned char lastack; /* Last ack received */ unsigned char win; /* Offered window */ unsigned char uwin; /* Usable window */ unsigned char dup_acks; /* Duplicate ack ctr */ unsigned char wuppend; /* persist timer armed */ unsigned char maxrxqlen; /* Maximum rx qlen */ unsigned char rxfull; /* rx queue filled */ unsigned int disable; /* Prevents redundant fast retx */ struct timeval lasttx; /* Time of last tx for wup */ /* These ring buffers are indexed by packet sequence numbers */ /* and used to hold pointers to transmitted buffers pending */ /* acks and out of order received packets. For 8 bit seq */ /* SEQ_SPACE_SIZE = 256 */ cop_oqe_t ackpnd[SEQ_SPACE_SIZE]; cop_oqe_t rcvpnd[SEQ_SPACE_SIZE]; /* Performance metrics */ unsigned long timeouts; /* Timeouts */ unsigned long fastretx; /* Fast retransmissions */ unsigned long txdrops; /* Synthesized drops */ unsigned long rxdrops; /* Drops for rcv queue */ unsigned long txtotal; /* Total tx data packets */ unsigned long rxtotal; /* Total rx data packets */ unsigned long txwups; /* WUP requests sent */ unsigned long rxwups; /* WUP acks received */ unsigned long txacks; /* ACKs sent */ unsigned long rxacks; /* ACKs received */ unsigned long ooacks; /* out of order acks */ unsigned long dupacks; /* duplicate acks */ unsigned long tototal; /* Total timeouts */ unsigned long restarts; /* Token bucket flow control data */ unsigned int maxrate; /* max number of packets per jiffy */ unsigned int maxcredit; /* max accumlated credits */ unsigned int millicredits; /* current number of millicredits */ int tickintvl; /* in jiffies */ struct timeval lasttick; /* time of last tick... */ struct timer_list resend_timer; /* timer for send retransmits */ struct timer_list token_timer; /* timer token bucket timer */ struct timer_list persist_timer; /* persist timer */ spinlock_t cop_txlock; spinlock_t cop_loglock; spinlock_t cop_rxlock; } cop_sock_t;