1 #ifndef RANGEREQUESTTHREAD_H_
2 #define RANGEREQUESTTHREAD_H_
6 #define CHUNK_INFO_SIZE 3
7 #define MAX_HEADERS_SIZE 2048
8 #define MAX_RANGE_FIELD_LEN 100
10 #define FIRST_RSP_STATUS_SUCCESS 0
11 #define FIRST_RSP_STATUS_PENDING -2
12 #define FIRST_RSP_STATUS_FAILED -1
14 #define RANGE_REQUEST_THREAD_GET_FIRST_RANGE_STATUS(a) ((a)->firstRngStatus)
17 * @brief initialization of range request thread
18 * @param[in] rrthread range request thread
19 * @param[in] threadData threadData object
23 void range_request_thread_init(RangeRequestThread *rrthread, SmartBondingData *SBData);
26 * @brief start the range request thread
27 * @param[in] rrthread range request thread object
28 * @return status if thread is started
29 * @retval 1 range request thread created
30 * @retval 0 error creating range request thread
33 uint32 range_request_thread_start(RangeRequestThread *rrthread);
36 * @brief callback function while creating rr thread
37 * @param[in] pArg arguments passed in callback function
41 void *range_request_thread_rngreq_thread_callback(void *pArg);
44 * @brief range request thread run
45 * @param[in] rrthread range request thread object
49 void range_request_thread_run(RangeRequestThread *rrthread);
52 * @brief range_request_thread_reconnect
53 * @param[in] newRequest object to store new request
54 * @param[in] chunkInfo chunk information
55 * @param[in] rrthread range request thread
56 * @return range length and header length
59 uint32 range_request_thread_rebuild_req(int8 *newRequest, int64 *chunkInfo,
60 RangeRequestThread *rrthread);
63 * @brief exit the range request thread
64 * @param[in] rrthread range request thread object
68 void range_request_thread_exit(RangeRequestThread *rrthread);
71 * @brief process range request response headers
72 * @param[in] socket_fd socket file_descriptor
73 * @param[in] size size
74 * @param[in] timeout timeout for socket polling
75 * @param[in] instanceSize size of response instance
76 * @param[in] currChunkLen currChunkLen
77 * @param[in] bodylen response body length
78 * @param[in] blocksize blocksize
79 * @param[in] respLen length of response
80 * @return response decode status
81 * @retval 0 http response decoding success
82 * @retval -1 http response decoding error
83 * @retval -2 http response socket error
86 int32 range_request_recv_rng_rsp_headers(int32 socket_fd, uint32 size, uint32 timeout, uint64 instanceSize,
87 uint64 currChunkLen, int32 *bodyLen, int8 *blockSize, uint64 respLen, uint32 *connClose);
89 * @brief validate range request response
90 * @param[in] instanceSize instance size
91 * @param[in] httpRsp http response
92 * @param[in] currChunkLen current chunk len
93 * @param[in] respLen response length
94 * @return response decode status
95 * @retval -1 http response decoding error
96 * @retval 0 http response decoding success
99 int32 range_request_validate_rsp(uint64 instanceSize, httpResp *httpRsp,
100 uint64 currChunkLen, uint64 respLen, uint32 *connClose);
102 #endif /* RANGEREQUESTTHREAD_H_ */