2 * Copyright (c) 2018 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.
16 #include <vnet/vnet.h>
17 #include <vlibapi/api.h>
18 #include <vlibmemory/api.h>
19 #include <vpp/app/version.h>
20 #include <tlsopenssl/tls_openssl.h>
22 /* define message IDs */
23 #include <tlsopenssl/tls_openssl_msg_enum.h>
25 /* define message structures */
27 #include <tlsopenssl/tls_openssl_all_api_h.h>
30 /* define generated endian-swappers */
32 #include <tlsopenssl/tls_openssl_all_api_h.h>
35 /* instantiate all the print functions we know about */
36 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
38 #include <tlsopenssl/tls_openssl_all_api_h.h>
41 /* Get the API version number */
42 #define vl_api_version(n, v) static u32 api_version = (v);
43 #include <tlsopenssl/tls_openssl_all_api_h.h>
46 #define REPLY_MSG_ID_BASE om->msg_id_base
47 #include <vlibapi/api_helper_macros.h>
49 /* List of message types that this plugin understands */
51 #define foreach_tls_openssl_plugin_api_msg \
52 _ (TLS_OPENSSL_SET_ENGINE, tls_openssl_set_engine)
54 extern openssl_main_t openssl_main;
56 /* API message handler */
58 vl_api_tls_openssl_set_engine_t_handler (vl_api_tls_openssl_set_engine_t * mp)
60 vl_api_tls_openssl_set_engine_reply_t *rmp;
61 openssl_main_t *om = &openssl_main;
69 openssl_async_node_enable_disable (1);
72 ciphers = (char *) &mp->ciphers;
75 tls_openssl_set_ciphers (ciphers);
77 engine = (char *) mp->engine;
79 alg = (char *) mp->algorithm;
81 rv = openssl_engine_register (engine, alg);
83 REPLY_MACRO (VL_API_TLS_OPENSSL_SET_ENGINE_REPLY);
86 /* Set up the API message handling tables */
88 tls_openssl_plugin_api_hookup (vlib_main_t * vm)
90 openssl_main_t *om = &openssl_main;
92 vl_msg_api_set_handlers ((VL_API_##N + om->msg_id_base), #n, \
93 vl_api_##n##_t_handler, vl_noop_handler, \
94 vl_api_##n##_t_endian, vl_api_##n##_t_print, \
95 sizeof (vl_api_##n##_t), 1);
96 foreach_tls_openssl_plugin_api_msg;
102 #define vl_msg_name_crc_list
103 #include <tlsopenssl/tls_openssl_all_api_h.h>
104 #undef vl_msg_name_crc_list
107 setup_message_id_table (openssl_main_t * om, api_main_t * am)
109 #define _(id, n, crc) \
110 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + om->msg_id_base);
111 foreach_vl_msg_name_crc_tls_openssl;
116 tls_openssl_api_init (vlib_main_t * vm)
118 openssl_main_t *om = &openssl_main;
119 clib_error_t *error = 0;
122 name = format (0, "tls_openssl_%08x%c", api_version, 0);
124 /* Ask for a correctly-sized block of API message decode slots */
126 vl_msg_api_get_msg_ids ((char *) name, VL_MSG_FIRST_AVAILABLE);
128 error = tls_openssl_plugin_api_hookup (vm);
130 /* Add our API messages to the global name_crc hash table */
131 setup_message_id_table (om, &api_main);
138 * fd.io coding-style-patch-verification: ON
141 * eval: (c-set-style "gnu")