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