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