1 /* ****************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ******************************************************************/
24 * This file contains the APIs for Resource Model to use.
27 #ifndef CA_INTERFACE_H_
28 #define CA_INTERFACE_H_
31 * Connectivity Abstraction Interface APIs.
34 #include "casecurityinterface.h"
42 * Callback function type for request delivery.
43 * @param[out] object Endpoint object from which the request is received.
44 * It contains endpoint address based on the connectivity type.
45 * @param[out] requestInfo Info for resource model to understand about the request.
47 typedef void (*CARequestCallback)(const CAEndpoint_t *object,
48 const CARequestInfo_t *requestInfo);
51 * Callback function type for response delivery.
52 * @param[out] object Endpoint object from which the response is received.
53 * @param[out] responseInfo Identifier which needs to be mapped with response.
55 typedef void (*CAResponseCallback)(const CAEndpoint_t *object,
56 const CAResponseInfo_t *responseInfo);
58 * Callback function type for error.
59 * @param[out] object remote device information.
60 * @param[out] errorInfo CA Error information.
62 typedef void (*CAErrorCallback)(const CAEndpoint_t *object,
63 const CAErrorInfo_t *errorInfo);
66 * Initialize the connectivity abstraction module.
67 * It will initialize adapters, thread pool and other modules based on the platform
68 * compilation options.
70 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
72 CAResult_t CAInitialize();
75 * Terminate the connectivity abstraction module.
76 * All threads, data structures are destroyed for next initializations.
81 * Starts listening servers.
82 * This API is used by resource hosting server for listening multicast requests.
83 * Based on the adapters configurations, different kinds of servers are started.
84 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED
86 CAResult_t CAStartListeningServer();
89 * Stops the server from receiving the multicast traffic. This is used by sleeping
90 * device to not receives the multicast traffic.
91 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED
93 CAResult_t CAStopListeningServer();
96 * Starts discovery servers.
97 * This API is used by resource required clients for listening multicast requests.
98 * Based on the adapters configurations, different kinds of servers are started.
99 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED
101 CAResult_t CAStartDiscoveryServer();
104 * Register request callbacks and response callbacks.
105 * Requests and responses are delivered these callbacks.
106 * @param[in] ReqHandler Request callback ( for GET,PUT ..etc).
107 * @param[in] RespHandler Response Handler Callback.
108 * @see CARequestCallback
109 * @see CAResponseCallback
110 * @see CAErrorCallback
112 void CARegisterHandler(CARequestCallback ReqHandler, CAResponseCallback RespHandler,
113 CAErrorCallback ErrorHandler);
116 * Create an endpoint description.
117 * @param[in] flags how the adapter should be used.
118 * @param[in] adapter which adapter to use.
119 * @param[in] addr string representation of address.
120 * @param[in] port port (for IP_ADAPTER).
121 * @param[in] endpoint Endpoint which contains the above.
122 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED
123 * @remark The created Remote endpoint can be freed using CADestroyEndpoint().
124 * @see CADestroyEndpoint
126 CAResult_t CACreateEndpoint(CATransportFlags_t flags,
127 CATransportAdapter_t adapter,
130 CAEndpoint_t **object);
133 * Destroy the remote endpoint created.
134 * @param[in] object Remote Endpoint object created with CACreateEndpoint.
136 void CADestroyEndpoint(CAEndpoint_t *object);
139 * Generating the token for matching the request and response.
140 * @param[in] token Token for the request.
141 * @param[in] tokenLength length of the token.
142 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or
143 * ::CA_MEMORY_ALLOC_FAILED or ::CA_STATUS_NOT_INITIALIZED
144 * @remark Token memory is destroyed by the caller using CADestroyToken().
145 * @see CADestroyToken
147 CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength);
150 * Destroy the token generated by CAGenerateToken.
151 * @param[in] token token to be freed.
153 void CADestroyToken(CAToken_t token);
156 * Send control Request on a resource.
157 * @param[in] object Endpoint where the payload need to be sent.
158 * This endpoint is delivered with Request or response callback.
159 * @param[in] requestInfo Information for the request.
160 * @return ::CA_STATUS_OK ::CA_STATUS_FAILED ::CA_MEMORY_ALLOC_FAILED
162 CAResult_t CASendRequest(const CAEndpoint_t *object, const CARequestInfo_t *requestInfo);
166 * @param[in] object Endpoint where the payload need to be sent.
167 * This endpoint is delivered with Request or response callback.
168 * @param[in] responseInfo Information for the response.
169 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
171 CAResult_t CASendResponse(const CAEndpoint_t *object, const CAResponseInfo_t *responseInfo);
174 * Select network to use.
175 * @param[in] interestedNetwork Connectivity Type enum.
176 * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED or
177 * ::CA_STATUS_FAILED or ::CA_NOT_SUPPORTED
179 CAResult_t CASelectNetwork(CATransportAdapter_t interestedNetwork);
182 * Select network to unuse.
183 * @param[in] nonInterestedNetwork Connectivity Type enum.
184 * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED or ::CA_STATUS_FAILED
186 CAResult_t CAUnSelectNetwork(CATransportAdapter_t nonInterestedNetwork);
189 * Get network information.
190 * It should be destroyed by the caller as it Get Information.
191 * @param[out] info LocalConnectivity objects
192 * @param[out] size No Of Array objects
193 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or
194 * ::CA_STATUS_INVALID_PARAM or ::CA_MEMORY_ALLOC_FAILED
196 CAResult_t CAGetNetworkInformation(CAEndpoint_t **info, uint32_t *size);
199 * To Handle the Request or Response.
200 * @return ::CA_STATUS_OK
202 CAResult_t CAHandleRequestResponse();
206 * Set Remote Access information for XMPP Client.
207 * @param[in] caraInfo remote access info.
209 * @return ::CA_STATUS_OK
211 CAResult_t CASetRAInfo(const CARAInfo_t *caraInfo);
220 #endif /* CA_INTERFACE_H_ */