tizen 2.3 release
[framework/connectivity/multirat.git] / include / multirat_range_request_thread.h
1 #ifndef RANGEREQUESTTHREAD_H_
2 #define RANGEREQUESTTHREAD_H_
3
4 #include <pthread.h>
5
6 #define CHUNK_INFO_SIZE                         3
7 #define MAX_HEADERS_SIZE                        2048
8 #define MAX_RANGE_FIELD_LEN                     100
9
10 #define FIRST_RSP_STATUS_SUCCESS                0
11 #define FIRST_RSP_STATUS_PENDING                -2
12 #define FIRST_RSP_STATUS_FAILED                 -1
13
14 #define RANGE_REQUEST_THREAD_GET_FIRST_RANGE_STATUS(a) ((a)->firstRngStatus)
15
16 /**
17  * @brief                            initialization of range request thread
18  * @param[in]           rrthread     range request thread
19  * @param[in]           threadData   threadData object
20  * @return                           void
21  */
22
23 void range_request_thread_init(RangeRequestThread *rrthread, SmartBondingData *SBData);
24
25 /**
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
31  */
32
33 uint32 range_request_thread_start(RangeRequestThread *rrthread);
34
35 /**
36  * @brief                           callback function while creating rr thread
37  * @param[in]           pArg        arguments passed in callback function
38  * @return                          NULL
39  */
40
41 void *range_request_thread_rngreq_thread_callback(void *pArg);
42
43 /**
44  * @brief                           range request thread run
45  * @param[in]           rrthread    range request thread object
46  * @return                          void
47  */
48
49 void range_request_thread_run(RangeRequestThread *rrthread);
50
51 /**
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
57  */
58
59 uint32 range_request_thread_rebuild_req(int8 *newRequest, int64 *chunkInfo,
60                   RangeRequestThread *rrthread);
61
62 /**
63  * @brief                           exit the range request thread
64  * @param[in]           rrthread    range request thread object
65  * @return                          void
66  */
67
68 void range_request_thread_exit(RangeRequestThread *rrthread);
69
70 /**
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
84  */
85
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);
88 /**
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
97  */
98
99 int32 range_request_validate_rsp(uint64 instanceSize, httpResp *httpRsp,
100                   uint64 currChunkLen, uint64 respLen, uint32 *connClose);
101
102 #endif /* RANGEREQUESTTHREAD_H_ */
103