1 #ifndef __TIMER_H_ 2 #define __TIMER_H_ 3 4 #include "mtcp.h" 5 #include "tcp_stream.h" 6 7 #define RTO_HASH 2048 8 9 #define TIMEVAL_LT(a, b) \ 10 (((a)->tv_sec < (b)->tv_sec) ? 1 : \ 11 ((a)->tv_sec < (b)->tv_sec) ? 1 : \ 12 ((a)->tv_usec < (b)->tv_usec) ? 1 : 0) 13 14 struct timer { 15 int id; 16 struct timeval exp; /* expiration time */ 17 callback_t cb; 18 19 TAILQ_ENTRY(timer) timer_link; 20 }; 21 22 struct rto_hashstore 23 { 24 uint32_t rto_now_idx; // pointing the hs_table_s index 25 uint32_t rto_now_ts; // 26 27 TAILQ_HEAD(rto_head , tcp_stream) rto_list[RTO_HASH+1]; 28 }; 29 30 struct rto_hashstore* 31 InitRTOHashstore(); 32 33 extern inline void 34 AddtoRTOList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 35 36 extern inline void 37 RemoveFromRTOList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 38 39 extern inline void 40 AddtoTimewaitList(mtcp_manager_t mtcp, tcp_stream *cur_stream, uint32_t cur_ts); 41 42 extern inline void 43 RemoveFromTimewaitList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 44 45 extern inline void 46 AddtoTimeoutList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 47 48 extern inline void 49 RemoveFromTimeoutList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 50 51 extern inline void 52 UpdateTimeoutList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 53 54 extern inline void 55 UpdateRetransmissionTimer(mtcp_manager_t mtcp, 56 tcp_stream *cur_stream, uint32_t cur_ts); 57 58 void 59 CheckRtmTimeout(mtcp_manager_t mtcp, uint32_t cur_ts, int thresh); 60 61 void 62 CheckTimewaitExpire(mtcp_manager_t mtcp, uint32_t cur_ts, int thresh); 63 64 void 65 CheckConnectionTimeout(mtcp_manager_t mtcp, uint32_t cur_ts, int thresh); 66 67 void 68 DelTimer(mtcp_manager_t mtcp, struct timer *timer); 69 70 #endif /* __TIMER_H_ */ 71