1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef OC_RESOURCEHANDLER_H
22 #define OC_RESOURCEHANDLER_H
25 #include "ocstackinternal.h"
26 #include "ocserverrequest.h"
28 #define OC_RSRVD_OC "oc"
29 #define OC_RSRVD_PAYLOAD "payload"
30 #define OC_RSRVD_HREF "href"
31 #define OC_RSRVD_REPRESENTATION "rep"
32 #define OC_RSRVD_CONTENT_TYPE "ct"
33 #define OC_RSRVD_RESOURCE_TYPE "rt"
34 #define OC_RSRVD_RESOURCE_TYPE_PRESENCE "core.presence"
35 #define OC_RSRVD_INTERFACE "if"
36 #define OC_RSRVD_DEVICE_ID "di"
37 #define OC_RSRVD_DEVICE_NAME "dn"
38 #define OC_RSRVD_INTERFACE_DEFAULT "oc.mi.def"
39 #define OC_RSRVD_INTERFACE_LL "oc.mi.ll"
40 #define OC_RSRVD_INTERFACE_BATCH "oc.mi.b"
41 #define OC_RSRVD_INTERFACE_GROUP "oc.mi.grp"
43 #define OC_RSRVD_MFG_DATE "mndt"
44 #define OC_RSRVD_FW_VERSION "mnfv"
45 #define OC_RSRVD_HOST_NAME "hn"
46 #define OC_RSRVD_MFG_NAME "mnmn"
47 #define OC_RSRVD_MFG_URL "mnml"
48 #define OC_RSRVD_MODEL_NUM "mnmo"
49 #define OC_RSRVD_PLATFORM_VERSION "mnpv"
50 #define OC_RSRVD_SUPPORT_URL "mnsl"
51 #define OC_RSRVD_VERSION "icv"
54 #define OC_RSRVD_OBSERVABLE "obs"
55 #define OC_RSRVD_SECURE "sec"
56 #define OC_RSRVD_HOSTING_PORT "port"
57 #define OC_RSRVD_SERVER_INSTANCE_ID "sid"
59 #define OC_JSON_PREFIX "{\"oc\":["
60 #define OC_JSON_PREFIX_LEN (sizeof(OC_JSON_PREFIX) - 1)
61 #define OC_JSON_SUFFIX "]}"
62 #define OC_JSON_SUFFIX_LEN (sizeof(OC_JSON_SUFFIX) - 1)
63 #define OC_JSON_SEPARATOR ','
64 #define OC_JSON_SEPARATOR_STR ","
66 #define OC_RESOURCE_OBSERVABLE 1
67 #define OC_RESOURCE_SECURE 1
71 STACK_RES_DISCOVERY_NOFILTER = 0,
72 STACK_RES_DISCOVERY_IF_FILTER,
73 STACK_RES_DISCOVERY_RT_FILTER,
74 STACK_DEVICE_DISCOVERY_DI_FILTER,
75 STACK_DEVICE_DISCOVERY_DN_FILTER
80 OC_RESOURCE_VIRTUAL = 0,
81 OC_RESOURCE_NOT_COLLECTION_WITH_ENTITYHANDLER,
82 OC_RESOURCE_NOT_COLLECTION_DEFAULT_ENTITYHANDLER,
83 OC_RESOURCE_COLLECTION_WITH_ENTITYHANDLER,
84 OC_RESOURCE_COLLECTION_DEFAULT_ENTITYHANDLER,
85 OC_RESOURCE_DEFAULT_DEVICE_ENTITYHANDLER,
86 OC_RESOURCE_NOT_SPECIFIED
89 OCEntityHandlerResult defaultResourceEHandler(OCEntityHandlerFlag flag,
90 OCEntityHandlerRequest * request);
92 const char * GetVirtualResourceUri( OCVirtualResources resource);
93 OCResource *FindResourceByUri(const char* resourceUri);
94 uint8_t IsVirtualResource(const char* resourceUri);
96 OCStackResult DetermineResourceHandling (OCServerRequest *request,
97 ResourceHandling *handling,
98 OCResource **resource);
101 ProcessRequest(ResourceHandling resHandling, OCResource *resource, OCServerRequest *request);
103 OCStackResult SaveDeviceInfo(OCDeviceInfo deviceInfo);
105 void DeleteDeviceInfo();
108 BuildVirtualResourceResponse(OCResource *resourcePtr, uint8_t filterOn,
109 char *filterValue, char * out, uint16_t *remaining,
110 CAConnectivityType_t connType );
112 OCStackResult EntityHandlerCodeToOCStackCode(OCEntityHandlerResult ehResult);
114 #endif //OC_RESOURCEHANDLER_H