X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fsecurity%2Finclude%2Fsrmutility.h;h=3608bbca986854fe007cb16cf033d2d92694c11c;hb=3c093548382bb2542c87a67e6e5fa32552c29cb3;hp=029a41b6d20f178762f7940afab2fe3da2d28836;hpb=4d7d7d3bf745e9c42d1620de158820bd4ec9ae76;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/security/include/srmutility.h b/resource/csdk/security/include/srmutility.h index 029a41b..3608bbc 100644 --- a/resource/csdk/security/include/srmutility.h +++ b/resource/csdk/security/include/srmutility.h @@ -22,13 +22,17 @@ #define IOTVT_SRM_UTILITY_H #include "ocstack.h" +#if defined (__TIZENRT__) +#include +#else #include "cJSON.h" +#endif #include "securevirtualresourcetypes.h" #ifdef __cplusplus extern "C" { #endif -#include "uri.h" +#include #ifdef __cplusplus } #endif @@ -55,6 +59,24 @@ struct OicParseQueryIter coap_parse_iterator_t pi; /**< coap struct for tokenizing the query.*/ }; +typedef enum OicSecOtmEvent{ + OIC_OTM_READY = 0, + OIC_OTM_STARTED = 1, + OIC_OTM_DONE = 2, + OIC_OTM_ERROR = 3 +}OicSecOtmEvent_t; + +/** + * Callback function to recevie the OTM event on server side. + * + * @param addr PT's address (address can be NULL in case of init state) + * @param port PT's port (It is meaningless in case of init state & BLE) + * @param uuid PT's UUID (UUID can be NULL in case of init state & coap reqest) + * @param event OTM state (@ref OicSecOtmEvent_t) + */ +typedef void (*OicSecOtmEventHandler_t)(const char* addr, uint16_t port, + const char* uuid, int event); + /** * Macro to verify success of operation. * eg: VERIFY_SUCCESS(TAG, OC_STACK_OK == foo(), ERROR); @@ -113,6 +135,60 @@ OCStackResult AddUuidArray(const cJSON* jsonRoot, const char* arrayItem, */ const char* GetOxmString(OicSecOxm_t oxmType); +/* + * This method converts UUID to canonical format string. + * + * @param uuid Device UUID + * @param strUuid converted UUID in canonical format + * @return OC_STACK_OK for success. + * + * @note Caller needs to invoke OICFree after done using the return pointer + */ +OCStackResult ConvertUuidToStr(const OicUuid_t* uuid, char** strUuid); + + +/* + * This method converts string UUID to OicUuid_t. + * + * @param strUuid Device UUID in string format + * @param uuid converted UUID in OicUuid_t format + * @return OC_STACK_OK for success. + * + */ +OCStackResult ConvertStrToUuid(const char* strUuid, OicUuid_t* uuid); + + +#if defined(__WITH_DTLS__) || defined (__WITH_TLS__) +/** + * API to save the seed value to generate device UUID. + * + * @param seed buffer of seed value. + * @param seedSize byte length of seed + * + * @return ::OC_STACK_OK for Success, otherwise some error value. + */ +OCStackResult SetDeviceIdSeed(const uint8_t* seed, size_t seedSize); + +/** + * API to register OTM event handler + * + * @param otmEventHandler implementation of OTM event handler (@ref OicSecOtmEventHandler_t) + */ +void SetOtmEventHandler(OicSecOtmEventHandler_t otmEventHandler); + +/** + * Invoke OTM event handler to notify the OTM state. + * + * @param addr PT's address (address can be NULL in case of init state) + * @param port PT's port (It is meaningless in case of init state & BLE) + * @param uuid PT's UUID (UUID can be NULL in case of init state & coap reqest) + * @param event OTM state (@ref OicSecOtmEvent_t) + * @param result OTM result code + */ +void InvokeOtmEventHandler(const char* addr, uint16_t port, + const OicUuid_t* uuid, OicSecOtmEvent_t event); +#endif + #ifdef __cplusplus } #endif // __cplusplus