Merge "Fix compiler warnings" into connectivity-abstraction
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / caretransmission.h
1 /******************************************************************
2  *
3  * Copyright 2014 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ******************************************************************/
20 /**
21  * @file caretransmission.h
22  * @brief
23  */
24 #ifndef __CA_RETRANSMISSION_H_
25 #define __CA_RETRANSMISSION_H_
26
27 #include <stdint.h>
28
29 #include "uthreadpool.h"
30 #include "umutex.h"
31 #include "uarraylist.h"
32 #include "cacommon.h"
33
34 /** CA_ETHERNET, CA_WIFI **/
35 #define DEFAULT_RETRANSMISSION_TYPE     ((1<<0)|(1<<1))
36
37 /** default retransmission trying count is 4. **/
38 #define DEFAULT_RETRANSMISSION_COUNT    4
39
40 /** check period is 1 sec. **/
41 #define RETRANSMISSION_CHECK_PERIOD     1000000
42
43 /** retransmission data send method type**/
44 typedef CAResult_t (*CADataSendMethod_t)(const CARemoteEndpoint_t *endpoint, void *data,
45         uint32_t length);
46
47 typedef struct
48 {
49     /** retransmission support connectivity type **/
50     CAConnectivityType_t supportType;
51     /** retransmission trying count **/
52     uint8_t tryingCount;
53
54 } CARetransmissionConfig_t;
55
56 typedef struct
57 {
58     /** Thread pool of the thread started **/
59     u_thread_pool_t threadPool;
60     /** mutex for synchrnoization **/
61     u_mutex threadMutex;
62     /** conditional mutex for synchrnoization **/
63     u_cond threadCond;
64     /** send method for retransmission data **/
65     CADataSendMethod_t dataSendMethod;
66     /** retransmission configure data **/
67     CARetransmissionConfig_t config;
68     /** Variable to inform the thread to stop **/
69     CABool_t isStop;
70     /** array list on which the thread is operating. **/
71     u_arraylist_t* dataList;
72 } CARetransmission_t;
73
74 #ifdef __cplusplus
75 extern "C"
76 {
77 #endif
78
79 CAResult_t CARetransmissionInitialize(CARetransmission_t* context, u_thread_pool_t handle,
80         CADataSendMethod_t retransmissionSendMethod, CARetransmissionConfig_t* config);
81
82 CAResult_t CARetransmissionStart(CARetransmission_t* context);
83
84 CAResult_t CARetransmissionSentData(CARetransmission_t* context, const CARemoteEndpoint_t* endpoint,
85         const void* pdu, uint32_t size);
86
87 CAResult_t CARetransmissionReceivedData(CARetransmission_t* context,
88         const CARemoteEndpoint_t* endpoint, const void* pdu, uint32_t size);
89
90 CAResult_t CARetransmissionStop(CARetransmission_t* context);
91
92 CAResult_t CARetransmissionDestroy(CARetransmission_t* context);
93
94 #ifdef __cplusplus
95 } /* extern "C" */
96 #endif
97
98 #endif  // __CA_RETRANSMISSION_H_