Commit ea02396d authored by Oleksandr Dmitrenko's avatar Oleksandr Dmitrenko Committed by Uze Choi

OTM Failure Notification callback

This is a API that allows to register user callback function,
which calls in OTM failure cases.
Any error by accessing to the all secure resurces will call user
callback in RF_OTM device state.

Change-Id: I63760869170e6c383d5d61cefaa2e40e08313a48
Signed-off-by: default avatarOleksandr Dmytrenko <o.dmytrenko@samsung.com>
Signed-off-by: Aleksey's avatarAleksey Volkov <a.volkov@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/25627Tested-by: default avatarIoTivity Jenkins <jenkins-daemon@iotivity.org>
Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
Tested-by: default avatarUze Choi <uzchoi@samsung.com>
parent 007faa90
......@@ -128,7 +128,7 @@ ifeq ($(DYNAMIC),1)
endif
ifneq ($(SECURE),0)
SRC += $(addprefix ../../security/,oc_acl.c oc_cred.c oc_doxm.c oc_pstat.c oc_tls.c oc_svr.c oc_store.c)
SRC += $(addprefix ../../security/,oc_acl.c oc_cred.c oc_doxm.c oc_pstat.c oc_tls.c oc_svr.c oc_store.c oc_err.c)
SRC_COMMON += $(addprefix $(MBEDTLS_DIR)/library/,${DTLS})
MBEDTLS_PATCH_FILE := $(MBEDTLS_DIR)/patched.txt
ifeq ($(DYNAMIC)$(OPTIMIZE),10)
......
......@@ -26,6 +26,7 @@
#include "oc_rep.h"
#include "oc_store.h"
#include "oc_tls.h"
#include "oc_err.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
......@@ -1147,6 +1148,7 @@ post_acl(oc_request_t *request, oc_interface_mask_t interface, void *data)
oc_sec_dump_acl(request->resource->device);
} else {
oc_send_response(request, OC_STATUS_BAD_REQUEST);
oc_sec_otm_err(request->resource->device, OC_SEC_ERR_ACL);
}
}
......
......@@ -28,6 +28,7 @@
#include "port/oc_log.h"
#include "util/oc_list.h"
#include "util/oc_memb.h"
#include "oc_err.h"
OC_MEMB(creds, oc_sec_cred_t, OC_MAX_NUM_DEVICES *OC_MAX_NUM_SUBJECTS + 1);
#define OXM_JUST_WORKS "oic.sec.doxm.jw"
......@@ -551,6 +552,8 @@ post_cred(oc_request_t *request, oc_interface_mask_t interface, void *data)
if (!success) {
if (owner) {
oc_sec_remove_cred_by_credid(owner->credid, request->resource->device);
} else {
oc_sec_otm_err(request->resource->device, OC_SEC_ERR_CRED);
}
oc_send_response(request, OC_STATUS_BAD_REQUEST);
} else {
......
......@@ -22,6 +22,7 @@
#include "oc_core_res.h"
#include "oc_pstat.h"
#include "oc_store.h"
#include "oc_err.h"
#include <stddef.h>
#include <string.h>
......@@ -265,6 +266,7 @@ post_doxm(oc_request_t *request, oc_interface_mask_t interface, void *data)
oc_sec_dump_doxm(request->resource->device);
} else {
oc_send_response(request, OC_STATUS_BAD_REQUEST);
oc_sec_otm_err(request->resource->device, OC_SEC_ERR_DOXM);
}
}
......
/****************************************************************************
*
* Copyright 2018 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 "oc_err.h"
#include "oc_pstat.h"
static oc_sec_otm_err_cb_t _cb;
void oc_sec_otm_set_err_cb(oc_sec_otm_err_cb_t cb)
{
_cb = cb;
}
void oc_sec_otm_err(int device, oc_sec_otm_err_code_t code)
{
if (_cb) {
oc_sec_pstat_t *pstat = oc_sec_get_pstat(device);
if (pstat->s == OC_DOS_RFOTM) {
_cb(code);
}
}
}
/****************************************************************************
*
* Copyright 2018 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.
*
****************************************************************************/
#ifndef OC_SEC_ERROR_H
#define OC_SEC_ERROR_H
typedef enum {
OC_SEC_ERR_ACL,
OC_SEC_ERR_CRED,
OC_SEC_ERR_DOXM,
OC_SEC_ERR_PSTAT
} oc_sec_otm_err_code_t;
typedef void (*oc_sec_otm_err_cb_t)(oc_sec_otm_err_code_t);
void oc_sec_otm_set_err_cb(oc_sec_otm_err_cb_t cb);
void oc_sec_otm_err(int device, oc_sec_otm_err_code_t code);
#endif /* OC_SEC_ERROR_H */
......@@ -23,6 +23,7 @@
#include "oc_doxm.h"
#include "oc_store.h"
#include "oc_tls.h"
#include "oc_err.h"
#ifdef OC_DYNAMIC_ALLOCATION
#include "port/oc_assert.h"
......@@ -533,6 +534,7 @@ post_pstat(oc_request_t *request, oc_interface_mask_t interface, void *data)
oc_sec_dump_pstat(device);
} else {
oc_send_response(request, OC_STATUS_BAD_REQUEST);
oc_sec_otm_err(device, OC_SEC_ERR_PSTAT);
}
}
......
......@@ -25,10 +25,18 @@
#include "oc_pstat.h"
#include "oc_ri.h"
#include "port/oc_log.h"
#include "oc_err.h"
void
oc_sec_otm_err_cb(oc_sec_otm_err_code_t code)
{
OC_ERR("error code: %d", code);
}
void
oc_sec_create_svr(void)
{
oc_sec_otm_set_err_cb(oc_sec_otm_err_cb);
oc_sec_doxm_init();
oc_sec_pstat_init();
oc_sec_cred_init();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment