Implementation of connectivity abstraction feature Release v0.61
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / camessagehandler.h
1 /******************************************************************
2  *
3  * Copyright 2014 Samsung Electronics 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  * @file camessagehandler.h
22  * @brief This file contains message functionality.
23  */
24
25 #ifndef __CA_MESSAGE_HANDLER_H_
26 #define __CA_MESSAGE_HANDLER_H_
27
28 #include <stdint.h>
29 #include "cacommon.h"
30
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35
36 /**
37  * @brief   Detaches control from the caller for sending unicast request
38  * @param   endpoint       [IN]    endpoint information where the data has to be sent
39  * @param   request              [IN]    request that needs to be sent
40  * @return  CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
41  */
42 CAResult_t CADetachRequestMessage(const CARemoteEndpoint_t *endpoint,
43                                   const CARequestInfo_t *request);
44
45 /**
46  * @brief   Detaches control from the caller for sending multicast request
47  * @param   endpoint       [IN]    endpoint information where the data has to be sent
48  * @param   request              [IN]    request that needs to be sent
49  * @return  CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
50  */
51 CAResult_t CADetachRequestToAllMessage(const CAGroupEndpoint_t *object,
52                                        const CARequestInfo_t *request);
53
54 /**
55  * @brief   Detaches control from the caller for sending response
56  * @param   endpoint       [IN]    endpoint information where the data has to be sent
57  * @param   response              [IN]    request that needs to be sent
58  * @return  CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
59  */
60 CAResult_t CADetachResponseMessage(const CARemoteEndpoint_t *endpoint,
61                                    const CAResponseInfo_t *response);
62
63 /**
64  * @brief   Detaches control from the caller for sending request
65  * @param   resourceUri       [IN]   resource uri that needs to  be sent in the request
66  * @param   token              [IN]    token information of the request
67  * @param   options       [IN]    header options that need to be append in the request
68  * @param   numOptions              [IN]    number of options be appended
69  * @return  CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
70  */
71 CAResult_t CADetachMessageResourceUri(const CAURI_t resourceUri, const CAToken_t token,
72                                       const CAHeaderOption_t *options, uint8_t numOptions);
73
74 /**
75  * @brief   Setting the request and response callbacks for network packets
76  * @param   ReqHandler       [IN]    callback for receiving the requests
77  * @param   RespHandler  [IN]    callback for receiving the response
78  * @return  void
79  */
80 void CASetRequestResponseCallbacks(CARequestCallback ReqHandler,
81                                    CAResponseCallback RespHandler);
82
83 /**
84  * @brief  Initialize the message handler by starting thread pool and initializing the send and reive queue
85  * @return  CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
86  */
87 CAResult_t CAInitializeMessageHandler();
88
89 /**
90  * @brief Terminate the message handler by stopping  the thread pool and destroying the queues
91  * @return  CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
92  */
93 void CATerminateMessageHandler();
94
95 /**
96  * @brief Handler for receiving request and response callback in singled thread model
97  */
98 void CAHandleRequestResponseCallbacks();
99
100 #ifdef __cplusplus
101 } /* extern "C" */
102 #endif
103
104 #endif //#ifndef __CA_MESSAGE_HANDLER_H_