1 #ifndef MULTIRAT_WATCH_DOG_H_
2 #define MULTIRAT_WATCH_DOG_H_
4 #include "multirat_SB_http.h"
5 #include "multirat_connection.h"
13 /*struct http_sample {
19 * @brief initialize cthread
24 CThread * cthread_init(void);
27 * @brief thread function running
28 * @param[in] cthread CThread object
34 void cthread_run_thread(SmartBondingData *SBData);
37 * @brief get the bytes from range request header
38 * @param[in] start buffer to store the bytes
39 * @param[in] rangeHeader rangeHeader to decode
40 * @return bytes of range request
41 * @retval 1 bytes updated in param start
45 int32 get_bytesof_range_request(uint64 *start, int8 *rangeHeader);
48 * @brief check if connection is keep-alive
49 * @param[in] SBData Smart bonding object
50 * @return status of connection
51 * @retval 1 connection header is keep alive
52 * @retval 0 connection header is not keep alive
55 int32 is_connection_header_keepalive(SmartBondingData *SBData);
58 * @brief start the watch_dog_thread
59 * @param[in] cthread cthread object
63 void cthread_start_thread(SmartBondingData *SBData);
66 * @brief watch dog thread entry function
67 * @param[in] pArg cthread entry params
70 void * cthread_entry_function (void *pArg);
73 * @brief check the status of the thread
74 * @param[in] cthread cthread object
75 * @return status of cthread
76 * @return 0 thread init
77 * @retval 1 thread running
78 * @retval 2 thread finish
80 int32 cthread_get_thread_status(CThread *cthread);
83 * @brief exit the watch dog thread
84 * @param[in] cthread cthread object
87 void cthread_exit(CThread *cthread);
90 * @brief creat,bind and check the watch dog thread
91 * @param[in] SBData smartbonding data object
92 * @return status of connection
93 * @retval 0 successful connection
96 int32 watchdog_test_connection_type(SmartBondingData *SBData);
99 * @brief calculate no of chunks in watchdog thread
100 * @param[in] chunkSize chunk size
101 * @param[in] noOfChunks total no of chunks
102 * @param[in] lastChunk last chunk
103 * @param[in] totalSize total size
106 void multirat_watchdogthread_calnochunks(uint32 chunkSize,uint32 *noOfChunks,uint32 *lastChunk,uint64 totalSize);
109 * @brief get request without range from range header
110 * @param[in] oldReq old request
111 * @param[in] newReq new request
112 * @param[in] rangeHeader rangeHeader
113 * @param[in] rangeStart range start buffer
114 * @return status of getting request from header
115 * @retval 1 successfully removed range header
116 * @retval 0 copied old request to new request
117 * @retval -1 unseccessful decoding of range request
119 int32 get_req_without_range(int8 *oldReq, int8 *newReq, int8 *rangeHeader, uint64 *rangeStart);
121 int32 check_speed(SmartBondingData *SBData, uint32 timeT2, uint32 resp_offset,
122 uint32 resp_len, int8 *recv_buf, int32 socket, uint64 contLength);
124 void switch_to_watchdog(SmartBondingData *SBData, uint32 resp_offset, uint32 resp_len, int8 *recv_buf, int32 socket);
126 void file_cthread_run_thread(SmartBondingData *SBData);
128 int32 file_thread_FirstConnection(SmartBondingData *SBData, fileThread *fThread, int64 *chunkInfo, int8 *recv_buf, int32 *lengthRcvd);