Implementation of connectivity abstraction feature Release v0.5
[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 caadapterutils.h
23  * @brief This file contains common utility function for CA transport adaptors.
24  */
25
26 #ifndef __CA_INTERFACE_CONTROLLER_H_
27 #define __CA_INTERFACE_CONTROLLER_H_
28
29 #include "caadapterinterface.h"
30 #include "uthreadpool.h" /* for thread pool */
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 adapters.
40  * @return  none
41  */
42 void CAInitializeAdapters(u_thread_pool_t handle);
43
44 /**
45  * @brief   Set the received packets callback for message handler
46  * @param   callback       [IN]    message handler callback to receive packets from different adapters.
47  * @return  none
48  */
49 void CASetPacketReceivedCallback(CANetworkPacketReceivedCallback callback);
50
51 /**
52  * @brief   Set the network status changed callback for message handler
53  * @param   callback       [IN]    message handler network status callback to receive network changes.
54  * @return  none
55  */
56 void CASetNetworkChangeCallback(CANetworkChangeCallback callback);
57
58 /**
59  * @brief   Starting different connectivity adapters based on the network selection.
60  * @param   connectivity       [IN]    interested network for starting
61  * @return  none
62  */
63 void CAStartAdapter(CAConnectivityType_t connectivity);
64
65 /**
66  * @brief   Stopping different connectivity adapters based on the network un-selection.
67  * @param   callback       [IN]    un selected network for stopping the packets transfer
68  * @return  none
69  */
70 void CAStopAdapter(CAConnectivityType_t connectivity);
71
72 /**
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)
77  */
78 CAResult_t CAGetNetworkInfo(CALocalConnectivity_t **info, uint32_t *size);
79
80 /**
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)
86  */
87 CAResult_t CASendUnicastData(const CARemoteEndpoint_t* endpoint, void* data, uint32_t length);
88
89 /**
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)
94  */
95
96 CAResult_t CASendMulticastData(void *data, uint32_t length);
97
98 /**
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)
101  */
102 CAResult_t CAStartListeningServerAdapters();
103
104 /**
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)
107  */
108 CAResult_t CAStartDiscoveryServerAdapters();
109
110 /**
111  * @brief   Terminates  the adapters which are initialized during the initialization
112  * @return  none
113  */
114 void CATerminateAdapters();
115
116 #ifdef __cplusplus
117 } /* extern "C" */
118 #endif
119
120 #endif //#ifndef __CA_INTERFACE_CONTROLLER_H_