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"
44 * Callback for bound JID
45 * @param[out] jid Boud Jabber Identifier.
47 typedef void (*CAJidBoundCallback)(char *jid);
50 * CA Remote Access information for XMPP Client
55 char *hostName; /**< XMPP server hostname */
56 uint16_t port; /**< XMPP server serivce port */
57 char *xmppDomain; /**< XMPP login domain */
58 char *userName; /**< login username */
59 char *password; /**< login password */
60 char *resource; /**< specific resource for login */
61 char *userJid; /**< specific JID for login */
62 CAJidBoundCallback jidBoundCallback; /**< callback when JID bound */
69 * Callback function to pass the connection information from CA to RI.
70 * @param[out] object remote device information.
72 typedef void (*CAKeepAliveConnectedCallback)(const CAEndpoint_t *object);
75 * Callback function to pass the disconnection information from CA to RI.
76 * @param[out] object remote device information.
78 typedef void (*CAKeepAliveDisconnectedCallback)(const CAEndpoint_t *object);
81 * Register connected callback and disconnected callback to process KeepAlive.
82 * connection informations are delivered these callbacks.
83 * @param[in] ConnHandler Connected callback.
84 * @param[in] DisconnHandler Disconnected Callback.
86 void CARegisterKeepAliveHandler(CAKeepAliveConnectedCallback ConnHandler,
87 CAKeepAliveDisconnectedCallback DisconnHandler);
90 * Initialize the connectivity abstraction module.
91 * It will initialize adapters, thread pool and other modules based on the platform
92 * compilation options.
94 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
96 CAResult_t CAInitialize();
99 * Terminate the connectivity abstraction module.
100 * All threads, data structures are destroyed for next initializations.
105 * Starts listening servers.
106 * This API is used by resource hosting server for listening multicast requests.
107 * Based on the adapters configurations, different kinds of servers are started.
108 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED
110 CAResult_t CAStartListeningServer();
113 * Stops the server from receiving the multicast traffic. This is used by sleeping
114 * device to not receives the multicast traffic.
115 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED
117 CAResult_t CAStopListeningServer();
120 * Starts discovery servers.
121 * This API is used by resource required clients for listening multicast requests.
122 * Based on the adapters configurations, different kinds of servers are started.
123 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED
125 CAResult_t CAStartDiscoveryServer();
128 * Register request callbacks and response callbacks.
129 * Requests and responses are delivered these callbacks.
130 * @param[in] ReqHandler Request callback ( for GET,PUT ..etc).
131 * @param[in] RespHandler Response Handler Callback.
132 * @param[in] ErrorHandler Error Handler Callback.
133 * @see CARequestCallback
134 * @see CAResponseCallback
135 * @see CAErrorCallback
137 void CARegisterHandler(CARequestCallback ReqHandler, CAResponseCallback RespHandler,
138 CAErrorCallback ErrorHandler);
141 * Create an endpoint description.
142 * @param[in] flags how the adapter should be used.
143 * @param[in] adapter which adapter to use.
144 * @param[in] addr string representation of address.
145 * @param[in] port port (for IP_ADAPTER).
146 * @param[out] object Endpoint which contains the above.
147 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_INVALID_PARAM
148 * @remark The created Remote endpoint can be freed using CADestroyEndpoint().
149 * @see CADestroyEndpoint
151 CAResult_t CACreateEndpoint(CATransportFlags_t flags,
152 CATransportAdapter_t adapter,
155 CAEndpoint_t **object);
158 * Destroy the remote endpoint created.
159 * @param[in] object Remote Endpoint object created with CACreateEndpoint.
161 void CADestroyEndpoint(CAEndpoint_t *object);
164 * Generating the token for matching the request and response.
165 * @param[out] token Token for the request.
166 * @param[in] tokenLength length of the token.
167 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or
168 * ::CA_MEMORY_ALLOC_FAILED or ::CA_STATUS_INVALID_PARAM
169 * @remark Token memory is destroyed by the caller using CADestroyToken().
170 * @see CADestroyToken
172 CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength);
175 * Destroy the token generated by CAGenerateToken.
176 * @param[in] token token to be freed.
178 void CADestroyToken(CAToken_t token);
181 * Send control Request on a resource.
182 * @param[in] object Endpoint where the payload need to be sent.
183 * This endpoint is delivered with Request or response callback.
184 * @param[in] requestInfo Information for the request.
185 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED or
186 ::CA_SEND_FAILED or ::CA_STATUS_INVALID_PARAM or ::CA_MEMORY_ALLOC_FAILED
188 CAResult_t CASendRequest(const CAEndpoint_t *object, const CARequestInfo_t *requestInfo);
192 * @param[in] object Endpoint where the payload need to be sent.
193 * This endpoint is delivered with Request or response callback.
194 * @param[in] responseInfo Information for the response.
195 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED or
196 ::CA_SEND_FAILED or ::CA_STATUS_INVALID_PARAM or ::CA_MEMORY_ALLOC_FAILED
198 CAResult_t CASendResponse(const CAEndpoint_t *object, const CAResponseInfo_t *responseInfo);
201 * Select network to use.
202 * @param[in] interestedNetwork Connectivity Type enum.
203 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED or
204 * ::CA_NOT_SUPPORTED or ::CA_ADAPTER_NOT_ENABLED or ::CA_MEMORY_ALLOC_FAILED
206 CAResult_t CASelectNetwork(CATransportAdapter_t interestedNetwork);
209 * Select network to unuse.
210 * @param[in] nonInterestedNetwork Connectivity Type enum.
211 * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED or ::CA_STATUS_FAILED or
212 ::CA_STATUS_NOT_INITIALIZED
214 CAResult_t CAUnSelectNetwork(CATransportAdapter_t nonInterestedNetwork);
217 * Get network information.
218 * It should be destroyed by the caller as it Get Information.
219 * @param[out] info LocalConnectivity objects
220 * @param[out] size No Of Array objects
221 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED or
222 * ::CA_STATUS_INVALID_PARAM or ::CA_MEMORY_ALLOC_FAILED
224 CAResult_t CAGetNetworkInformation(CAEndpoint_t **info, uint32_t *size);
227 * To Handle the Request or Response.
228 * @return ::CA_STATUS_OK or ::CA_STATUS_NOT_INITIALIZED
230 CAResult_t CAHandleRequestResponse();
234 * Set Remote Access information for XMPP Client.
235 * @param[in] caraInfo remote access info.
237 * @return ::CA_STATUS_OK or ::CA_STATUS_INVALID_PARAM
239 CAResult_t CASetRAInfo(const CARAInfo_t *caraInfo);
248 #endif /* CA_INTERFACE_H_ */