Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / cainterfacecontroller_singlethread.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 the APIs for the interface controller.
25  */
26
27 #ifndef CA_INTERFACE_CONTROLLER_SINGLETHREAD_H_
28 #define CA_INTERFACE_CONTROLLER_SINGLETHREAD_H_
29
30 #include "caadapterinterface.h"
31
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36
37 /**
38  * @brief   Initializes different adapters based on the compilation flags.
39  * @param   handle          [IN]    thread pool handle created by message handler for different
40  *                                  adapters.
41  * @return   none
42  */
43 void CAInitializeAdapters();
44
45 /**
46  * @brief   Set the received packets callback for message handler
47  * @param   callback        [IN]    message handler callback to receive packets from different
48  *                                  adapters.
49  * @return   none
50  */
51 void CASetPacketReceivedCallback(CANetworkPacketReceivedCallback callback);
52
53 /**
54  * @brief   Set the network status changed callback for message handler
55  * @param   callback        [IN]    message handler network status callback to receive network
56  *                                  changes.
57  * @return   none
58  */
59 void CASetNetworkChangeCallback(CANetworkChangeCallback callback);
60
61 /**
62  * @brief   Set the error handler callback for message handler
63  * @param   errorCallback       [IN]    error handler callback from adapters
64  * @return  none
65  */
66 void CASetErrorHandleCallback(CAErrorHandleCallback errorCallback);
67
68 /**
69  * @brief   Starting different connectivity adapters based on the network selection.
70  * @param   transportAdapter [IN]    network type that want to stop
71  * @return  none
72  */
73 CAResult_t CAStartAdapter(CATransportAdapter_t transportType);
74
75 /**
76  * @brief   Stopping different connectivity adapters based on the network un-selection.
77  * @param   transportAdapter [IN]    un selected network for stopping the packets transfer
78  * @return   none
79  */
80 void CAStopAdapter(CATransportAdapter_t transportType);
81
82 /**
83  * @brief   Get network information such as ipaddress and mac information.  Gets the network
84  *          information of the adapter whichever is enabled. Otherwise info is NULL.
85  * @param   info            [OUT]    connectivity information such as ipaddress and mac information
86  * @param   size            [OUT]    number of connectivity information structures
87  * @return   CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
88  */
89 CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, uint32_t *size);
90
91 /**
92  * @brief   Sends unicast data to the remote endpoint
93  * @param   endpoint        [IN]    endpoint information where the data has to be sent
94  * @param   data            [IN]    data that needs to be sent
95  * @param   length          [IN]    length of the data that needs to be sent
96  * @return   CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
97  */
98 CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length);
99
100 /**
101  * @brief   Sends multicast data to all endpoints in the network.
102  * @param   endpoint        [IN]    endpoint information where the data has to be sent
103  * @param   data            [IN]    data that needs to be sent
104  * @param   length          [IN]    length of the data that needs to be sent
105  * @return   CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
106  */
107 CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length);
108
109 /**
110  * @brief   Start listening servers to receive search requests from clients
111  * @return   CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
112  */
113 CAResult_t CAStartListeningServerAdapters();
114
115 /**
116  * @brief   Stops listening servers to receive search requests from clients
117  * @return   CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
118  */
119 CAResult_t CAStopListeningServerAdapters();
120
121 /**
122  * @brief   Start discovery servers to receive advertisements from server
123  * @return   CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
124  */
125 CAResult_t CAStartDiscoveryServerAdapters();
126
127 /**
128  * @brief   Terminates  the adapters which are initialized during the initialization
129  * @return  none
130  */
131 void CATerminateAdapters();
132
133 /**
134  * @brief   Checks for available data and reads it
135  * @return   CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
136  */
137 CAResult_t CAReadData();
138
139 #ifdef __cplusplus
140 } /* extern "C" */
141 #endif
142
143 #endif /* CA_INTERFACE_CONTROLLER_SINGLETHREAD_H_ */
144