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);
67 * Callback for bound JID
68 * @param[out] jid Boud Jabber Identifier.
70 typedef void (*CAJidBoundCallback)(char *jid);
73 * CA Remote Access information for XMPP Client
78 char *hostName; /**< XMPP server hostname */
79 uint16_t port; /**< XMPP server serivce port */
80 char *xmppDomain; /**< XMPP login domain */
81 char *userName; /**< login username */
82 char *password; /**< login password */
83 char *resource; /**< specific resource for login */
84 char *userJid; /**< specific JID for login */
85 CAJidBoundCallback jidBoundCallback; /**< callback when JID bound */
91 * Initialize the connectivity abstraction module.
92 * It will initialize adapters, thread pool and other modules based on the platform
93 * compilation options.
95 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
97 CAResult_t CAInitialize();
100 * Terminate the connectivity abstraction module.
101 * All threads, data structures are destroyed for next initializations.
106 * Starts listening servers.
107 * This API is used by resource hosting server for listening multicast requests.
108 * Based on the adapters configurations, different kinds of servers are started.
109 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED
111 CAResult_t CAStartListeningServer();
114 * Starts discovery servers.
115 * This API is used by resource required clients for listening multicast requests.
116 * Based on the adapters configurations, different kinds of servers are started.
117 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED
119 CAResult_t CAStartDiscoveryServer();
122 * Register request callbacks and response callbacks.
123 * Requests and responses are delivered these callbacks.
124 * @param[in] ReqHandler Request callback ( for GET,PUT ..etc).
125 * @param[in] RespHandler Response Handler Callback.
126 * @see CARequestCallback
127 * @see CAResponseCallback
128 * @see CAErrorCallback
130 void CARegisterHandler(CARequestCallback ReqHandler, CAResponseCallback RespHandler,
131 CAErrorCallback ErrorHandler);
134 * Create an endpoint description.
135 * @param[in] flags how the adapter should be used.
136 * @param[in] adapter which adapter to use.
137 * @param[in] addr string representation of address.
138 * @param[in] port port (for IP_ADAPTER).
139 * @param[in] endpoint Endpoint which contains the above.
140 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED
141 * @remark The created Remote endpoint can be freed using CADestroyEndpoint().
142 * @see CADestroyEndpoint
144 CAResult_t CACreateEndpoint(CATransportFlags_t flags,
145 CATransportAdapter_t adapter,
148 CAEndpoint_t **object);
151 * Destroy the remote endpoint created.
152 * @param[in] object Remote Endpoint object created with CACreateEndpoint.
154 void CADestroyEndpoint(CAEndpoint_t *object);
157 * Generating the token for matching the request and response.
158 * @param[in] token Token for the request.
159 * @param[in] tokenLength length of the token.
160 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or
161 * ::CA_MEMORY_ALLOC_FAILED or ::CA_STATUS_NOT_INITIALIZED
162 * @remark Token memory is destroyed by the caller using CADestroyToken().
163 * @see CADestroyToken
165 CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength);
168 * Destroy the token generated by CAGenerateToken.
169 * @param[in] token token to be freed.
171 void CADestroyToken(CAToken_t token);
174 * Send control Request on a resource.
175 * @param[in] object Endpoint where the payload need to be sent.
176 * This endpoint is delivered with Request or response callback.
177 * @param[in] requestInfo Information for the request.
178 * @return ::CA_STATUS_OK ::CA_STATUS_FAILED ::CA_MEMORY_ALLOC_FAILED
180 CAResult_t CASendRequest(const CAEndpoint_t *object, const CARequestInfo_t *requestInfo);
184 * @param[in] object Endpoint where the payload need to be sent.
185 * This endpoint is delivered with Request or response callback.
186 * @param[in] responseInfo Information for the response.
187 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
189 CAResult_t CASendResponse(const CAEndpoint_t *object, const CAResponseInfo_t *responseInfo);
192 * Send notification to the remote object.
193 * @param[in] object Endpoint where the payload need to be sent.
194 * This endpoint is delivered with Request or response callback.
195 * @param[in] responseInfo Information for the response.
196 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
198 CAResult_t CASendNotification(const CAEndpoint_t *object,
199 const CAResponseInfo_t *responseInfo);
202 * Select network to use.
203 * @param[in] interestedNetwork Connectivity Type enum.
204 * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED or
205 * ::CA_STATUS_FAILED or ::CA_NOT_SUPPORTED
207 CAResult_t CASelectNetwork(CATransportAdapter_t interestedNetwork);
210 * Select network to unuse.
211 * @param[in] nonInterestedNetwork Connectivity Type enum.
212 * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED or ::CA_STATUS_FAILED
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
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
230 CAResult_t CAHandleRequestResponse();
234 * Set Remote Access information for XMPP Client.
235 * @param[in] caraInfo remote access info.
237 * @return ::CA_STATUS_OK
239 CAResult_t CASetRAInfo(const CARAInfo_t *caraInfo);
248 #endif /* CA_INTERFACE_H_ */