Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
37typedef void *(*mgmt_alloc_rsp_fn)(const void *src_buf, void *arg);
38
47typedef void (*mgmt_reset_buf_fn)(void *buf, void *arg);
48
49#ifdef CONFIG_MCUMGR_SMP_VERBOSE_ERR_RESPONSE
50#define MGMT_CTXT_SET_RC_RSN(mc, rsn) ((mc->rc_rsn) = (rsn))
51#define MGMT_CTXT_RC_RSN(mc) ((mc)->rc_rsn)
52#else
53#define MGMT_CTXT_SET_RC_RSN(mc, rsn)
54#define MGMT_CTXT_RC_RSN(mc) NULL
55#endif
56
66typedef int (*mgmt_handler_fn)(struct smp_streamer *ctxt);
67
74#if IS_ENABLED(CONFIG_MCUMGR_MGMT_HANDLER_USER_DATA)
75 void *user_data;
76#endif
77};
78
82struct mgmt_group {
85
89
92
93#if IS_ENABLED(CONFIG_MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL)
97 smp_translate_error_fn mg_translate_error;
98#endif
99};
100
106void mgmt_register_group(struct mgmt_group *group);
107
114
124const struct mgmt_handler *mgmt_find_handler(uint16_t group_id, uint16_t command_id);
125
134const struct mgmt_group *mgmt_find_group(uint16_t group_id);
135
136#if IS_ENABLED(CONFIG_MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL)
146smp_translate_error_fn mgmt_find_error_translation_function(uint16_t group_id);
147#endif
148
153#ifdef __cplusplus
154}
155#endif
156
157#endif /* MGMT_MGMT_H_ */
void(* mgmt_reset_buf_fn)(void *buf, void *arg)
Resets a buffer to a length of 0.
Definition: mgmt.h:47
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.
int(* mgmt_handler_fn)(struct smp_streamer *ctxt)
Processes a request and writes the corresponding response.
Definition: mgmt.h:66
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:82
const struct mgmt_handler * mg_handlers
Array of handlers; one entry per command ID.
Definition: mgmt.h:87
uint16_t mg_handlers_count
Definition: mgmt.h:88
uint16_t mg_group_id
The numeric ID of this group.
Definition: mgmt.h:91
sys_snode_t node
Entry list node.
Definition: mgmt.h:84
Read handler and write handler for a single command ID.
Definition: mgmt.h:71
mgmt_handler_fn mh_write
Definition: mgmt.h:73
mgmt_handler_fn mh_read
Definition: mgmt.h:72
Decodes, encodes, and transmits SMP packets.
Definition: smp.h:83