blob: e701864a5baafff8627e639dc8b5e4e10b7c6f3f [file] [log] [blame]
Nathan Skrzypczak0c936b12020-08-31 15:33:57 +02001/*
2 * Copyright (c) 2020 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 <stddef.h>
17
18#include <vnet/vnet.h>
19
20#include <vnet/ip/ip_types_api.h>
21#include <vpp/app/version.h>
22
23#include <vlibapi/api.h>
24#include <vlibmemory/api.h>
25
26#include <vnet/crypto/crypto.h>
27
28/* define message IDs */
29#include <vnet/format_fns.h>
30#include <vnet/crypto/crypto.api_enum.h>
31#include <vnet/crypto/crypto.api_types.h>
32
33/**
34 * Base message ID fot the plugin
35 */
36static u32 crypto_base_msg_id;
37
38#define REPLY_MSG_ID_BASE crypto_base_msg_id
39
40#include <vlibapi/api_helper_macros.h>
41
42static void
43vl_api_crypto_set_async_dispatch_t_handler (vl_api_crypto_set_async_dispatch_t
44 * mp)
45{
46 vl_api_crypto_set_async_dispatch_reply_t *rmp;
47 int rv = 0;
48
Vratko Polak139aba22023-08-17 16:22:48 +020049 vnet_crypto_set_async_dispatch ((u8) mp->mode, 0);
50
Nathan Skrzypczak0c936b12020-08-31 15:33:57 +020051 REPLY_MACRO (VL_API_CRYPTO_SET_ASYNC_DISPATCH_REPLY);
52}
53
54static void
Vratko Polak139aba22023-08-17 16:22:48 +020055vl_api_crypto_set_async_dispatch_v2_t_handler (
56 vl_api_crypto_set_async_dispatch_v2_t *mp)
57{
58 vl_api_crypto_set_async_dispatch_v2_reply_t *rmp;
59 int rv = 0;
60
61 vnet_crypto_set_async_dispatch ((u8) mp->mode, mp->adaptive ? 1 : 0);
62
63 REPLY_MACRO (VL_API_CRYPTO_SET_ASYNC_DISPATCH_V2_REPLY);
64}
65
66static void
Nathan Skrzypczak0c936b12020-08-31 15:33:57 +020067vl_api_crypto_set_handler_t_handler (vl_api_crypto_set_handler_t * mp)
68{
69 vl_api_crypto_set_handler_reply_t *rmp;
70 int rv = 0;
71 char *engine;
72 char *alg_name;
73 crypto_op_class_type_t oct;
74
75 engine = (char *) mp->engine;
76 alg_name = (char *) mp->alg_name;
77 oct = (crypto_op_class_type_t) mp->oct;
78
Yulong Pei6816c3b2020-09-21 13:41:56 -070079 if (mp->is_async)
80 rv = vnet_crypto_set_async_handler2 (alg_name, engine);
Nathan Skrzypczak0c936b12020-08-31 15:33:57 +020081 else
Yulong Pei6816c3b2020-09-21 13:41:56 -070082 rv = vnet_crypto_set_handler2 (alg_name, engine, oct);
Nathan Skrzypczak0c936b12020-08-31 15:33:57 +020083
84 REPLY_MACRO (VL_API_CRYPTO_SET_HANDLER_REPLY);
85}
86
87#include <vnet/crypto/crypto.api.c>
88
89clib_error_t *
90crypto_api_hookup (vlib_main_t * vm)
91{
92 /* Ask for a correctly-sized block of API message decode slots */
93 crypto_base_msg_id = setup_message_id_table ();
94
95 return 0;
96}
97
98VLIB_API_INIT_FUNCTION (crypto_api_hookup);
99
100/*
101 * fd.io coding-style-patch-verification: ON
102 *
103 * Local Variables:
104 * eval: (c-set-style "gnu")
105 * End:
106 */