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 ******************************************************************/
22 * @file caadapterutils.h
23 * @brief This file contains common utility function for CA transport adaptors.
26 #ifndef __CA_INTERFACE_CONTROLLER_H_
27 #define __CA_INTERFACE_CONTROLLER_H_
29 #include "caadapterinterface.h"
30 #include "uthreadpool.h" /* for thread pool */
38 * @brief Initializes different adapters based on the compilation flags.
39 * @param handle [IN] thread pool handle created by message handler for different adapters.
42 void CAInitializeAdapters(u_thread_pool_t handle);
45 * @brief Set the received packets callback for message handler
46 * @param callback [IN] message handler callback to receive packets from different adapters.
49 void CASetPacketReceivedCallback(CANetworkPacketReceivedCallback callback);
52 * @brief Set the network status changed callback for message handler
53 * @param callback [IN] message handler network status callback to receive network changes.
56 void CASetNetworkChangeCallback(CANetworkChangeCallback callback);
59 * @brief Starting different connectivity adapters based on the network selection.
60 * @param connectivity [IN] interested network for starting
63 void CAStartAdapter(CAConnectivityType_t connectivity);
66 * @brief Stopping different connectivity adapters based on the network un-selection.
67 * @param callback [IN] un selected network for stopping the packets transfer
70 void CAStopAdapter(CAConnectivityType_t connectivity);
73 * @brief Get network information such as ipaddress and mac information
74 * @param info [OUT] connectivity information such as ipaddress and mac information
75 * @param size [OUT] number of connectivity information structures
76 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
78 CAResult_t CAGetNetworkInfo(CALocalConnectivity_t **info, uint32_t *size);
81 * @brief Sends unicast data to the remote endpoint
82 * @param endpoint [IN] endpoint information where the data has to be sent
83 * @param data [IN] data that needs to be sent
84 * @param length [IN] length of the data that needs to be sent
85 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
87 CAResult_t CASendUnicastData(const CARemoteEndpoint_t *endpoint, void *data, uint32_t length);
90 * @brief Sends multicast data to all endpoints in the network.
91 * @param data [IN] data that needs to be sent
92 * @param length [IN] length of the data that needs to be sent
93 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
96 CAResult_t CASendMulticastData(void *data, uint32_t length);
99 * @brief Start listening servers to receive search requests from clients
100 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
102 CAResult_t CAStartListeningServerAdapters();
105 * @brief Start discovery servers to receive advertisements from server
106 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
108 CAResult_t CAStartDiscoveryServerAdapters();
111 * @brief Terminates the adapters which are initialized during the initialization
114 void CATerminateAdapters();
120 #endif //#ifndef __CA_INTERFACE_CONTROLLER_H_