Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / resource / csdk / stack / samples / linux / secure / occlientbasicops.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH 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 #ifndef OCCLIENT_BASICOPS_H_
22 #define OCCLIENT_BASICOPS_H_
23
24 #include "ocstack.h"
25
26 //-----------------------------------------------------------------------------
27 // Typedefs
28 //-----------------------------------------------------------------------------
29
30 /**
31  * List of methods that can be inititated from the client
32  */
33 typedef enum {
34     TEST_DISCOVER_REQ = 1,
35     TEST_NON_CON_OP,
36     TEST_CON_OP,
37     MAX_TESTS
38 } CLIENT_TEST;
39
40 /**
41  * List of connectivity types that can be initiated from the client
42  * Required for user input validation
43  */
44 typedef enum {
45     CT_ADAPTER_DEFAULT = 0,
46     CT_IP,
47     MAX_CT
48 } CLIENT_CONNECTIVITY_TYPE;
49
50 //-----------------------------------------------------------------------------
51 // Function prototype
52 //-----------------------------------------------------------------------------
53
54 /* Get the IP address of the server */
55 std::string getIPAddrTBServer(OCClientResponse * clientResponse);
56
57 /* Get the port number the server is listening on */
58 std::string getPortTBServer(OCClientResponse * clientResponse);
59
60 /* Returns the query string for GET and PUT operations */
61 std::string getQueryStrForGetPut(OCClientResponse * clientResponse);
62
63 /* Following are initialization functions for GET, PUT
64  * POST & Discovery operations
65  */
66 int InitPutRequest(OCQualityOfService qos);
67 int InitGetRequest(OCQualityOfService qos);
68 int InitPostRequest(OCQualityOfService qos);
69 int InitDiscovery();
70
71 /* Function to retrieve ip address, port no. of the server
72  *  and query for the operations to be performed.
73  */
74 int parseClientResponse(OCClientResponse * clientResponse);
75
76 /* This method calls OCDoResource() which in turn makes calls
77  * to the lower layers
78  */
79 OCStackResult InvokeOCDoResource(std::ostringstream &query,
80         OCMethod method, OCQualityOfService qos,
81         OCClientResponseHandler cb, OCHeaderOption * options, uint8_t numOptions);
82
83 //-----------------------------------------------------------------------------
84 // Callback functions
85 //-----------------------------------------------------------------------------
86
87 /* Following are callback functions for the  GET, PUT
88  * POST & Discovery operations
89  */
90
91 OCStackApplicationResult putReqCB(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse);
92
93 OCStackApplicationResult postReqCB(void *ctx, OCDoHandle handle, OCClientResponse *clientResponse);
94
95 OCStackApplicationResult getReqCB(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse);
96
97 OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle,
98         OCClientResponse * clientResponse);
99
100 #endif
101