Zephyr Project API  3.3.0
A Scalable Open Source RTOS
mgmt.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2021 mcumgr authors
3 * Copyright (c) 2022 Nordic Semiconductor ASA
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef H_MGMT_MGMT_
9#define H_MGMT_MGMT_
10
11#include <inttypes.h>
12#include <zephyr/sys/slist.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
30
33
36
39};
40
48
51
54
57
60
63
66
69
72
75
78
84};
85
92
95
98
101
104
107
110
113
116
119
122
125
129
130#define MGMT_HDR_SIZE 8
131
142typedef void *(*mgmt_alloc_rsp_fn)(const void *src_buf, void *arg);
143
152typedef void (*mgmt_reset_buf_fn)(void *buf, void *arg);
153
154#ifdef CONFIG_MCUMGR_SMP_VERBOSE_ERR_RESPONSE
155#define MGMT_CTXT_SET_RC_RSN(mc, rsn) ((mc->rc_rsn) = (rsn))
156#define MGMT_CTXT_RC_RSN(mc) ((mc)->rc_rsn)
157#else
158#define MGMT_CTXT_SET_RC_RSN(mc, rsn)
159#define MGMT_CTXT_RC_RSN(mc) NULL
160#endif
161
171typedef int (*mgmt_handler_fn)(struct smp_streamer *ctxt);
172
179};
180
187
191
192 /* The numeric ID of this group. */
194};
195
201void mgmt_register_group(struct mgmt_group *group);
202
209
219const struct mgmt_handler *mgmt_find_handler(uint16_t group_id, uint16_t command_id);
220
225#ifdef __cplusplus
226}
227#endif
228
229#endif /* MGMT_MGMT_H_ */
void(* mgmt_reset_buf_fn)(void *buf, void *arg)
Resets a buffer to a length of 0.
Definition: mgmt.h:152
const struct mgmt_handler * mgmt_find_handler(uint16_t group_id, uint16_t command_id)
Finds a registered command handler.
void mgmt_register_group(struct mgmt_group *group)
Registers a full command group.
mcumgr_group_t
Definition: mgmt.h:45
void mgmt_unregister_group(struct mgmt_group *group)
Unregisters a full command group.
mcumgr_err_t
Definition: mgmt.h:89
mcumgr_op_t
Definition: mgmt.h:27
int(* mgmt_handler_fn)(struct smp_streamer *ctxt)
Processes a request and writes the corresponding response.
Definition: mgmt.h:171
@ MGMT_GROUP_ID_CONFIG
Definition: mgmt.h:56
@ MGMT_GROUP_ID_SPLIT
Definition: mgmt.h:65
@ MGMT_GROUP_ID_IMAGE
Definition: mgmt.h:50
@ MGMT_GROUP_ID_RUN
Definition: mgmt.h:68
@ MGMT_GROUP_ID_OS
Definition: mgmt.h:47
@ MGMT_GROUP_ID_SHELL
Definition: mgmt.h:74
@ MGMT_GROUP_ID_STAT
Definition: mgmt.h:53
@ ZEPHYR_MGMT_GRP_BASIC
Definition: mgmt.h:83
@ MGMT_GROUP_ID_FS
Definition: mgmt.h:71
@ MGMT_GROUP_ID_LOG
Definition: mgmt.h:59
@ MGMT_GROUP_ID_PERUSER
Definition: mgmt.h:77
@ MGMT_GROUP_ID_CRASH
Definition: mgmt.h:62
@ MGMT_ERR_EPERUSER
Definition: mgmt.h:127
@ MGMT_ERR_EMSGSIZE
Definition: mgmt.h:112
@ MGMT_ERR_ENOTSUP
Definition: mgmt.h:115
@ MGMT_ERR_EINVAL
Definition: mgmt.h:100
@ MGMT_ERR_EOK
Definition: mgmt.h:91
@ MGMT_ERR_EBADSTATE
Definition: mgmt.h:109
@ MGMT_ERR_ENOENT
Definition: mgmt.h:106
@ MGMT_ERR_EUNKNOWN
Definition: mgmt.h:94
@ MGMT_ERR_EBUSY
Definition: mgmt.h:121
@ MGMT_ERR_EACCESSDENIED
Definition: mgmt.h:124
@ MGMT_ERR_ECORRUPT
Definition: mgmt.h:118
@ MGMT_ERR_ETIMEOUT
Definition: mgmt.h:103
@ MGMT_ERR_ENOMEM
Definition: mgmt.h:97
@ MGMT_OP_WRITE
Definition: mgmt.h:35
@ MGMT_OP_WRITE_RSP
Definition: mgmt.h:38
@ MGMT_OP_READ
Definition: mgmt.h:29
@ MGMT_OP_READ_RSP
Definition: mgmt.h:32
Single-linked list implementation.
struct _snode sys_snode_t
Definition: slist.h:33
SMP - Simple Management Protocol.
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
A collection of handlers for an entire command group.
Definition: mgmt.h:184
const struct mgmt_handler * mg_handlers
Definition: mgmt.h:189
uint16_t mg_handlers_count
Definition: mgmt.h:190
uint16_t mg_group_id
Definition: mgmt.h:193
sys_snode_t node
Definition: mgmt.h:186
Read handler and write handler for a single command ID.
Definition: mgmt.h:176
mgmt_handler_fn mh_write
Definition: mgmt.h:178
mgmt_handler_fn mh_read
Definition: mgmt.h:177
Decodes, encodes, and transmits SMP packets.
Definition: smp.h:69