You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2017/12/21 02:55:43 UTC
[mynewt-mcumgr] 01/02: Rename some poorly names identifiers
(NMGR-->MGMT)
This is an automated email from the ASF dual-hosted git repository.
ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git
commit 68fe44a57ab2da520255edede80043e0523808f6
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Wed Dec 20 17:47:36 2017 -0800
Rename some poorly names identifiers (NMGR-->MGMT)
---
mgmt/include/mgmt/mgmt.h | 36 ++++++++++++++++-----------------
newtmgr/include/newtmgr/newtmgr.h | 6 +++---
newtmgr/src/newtmgr.c | 42 +++++++++++++++++++--------------------
3 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/mgmt/include/mgmt/mgmt.h b/mgmt/include/mgmt/mgmt.h
index b2c5dd1..5ed55d3 100644
--- a/mgmt/include/mgmt/mgmt.h
+++ b/mgmt/include/mgmt/mgmt.h
@@ -31,10 +31,10 @@ extern "C" {
/* MTU for newtmgr responses */
#define MGMT_MAX_MTU 1024
-#define NMGR_OP_READ (0)
-#define NMGR_OP_READ_RSP (1)
-#define NMGR_OP_WRITE (2)
-#define NMGR_OP_WRITE_RSP (3)
+#define MGMT_OP_READ (0)
+#define MGMT_OP_READ_RSP (1)
+#define MGMT_OP_WRITE (2)
+#define MGMT_OP_WRITE_RSP (3)
/* First 64 groups are reserved for system level newtmgr commands.
* Per-user commands are then defined after group 64.
@@ -53,30 +53,30 @@ extern "C" {
/**
* Newtmgr error codes
*/
-#define MGMT_ERR_EOK (0)
-#define MGMT_ERR_EUNKNOWN (1)
-#define MGMT_ERR_ENOMEM (2)
-#define MGMT_ERR_EINVAL (3)
-#define MGMT_ERR_ETIMEOUT (4)
-#define MGMT_ERR_ENOENT (5)
-#define MGMT_ERR_EBADSTATE (6) /* Current state disallows command. */
-#define MGMT_ERR_EMSGSIZE (7) /* Response too large. */
-#define MGMT_ERR_EPERUSER (256)
+#define MGMT_ERR_EOK (0)
+#define MGMT_ERR_EUNKNOWN (1)
+#define MGMT_ERR_ENOMEM (2)
+#define MGMT_ERR_EINVAL (3)
+#define MGMT_ERR_ETIMEOUT (4)
+#define MGMT_ERR_ENOENT (5)
+#define MGMT_ERR_EBADSTATE (6) /* Current state disallows command. */
+#define MGMT_ERR_EMSGSIZE (7) /* Response too large. */
+#define MGMT_ERR_EPERUSER (256)
#define NMGR_HDR_SIZE (8)
-struct nmgr_hdr {
+struct mgmt_hdr {
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
- uint8_t nh_op:3; /* NMGR_OP_XXX */
+ uint8_t nh_op:3; /* MGMT_OP_XXX */
uint8_t _res1:5;
#endif
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
uint8_t _res1:5;
- uint8_t nh_op:3; /* NMGR_OP_XXX */
+ uint8_t nh_op:3; /* MGMT_OP_XXX */
#endif
uint8_t nh_flags; /* reserved for future flags */
uint16_t nh_len; /* length of the payload */
- uint16_t nh_group; /* NMGR_GROUP_XXX */
+ uint16_t nh_group; /* MGMT_GROUP_XXX */
uint8_t nh_seq; /* sequence number */
uint8_t nh_id; /* message ID within group */
};
@@ -122,7 +122,7 @@ struct mgmt_cbuf {
typedef int mgmt_handler_fn(struct mgmt_cbuf *cbuf);
-/** Read and write handlers for a single command ID. */
+/** Read handler and write handler for a single command ID. */
struct mgmt_handler {
mgmt_handler_fn *mh_read;
mgmt_handler_fn *mh_write;
diff --git a/newtmgr/include/newtmgr/newtmgr.h b/newtmgr/include/newtmgr/newtmgr.h
index 23ae190..c6b3806 100644
--- a/newtmgr/include/newtmgr/newtmgr.h
+++ b/newtmgr/include/newtmgr/newtmgr.h
@@ -28,7 +28,7 @@ extern "C" {
struct mynewt_nmgr_transport;
struct nmgr_streamer;
-struct nmgr_hdr;
+struct mgmt_hdr;
typedef int nmgr_tx_rsp_fn(struct nmgr_streamer *ns, void *buf, void *arg);
struct nmgr_streamer {
@@ -36,9 +36,9 @@ struct nmgr_streamer {
nmgr_tx_rsp_fn *ns_tx_rsp;
};
-void nmgr_ntoh_hdr(struct nmgr_hdr *hdr);
+void nmgr_ntoh_hdr(struct mgmt_hdr *hdr);
int nmgr_handle_single_payload(struct mgmt_cbuf *cbuf,
- const struct nmgr_hdr *req_hdr);
+ const struct mgmt_hdr *req_hdr);
int nmgr_process_single_packet(struct nmgr_streamer *streamer, void *req);
#ifdef __cplusplus
diff --git a/newtmgr/src/newtmgr.c b/newtmgr/src/newtmgr.c
index 0bf5bcc..7f12f76 100644
--- a/newtmgr/src/newtmgr.c
+++ b/newtmgr/src/newtmgr.c
@@ -67,31 +67,31 @@ nmgr_align4(int x)
static uint8_t
nmgr_rsp_op(uint8_t req_op)
{
- if (req_op == NMGR_OP_READ) {
- return NMGR_OP_READ_RSP;
+ if (req_op == MGMT_OP_READ) {
+ return MGMT_OP_READ_RSP;
} else {
- return NMGR_OP_WRITE_RSP;
+ return MGMT_OP_WRITE_RSP;
}
}
void
-nmgr_ntoh_hdr(struct nmgr_hdr *hdr)
+nmgr_ntoh_hdr(struct mgmt_hdr *hdr)
{
hdr->nh_len = ntohs(hdr->nh_len);
hdr->nh_group = ntohs(hdr->nh_group);
}
static void
-nmgr_hton_hdr(struct nmgr_hdr *hdr)
+nmgr_hton_hdr(struct mgmt_hdr *hdr)
{
hdr->nh_len = htons(hdr->nh_len);
hdr->nh_group = htons(hdr->nh_group);
}
static void
-nmgr_init_rsp_hdr(const struct nmgr_hdr *req_hdr, struct nmgr_hdr *rsp_hdr)
+nmgr_init_rsp_hdr(const struct mgmt_hdr *req_hdr, struct mgmt_hdr *rsp_hdr)
{
- *rsp_hdr = (struct nmgr_hdr) {
+ *rsp_hdr = (struct mgmt_hdr) {
.nh_len = 0,
.nh_flags = 0,
.nh_op = nmgr_rsp_op(req_hdr->nh_op),
@@ -102,7 +102,7 @@ nmgr_init_rsp_hdr(const struct nmgr_hdr *req_hdr, struct nmgr_hdr *rsp_hdr)
}
static int
-nmgr_read_hdr(struct nmgr_streamer *streamer, struct nmgr_hdr *hdr)
+nmgr_read_hdr(struct nmgr_streamer *streamer, struct mgmt_hdr *hdr)
{
struct mgmt_streamer *base;
@@ -117,7 +117,7 @@ nmgr_read_hdr(struct nmgr_streamer *streamer, struct nmgr_hdr *hdr)
}
static int
-nmgr_write_hdr(struct nmgr_streamer *streamer, const struct nmgr_hdr *hdr)
+nmgr_write_hdr(struct nmgr_streamer *streamer, const struct mgmt_hdr *hdr)
{
int rc;
@@ -127,12 +127,12 @@ nmgr_write_hdr(struct nmgr_streamer *streamer, const struct nmgr_hdr *hdr)
static int
nmgr_build_err_rsp(struct nmgr_streamer *streamer,
- const struct nmgr_hdr *req_hdr,
+ const struct mgmt_hdr *req_hdr,
int status)
{
struct CborEncoder map;
struct mgmt_cbuf cbuf;
- struct nmgr_hdr rsp_hdr;
+ struct mgmt_hdr rsp_hdr;
int rc;
rc = mgmt_cbuf_init(&cbuf, &streamer->ns_base);
@@ -161,7 +161,7 @@ nmgr_build_err_rsp(struct nmgr_streamer *streamer,
return rc;
}
- rsp_hdr.nh_len = cbor_encode_bytes_written(&cbuf.encoder) - NMGR_HDR_SIZE;
+ rsp_hdr.nh_len = cbor_encode_bytes_written(&cbuf.encoder) - MGMT_HDR_SIZE;
nmgr_hton_hdr(&rsp_hdr);
rc = nmgr_write_hdr(streamer, &rsp_hdr);
if (rc != 0) {
@@ -173,7 +173,7 @@ nmgr_build_err_rsp(struct nmgr_streamer *streamer,
int
nmgr_handle_single_payload(struct mgmt_cbuf *cbuf,
- const struct nmgr_hdr *req_hdr)
+ const struct mgmt_hdr *req_hdr)
{
const struct mgmt_handler *handler;
struct CborEncoder payload_encoder;
@@ -194,13 +194,13 @@ nmgr_handle_single_payload(struct mgmt_cbuf *cbuf,
return rc;
}
- if (req_hdr->nh_op == NMGR_OP_READ) {
+ if (req_hdr->nh_op == MGMT_OP_READ) {
if (handler->mh_read) {
rc = handler->mh_read(cbuf);
} else {
rc = MGMT_ERR_ENOENT;
}
- } else if (req_hdr->nh_op == NMGR_OP_WRITE) {
+ } else if (req_hdr->nh_op == MGMT_OP_WRITE) {
if (handler->mh_write) {
rc = handler->mh_write(cbuf);
} else {
@@ -226,10 +226,10 @@ nmgr_handle_single_payload(struct mgmt_cbuf *cbuf,
static int
nmgr_handle_single_req(struct nmgr_streamer *streamer,
- const struct nmgr_hdr *req_hdr)
+ const struct mgmt_hdr *req_hdr)
{
struct mgmt_cbuf cbuf;
- struct nmgr_hdr rsp_hdr;
+ struct mgmt_hdr rsp_hdr;
int rc;
rc = mgmt_cbuf_init(&cbuf, &streamer->ns_base);
@@ -251,7 +251,7 @@ nmgr_handle_single_req(struct nmgr_streamer *streamer,
return rc;
}
- rsp_hdr.nh_len = cbor_encode_bytes_written(&cbuf.encoder) - NMGR_HDR_SIZE;
+ rsp_hdr.nh_len = cbor_encode_bytes_written(&cbuf.encoder) - MGMT_HDR_SIZE;
nmgr_hton_hdr(&rsp_hdr);
rc = nmgr_write_hdr(streamer, &rsp_hdr);
if (rc != 0) {
@@ -263,7 +263,7 @@ nmgr_handle_single_req(struct nmgr_streamer *streamer,
static void
nmgr_on_err(struct nmgr_streamer *streamer,
- const struct nmgr_hdr *req_hdr,
+ const struct mgmt_hdr *req_hdr,
void *req,
void *rsp,
int status)
@@ -291,7 +291,7 @@ nmgr_on_err(struct nmgr_streamer *streamer,
int
nmgr_process_single_packet(struct nmgr_streamer *streamer, void *req)
{
- struct nmgr_hdr req_hdr;
+ struct mgmt_hdr req_hdr;
void *rsp;
bool valid_hdr;
int rc;
@@ -312,7 +312,7 @@ nmgr_process_single_packet(struct nmgr_streamer *streamer, void *req)
break;
}
nmgr_ntoh_hdr(&req_hdr);
- rc = mgmt_streamer_trim_front(&streamer->ns_base, req, NMGR_HDR_SIZE);
+ rc = mgmt_streamer_trim_front(&streamer->ns_base, req, MGMT_HDR_SIZE);
assert(rc == 0);
rsp = mgmt_streamer_alloc_rsp(&streamer->ns_base, req);
--
To stop receiving notification emails like this one, please contact
"commits@mynewt.apache.org" <co...@mynewt.apache.org>.