From d7c888b3f2d2c0bbb807e5ba7e5fd852808d6938 Mon Sep 17 00:00:00 2001 From: Miguel Azevedo Date: Thu, 29 Aug 2019 00:29:58 +0100 Subject: [PATCH 1/3] OMP_OIC_RESOURCE_NAME now defined on mynewt-core/oicmgr side --- omp/syscfg.yml | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 omp/syscfg.yml diff --git a/omp/syscfg.yml b/omp/syscfg.yml deleted file mode 100644 index 0efa3205..00000000 --- a/omp/syscfg.yml +++ /dev/null @@ -1,24 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# - -syscfg.defs: - OMP_OIC_RESOURCE_NAME: - description: > - The OMP OIC Resource name. - value: '"x.mynewt.nmgr"' From 233da250449d89c28c9e4af68efce6c376095d36 Mon Sep 17 00:00:00 2001 From: Miguel Azevedo Date: Fri, 30 Aug 2019 00:53:36 +0100 Subject: [PATCH 2/3] Fixed timeout on invalid log show command, omp_process_mgmt_hdr refactored --- cmd/log_mgmt/src/log_mgmt.c | 1 + omp/port/mynewt/src/mynewt_omp.c | 3 --- omp/src/omp.c | 30 +++++++++++++----------------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/cmd/log_mgmt/src/log_mgmt.c b/cmd/log_mgmt/src/log_mgmt.c index 4f92390a..58ecddb7 100644 --- a/cmd/log_mgmt/src/log_mgmt.c +++ b/cmd/log_mgmt/src/log_mgmt.c @@ -317,6 +317,7 @@ log_mgmt_show(struct mgmt_ctxt *ctxt) /* Log list fully iterated. */ if (name_len != 0) { /* Client specified log name, but the log wasn't found. */ + cbor_encoder_close_container(&ctxt->encoder, &logs); return MGMT_ERR_ENOENT; } else { break; diff --git a/omp/port/mynewt/src/mynewt_omp.c b/omp/port/mynewt/src/mynewt_omp.c index 2cda55e1..38b1ef4c 100644 --- a/omp/port/mynewt/src/mynewt_omp.c +++ b/omp/port/mynewt/src/mynewt_omp.c @@ -78,9 +78,6 @@ omp_impl_process_request_packet(struct omp_state *omgr_st, void *req_buf) } rc = omp_process_mgmt_hdr(&req_hdr, &rsp_hdr, &ctxt); - /* if (err != 0) { */ - /* rc = MGMT_ERR_EINVAL; */ - /* } */ cbor_encoder_close_container(streamer->rsp_encoder, &ctxt.encoder); if (rc != 0) { diff --git a/omp/src/omp.c b/omp/src/omp.c index 615c7984..f6ae4697 100644 --- a/omp/src/omp.c +++ b/omp/src/omp.c @@ -112,6 +112,7 @@ omp_process_mgmt_hdr(struct mgmt_hdr *req_hdr, int rc = 0; bool rsp_hdr_filled = true; const struct mgmt_handler *handler; + mgmt_handler_fn *handler_fn = NULL; handler = mgmt_find_handler(req_hdr->nh_group, req_hdr->nh_id); if (handler == NULL) { @@ -121,32 +122,27 @@ omp_process_mgmt_hdr(struct mgmt_hdr *req_hdr, switch (req_hdr->nh_op) { case MGMT_OP_READ: - if (handler->mh_read == NULL) { - rc = MGMT_ERR_ENOENT; - } else { - rsp_hdr->nh_op = MGMT_OP_READ_RSP; - rc = handler->mh_read(ctxt); - } + rsp_hdr->nh_op = MGMT_OP_READ_RSP; + handler_fn = handler->mh_read; break; case MGMT_OP_WRITE: - if (handler->mh_write == NULL) { - rc = MGMT_ERR_ENOENT; - } else { - rsp_hdr->nh_op = MGMT_OP_WRITE_RSP; - rc = handler->mh_write(ctxt); - } + rsp_hdr->nh_op = MGMT_OP_WRITE_RSP; + handler_fn = handler->mh_write; break; default: rc = MGMT_ERR_EINVAL; - rsp_hdr_filled = false; - goto done; - break; + } + + if (handler_fn) { + rc = handler_fn(ctxt); + } else { + rc = MGMT_ERR_ENOTSUP; } /* Encode the MGMT header in the response. */ -done: + if (rc != 0) { if (rsp_hdr_filled) { rc = omp_send_err_rsp(&ctxt->encoder, rsp_hdr, rc); @@ -158,5 +154,5 @@ omp_process_mgmt_hdr(struct mgmt_hdr *req_hdr, } } - return rc; + return mgmt_err_from_cbor(rc); } From a7238260820bad2894133a05a6d1f28808133201 Mon Sep 17 00:00:00 2001 From: Miguel Azevedo Date: Fri, 30 Aug 2019 13:53:11 +0100 Subject: [PATCH 3/3] Fixed timeout on invalid log show command, omp_process_mgmt_hdr refactored --- omp/src/omp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/omp/src/omp.c b/omp/src/omp.c index f6ae4697..fb1cc1e9 100644 --- a/omp/src/omp.c +++ b/omp/src/omp.c @@ -110,7 +110,6 @@ omp_process_mgmt_hdr(struct mgmt_hdr *req_hdr, struct mgmt_ctxt *ctxt) { int rc = 0; - bool rsp_hdr_filled = true; const struct mgmt_handler *handler; mgmt_handler_fn *handler_fn = NULL; @@ -144,7 +143,7 @@ omp_process_mgmt_hdr(struct mgmt_hdr *req_hdr, /* Encode the MGMT header in the response. */ if (rc != 0) { - if (rsp_hdr_filled) { + if (handler_fn) { rc = omp_send_err_rsp(&ctxt->encoder, rsp_hdr, rc); } } else {