1 /* ****************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ******************************************************************/
24 * This file contains common utility function for CA transport adaptors.
27 #ifndef CA_INTERFACE_CONTROLLER_H_
28 #define CA_INTERFACE_CONTROLLER_H_
30 #include "caadapterinterface.h"
31 #include "cainterface.h"
32 #include "cautilinterface.h"
35 #include "cathreadpool.h" /* for thread pool */
45 * Initializes different adapters based on the compilation flags.
47 void CAInitializeAdapters();
50 * Initializes different adapters based on the compilation flags.
51 * @param[in] handle thread pool handle created by message handler
52 * for different adapters.
54 void CAInitializeAdapters(ca_thread_pool_t handle);
58 * Set the received packets callback for message handler.
59 * @param[in] callback message handler callback to receive packets
60 * from different adapters.
62 void CASetPacketReceivedCallback(CANetworkPacketReceivedCallback callback);
65 * Set the error handler callback for message handler.
66 * @param[in] errorCallback error handler callback from adapters
68 void CASetErrorHandleCallback(CAErrorHandleCallback errorCallback);
71 * Set the network status changed callback for CAUtil.
72 * @param[in] adapterCB CAUtil callback to receive adapter status changes.
73 * @param[in] connCB CAUtil callback to receive connection status changes.
75 void CASetNetworkMonitorCallbacks(CAAdapterStateChangedCB adapterCB,
76 CAConnectionStateChangedCB connCB);
79 * Unset the network status changed callback for CAUtil.
80 * @param[in] adapterCB CAUtil callback to receive adapter status changes.
81 * @param[in] connCB CAUtil callback to receive connection status changes.
82 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
84 CAResult_t CAUnsetNetworkMonitorCallbacks(CAAdapterStateChangedCB adapterCB,
85 CAConnectionStateChangedCB connCB);
88 * Starting different connectivity adapters based on the network selection.
89 * @param[in] transportType interested network for starting.
90 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
92 CAResult_t CAStartAdapter(CATransportAdapter_t transportType);
95 * Stopping different connectivity adapters based on the network un-selection.
96 * @param[in] transportType network type that want to stop.
98 void CAStopAdapter(CATransportAdapter_t transportType);
102 * Set Remote Access information for XMPP Client.
103 * @param[in] caraInfo remote access info..
105 * @return CA_STATUS_OK
107 CAResult_t CASetAdapterRAInfo(const CARAInfo_t *caraInfo);
111 * Get network information such as ipaddress and mac information.
112 * @param[out] info connectivity information
113 * such as ipaddress and mac information.
114 * @param[out] size number of connectivity information structures.
115 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
117 CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, uint32_t *size);
120 * Sends unicast data to the remote endpoint.
121 * @param[in] endpoint endpoint information where the data has to be sent.
122 * @param[in] data data that needs to be sent.
123 * @param[in] length length of the data that needs to be sent.
124 * @param[in] dataType Data type which is REQUEST or RESPONSE.
125 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
127 CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data,
128 uint32_t length, CADataType_t dataType);
131 * Sends multicast data to all endpoints in the network.
132 * @param[in] endpoint endpoint information where the data has to be sent.
133 * @param[in] data data that needs to be sent.
134 * @param[in] length length of the data that needs to be sent.
135 * @param[in] dataType Data type which is REQUEST or RESPONSE.
136 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
139 CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data,
140 uint32_t length, CADataType_t dataType);
143 * Start listening servers to receive search requests from clients.
144 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
146 CAResult_t CAStartListeningServerAdapters();
149 * Stop listening servers to receive search requests from clients.
150 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
152 CAResult_t CAStopListeningServerAdapters();
155 * Start discovery servers to receive advertisements from server.
156 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
158 CAResult_t CAStartDiscoveryServerAdapters();
161 * Terminates the adapters which are initialized during the initialization.
163 void CATerminateAdapters();
167 * Checks for available data and reads it.
168 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
170 CAResult_t CAReadData();
177 #endif /* CA_INTERFACE_CONTROLLER_H_ */