Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
mgmt.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2021 mcumgr authors
3 * Copyright (c) 2022-2024 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>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
39typedef void *(*mgmt_alloc_rsp_fn)(const void *src_buf, void *arg);
40
49typedef void (*mgmt_reset_buf_fn)(void *buf, void *arg);
50
51#ifdef CONFIG_MCUMGR_SMP_VERBOSE_ERR_RESPONSE
52#define MGMT_CTXT_SET_RC_RSN(mc, rsn) ((mc->rc_rsn) = (rsn))
53#define MGMT_CTXT_RC_RSN(mc) ((mc)->rc_rsn)
54#else
55#define MGMT_CTXT_SET_RC_RSN(mc, rsn)
56#define MGMT_CTXT_RC_RSN(mc) NULL
57#endif
58
68typedef int (*mgmt_handler_fn)(struct smp_streamer *ctxt);
69
77#if defined(CONFIG_MCUMGR_MGMT_HANDLER_USER_DATA)
78 void *user_data;
79#endif
80};
81
85struct mgmt_group {
88
92
95
96#if defined(CONFIG_MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL)
100 smp_translate_error_fn mg_translate_error;
101#endif
102
103#if defined(CONFIG_MCUMGR_MGMT_CUSTOM_PAYLOAD)
105 bool custom_payload;
106#endif
107
108#if IS_ENABLED(CONFIG_MCUMGR_GRP_ENUM_DETAILS_NAME)
110 const char *mg_group_name;
111#endif
112};
113
120
127
136typedef bool (*mgmt_groups_cb_t)(const struct mgmt_group *group, void *user_data);
137
144void mgmt_groups_foreach(mgmt_groups_cb_t user_cb, void *user_data);
145
155const struct mgmt_handler *mgmt_find_handler(uint16_t group_id, uint16_t command_id);
156
165const struct mgmt_group *mgmt_find_group(uint16_t group_id);
166
176const struct mgmt_handler *mgmt_get_handler(const struct mgmt_group *group, uint16_t command_id);
177
178#if defined(CONFIG_MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL)
188smp_translate_error_fn mgmt_find_error_translation_function(uint16_t group_id);
189#endif
190
195#ifdef __cplusplus
196}
197#endif
198
199#endif /* MGMT_MGMT_H_ */
void mgmt_groups_foreach(mgmt_groups_cb_t user_cb, void *user_data)
Iterate over groups.
void(* mgmt_reset_buf_fn)(void *buf, void *arg)
Resets a buffer to a length of 0.
Definition mgmt.h:49
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.
void mgmt_unregister_group(struct mgmt_group *group)
Unregisters a full command group.
bool(* mgmt_groups_cb_t)(const struct mgmt_group *group, void *user_data)
Group iteration callback.
Definition mgmt.h:136
int(* mgmt_handler_fn)(struct smp_streamer *ctxt)
Processes a request and writes the corresponding response.
Definition mgmt.h:68
const struct mgmt_group * mgmt_find_group(uint16_t group_id)
Finds a registered command group.
const struct mgmt_handler * mgmt_get_handler(const struct mgmt_group *group, uint16_t command_id)
Finds a registered command handler.
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
SMP - Simple Management Protocol.
#define bool
Definition stdbool.h:13
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Group structure.
Definition grp.h:18
A collection of handlers for an entire command group.
Definition mgmt.h:85
const struct mgmt_handler * mg_handlers
Array of handlers; one entry per command ID.
Definition mgmt.h:90
uint16_t mg_handlers_count
Definition mgmt.h:91
uint16_t mg_group_id
The numeric ID of this group.
Definition mgmt.h:94
sys_snode_t node
Entry list node.
Definition mgmt.h:87
Read handler and write handler for a single command ID.
Definition mgmt.h:74
mgmt_handler_fn mh_write
Definition mgmt.h:76
mgmt_handler_fn mh_read
Definition mgmt.h:75
Decodes, encodes, and transmits SMP packets.
Definition smp.h:83