Merge branch 'plugin-interface' into master
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / cainterfacecontroller.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
23  *
24  * This file contains common utility function for CA transport adaptors.
25  */
26
27 #ifndef CA_INTERFACE_CONTROLLER_H_
28 #define CA_INTERFACE_CONTROLLER_H_
29
30 #include "caadapterinterface.h"
31 #include "cainterface.h"
32
33 #ifndef SINGLE_THREAD
34 #include "cathreadpool.h" /* for thread pool */
35 #endif
36
37 #ifdef __cplusplus
38 extern "C"
39 {
40 #endif
41
42 #ifdef SINGLE_THREAD
43 /**
44  * Initializes different adapters based on the compilation flags.
45  */
46 void CAInitializeAdapters();
47 #else
48 /**
49  * Initializes different adapters based on the compilation flags.
50  * @param[in]   handle           thread pool handle created by message handler
51  *                               for different adapters.
52  */
53 void CAInitializeAdapters(ca_thread_pool_t handle);
54 #endif
55
56 /**
57  * Set the received packets callback for message handler.
58  * @param[in]   callback         message handler callback to receive packets
59  *                               from different adapters.
60  */
61 void CASetPacketReceivedCallback(CANetworkPacketReceivedCallback callback);
62
63 /**
64  * Set the error handler callback for message handler.
65  * @param[in]   errorCallback    error handler callback from adapters
66  */
67 void CASetErrorHandleCallback(CAErrorHandleCallback errorCallback);
68
69 /**
70  * Set the network status changed callback for message handler.
71  * @param[in]   callback         message handler network status callback
72  *                               to receive network changes.
73  */
74 void CASetNetworkChangeCallback(CANetworkChangeCallback callback);
75
76 /**
77  * Starting different connectivity adapters based on the network selection.
78  * @param[in]   transportType    interested network for starting.
79  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
80  */
81 CAResult_t CAStartAdapter(CATransportAdapter_t transportType);
82
83 /**
84  * Stopping different connectivity adapters based on the network un-selection.
85  * @param[in]   transportType    network type that want to stop.
86  */
87 void CAStopAdapter(CATransportAdapter_t transportType);
88
89 #ifdef RA_ADAPTER
90 /**
91  * Set Remote Access information for XMPP Client.
92  * @param[in]   caraInfo         remote access info..
93  *
94  * @return  CA_STATUS_OK
95  */
96 CAResult_t CASetAdapterRAInfo(const CARAInfo_t *caraInfo);
97 #endif
98
99 /**
100  * Get network information such as ipaddress and mac information.
101  * @param[out]   info           connectivity information
102  *                                  such as ipaddress and mac information.
103  * @param[out]   size           number of connectivity information structures.
104  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
105  */
106 CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, uint32_t *size);
107
108 /**
109  * Sends unicast data to the remote endpoint.
110  * @param[in]   endpoint       endpoint information where the data has to be sent.
111  * @param[in]   data           data that needs to be sent.
112  * @param[in]   length         length of the data that needs to be sent.
113  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
114  */
115 CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length);
116
117 /**
118  * Sends multicast data to all endpoints in the network.
119  * @param[in]   endpoint       endpoint information where the data has to be sent.
120  * @param[in]   data           data that needs to be sent.
121  * @param[in]   length         length of the data that needs to be sent.
122  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
123  */
124
125 CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length);
126
127 /**
128  * Start listening servers to receive search requests from clients.
129  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
130  */
131 CAResult_t CAStartListeningServerAdapters();
132
133 /**
134  * Stop listening servers to receive search requests from clients.
135  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
136  */
137 CAResult_t CAStopListeningServerAdapters();
138
139 /**
140  * Start discovery servers to receive advertisements from server.
141  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
142  */
143 CAResult_t CAStartDiscoveryServerAdapters();
144
145 /**
146  * Terminates the adapters which are initialized during the initialization.
147  */
148 void CATerminateAdapters();
149
150 #ifdef SINGLE_THREAD
151 /**
152  * Checks for available data and reads it.
153  * @return   ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
154  */
155 CAResult_t CAReadData();
156 #endif
157
158 #ifdef __cplusplus
159 } /* extern "C" */
160 #endif
161
162 #endif /* CA_INTERFACE_CONTROLLER_H_ */
163