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