5b9c04c53e63cc2de4bd1ca05706345efc6058cd
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / caraadapter.h
1 //*****************************************************************
2 //
3 // Copyright 2015 Intel Mobile Communications GmbH 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 caraadapter.h
23  * This file contains the APIs for IP Adapter.
24  */
25 #ifndef CA_RA_ADAPTER_H_
26 #define CA_RA_ADAPTER_H_
27
28 #include "cacommon.h"
29 #include "caadapterinterface.h"
30 #include "cathreadpool.h"
31
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36
37
38 /**
39  * API to initialize RA Interface.
40  * @param[in] registerCallback      Callback to register RA interfaces to
41  *                                   Connectivity Abstraction Layer.
42  * @param[in] networkPacketCallback Callback to notify request and
43  *                                   response messages from server(s)
44  *                                   started at Connectivity Abstraction Layer.
45  * @param[in] netCallback           Callback to notify the network
46  *                                   additions to Connectivity Abstraction
47  *                                   Layer.
48  * @param[in] handle                Threadpool Handle.
49  * @return  ::CA_STATUS_OK or Appropriate error code.
50  */
51 CAResult_t CAInitializeRA(CARegisterConnectivityCallback registerCallback,
52                           CANetworkPacketReceivedCallback networkPacketCallback,
53                           CANetworkChangeCallback netCallback,
54                           ca_thread_pool_t handle);
55
56
57 /**
58  * Start RA Interface adapter.
59  * @return  ::CA_STATUS_OK or Appropriate error code.
60  */
61 CAResult_t CAStartRA();
62
63 /**
64  * Sends data to the endpoint using the adapter connectivity.
65  * @param[in]   endpoint    Remote Endpoint information (like ipaddress, port,
66  *                           reference uri and transport type) to which
67  *                           the unicast data has to be sent.
68  * @param[in]   data        Data which is required to be sent.
69  * @param[in]   dataLen     Size of data to be sent.
70  * @note dataLen must be > 0.
71  * @return The number of bytes sent on the network, or -1 upon error.
72  */
73 int32_t CASendRAUnicastData(const CAEndpoint_t *endpoint, const void *data,
74                             uint32_t dataLen);
75
76 /**
77  * Get RA Connectivity network information.
78  * @param[out]   info        Local connectivity information structures.
79  * @note info is allocated in this API and should be freed by the caller.
80  * @param[out]   size        Number of local connectivity structures.
81  * @return  ::CA_STATUS_OK or Appropriate error code.
82  */
83 CAResult_t CAGetRAInterfaceInformation(CAEndpoint_t **info, uint32_t *size);
84
85 /**
86  * Stops RA server and de-register XMPP callback listeners.
87  * @return  ::CA_STATUS_OK or Appropriate error code.
88  */
89 CAResult_t CAStopRA();
90
91 /**
92  * Terminate the RA connectivity adapter.
93  * Configuration information will be deleted from further use.
94  */
95 void CATerminateRA();
96
97 /**
98  * Set Remote Access information for XMPP Client.
99  * @param[in]   caraInfo            remote access info.
100  *
101  * @return  ::CA_STATUS_OK.
102  */
103 CAResult_t CASetRAInfo(const CARAInfo_t *caraInfo);
104
105 /**
106  * These functions are not applicable to Remote Access adapter.
107  */
108 int32_t CASendRAMulticastData(const CAEndpoint_t *endpoint,
109                  const void *data, uint32_t dataLen);
110
111 /**
112  * Start listening server for receiving search requests.
113  * @return  ::CA_NOT_SUPPORTED.
114  */
115 CAResult_t CAStartRAListeningServer();
116
117 /**
118  * Stops listening server from receiving search requests.
119  * @return  ::CA_NOT_SUPPORTED.
120  */
121 CAResult_t CAStopRAListeningServer();
122
123 /**
124  * Start discovery servers for receiving advertisements.
125  * @return  ::CA_NOT_SUPPORTED.
126  */
127 CAResult_t CAStartRADiscoveryServer();
128
129 /**
130  * Read Synchronous API callback.
131  * @return  ::CA_NOT_SUPPORTED.
132  */
133 CAResult_t CAReadRAData();
134
135 #ifdef __cplusplus
136 } /* extern "C" */
137 #endif
138
139 #endif  //CA_RA_ADAPTER_H_