Zephyr Project API
3.5.0
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
>
13
#include <
zephyr/mgmt/mcumgr/smp/smp.h
>
14
#include <
zephyr/mgmt/mcumgr/mgmt/mgmt_defines.h
>
15
16
#ifdef __cplusplus
17
extern
"C"
{
18
#endif
19
37
typedef
void
*(*mgmt_alloc_rsp_fn)(
const
void
*src_buf,
void
*arg);
38
47
typedef
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
66
typedef
int (*
mgmt_handler_fn
)(
struct
smp_streamer
*ctxt);
67
71
struct
mgmt_handler
{
72
mgmt_handler_fn
mh_read
;
73
mgmt_handler_fn
mh_write
;
74
#if IS_ENABLED(CONFIG_MCUMGR_MGMT_HANDLER_USER_DATA)
75
void
*
user_data
;
76
#endif
77
};
78
82
struct
mgmt_group
{
84
sys_snode_t
node
;
85
87
const
struct
mgmt_handler
*
mg_handlers
;
88
uint16_t
mg_handlers_count
;
89
91
uint16_t
mg_group_id
;
92
93
#if IS_ENABLED(CONFIG_MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL)
97
smp_translate_error_fn mg_translate_error;
98
#endif
99
};
100
106
void
mgmt_register_group
(
struct
mgmt_group
*group);
107
113
void
mgmt_unregister_group
(
struct
mgmt_group
*group);
114
124
const
struct
mgmt_handler
*
mgmt_find_handler
(
uint16_t
group_id,
uint16_t
command_id);
125
134
const
struct
mgmt_group
*
mgmt_find_group
(
uint16_t
group_id);
135
136
#if IS_ENABLED(CONFIG_MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL)
146
smp_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_ */
mgmt_reset_buf_fn
void(* mgmt_reset_buf_fn)(void *buf, void *arg)
Resets a buffer to a length of 0.
Definition
mgmt.h:47
mgmt_find_handler
const struct mgmt_handler * mgmt_find_handler(uint16_t group_id, uint16_t command_id)
Finds a registered command handler.
mgmt_register_group
void mgmt_register_group(struct mgmt_group *group)
Registers a full command group.
mgmt_unregister_group
void mgmt_unregister_group(struct mgmt_group *group)
Unregisters a full command group.
mgmt_find_group
const struct mgmt_group * mgmt_find_group(uint16_t group_id)
Finds a registered command group.
mgmt_handler_fn
int(* mgmt_handler_fn)(struct smp_streamer *ctxt)
Processes a request and writes the corresponding response.
Definition
mgmt.h:66
sys_snode_t
struct _snode sys_snode_t
Single-linked list node structure.
Definition
slist.h:39
inttypes.h
smp.h
SMP - Simple Management Protocol.
mgmt_defines.h
slist.h
uint16_t
__UINT16_TYPE__ uint16_t
Definition
stdint.h:89
mgmt_group
A collection of handlers for an entire command group.
Definition
mgmt.h:82
mgmt_group::mg_handlers
const struct mgmt_handler * mg_handlers
Array of handlers; one entry per command ID.
Definition
mgmt.h:87
mgmt_group::mg_handlers_count
uint16_t mg_handlers_count
Definition
mgmt.h:88
mgmt_group::mg_group_id
uint16_t mg_group_id
The numeric ID of this group.
Definition
mgmt.h:91
mgmt_group::node
sys_snode_t node
Entry list node.
Definition
mgmt.h:84
mgmt_handler
Read handler and write handler for a single command ID.
Definition
mgmt.h:71
mgmt_handler::mh_write
mgmt_handler_fn mh_write
Definition
mgmt.h:73
mgmt_handler::mh_read
mgmt_handler_fn mh_read
Definition
mgmt.h:72
smp_streamer
Decodes, encodes, and transmits SMP packets.
Definition
smp.h:83
user_data
static const intptr_t user_data[5]
Definition
main.c:588
include
zephyr
mgmt
mcumgr
mgmt
mgmt.h
Generated on Tue Mar 5 2024 08:42:06 for Zephyr Project API by
1.9.8