11/*
22 * Copyright Runtime.io 2018. All rights reserved.
3- * Copyright (c) 2022 Nordic Semiconductor ASA
3+ * Copyright (c) 2022-2023 Nordic Semiconductor ASA
44 *
55 * SPDX-License-Identifier: Apache-2.0
66 */
@@ -35,8 +35,6 @@ struct net_buf;
3535 * @return 0 on success, #mcumgr_err_t code on failure.
3636 */
3737typedef int (* smp_transport_out_fn )(struct net_buf * nb );
38- /* use smp_transport_out_fn instead */
39- typedef int zephyr_smp_transport_out_fn (struct net_buf * nb );
4038
4139/** @typedef smp_transport_get_mtu_fn
4240 * @brief SMP MTU query callback for transport
@@ -52,8 +50,6 @@ typedef int zephyr_smp_transport_out_fn(struct net_buf *nb);
5250 * 0 if transmission is currently not possible.
5351 */
5452typedef uint16_t (* smp_transport_get_mtu_fn )(const struct net_buf * nb );
55- /* use smp_transport_get_mtu_fn instead */
56- typedef uint16_t zephyr_smp_transport_get_mtu_fn (const struct net_buf * nb );
5753
5854/** @typedef smp_transport_ud_copy_fn
5955 * @brief SMP copy user_data callback
@@ -70,9 +66,6 @@ typedef uint16_t zephyr_smp_transport_get_mtu_fn(const struct net_buf *nb);
7066 */
7167typedef int (* smp_transport_ud_copy_fn )(struct net_buf * dst ,
7268 const struct net_buf * src );
73- /* use smp_transport_ud_copy_fn instead */
74- typedef int zephyr_smp_transport_ud_copy_fn (struct net_buf * dst ,
75- const struct net_buf * src );
7669
7770/** @typedef smp_transport_ud_free_fn
7871 * @brief SMP free user_data callback
@@ -84,8 +77,6 @@ typedef int zephyr_smp_transport_ud_copy_fn(struct net_buf *dst,
8477 * @param ud Contains a user_data pointer to be freed.
8578 */
8679typedef void (* smp_transport_ud_free_fn )(void * ud );
87- /* use smp_transport_ud_free_fn instead */
88- typedef void zephyr_smp_transport_ud_free_fn (void * ud );
8980
9081/** @typedef smp_transport_query_valid_check_fn
9182 * @brief Function for checking if queued data is still valid.
@@ -101,42 +92,38 @@ typedef void zephyr_smp_transport_ud_free_fn(void *ud);
10192typedef bool (* smp_transport_query_valid_check_fn )(struct net_buf * nb , void * arg );
10293
10394/**
104- * @brief SMP transport object for sending SMP responses.
95+ * @brief Function pointers of SMP transport functions, if a handler is NULL then it is not
96+ * supported/implemented.
10597 */
106- struct smp_transport {
107- /* Must be the first member. */
108- struct k_work work ;
109-
110- /* FIFO containing incoming requests to be processed. */
111- struct k_fifo fifo ;
112-
98+ struct smp_transport_api_t {
99+ /** Transport's send function. */
113100 smp_transport_out_fn output ;
101+
102+ /** Transport's get-MTU function. */
114103 smp_transport_get_mtu_fn get_mtu ;
104+
105+ /** Transport buffer user_data copy function. */
115106 smp_transport_ud_copy_fn ud_copy ;
107+
108+ /** Transport buffer user_data free function. */
116109 smp_transport_ud_free_fn ud_free ;
117- smp_transport_query_valid_check_fn query_valid_check ;
118110
119- #ifdef CONFIG_MCUMGR_TRANSPORT_REASSEMBLY
120- /* Packet reassembly internal data, API access only */
121- struct {
122- struct net_buf * current ; /* net_buf used for reassembly */
123- uint16_t expected ; /* expected bytes to come */
124- } __reassembly ;
125- #endif
111+ /** Transport's check function for if a query is valid. */
112+ smp_transport_query_valid_check_fn query_valid_check ;
126113};
127114
128- /* Deprecated, use smp_transport instead */
129- struct zephyr_smp_transport {
115+ /**
116+ * @brief SMP transport object for sending SMP responses.
117+ */
118+ struct smp_transport {
130119 /* Must be the first member. */
131- struct k_work zst_work ;
120+ struct k_work work ;
132121
133122 /* FIFO containing incoming requests to be processed. */
134- struct k_fifo zst_fifo ;
123+ struct k_fifo fifo ;
135124
136- smp_transport_out_fn zst_output ;
137- smp_transport_get_mtu_fn zst_get_mtu ;
138- smp_transport_ud_copy_fn zst_ud_copy ;
139- smp_transport_ud_free_fn zst_ud_free ;
125+ /* Function pointers */
126+ struct smp_transport_api_t functions ;
140127
141128#ifdef CONFIG_MCUMGR_TRANSPORT_REASSEMBLY
142129 /* Packet reassembly internal data, API access only */
@@ -150,33 +137,12 @@ struct zephyr_smp_transport {
150137/**
151138 * @brief Initializes a Zephyr SMP transport object.
152139 *
153- * @param smpt The transport to construct.
154- * @param output_func The transport's send function.
155- * @param get_mtu_func The transport's get-MTU function.
156- * @param ud_copy_func The transport buffer user_data copy function.
157- * @param ud_free_func The transport buffer user_data free function.
158- * @param query_valid_check_func The transport's check function for if a query is valid.
140+ * @param smpt The transport to construct.
141+ *
142+ * @return 0 If successful
143+ * @return Negative errno code if failure.
159144 */
160- void smp_transport_init (struct smp_transport * smpt ,
161- smp_transport_out_fn output_func ,
162- smp_transport_get_mtu_fn get_mtu_func ,
163- smp_transport_ud_copy_fn ud_copy_func ,
164- smp_transport_ud_free_fn ud_free_func ,
165- smp_transport_query_valid_check_fn query_valid_check_func );
166-
167- __deprecated static inline
168- void zephyr_smp_transport_init (struct zephyr_smp_transport * smpt ,
169- zephyr_smp_transport_out_fn * output_func ,
170- zephyr_smp_transport_get_mtu_fn * get_mtu_func ,
171- zephyr_smp_transport_ud_copy_fn * ud_copy_func ,
172- zephyr_smp_transport_ud_free_fn * ud_free_func )
173- {
174- smp_transport_init ((struct smp_transport * )smpt ,
175- (smp_transport_out_fn )output_func ,
176- (smp_transport_get_mtu_fn )get_mtu_func ,
177- (smp_transport_ud_copy_fn )ud_copy_func ,
178- (smp_transport_ud_free_fn )ud_free_func , NULL );
179- }
145+ int smp_transport_init (struct smp_transport * smpt );
180146
181147/**
182148 * @brief Used to remove queued requests for an SMP transport that are no longer valid. A
0 commit comments