Merge branch 'resource-container'
[platform/upstream/iotivity.git] / resource / csdk / stack / include / internal / oickeepalive.h
1 /* ****************************************************************
2  *
3  * Copyright 2015 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  * This file contains the APIs for KeepAlive Mechanism.
24  * In order to ensure that the connection between an OIC Devices,
25  * when using CoAP over TCP, OIC Device should send application layer
26  * KeepAlive messages.
27  */
28 #ifndef KEEP_ALIVE_H_
29 #define KEEP_ALIVE_H_
30
31 #include "octypes.h"
32 #include "ocserverrequest.h"
33 #include "ocresource.h"
34
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39
40 /**
41  * Name of resource type.
42  */
43 #define KEEPALIVE_RESOURCE_TYPE_NAME "oic.wk.ping"
44
45 /**
46  * Name of resource interface.
47  */
48 #define KEEPALIVE_RESOURCE_INTF_NAME "oic.if.rw"
49
50 /**
51  * URI of the resource.
52  */
53 #define KEEPALIVE_RESOURCE_URI "/oic/ping"
54
55 /**
56  * Initialize the KeepAlive.
57  * @return  ::OC_STACK_OK or Appropriate error code.
58  */
59 OCStackResult InitializeKeepAlive();
60
61 /**
62  * Terminates the KeepAlive.
63  * @return  ::OC_STACK_OK or Appropriate error code.
64  */
65 OCStackResult TerminateKeepAlive();
66
67 /**
68  * Process the KeepAlive timer to send ping message to OIC Server.
69  */
70 void ProcessKeepAlive();
71
72 /**
73  * This API will be called from RI layer whenever there is a request for KeepAlive.
74  * Virtual Resource.
75  * @param[in]   endPoint        RemoteEndpoint which sent the packet.
76  * @param[in]   requestInfo     Received coap packet.
77  * @return  ::OC_STACK_OK or Appropriate error code.
78  */
79 OCStackResult HandleKeepAliveRequest(const CAEndpoint_t* endPoint,
80                                      const CARequestInfo_t* requestInfo);
81
82 /**
83  * API to handle the connected device for KeepAlive.
84  * @return  Current Time.
85  */
86 void HandleKeepAliveConnCB(const CAEndpoint_t *endpoint);
87
88 /**
89  * API to handle the disconnected device for KeepAlive.
90  * @return  Current Time.
91  */
92 void HandleKeepAliveDisconnCB(const CAEndpoint_t *endpoint);
93
94 #ifdef __cplusplus
95 } // extern "C"
96 #endif
97
98 #endif // KEEP_ALIVE_H_