X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fstack%2Finclude%2Finternal%2Focstackinternal.h;h=4885b566035576bef754e549fc54be9f8921e87a;hb=53427ddcd8a79536638ce85e61a6630a9e6b3139;hp=d1051050eb978e807ab998f6bacee4aef0fe7ff8;hpb=01be9765a95ede47003777ee576fe9a4de4229e5;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/stack/include/internal/ocstackinternal.h b/resource/csdk/stack/include/internal/ocstackinternal.h index d105105..4885b56 100644 --- a/resource/csdk/stack/include/internal/ocstackinternal.h +++ b/resource/csdk/stack/include/internal/ocstackinternal.h @@ -66,8 +66,8 @@ extern void* defaultDeviceHandlerCallbackParameter; /** The coap scheme */ #define OC_COAP_SCHEME "coap://" -/** the first outgoing sequence number will be 5*/ -#define OC_OFFSET_SEQUENCE_NUMBER (4) +/** the first outgoing sequence number will be 1*/ +#define OC_OFFSET_SEQUENCE_NUMBER (0) /** * This structure will be created in occoap and passed up the stack on the server side. @@ -99,7 +99,7 @@ typedef struct uint8_t numRcvdVendorSpecificHeaderOptions; /** Array of received vendor specific header option .*/ - OCHeaderOption rcvdVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS]; + OCHeaderOption *rcvdVendorSpecificHeaderOptions; /** Remote end-point address **/ OCDevAddr devAddr; @@ -136,33 +136,6 @@ typedef struct } OCServerProtocolRequest; /** - * This structure will be created in occoap and passed up the stack on the client side. - */ -typedef struct -{ - /** handle is retrieved by comparing the token-handle pair in the PDU.*/ - ClientCB * cbNode; - - /** This is how long this response is valid for (in seconds).*/ - uint32_t maxAge; - - /** This is the Uri of the resource. (ex. "coap://192.168.1.1/a/led").*/ - char * fullUri; - - /** This is the relative Uri of the resource. (ex. "/a/led").*/ - char * rcvdUri; - - /** This is the received payload.*/ - char * bufRes; - - /** This is the token received OTA.*/ - CAToken_t rcvdToken; - - /** this structure will be passed to client.*/ - OCClientResponse * clientResponse; -} OCResponse; - -/** * This typedef is to represent our Server Instance identification. */ typedef uint8_t ServerID[16]; @@ -202,7 +175,8 @@ OCStackResult HandleStackRequests(OCServerProtocolRequest * protocolRequest); OCStackResult SendDirectStackResponse(const CAEndpoint_t* endPoint, const uint16_t coapID, const CAResponseResult_t responseResult, const CAMessageType_t type, const uint8_t numOptions, const CAHeaderOption_t *options, - CAToken_t token, uint8_t tokenLength, const char *resourceUri); + CAToken_t token, uint8_t tokenLength, const char *resourceUri, + CADataType_t dataType); #ifdef WITH_PRESENCE @@ -256,6 +230,14 @@ OCStackResult BindResourceInterfaceToResource(OCResource* resource, OCStackResult BindResourceTypeToResource(OCResource* resource, const char *resourceTypeName); +/** + * Convert OCStackResult to CAResponseResult_t. + * + * @param ocCode OCStackResult code. + * @param method OCMethod method the return code replies to. + * @return ::CA_CONTENT on OK, some other value upon failure. + */ +CAResponseResult_t OCToCAStackResult(OCStackResult ocCode, OCMethod method); /** * Converts a CAResult_t type to a OCStackResult type. @@ -266,29 +248,12 @@ OCStackResult BindResourceTypeToResource(OCResource* resource, OCStackResult CAResultToOCResult(CAResult_t caResult); /** - * Get a byte representation of the server instance ID. - * The memory is managed internal to this function, so freeing it externally will - * result in a runtime error. + * Converts a OCStackResult type to a bool type. * - * Note: This will NOT seed the RNG, so it must be called after the RNG is seeded. - * This is done automatically during the OCInit process, - * so ensure that this call is done after that. - * - * @return A uint8_t representation the server instance ID. - */ -const OicUuid_t* OCGetServerInstanceID(void); - -/** - * Get a string representation the server instance ID. - * The memory is managed internal to this function, so freeing externally will result - * in a runtime error. - * Note: This will NOT seed the RNG, so it must be called after the RNG is seeded. - * This is done automatically during the OCInit process, - * so ensure that this call is done after that. - * - * @return A string representation the server instance ID. + * @param ocResult OCStackResult value to convert. + * @return true on success, false upon failure. */ -const char* OCGetServerInstanceIDString(void); +bool OCResultToSuccess(OCStackResult ocResult); /** * Map OCQualityOfService to CAMessageType. @@ -312,19 +277,98 @@ CAMessageType_t qualityOfServiceToMessageType(OCQualityOfService qos); //TODO: should the following function be public? OCStackResult OCChangeResourceProperty(OCResourceProperty * inputProperty, OCResourceProperty resourceProperties, uint8_t enable); -#endif const char *convertTriggerEnumToString(OCPresenceTrigger trigger); OCPresenceTrigger convertTriggerStringToEnum(const char * triggerStr); +#endif // WITH_PRESENCE void CopyEndpointToDevAddr(const CAEndpoint_t *in, OCDevAddr *out); void CopyDevAddrToEndpoint(const OCDevAddr *in, CAEndpoint_t *out); +/** + * Get the CoAP ticks after the specified number of milli-seconds. + * + * @param milliSeconds Milli-seconds. + * @return CoAP ticks + */ +uint32_t GetTicks(uint32_t milliSeconds); + +/** + * Extract interface and resource type from the query. + * + * @param query is the request received from the client + * @param filterOne will include result if the interface is included in the query. + * @param filterTwo will include result if the resource type is included in the query. + * + * @return ::OC_STACK_OK on success, some other value upon failure + */ +OCStackResult ExtractFiltersFromQuery(const char *query, char **filterOne, char **filterTwo); + +#if defined(RD_CLIENT) || defined(RD_SERVER) +/** + * This function binds an resource unique ins value to the resource. This can be only called + * when stack is received response from resource-directory. + * + * @param requestUri URI of the resource. + * @param response Response from queries to remote servers. + * + * @return ::OC_STACK_OK on success, some other value upon failure. + */ +OCStackResult OCUpdateResourceInsWithResponse(const char *requestUri, + const OCClientResponse *response); +#endif + +/** + * Get the CoAP ticks after the specified number of milli-seconds. + * + * @param milliSeconds Milli-seconds. + * @return CoAP ticks + */ +uint32_t GetTicks(uint32_t milliSeconds); + +/** + * Delete all of the dynamically allocated elements that were created for the resource attributes. + * + * @param resourceAttr Specified resource attribute. + */ +void OCDeleteResourceAttributes(OCAttribute *rsrcAttributes); + +/** + * A request uri consists of the following components in order: + * example + * optionally one of + * CoAP over UDP prefix "coap://" + * CoAP over TCP prefix "coap+tcp://" + * CoAP over DTLS prefix "coaps://" + * CoAP over TLS prefix "coaps+tcp://" + * optionally one of + * IPv6 address "[1234::5678]" + * IPv4 address "192.168.1.1" + * optional port ":5683" + * resource uri "/oc/core..." + * + * for PRESENCE requests, extract resource type. + * + * @return ::OC_STACK_OK on success, some other value upon failure. + */ +OCStackResult ParseRequestUri(const char *fullUri, + OCTransportAdapter adapter, + OCTransportFlags flags, + OCDevAddr **devAddr, + char **resourceUri, + char **resourceType); + +/** + * Fix up client response data. + * + * @param cr Response from queries to remote servers. + */ +void FixUpClientResponse(OCClientResponse *cr); + #ifdef __cplusplus } #endif // __cplusplus #endif /* OCSTACKINTERNAL_H_ */ -