Imported Upstream version 0.9.1
[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
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
41  *                                  adapters.
42  * @return   none
43  */
44 void CAInitializeAdapters();
45
46 /**
47  * @brief   Set the received packets callback for message handler
48  * @param   callback        [IN]    message handler callback to receive packets from different
49  *                                  adapters.
50  * @return   none
51  */
52 void CASetPacketReceivedCallback(CANetworkPacketReceivedCallback callback);
53
54 /**
55  * @brief   Set the network status changed callback for message handler
56  * @param   callback        [IN]    message handler network status callback to receive network
57  *                                  changes.
58  * @return   none
59  */
60 void CASetNetworkChangeCallback(CANetworkChangeCallback callback);
61
62 /**
63  * @brief   Starting different connectivity adapters based on the network selection.
64  * @param   transportType    [IN]    network type that want to stop
65  * @return  none
66  */
67 CAResult_t CAStartAdapter(CATransportType_t transportType);
68
69 /**
70  * @brief   Stopping different connectivity adapters based on the network un-selection.
71  * @param   transportType    [IN]    un selected network for stopping the packets transfer
72  * @return   none
73  */
74 void CAStopAdapter(CATransportType_t transportType);
75
76 /**
77  * @brief   Get network information such as ipaddress and mac information.  Gets the network
78  *          information of the adapter whichever is enabled. Otherwise info is NULL.
79  * @param   info            [OUT]    connectivity information such as ipaddress and mac information
80  * @param   size            [OUT]    number of connectivity information structures
81  * @return   CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
82  */
83 CAResult_t CAGetNetworkInfo(CALocalConnectivity_t **info, uint32_t *size);
84
85 /**
86  * @brief   Sends unicast data to the remote endpoint
87  * @param   endpoint        [IN]    endpoint information where the data has to be sent
88  * @param   data            [IN]    data that needs to be sent
89  * @param   length          [IN]    length of the data that needs to be sent
90  * @return   CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
91  */
92 CAResult_t CASendUnicastData(const CARemoteEndpoint_t *endpoint, const void *data, uint32_t length);
93
94 /**
95  * @brief   Sends multicast data to all endpoints in the network.
96  * @param   data            [IN]    data that needs to be sent
97  * @param   length          [IN]    length of the data that needs to be sent
98  * @return   CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
99  */
100 CAResult_t CASendMulticastData(const void *data, uint32_t length);
101
102 /**
103  * @brief   Start listening servers to receive search requests from clients
104  * @return   CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
105  */
106 CAResult_t CAStartListeningServerAdapters();
107
108 /**
109  * @brief   Start discovery servers to receive advertisements from server
110  * @return   CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
111  */
112 CAResult_t CAStartDiscoveryServerAdapters();
113
114 /**
115  * @brief   Terminates  the adapters which are initialized during the initialization
116  * @return  none
117  */
118 void CATerminateAdapters();
119
120 /**
121  * @brief   Checks for available data and reads it
122  * @return   CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
123  */
124 CAResult_t CAReadData();
125
126 #ifdef __cplusplus
127 } /* extern "C" */
128 #endif
129
130 #endif /* CA_INTERFACE_CONTROLLER_SINGLETHREAD_H_ */
131