<commit_before>/*
 * Copyright (c) 2018-2021 mcumgr authors
 * Copyright (c) 2022 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#ifndef H_MGMT_MGMT_
#define H_MGMT_MGMT_

#include <inttypes.h>
#include <zephyr/sys/slist.h>
#include <smp/smp.h>

#ifdef __cplusplus
extern "C" {
#endif

/** Opcodes; encoded in first byte of header. */
#define MGMT_OP_READ		0
#define MGMT_OP_READ_RSP	1
#define MGMT_OP_WRITE		2
#define MGMT_OP_WRITE_RSP	3

/**
 * The first 64 groups are reserved for system level mcumgr commands.
 * Per-user commands are then defined after group 64.
 */
#define MGMT_GROUP_ID_OS	0
#define MGMT_GROUP_ID_IMAGE	1
#define MGMT_GROUP_ID_STAT	2
#define MGMT_GROUP_ID_CONFIG	3
#define MGMT_GROUP_ID_LOG	4
#define MGMT_GROUP_ID_CRASH	5
#define MGMT_GROUP_ID_SPLIT	6
#define MGMT_GROUP_ID_RUN	7
#define MGMT_GROUP_ID_FS	8
#define MGMT_GROUP_ID_SHELL	9
#define MGMT_GROUP_ID_PERUSER	64

/**
 * mcumgr error codes.
 */
#define MGMT_ERR_EOK		0
#define MGMT_ERR_EUNKNOWN	1
#define MGMT_ERR_ENOMEM		2
#define MGMT_ERR_EINVAL		3
#define MGMT_ERR_ETIMEOUT	4
#define MGMT_ERR_ENOENT		5
#define MGMT_ERR_EBADSTATE	6	/* Current state disallows command. */
#define MGMT_ERR_EMSGSIZE	7	/* Response too large. */
#define MGMT_ERR_ENOTSUP	8	/* Command not supported. */
#define MGMT_ERR_ECORRUPT	9	/* Corrupt */
#define MGMT_ERR_EBUSY		10	/* Command blocked by processing of other command */
#define MGMT_ERR_EPERUSER	256

#define MGMT_HDR_SIZE		8

/** @typedef mgmt_alloc_rsp_fn
 * @brief Allocates a buffer suitable for holding a response.
 *
 * If a source buf is provided, its user data is copied into the new buffer.<commit_msg>mgmt: mcumgr: Add access denied error code<commit_after>/*
 * Copyright (c) 2018-2021 mcumgr authors
 * Copyright (c) 2022 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#ifndef H_MGMT_MGMT_
#define H_MGMT_MGMT_

#include <inttypes.h>
#include <zephyr/sys/slist.h>
#include <smp/smp.h>

#ifdef __cplusplus
extern "C" {
#endif

/** Opcodes; encoded in first byte of header. */
#define MGMT_OP_READ		0
#define MGMT_OP_READ_RSP	1
#define MGMT_OP_WRITE		2
#define MGMT_OP_WRITE_RSP	3

/**
 * The first 64 groups are reserved for system level mcumgr commands.
 * Per-user commands are then defined after group 64.
 */
#define MGMT_GROUP_ID_OS	0
#define MGMT_GROUP_ID_IMAGE	1
#define MGMT_GROUP_ID_STAT	2
#define MGMT_GROUP_ID_CONFIG	3
#define MGMT_GROUP_ID_LOG	4
#define MGMT_GROUP_ID_CRASH	5
#define MGMT_GROUP_ID_SPLIT	6
#define MGMT_GROUP_ID_RUN	7
#define MGMT_GROUP_ID_FS	8
#define MGMT_GROUP_ID_SHELL	9
#define MGMT_GROUP_ID_PERUSER	64

/**
 * mcumgr error codes.
 */
#define MGMT_ERR_EOK		0
#define MGMT_ERR_EUNKNOWN	1
#define MGMT_ERR_ENOMEM		2
#define MGMT_ERR_EINVAL		3
#define MGMT_ERR_ETIMEOUT	4
#define MGMT_ERR_ENOENT		5
#define MGMT_ERR_EBADSTATE	6	/* Current state disallows command. */
#define MGMT_ERR_EMSGSIZE	7	/* Response too large. */
#define MGMT_ERR_ENOTSUP	8	/* Command not supported. */
#define MGMT_ERR_ECORRUPT	9	/* Corrupt */
#define MGMT_ERR_EBUSY		10	/* Command blocked by processing of other command */
#define MGMT_ERR_EACCESSDENIED	11	/* Access to specific function or resource denied */
#define MGMT_ERR_EPERUSER	256

#define MGMT_HDR_SIZE		8

/** @typedef mgmt_alloc_rsp_fn
 * @brief Allocates a buffer suitable for holding a response.
 *
 * If a source buf is provided, its user data is copied into the new buffer.
{'fraction_non_alphanumeric': 0.07739485981308411, 'fraction_numerical': 0.029789719626168224, 'mean_word_length': 4.834752981260648, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7581963', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1340, 'n_words': 387}