Merge branch 'master' into resource-manipulation
[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 "cathreadpool.h" /* for thread pool */
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37
38 /**
39  * @brief   Initializes different adapters based on the compilation flags.
40  * @param   handle         [IN]    thread pool handle created by message handler for different adapters.
41  * @return  none
42  */
43 void CAInitializeAdapters(ca_thread_pool_t handle);
44
45 /**
46  * @brief   Set the received packets callback for message handler
47  * @param   callback       [IN]    message handler callback to receive packets from different adapters.
48  * @return  none
49  */
50 void CASetPacketReceivedCallback(CANetworkPacketReceivedCallback callback);
51
52 /**
53  * @brief   Set the error handler callback for message handler
54  * @param   errorCallback       [IN]    error handler callback from adapters
55  * @return  none
56  */
57 void CASetErrorHandleCallback(CAErrorHandleCallback errorCallback);
58
59 /**
60  * @brief   Set the network status changed callback for message handler
61  * @param   callback       [IN]    message handler network status callback to receive network changes.
62  * @return  none
63  */
64 void CASetNetworkChangeCallback(CANetworkChangeCallback callback);
65
66 /**
67  * @brief   Starting different connectivity adapters based on the network selection.
68  * @param   transportType   [IN]    interested network for starting
69  * @return  CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
70  */
71 CAResult_t CAStartAdapter(CATransportAdapter_t transportType);
72
73 /**
74  * @brief   Stopping different connectivity adapters based on the network un-selection.
75  * @param   transportType   [IN]    network type that want to stop
76  * @return  none
77  */
78 void CAStopAdapter(CATransportAdapter_t transportType);
79
80 /**
81  * @brief   Get network information such as ipaddress and mac information
82  * @param   info           [OUT]    connectivity information such as ipaddress and mac information
83  * @param   size           [OUT]    number of connectivity information structures
84  * @return  CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
85  */
86 CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, uint32_t *size);
87
88 /**
89  * @brief   Sends unicast data to the remote endpoint
90  * @param   endpoint       [IN]    endpoint information where the data has to be sent
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)
94  */
95 CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length);
96
97 /**
98  * @brief   Sends multicast data to all endpoints in the network.
99  * @param   endpoint       [IN]    endpoint information where the data has to be sent
100  * @param   data           [IN]    data that needs to be sent
101  * @param   length         [IN]    length of the data that needs to be sent
102  * @return  CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
103  */
104
105 CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length);
106
107 /**
108  * @brief   Start listening servers to receive search requests from clients
109  * @return  CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
110  */
111 CAResult_t CAStartListeningServerAdapters();
112
113 /**
114  * @brief   Start discovery servers to receive advertisements from server
115  * @return  CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
116  */
117 CAResult_t CAStartDiscoveryServerAdapters();
118
119 /**
120  * @brief   Terminates  the adapters which are initialized during the initialization
121  * @return  none
122  */
123 void CATerminateAdapters();
124
125 #ifdef __cplusplus
126 } /* extern "C" */
127 #endif
128
129 #endif /* CA_INTERFACE_CONTROLLER_H_ */
130