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