API change , Retransmission Callback on expiry , remove glib source for dynamic linking
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / caadapterinterface.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 /**
22  * @file caadapterinterface.h
23  * @brief This file contains the APIs for adapters to be implemented
24  */
25 #ifndef __CA_ADAPTER_INTERFACE_H_
26 #define __CA_ADAPTER_INTERFACE_H_
27
28 #include "cacommon.h"
29
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34
35 /**
36  * @brief Starting connectivity adapters and each adapter have transport specific behavior.
37  * Transport Specific Behavior:
38  * WIFI/ETH connectivity Starts unicast server on  all available IPs and defined
39  * port number as per specification.
40  * EDR will not start any specific servers.
41  * LE will not start any specific servers.
42  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
43  */
44 typedef CAResult_t (*CAAdapterStart)();
45
46 /**
47  * @brief Starting listening server for receiving multicast search requests
48  * Transport Specific Behavior:
49  * WIFI/ETH Starts multicast server on  all available IPs and defined
50  * port number and as per specification.
51  * EDR  Starts RFCOMM Server with prefixed UUID as per specification.
52  * LE Start GATT Server with prefixed UUID and Characteristics as per OIC Specification.
53  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
54  */
55 typedef CAResult_t (*CAAdapterStartListeningServer)();
56
57 /**
58  * @brief for starting discovery servers for receiving multicast advertisements
59  * Transport Specific Behavior:
60  * WIFI/ETH Starts multicast server on all available IPs and defined port
61  * number as per OIC Specification.
62  * EDR Starts RFCOMM Server with prefixed UUID as per OIC Specification.
63  * LE Starts GATT Server with prefixed UUID and Characteristics as per OIC Specification.
64  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
65  */
66 typedef CAResult_t (*CAAdapterStartDiscoveryServer)();
67
68 /**
69  * @brief Sends data to the endpoint using the adapter connectivity.
70  * Note: length must be > 0.
71  * @param   endpoint    [IN]    Remote Endpoint information (like ipaddress , port,
72  * reference uri and connectivity type) to which the unicast data has to be sent.
73  * @param   data        [IN]    Data which required to be sent.
74  * @param   dataLen     [IN]    Size of data to be sent.
75  * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
76  */
77 typedef uint32_t (*CAAdapterSendUnitcastData)(const CARemoteEndpoint_t *endpoint, void *data,
78         uint32_t dataLen);
79
80 /**
81  * @brief Sends Multicast data to the endpoint using the adapter connectivity.
82  * Note: length must be > 0.
83  * @param   data        [IN]    Data which required to be sent.
84  * @param   dataLen     [IN]    Size of data to be sent.
85  * @return - The number of bytes sent on the network. Return value equal to zero indicates error.
86  */
87 typedef uint32_t (*CAAdapterSendMulticastData)(void *data, uint32_t dataLen);
88
89 /**
90  * @brief Get Network Information
91  * @param   info        [OUT]   Local connectivity information structures
92  * @param   size        [OUT]   Number of local connectivity structures.
93  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
94  */
95 typedef CAResult_t (*CAAdapterGetNetworkInfo)(CALocalConnectivity_t **info, uint32_t *size);
96
97 /**
98  * @brief Read Synchronous API callback.
99  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
100  */
101 typedef CAResult_t (*CAAdapterReadData)();
102
103 /**
104  * @brief Stopping the adapters and close socket connections
105  * Transport Specific Behavior:
106  * WIFI/ETH Stops all listening servers and close sockets.
107  * EDR Stops all RFCOMM servers and close sockets.
108  * LE Stops all GATT servers and close sockets.
109  * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
110  */
111 typedef CAResult_t (*CAAdapterStop)();
112
113 /**
114  * @brief Terminate the connectivity adapter.Configuration information will be deleted from
115  * further use
116  */
117 typedef void (*CAAdapterTerminate)();
118
119 /**
120  * @brief Connectivity handler information for adapter
121  */
122 typedef struct
123 {
124     /** Start Transport specific functions*/
125     CAAdapterStart startAdapter;
126     /** Listening Server function address*/
127     CAAdapterStartListeningServer startListenServer;
128     /** Discovery Server function address **/
129     CAAdapterStartDiscoveryServer startDiscoverServer;
130     /** Unicast data function address**/
131     CAAdapterSendUnitcastData sendData;
132     /** Multicast data function address**/
133     CAAdapterSendMulticastData sendDataToAll;
134     /** Get Networking information  **/
135     CAAdapterGetNetworkInfo GetnetInfo;
136     /** Read Data function address**/
137     CAAdapterReadData readData;
138     /** Stop Transport specific functions*/
139     CAAdapterStop stopAdapter;
140     /** Terminate function address stored in this pointer**/
141     CAAdapterTerminate terminate;
142
143 } CAConnectivityHandler_t;
144
145 /**
146  * @brief This will be used during the registration of adapters call backs to the common logic
147  * @see CAConnectivityHandler_t , CAConnectivityType_t
148  */
149 typedef void (*CARegisterConnectivityCallback)(CAConnectivityHandler_t handler,
150         CAConnectivityType_t cType);
151
152 /**
153  * @brief This will be used during the recive of network requests and response.
154  * @see SendUnitcastData(), SendMulticastData()
155  */
156 typedef void (*CANetworkPacketReceivedCallback)(CARemoteEndpoint_t *endPoint, void *data,
157         uint32_t dataLen);
158
159 /**
160  * @brief This will be used to intimate network changes to the connectivity common logic layer
161  * @see SendUnitcastData(), SendMulticastData()
162  */
163 typedef void (*CANetworkChangeCallback)(CALocalConnectivity_t *info, CANetworkStatus_t status);
164
165 /**
166  * @brief This will be used during the recive of network requests and response.
167  * @see SendUnitcastData(), SendMulticastData()
168  */
169 typedef CAResult_t (*CABLEClientDataReceivedCallback)(const char *remoteAddress, const char *serviceUUID,
170         void *data, uint32_t dataLength, uint32_t *sentLength);
171
172 /**
173  * @brief This will be used during the recive of network requests and response.
174  * @see SendUnitcastData(), SendMulticastData()
175  */
176 typedef CAResult_t (*CABLEServerDataReceivedCallback)(const char *remoteAddress, const char *serviceUUID,
177         void *data, uint32_t dataLength, uint32_t *sentLength);
178 #ifdef __cplusplus
179 } /* extern "C" */
180 #endif
181
182 #endif  // __CA_ADAPTER_INTERFACE_H_