FD.io VPP
v19.04.4-rc0-5-ge88582fac
Vector Packet Processing
format.c
Go to the documentation of this file.
1
/*
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:
6
*
7
* http://www.apache.org/licenses/LICENSE-2.0
8
*
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.
14
*/
15
16
#include <stdbool.h>
17
#include <
vlib/vlib.h
>
18
#include <
vnet/crypto/crypto.h
>
19
20
u8
*
21
format_vnet_crypto_alg
(
u8
* s, va_list * args)
22
{
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
);
27
}
28
29
u8
*
30
format_vnet_crypto_op
(
u8
* s, va_list * args)
31
{
32
vnet_crypto_main_t
*cm = &
crypto_main
;
33
vnet_crypto_op_id_t
op = va_arg (*args,
int
);
// vnet_crypto_op_id_t);
34
vnet_crypto_op_data_t
*otd = cm->
opt_data
+ op;
35
36
return
format
(s,
"%U-%U"
,
format_vnet_crypto_op_type
, otd->
type
,
37
format_vnet_crypto_alg
, otd->
alg
);
38
}
39
40
u8
*
41
format_vnet_crypto_op_type
(
u8
* s, va_list * args)
42
{
43
vnet_crypto_op_type_t
opt = va_arg (*args,
vnet_crypto_op_type_t
);
44
char
*strings[] = {
45
#define _(n, s) [VNET_CRYPTO_OP_TYPE_##n] = s,
46
foreach_crypto_op_type
47
#undef _
48
};
49
50
if
(opt >=
VNET_CRYPTO_OP_N_TYPES
)
51
return
format
(s,
"unknown"
);
52
53
return
format
(s,
"%s"
, strings[opt]);
54
}
55
56
u8
*
57
format_vnet_crypto_op_status
(
u8
* s, va_list * args)
58
{
59
vnet_crypto_op_status_t
st = va_arg (*args,
vnet_crypto_op_status_t
);
60
char
*strings[] = {
61
#define _(n, s) [VNET_CRYPTO_OP_STATUS_##n] = s,
62
foreach_crypto_op_status
63
#undef _
64
};
65
66
if
(st >=
VNET_CRYPTO_OP_N_STATUS
)
67
return
format
(s,
"unknown"
);
68
69
return
format
(s,
"%s"
, strings[st]);
70
}
71
72
u8
*
73
format_vnet_crypto_engine
(
u8
* s, va_list * args)
74
{
75
vnet_crypto_main_t
*cm = &
crypto_main
;
76
u32
crypto_engine_index = va_arg (*args,
u32
);
77
vnet_crypto_engine_t
*e;
78
79
if
(crypto_engine_index == ~0)
80
return
s;
81
82
e =
vec_elt_at_index
(cm->
engines
, crypto_engine_index);
83
84
return
format
(s,
"%s"
, e->
name
);
85
}
86
87
88
/*
89
* fd.io coding-style-patch-verification: ON
90
*
91
* Local Variables:
92
* eval: (c-set-style "gnu")
93
* End:
94
*/
format_vnet_crypto_op_type
u8 * format_vnet_crypto_op_type(u8 *s, va_list *args)
Definition:
format.c:41
foreach_crypto_op_status
#define foreach_crypto_op_status
Definition:
crypto.h:59
vnet_crypto_engine_t
Definition:
crypto.h:153
VNET_CRYPTO_OP_N_TYPES
Definition:
crypto.h:56
vnet_crypto_main_t::engines
vnet_crypto_engine_t * engines
Definition:
crypto.h:167
vnet_crypto_engine_t::name
char * name
Definition:
crypto.h:155
vnet_crypto_main_t::opt_data
vnet_crypto_op_data_t opt_data[VNET_CRYPTO_N_OP_IDS]
Definition:
crypto.h:166
vnet_crypto_main_t::algs
vnet_crypto_alg_data_t * algs
Definition:
crypto.h:163
format
u8 * format(u8 *s, const char *fmt,...)
Definition:
format.c:424
u8
unsigned char u8
Definition:
types.h:56
vnet_crypto_op_type_t
vnet_crypto_op_type_t
Definition:
crypto.h:51
crypto.h
VNET_CRYPTO_OP_N_STATUS
Definition:
crypto.h:71
format_vnet_crypto_op
u8 * format_vnet_crypto_op(u8 *s, va_list *args)
Definition:
format.c:30
vnet_crypto_op_data_t::alg
vnet_crypto_alg_t alg
Definition:
crypto.h:131
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition:
vec_bootstrap.h:175
u32
unsigned int u32
Definition:
types.h:88
vnet_crypto_alg_t
vnet_crypto_alg_t
Definition:
crypto.h:75
vnet_crypto_op_data_t
Definition:
crypto.h:128
format_vnet_crypto_op_status
u8 * format_vnet_crypto_op_status(u8 *s, va_list *args)
Definition:
format.c:57
vnet_crypto_alg_data_t
Definition:
crypto.h:101
vlib.h
vnet_crypto_op_status_t
vnet_crypto_op_status_t
Definition:
crypto.h:66
format_vnet_crypto_alg
u8 * format_vnet_crypto_alg(u8 *s, va_list *args)
Definition:
format.c:21
vnet_crypto_main_t
Definition:
crypto.h:161
foreach_crypto_op_type
#define foreach_crypto_op_type
Definition:
crypto.h:44
vnet_crypto_op_data_t::type
vnet_crypto_op_type_t type
Definition:
crypto.h:130
vnet_crypto_op_id_t
vnet_crypto_op_id_t
Definition:
crypto.h:87
vnet_crypto_alg_data_t::name
char * name
Definition:
crypto.h:103
format_vnet_crypto_engine
u8 * format_vnet_crypto_engine(u8 *s, va_list *args)
Definition:
format.c:73
crypto_main
vnet_crypto_main_t crypto_main
Definition:
crypto.c:20
src
vnet
crypto
format.c
Generated on Mon Jun 29 2020 12:03:51 for FD.io VPP by
1.8.13