replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / stack / include / ocpayload.h
index 4b62813..7d39aa8 100644 (file)
 #ifndef __STDC_LIMIT_MACROS
 #define __STDC_LIMIT_MACROS
 #endif
+
 #include <stdbool.h>
 #include <inttypes.h>
 #include "octypes.h"
 
+#if defined(__WITH_TLS__) || defined(__WITH_DTLS__)
+#include "securevirtualresourcetypes.h"
+#endif
+
 #ifdef __cplusplus
 extern "C"
 {
@@ -40,12 +45,12 @@ extern "C"
  * Macro to verify the validity of cbor operation.
  */
 #define VERIFY_CBOR_SUCCESS(log_tag, err, log_message) \
-    if ((CborNoError != (err)) && (CborErrorOutOfMemory != (err))) \
+    if ((CborNoError != (CborError)(err)) && (CborErrorOutOfMemory != (CborError)(err))) \
     { \
         if ((log_tag) && (log_message)) \
         { \
             OIC_LOG_V(ERROR, (log_tag), "%s with cbor error: \'%s\'.", \
-                    (log_message), (cbor_error_string(err))); \
+                    (log_message), (cbor_error_string((CborError)err))); \
         } \
         goto exit; \
     } \
@@ -69,15 +74,18 @@ size_t calcDimTotal(const size_t dimensions[MAX_REP_ARRAY_DEPTH]);
 
 OCRepPayload* OCRepPayloadClone(const OCRepPayload* payload);
 
+OCRepPayload* OCRepPayloadBatchClone(const OCRepPayload* repPayload);
+
 void OCRepPayloadAppend(OCRepPayload* parent, OCRepPayload* child);
 
 bool OCRepPayloadSetUri(OCRepPayload* payload, const char* uri);
 
 bool OCRepPayloadAddResourceType(OCRepPayload* payload, const char* resourceType);
-bool OCRepPayloadAddInterface(OCRepPayload* payload, const char* interface);
+bool OCRepPayloadAddInterface(OCRepPayload* payload, const char* iface);
+bool OCRepPayloadAddModelVersion(OCRepPayload* payload, const char* dmv);
 
 bool OCRepPayloadAddResourceTypeAsOwner(OCRepPayload* payload, char* resourceType);
-bool OCRepPayloadAddInterfaceAsOwner(OCRepPayload* payload, char* interface);
+bool OCRepPayloadAddInterfaceAsOwner(OCRepPayload* payload, char* iface);
 
 bool OCRepPayloadIsNull(const OCRepPayload* payload, const char* name);
 bool OCRepPayloadSetNull(OCRepPayload* payload, const char* name);
@@ -133,10 +141,15 @@ bool OCRepPayloadSetPropBool(OCRepPayload* payload, const char* name, bool value
 bool OCRepPayloadGetPropBool(const OCRepPayload* payload, const char* name, bool* value);
 
 bool OCRepPayloadSetPropObject(OCRepPayload* payload, const char* name, const OCRepPayload* value);
-bool OCRepPayloadSetPropObjectAsOwner(OCRepPayload* payload, const char* name,
-        OCRepPayload* value);
+bool OCRepPayloadSetPropObjectAsOwner(OCRepPayload* payload, const char* name, OCRepPayload* value);
 bool OCRepPayloadGetPropObject(const OCRepPayload* payload, const char* name, OCRepPayload** value);
 
+#ifdef __WITH_TLS__
+bool OCRepPayloadSetPropPubDataType(OCRepPayload *payload, const char *name, const OicSecKey_t *value);
+bool OCRepPayloadSetPropPubDataTypeAsOwner(OCRepPayload *payload, const char *name, const OicSecKey_t *value);
+bool OCRepPayloadGetPropPubDataType(const OCRepPayload *payload, const char *name, OicSecKey_t *value);
+#endif
+
 /**
  * This function allocates memory for the byte string array and sets it in the payload.
  *
@@ -222,8 +235,13 @@ OCDiscoveryPayload* OCDiscoveryPayloadCreate();
 OCSecurityPayload* OCSecurityPayloadCreate(const uint8_t* securityData, size_t size);
 void OCSecurityPayloadDestroy(OCSecurityPayload* payload);
 
+#ifndef TCP_ADAPTER
+void OCDiscoveryPayloadAddResource(OCDiscoveryPayload* payload, const OCResource* res,
+                                   uint16_t securePort);
+#else
 void OCDiscoveryPayloadAddResource(OCDiscoveryPayload* payload, const OCResource* res,
                                    uint16_t securePort, uint16_t tcpPort);
+#endif
 void OCDiscoveryPayloadAddNewResource(OCDiscoveryPayload* payload, OCResourcePayload* res);
 bool OCResourcePayloadAddStringLL(OCStringLL **payload, const char* type);
 
@@ -233,26 +251,41 @@ OCResourcePayload* OCDiscoveryPayloadGetResource(OCDiscoveryPayload* payload, si
 void OCDiscoveryResourceDestroy(OCResourcePayload* payload);
 void OCDiscoveryPayloadDestroy(OCDiscoveryPayload* payload);
 
-// Device Payload
-OCDevicePayload* OCDevicePayloadCreate(const char* sid, const char* dname,
-        const OCStringLL *types, const char* specVer, const char* dmVer);
-void OCDevicePayloadDestroy(OCDevicePayload* payload);
-
-// Platform Payload
-OCPlatformPayload* OCPlatformPayloadCreate(const OCPlatformInfo* platformInfo);
-OCPlatformPayload* OCPlatformPayloadCreateAsOwner(OCPlatformInfo* platformInfo);
-void OCPlatformInfoDestroy(OCPlatformInfo *info);
-void OCPlatformPayloadDestroy(OCPlatformPayload* payload);
-
+#ifdef WITH_PRESENCE
 // Presence Payload
 OCPresencePayload* OCPresencePayloadCreate(uint32_t seqNum, uint32_t maxAge,
         OCPresenceTrigger trigger, const char* resourceType);
 void OCPresencePayloadDestroy(OCPresencePayload* payload);
+#endif
 
 // Helper API
 OCStringLL* CloneOCStringLL (OCStringLL* ll);
 void OCFreeOCStringLL(OCStringLL* ll);
 
+/**
+ * This function creates a list from a string (with separated contents if several)
+ * @param text         single string or CSV text fields
+ * @return newly allocated linked list
+ * @note separator is ',' (according to rfc4180, ';' is not valid)
+ **/
+OCStringLL* OCCreateOCStringLL(const char* text);
+
+/**
+ * This function creates a string from a list (with separated contents if several)
+ * @param ll           Pointer to list
+ * @return newly allocated string. Caller takes ownership and must later free this memory with OICFree.
+ * @note separator is ',' (according to rfc4180)
+ **/
+char* OCCreateString(const OCStringLL* ll);
+
+/**
+ * This function copies contents (and allocates if necessary)
+ * @param dest existing bytestring (or null to allocate here)
+ * @param source existing bytestring
+ * @return true of success false on any errors
+ **/
+bool OCByteStringCopy(OCByteString *dest, const OCByteString *source);
+
 #ifdef __cplusplus
 }
 #endif