Line data Source code
1 : /* SPDX-License-Identifier: BSD-3-Clause 2 : * Copyright (c) 2024 Intel Corporation. All rights reserved. 3 : */ 4 : 5 : #include "keyring_linux.h" 6 : #include "spdk/rpc.h" 7 : #include "spdk/string.h" 8 : #include "spdk/util.h" 9 : 10 : static const struct spdk_json_object_decoder rpc_keyring_linux_set_options_decoders[] = { 11 : {"enable", offsetof(struct keyring_linux_opts, enable), spdk_json_decode_bool, true}, 12 : }; 13 : 14 : static void 15 0 : rpc_keyring_linux_set_options(struct spdk_jsonrpc_request *request, 16 : const struct spdk_json_val *params) 17 : { 18 0 : struct keyring_linux_opts opts = {}; 19 : int rc; 20 : 21 0 : keyring_linux_get_opts(&opts); 22 0 : if (spdk_json_decode_object(params, rpc_keyring_linux_set_options_decoders, 23 : SPDK_COUNTOF(rpc_keyring_linux_set_options_decoders), &opts)) { 24 0 : spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, 25 : spdk_strerror(EINVAL)); 26 0 : return; 27 : } 28 : 29 0 : rc = keyring_linux_set_opts(&opts); 30 0 : if (rc != 0) { 31 0 : spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc)); 32 0 : return; 33 : } 34 : 35 0 : spdk_jsonrpc_send_bool_response(request, true); 36 : } 37 0 : SPDK_RPC_REGISTER("keyring_linux_set_options", rpc_keyring_linux_set_options, SPDK_RPC_STARTUP)