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