Zephyr API Documentation  3.6.99
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-2023 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 IS_ENABLED(CONFIG_MCUMGR_MGMT_HANDLER_USER_DATA)
78 void *user_data;
79#endif
80};
81
85struct mgmt_group {
88
92
95
96#if IS_ENABLED(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
114void mgmt_register_group(struct mgmt_group *group);
115
122
132const struct mgmt_handler *mgmt_find_handler(uint16_t group_id, uint16_t command_id);
133
142const struct mgmt_group *mgmt_find_group(uint16_t group_id);
143
153const struct mgmt_handler *mgmt_get_handler(const struct mgmt_group *group, uint16_t command_id);
154
155#if IS_ENABLED(CONFIG_MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL)
165smp_translate_error_fn mgmt_find_error_translation_function(uint16_t group_id);
166#endif
167
172#ifdef __cplusplus
173}
174#endif
175
176#endif /* MGMT_MGMT_H_ */
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.
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.
int(* mgmt_handler_fn)(struct smp_streamer *ctxt)
Processes a request and writes the corresponding response.
Definition: mgmt.h:68
struct _snode sys_snode_t
Single-linked list node structure.
Definition: slist.h:39
SMP - Simple Management Protocol.
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
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