From: Chul Lee Date: Mon, 17 Oct 2016 14:35:21 +0000 (+0900) Subject: Remove unnecessary files for MOT X-Git-Tag: 1.2.0~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1e72e1c9654bf0669cdfb2bff02e242898dbb0cc;p=platform%2Fupstream%2Fiotivity.git Remove unnecessary files for MOT Change-Id: I9dbfab89b3c6cac1f82514dbb42c82c23808fc7e Signed-off-by: Chul Lee Reviewed-on: https://gerrit.iotivity.org/gerrit/13343 Reviewed-by: dongik Lee Tested-by: jenkins-iotivity Reviewed-by: Randeep Singh --- diff --git a/resource/csdk/security/provisioning/sample/SConscript b/resource/csdk/security/provisioning/sample/SConscript index a301f90..2b91aac 100644 --- a/resource/csdk/security/provisioning/sample/SConscript +++ b/resource/csdk/security/provisioning/sample/SConscript @@ -105,7 +105,6 @@ sampleserver_randompin = provisioning_env.Program('sampleserver_randompin', 'sam if provisioning_env.get('MULTIPLE_OWNER') == '1': subownerclient = provisioning_env.Program('subownerclient', 'subownerclient.c') - sampleclient_ownedbysubowner = provisioning_env.Program('sampleclient_ownedbysubowner', 'sampleclient_owned_by_subowner.cpp') if provisioning_env.get('WITH_TCP') == True: cloud_src = [ @@ -133,8 +132,6 @@ randompin_with_emptyuuid_dat = provisioning_env.Install(sec_provisioning_build_d if provisioning_env.get('MULTIPLE_OWNER') == '1': subownerclientdat = provisioning_env.Install(sec_provisioning_build_dir, sec_provisioning_src_dir + 'oic_svr_db_subowner_client.dat') - clientownedbysubownerdat = provisioning_env.Install(sec_provisioning_build_dir, - sec_provisioning_src_dir + 'oic_svr_db_client_owned_by_subowner.dat') if provisioning_env.get('WITH_TCP') == True: clouddat = provisioning_env.Install(sec_provisioning_build_dir, @@ -146,9 +143,9 @@ if provisioning_env.get('WITH_TCP') == True: if provisioning_env.get('MULTIPLE_OWNER') == '1': Alias("samples", [ - provisioningclient, subownerclient, sampleclient_ownedbysubowner, + provisioningclient, subownerclient, sampleserver_justworks, sampleserver_randompin, - clientdat, subownerclientdat, clientownedbysubownerdat, + clientdat, subownerclientdat, justworksdat, randompindat, randompin_with_emptyuuid_dat ]) else: diff --git a/resource/csdk/security/provisioning/sample/oic_svr_db_client_owned_by_subowner.dat b/resource/csdk/security/provisioning/sample/oic_svr_db_client_owned_by_subowner.dat deleted file mode 100644 index bc044c8..0000000 Binary files a/resource/csdk/security/provisioning/sample/oic_svr_db_client_owned_by_subowner.dat and /dev/null differ diff --git a/resource/csdk/security/provisioning/sample/oic_svr_db_client_owned_by_subowner.json b/resource/csdk/security/provisioning/sample/oic_svr_db_client_owned_by_subowner.json deleted file mode 100644 index 37b2a36..0000000 --- a/resource/csdk/security/provisioning/sample/oic_svr_db_client_owned_by_subowner.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "acl": { - "aclist": { - "aces": [ - { - "subjectuuid": "*", - "resources": [ - { - "href": "/oic/res", - "rel": "", - "rt": ["oic.wk.res"], - "if": ["oic.if.ll"] - },{ - "href": "/oic/d", - "rel": "", - "rt": ["oic.wk.d"], - "if": ["oic.if.baseline", "oic.if.r"] - },{ - "href": "/oic/p", - "rel": "", - "rt": ["oic.wk.p"], - "if": ["oic.if.baseline", "oic.if.r"] - } - ], - "permission": 2 - }, - { - "subjectuuid": "*", - "resources": [ - { - "href": "/oic/sec/doxm", - "rel": "", - "rt": ["oic.r.doxm"], - "if": ["oic.if.baseline"] - }, - { - "href": "/oic/sec/pstat", - "rel": "", - "rt": ["oic.r.pstat"], - "if": ["oic.if.baseline"] - }, - { - "href": "/oic/sec/acl", - "rel": "", - "rt": ["oic.r.acl"], - "if": ["oic.if.baseline"] - }, - { - "href": "/oic/sec/cred", - "rel": "", - "rt": ["oic.r.cred"], - "if": ["oic.if.baseline"] - } - ], - "permission": 6 - }, - { - "subjectuuid": "*", - "resources": [ - { - "href": "/oic/sec/pconf", - "rel": "", - "rt": ["oic.r.pconf"], - "if": ["oic.if.baseline"] - }, - { - "href": "/oic/sec/dpairing", - "rel": "", - "rt": ["oic.r.dpairing"], - "if": ["oic.if.baseline"] - } - ], - "permission": 6 - }, - { - "subjectuuid": "*", - "resources": [ - { - "href": "/oic/sec/ver", - "rel": "", - "rt": ["oic.r.ver"], - "if": ["oic.if.baseline"] - } - ], - "permission": 2 - } - ] - }, - "rowneruuid" : "4F776E65-6442-7953-7562-4F776E657230" - }, - "pstat": { - "isop": false, - "deviceuuid": "4F776E65-6442-7953-7562-4F776E657230", - "rowneruuid": "4F776E65-6442-7953-7562-4F776E657230", - "cm": 2, - "tm": 0, - "om": 3, - "sm": 3 - }, - "doxm": { - "oxms": [0], - "oxmsel": 0, - "sct": 1, - "owned": false, - "deviceuuid": "4F776E65-6442-7953-7562-4F776E657230", - "devowneruuid": "", - "rowneruuid": "4F776E65-6442-7953-7562-4F776E657230", - "x.org.iotivity.dpc": true - } -} diff --git a/resource/csdk/security/provisioning/sample/sampleclient_owned_by_subowner.cpp b/resource/csdk/security/provisioning/sample/sampleclient_owned_by_subowner.cpp deleted file mode 100644 index 848a0cd..0000000 --- a/resource/csdk/security/provisioning/sample/sampleclient_owned_by_subowner.cpp +++ /dev/null @@ -1,540 +0,0 @@ -/****************************************************************** - * - * Copyright 2015 Samsung Electronics All Rights Reserved. - * - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *****************************************************************/ - -#include -#include -#include - -#include "logger.h" -#include "oic_malloc.h" -#include "oic_string.h" -#include "ocprovisioningmanager.h" -#include "oxmjustworks.h" -#include "oxmrandompin.h" -#include "securevirtualresourcetypes.h" -#include "srmutility.h" -#include "pmtypes.h" - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif //__cplusplus - -#define TAG "ClientOwnedBySubOwner" -static bool g_doneCB; - -static pthread_t oc_process_thread; -static bool g_LoopFlag = true; - -static void* oc_process_loop(void* ptr) -{ - struct timespec timeout; - timeout.tv_sec = 0; - timeout.tv_nsec = 100000000L; - - while(g_LoopFlag) - { - OCProcess(); - nanosleep(&timeout, NULL); - } - pthread_join(&oc_process_thread, NULL); - return NULL; -} - -static void StartOCProcessThread() -{ - pthread_create(&oc_process_thread, NULL, oc_process_loop, NULL); -} - -static void StopOCProcessThread() -{ - g_LoopFlag = false; -} - -// declaration(s) for provisioning client using C-level provisioning API -// user input definition for main loop on provisioning client -#define _10_DISCOV_OWN_DEVS_ 10 -#define _20_GET_LED_RESOURCE_ 20 -#define _21_PUT_LED_RESOURCE_ 21 -#define _99_EXIT_PRVN_CLT_ 99 - -#define DISCOVERY_TIMEOUT 5 // 10 sec -#define CALLBACK_TIMEOUT 60 // 1 min - -static const char* SVR_DB_FILE_NAME = "oic_svr_db_client_owned_by_subowner.dat"; - // '_' for separaing from the same constant variable in |srmresourcestrings.c| -static const char* PRVN_DB_FILE_NAME = "oic_prvn_cobs.db"; -// |g_ctx| means provision manager application context and -// the following, includes |un/own_list|, could be variables, which |g_ctx| has, -// for accessing all function(s) for these, they are declared on global domain -static const char* g_ctx = "Provision Manager Client Application Context"; -static char* g_svr_fname; -static char* g_prvn_fname; -static OCProvisionDev_t* g_own_list; -static int g_own_cnt; - -// function declaration(s) for calling them before implementing -static OCProvisionDev_t* getDevInst(const OCProvisionDev_t*, const int); -static int printDevList(const OCProvisionDev_t*); -static size_t printUuidList(const OCUuidList_t*); -static int printResultList(const OCProvisionResult_t*, const int); -static void printUuid(const OicUuid_t*); -static FILE* fopen_prvnMng(const char*, const char*); -static int waitCallbackRet(void); -static int selectTwoDiffNum(int*, int*, const int, const char*); - -// callback function(s) for provisioning client using C-level provisioning API -static void ownershipTransferCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool hasError) -{ - if(!hasError) - { - OIC_LOG_V(INFO, TAG, "Ownership Transfer SUCCEEDED - ctx: %s", (char*) ctx); - } - else - { - OIC_LOG_V(ERROR, TAG, "Ownership Transfer FAILED - ctx: %s", (char*) ctx); - printResultList((const OCProvisionResult_t*) arr, nOfRes); - } - g_doneCB = true; -} - -// response handler for LED requests. -static void LedCB(void *ctx, OCDoHandle UNUSED, - OCClientResponse *clientResponse) -{ - if(clientResponse) - { - if(clientResponse->result == OC_STACK_OK) - { - printf("Get OC_STACK_OK from server\n"); - if(clientResponse->payload) - { - printf("Response ===================> %s\n", clientResponse->payload); - } - } - else - { - printf("Error in response : %d\n", clientResponse->result); - } - } - else - { - printf("Hit the response callback but can not find response data\n"); - } - - g_doneCB = true; -} - - -// function(s) for provisioning client using C-level provisioning API -static int initProvisionClient(void) -{ - // initialize persistent storage for SVR DB - static OCPersistentStorage ps = {fopen_prvnMng, fread, fwrite, fclose, unlink}; - if(OC_STACK_OK != OCRegisterPersistentStorageHandler(&ps)) - { - OIC_LOG(ERROR, TAG, "OCRegisterPersistentStorageHandler error"); - return -1; - } - - // initialize OC stack and provisioning manager - if(OC_STACK_OK != OCInit(NULL, 0, OC_CLIENT_SERVER)) - { - OIC_LOG(ERROR, TAG, "OCStack init error"); - return -1; - } - - if (access(PRVN_DB_FILE_NAME, F_OK) != -1) - { - printf("************************************************************\n"); - printf("************Provisioning DB file already exists.************\n"); - printf("************************************************************\n"); - } - else - { - printf("*************************************************************\n"); - printf("************No provisioning DB file, creating new************\n"); - printf("*************************************************************\n"); - } - - if(OC_STACK_OK != OCInitPM(PRVN_DB_FILE_NAME)) - { - OIC_LOG(ERROR, TAG, "OC_PM init error"); - return -1; - } - - return 0; -} - -static int discoverOwnedDevices(void) -{ - // delete owned device list before updating it - if(g_own_list) - { - OCDeleteDiscoveredDevices(g_own_list); - g_own_list = NULL; - } - - // call |OCDiscoverOwnedDevices| API actually - printf(" Discovering Only Owned Devices on Network..\n"); - if(OC_STACK_OK != OCDiscoverOwnedDevices(DISCOVERY_TIMEOUT, &g_own_list)) - { - OIC_LOG(ERROR, TAG, "OCDiscoverOwnedDevices API error"); - return -1; - } - - // display the discovered owned list - printf(" > Discovered Owned Devices\n"); - g_own_cnt = printDevList(g_own_list); - - return 0; -} - -static OCProvisionDev_t* getDevInst(const OCProvisionDev_t* dev_lst, const int dev_num) -{ - if(!dev_lst || 0>=dev_num) - { - printf(" Device List is Empty..\n"); - return NULL; - } - - OCProvisionDev_t* lst = (OCProvisionDev_t*) dev_lst; - for(int i=0; lst; ) - { - if(dev_num == ++i) - { - return lst; - } - lst = lst->next; - } - - return NULL; // in here |lst| is always |NULL| -} - -static int printDevList(const OCProvisionDev_t* dev_lst) -{ - if(!dev_lst) - { - printf(" Device List is Empty..\n\n"); - return 0; - } - - OCProvisionDev_t* lst = (OCProvisionDev_t*) dev_lst; - int lst_cnt = 0; - for( ; lst; ) - { - printf(" [%d] ", ++lst_cnt); - printUuid((const OicUuid_t*) &lst->doxm->deviceID); - printf("\n"); - lst = lst->next; - } - printf("\n"); - - return lst_cnt; -} - -static size_t printUuidList(const OCUuidList_t* uid_lst) -{ - if(!uid_lst) - { - printf(" Device List is Empty..\n\n"); - return 0; - } - - OCUuidList_t* lst = (OCUuidList_t*) uid_lst; - size_t lst_cnt = 0; - for( ; lst; ) - { - printf(" [%zu] ", ++lst_cnt); - printUuid((const OicUuid_t*) &lst->dev); - printf("\n"); - lst = lst->next; - } - printf("\n"); - - return lst_cnt; -} - -static int printResultList(const OCProvisionResult_t* rslt_lst, const int rslt_cnt) -{ - if(!rslt_lst || 0>=rslt_cnt) - { - printf(" Device List is Empty..\n\n"); - return 0; - } - - int lst_cnt = 0; - for( ; rslt_cnt>lst_cnt; ++lst_cnt) - { - printf(" [%d] ", lst_cnt+1); - printUuid((const OicUuid_t*) &rslt_lst[lst_cnt].deviceId); - printf(" - result: %d\n", rslt_lst[lst_cnt].res); - } - printf("\n"); - - return lst_cnt; -} - -static void printUuid(const OicUuid_t* uid) -{ - int i; - for(i=0; ii; ++i) - { - sleep(1); - } - - return 0; -} - -static void printMenu(void) -{ - printf("************************************************************\n"); - printf("****** OIC MOT Client with using C-level API ******\n"); - printf("************************************************************\n\n"); - - printf("** [A] DISCOVER DEVICES ON NETWORK\n"); - printf("** 10. Discover Owned Devices on Network\n\n"); - - printf("** [B] SEND GET/PUT Request\n"); - printf("** 20. Send GET request\n"); - printf("** 21. Send PUT request\n\n"); - - printf("** [G] EXIT PROVISIONING CLIENT\n"); - printf("** 99. Exit Provisionong Client\n\n"); - - printf("************************************************************\n\n"); -} - -#if 0 // Code for enabling path configuration for PDB and SVR DBf -static void printUsage(void) -{ - printf("\n"); - printf("OIC Provisioning Client with using C-level API\n"); - printf("Usage: provisioningclient [option]...\n"); - printf("\n"); - printf(" -h print help for this provisioning client\n"); - printf(" -p=[prvn_db_file_path/name] input PRVN DB file path and name\n"); - printf(" if not exists, will load default DB file\n"); - printf(" (default: |oic_prvn_mng.db| on working dir)\n"); - printf(" (ex. -p=oic_prvn_mng.db)\n"); - printf(" -s=[svr_db_file_path/name] input SVR DB file path and name\n"); - printf(" if not exists, will load default DB file\n"); - printf(" (default: |oic_svr_db_client.json| on working dir)\n"); - printf(" (ex. -s=oic_svr_db_client.json)\n"); - printf("\n"); -} -#endif - -// main function for provisioning client using C-level provisioning API -int main() -{ - OCProvisionDev_t* selDev = NULL; - int selDevNum = 0; - int mn_num = 0; - - // initialize provisioning client - if(initProvisionClient()) - { - OIC_LOG(ERROR, TAG, "ProvisionClient init error"); - goto PMCLT_ERROR; - } - - StartOCProcessThread(); - printf("Client started...\n"); - // main loop for provisioning manager - for( ; ; ) - { - printf("\n"); - printMenu(); - printf(">> Enter Menu Number: "); - for(int ret=0; 1!=ret; ) - { - ret = scanf("%d", &mn_num); - for( ; 0x20<=getchar(); ); // for removing overflow garbages - // '0x20<=code' is character region - } - printf("\n"); - switch(mn_num) - { - case _10_DISCOV_OWN_DEVS_: - if(discoverOwnedDevices()) - { - OIC_LOG(ERROR, TAG, "_12_DISCOV_OWN_DEVS_: error"); - } - break; - case _20_GET_LED_RESOURCE_: - { - char query[256] = {0}; - OCCallbackData cbData; - cbData.cb = &LedCB; - cbData.context = NULL; - cbData.cd = NULL; - - printDevList(g_own_list); - - for( ; ; ) - { - printf("Select the device : "); - for(int ret=0; 1!=ret; ) - { - scanf(" %d", &selDevNum); - for( ; 0x20<=getchar(); ); // for removing overflow garbages - // '0x20<=code' is character region - } - if(0=selDevNum) - { - break; - } - printf(" Entered Wrong Number. Please Enter Again\n"); - } - - selDev = getDevInst(g_own_list, selDevNum); - if(!selDev) - { - OIC_LOG(ERROR, TAG, "getDevInst: device instance empty"); - goto PMCLT_ERROR; - } - - g_doneCB = false; - snprintf(query, MAX_URI_LENGTH, "coaps://%s:%d/a/led", selDev->endpoint.addr, selDev->securePort); - if(OC_STACK_OK != OCDoResource(NULL, OC_REST_GET, query, NULL, NULL, selDev->connType, OC_LOW_QOS, &cbData, NULL, 0)) - { - printf("********************************\n"); - printf("Failed to send GET request to %s\n", query); - printf("********************************\n"); - g_doneCB = true; - break; - } - - waitCallbackRet(); - - break; - } - case _21_PUT_LED_RESOURCE_: - { - char query[256] = {0}; - OCCallbackData cbData; - cbData.cb = &LedCB; - cbData.context = NULL; - cbData.cd = NULL; - - printDevList(g_own_list); - - for( ; ; ) - { - printf("Select the device : "); - for(int ret=0; 1!=ret; ) - { - scanf(" %d", &selDevNum); - for( ; 0x20<=getchar(); ); // for removing overflow garbages - // '0x20<=code' is character region - } - if(0=selDevNum) - { - break; - } - printf(" Entered Wrong Number. Please Enter Again\n"); - } - - selDev = getDevInst(g_own_list, selDevNum); - if(!selDev) - { - OIC_LOG(ERROR, TAG, "getDevInst: device instance empty"); - goto PMCLT_ERROR; - } - - g_doneCB = false; - snprintf(query, MAX_URI_LENGTH, "coaps://%s:%d/a/led", selDev->endpoint.addr, selDev->securePort); - if(OC_STACK_OK != OCDoResource(NULL, OC_REST_PUT, query, NULL, NULL, selDev->connType, OC_LOW_QOS, &cbData, NULL, 0)) - { - printf("********************************\n"); - printf("Failed to send PUT request to %s\n", query); - printf("********************************\n"); - g_doneCB = true; - break; - } - - waitCallbackRet(); - - break; - } - case _99_EXIT_PRVN_CLT_: - goto PMCLT_ERROR; - default: - printf(">> Entered Wrong Number. Please Enter Again\n\n"); - break; - } - } - -PMCLT_ERROR: - if(OC_STACK_OK != OCStop()) - { - OIC_LOG(ERROR, TAG, "OCStack stop error"); - } - OCDeleteDiscoveredDevices(g_own_list); // after here |g_own_list| points nothing - - if(g_svr_fname) - { - OICFree(g_svr_fname); // after here |g_svr_fname| points nothing - } - if(g_prvn_fname) - { - OICFree(g_prvn_fname); // after here |g_prvn_fname| points nothing - } - - StopOCProcessThread(); - - return 0; // always return normal case -} - -#ifdef __cplusplus -} -#endif //__cplusplus