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 */
68 * Initialize the connectivity abstraction module.
69 * It will initialize adapters, thread pool and other modules based on the platform
70 * compilation options.
72 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
74 CAResult_t CAInitialize();
77 * Terminate the connectivity abstraction module.
78 * All threads, data structures are destroyed for next initializations.
83 * Starts listening servers.
84 * This API is used by resource hosting server for listening multicast requests.
85 * Based on the adapters configurations, different kinds of servers are started.
86 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED
88 CAResult_t CAStartListeningServer();
91 * Stops the server from receiving the multicast traffic. This is used by sleeping
92 * device to not receives the multicast traffic.
93 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED
95 CAResult_t CAStopListeningServer();
98 * Starts discovery servers.
99 * This API is used by resource required clients for listening multicast requests.
100 * Based on the adapters configurations, different kinds of servers are started.
101 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED
103 CAResult_t CAStartDiscoveryServer();
106 * Register request callbacks and response callbacks.
107 * Requests and responses are delivered these callbacks.
108 * @param[in] ReqHandler Request callback ( for GET,PUT ..etc).
109 * @param[in] RespHandler Response Handler Callback.
110 * @see CARequestCallback
111 * @see CAResponseCallback
112 * @see CAErrorCallback
114 void CARegisterHandler(CARequestCallback ReqHandler, CAResponseCallback RespHandler,
115 CAErrorCallback ErrorHandler);
118 * Create an endpoint description.
119 * @param[in] flags how the adapter should be used.
120 * @param[in] adapter which adapter to use.
121 * @param[in] addr string representation of address.
122 * @param[in] port port (for IP_ADAPTER).
123 * @param[in] endpoint Endpoint which contains the above.
124 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED
125 * @remark The created Remote endpoint can be freed using CADestroyEndpoint().
126 * @see CADestroyEndpoint
128 CAResult_t CACreateEndpoint(CATransportFlags_t flags,
129 CATransportAdapter_t adapter,
132 CAEndpoint_t **object);
135 * Destroy the remote endpoint created.
136 * @param[in] object Remote Endpoint object created with CACreateEndpoint.
138 void CADestroyEndpoint(CAEndpoint_t *object);
141 * Generating the token for matching the request and response.
142 * @param[in] token Token for the request.
143 * @param[in] tokenLength length of the token.
144 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or
145 * ::CA_MEMORY_ALLOC_FAILED or ::CA_STATUS_NOT_INITIALIZED
146 * @remark Token memory is destroyed by the caller using CADestroyToken().
147 * @see CADestroyToken
149 CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength);
152 * Destroy the token generated by CAGenerateToken.
153 * @param[in] token token to be freed.
155 void CADestroyToken(CAToken_t token);
158 * Send control Request on a resource.
159 * @param[in] object Endpoint where the payload need to be sent.
160 * This endpoint is delivered with Request or response callback.
161 * @param[in] requestInfo Information for the request.
162 * @return ::CA_STATUS_OK ::CA_STATUS_FAILED ::CA_MEMORY_ALLOC_FAILED
164 CAResult_t CASendRequest(const CAEndpoint_t *object, const CARequestInfo_t *requestInfo);
168 * @param[in] object Endpoint where the payload need to be sent.
169 * This endpoint is delivered with Request or response callback.
170 * @param[in] responseInfo Information for the response.
171 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
173 CAResult_t CASendResponse(const CAEndpoint_t *object, const CAResponseInfo_t *responseInfo);
176 * Select network to use.
177 * @param[in] interestedNetwork Connectivity Type enum.
178 * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED or
179 * ::CA_STATUS_FAILED or ::CA_NOT_SUPPORTED
181 CAResult_t CASelectNetwork(CATransportAdapter_t interestedNetwork);
184 * Select network to unuse.
185 * @param[in] nonInterestedNetwork Connectivity Type enum.
186 * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED or ::CA_STATUS_FAILED
188 CAResult_t CAUnSelectNetwork(CATransportAdapter_t nonInterestedNetwork);
191 * Get network information.
192 * It should be destroyed by the caller as it Get Information.
193 * @param[out] info LocalConnectivity objects
194 * @param[out] size No Of Array objects
195 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or
196 * ::CA_STATUS_INVALID_PARAM or ::CA_MEMORY_ALLOC_FAILED
198 CAResult_t CAGetNetworkInformation(CAEndpoint_t **info, uint32_t *size);
201 * To Handle the Request or Response.
202 * @return ::CA_STATUS_OK
204 CAResult_t CAHandleRequestResponse();
208 * Set Remote Access information for XMPP Client.
209 * @param[in] caraInfo remote access info.
211 * @return ::CA_STATUS_OK
213 CAResult_t CASetRAInfo(const CARAInfo_t *caraInfo);
222 #endif /* CA_INTERFACE_H_ */