2 * Copyright (c) 2019 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 #include <vlib/vlib.h>
18 #include <vnet/crypto/crypto.h>
21 format_vnet_crypto_alg (u8 * s, va_list * args)
23 vnet_crypto_alg_t alg = va_arg (*args, vnet_crypto_alg_t);
24 vnet_crypto_main_t *cm = &crypto_main;
25 vnet_crypto_alg_data_t *d = vec_elt_at_index (cm->algs, alg);
26 return format (s, "%s", d->name);
30 unformat_vnet_crypto_alg (unformat_input_t * input, va_list * args)
32 vnet_crypto_main_t *cm = &crypto_main;
33 vnet_crypto_alg_t *alg = va_arg (*args, vnet_crypto_alg_t *);
37 if (!unformat (input, "%s", &name))
40 p = hash_get_mem (cm->alg_index_by_name, name);
51 format_vnet_crypto_op (u8 * s, va_list * args)
53 vnet_crypto_main_t *cm = &crypto_main;
54 vnet_crypto_op_id_t op = va_arg (*args, int); // vnet_crypto_op_id_t);
55 vnet_crypto_op_data_t *otd = cm->opt_data + op;
57 return format (s, "%U-%U", format_vnet_crypto_op_type, otd->type, 0,
58 format_vnet_crypto_alg, otd->alg);
62 format_vnet_crypto_op_type (u8 * s, va_list * args)
64 vnet_crypto_op_type_t opt = va_arg (*args, vnet_crypto_op_type_t);
65 int is_chained = va_arg (*args, int);
67 #define _(n, s) [VNET_CRYPTO_OP_TYPE_##n] = s,
68 foreach_crypto_op_type
72 if (opt >= VNET_CRYPTO_OP_N_TYPES)
73 return format (s, "unknown");
75 return format (s, "%s%s", strings[opt], is_chained ? "-chained" : "");
79 format_vnet_crypto_op_status (u8 * s, va_list * args)
81 vnet_crypto_op_status_t st = va_arg (*args, vnet_crypto_op_status_t);
83 #define _(n, s) [VNET_CRYPTO_OP_STATUS_##n] = s,
84 foreach_crypto_op_status
88 if (st >= VNET_CRYPTO_OP_N_STATUS)
89 return format (s, "unknown");
91 return format (s, "%s", strings[st]);
95 format_vnet_crypto_engine (u8 * s, va_list * args)
97 vnet_crypto_main_t *cm = &crypto_main;
98 u32 crypto_engine_index = va_arg (*args, u32);
99 vnet_crypto_engine_t *e;
101 if (crypto_engine_index == ~0)
104 e = vec_elt_at_index (cm->engines, crypto_engine_index);
106 return format (s, "%s", e->name);
111 * fd.io coding-style-patch-verification: ON
114 * eval: (c-set-style "gnu")