1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (c) 2024 Intel Corporation. All rights reserved. 3 */ 4 5 #include "keyring_internal.h" 6 #include "spdk/keyring.h" 7 #include "spdk/rpc.h" 8 #include "spdk/string.h" 9 #include "spdk/util.h" 10 11 static void 12 rpc_keyring_for_each_key_cb(void *ctx, struct spdk_key *key) 13 { 14 struct spdk_json_write_ctx *w = ctx; 15 16 spdk_json_write_object_begin(w); 17 keyring_dump_key_info(key, w); 18 spdk_json_write_object_end(w); 19 } 20 21 static void 22 rpc_keyring_get_keys(struct spdk_jsonrpc_request *request, 23 const struct spdk_json_val *params) 24 { 25 struct spdk_json_write_ctx *w; 26 27 w = spdk_jsonrpc_begin_result(request); 28 spdk_json_write_array_begin(w); 29 spdk_keyring_for_each_key(NULL, w, rpc_keyring_for_each_key_cb, SPDK_KEYRING_FOR_EACH_ALL); 30 spdk_json_write_array_end(w); 31 32 spdk_jsonrpc_end_result(request, w); 33 34 } 35 SPDK_RPC_REGISTER("keyring_get_keys", rpc_keyring_get_keys, SPDK_RPC_RUNTIME) 36