LCOV - code coverage report
Current view: top level - plugins/tlsopenssl - tls_openssl_test.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 0 30 0.0 %
Date: 2023-07-05 22:20:52 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*
       2             :  * tls_openssl_test.c - skeleton vpp-api-test plug-in
       3             :  *
       4             :  * Copyright (c) 2019 Intel Corporation
       5             :  * Licensed under the Apache License, Version 2.0 (the "License");
       6             :  * you may not use this file except in compliance with the License.
       7             :  * You may obtain a copy of the License at:
       8             :  *
       9             :  *     http://www.apache.org/licenses/LICENSE-2.0
      10             :  *
      11             :  * Unless required by applicable law or agreed to in writing, software
      12             :  * distributed under the License is distributed on an "AS IS" BASIS,
      13             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      14             :  * See the License for the specific language governing permissions and
      15             :  * limitations under the License.
      16             :  */
      17             : #include <vat/vat.h>
      18             : #include <vlibapi/api.h>
      19             : #include <vlibmemory/api.h>
      20             : #include <vppinfra/error.h>
      21             : #include <ctype.h>
      22             : 
      23             : uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
      24             : 
      25             : /* Declare message IDs */
      26             : #include <tlsopenssl/tls_openssl.api_enum.h>
      27             : #include <tlsopenssl/tls_openssl.api_types.h>
      28             : 
      29             : typedef struct
      30             : {
      31             :   /* API message ID base */
      32             :   u16 msg_id_base;
      33             :   vat_main_t *vat_main;
      34             : } tls_openssl_test_main_t;
      35             : 
      36             : tls_openssl_test_main_t tls_openssl_test_main;
      37             : 
      38             : #define __plugin_msg_base tls_openssl_test_main.msg_id_base
      39             : #include <vlibapi/vat_helper_macros.h>
      40             : 
      41             : static int
      42           0 : api_tls_openssl_set_engine (vat_main_t * vam)
      43             : {
      44           0 :   unformat_input_t *line_input = vam->input;
      45             :   vl_api_tls_openssl_set_engine_t *mp;
      46           0 :   u8 *engine_name = 0;
      47           0 :   u8 *engine_alg = 0;
      48           0 :   u8 *ciphers = 0;
      49           0 :   u32 async = 0;
      50             :   int ret;
      51             : 
      52             :   /* Parse args required to build the message */
      53           0 :   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
      54             :     {
      55           0 :       if (unformat (line_input, "engine %s", &engine_name))
      56             :         ;
      57           0 :       else if (unformat (line_input, "async"))
      58             :         {
      59           0 :           async = 1;
      60             :         }
      61           0 :       else if (unformat (line_input, "alg %s", &engine_alg))
      62             :         ;
      63           0 :       else if (unformat (line_input, "ciphers %s", &ciphers))
      64             :         ;
      65             :       else
      66             :         {
      67           0 :           errmsg ("unknown input `%U'", format_unformat_error, line_input);
      68           0 :           return -99;
      69             :         }
      70             :     }
      71             : 
      72           0 :   if (engine_name == 0)
      73             :     {
      74           0 :       errmsg ("Must specify engine name");
      75           0 :       return -99;
      76             :     }
      77             : 
      78           0 :   if (engine_alg == 0)
      79           0 :     engine_alg = format (0, "ALL");
      80             :   else
      81             :     {
      82           0 :       for (int i = 0; i < strnlen ((char *) engine_alg, 63); i++)
      83           0 :         engine_alg[i] = toupper (engine_alg[i]);
      84             :     }
      85             : 
      86             : 
      87             :   /* Construct the API message */
      88           0 :   M (TLS_OPENSSL_SET_ENGINE, mp);
      89           0 :   mp->async_enable = async;
      90             : 
      91           0 :   clib_memcpy_fast (mp->engine, engine_name,
      92             :                     strnlen ((const char *) engine_name, 63));
      93             : 
      94           0 :   clib_memcpy_fast (mp->algorithm, engine_alg,
      95             :                     strnlen ((const char *) engine_alg, 63));
      96             : 
      97           0 :   if (ciphers)
      98           0 :     clib_memcpy_fast (mp->ciphers, ciphers,
      99             :                       strnlen ((const char *) ciphers, 63));
     100             : 
     101             :   /* send it... */
     102           0 :   S (mp);
     103             : 
     104             :   /* Wait for a reply... */
     105           0 :   W (ret);
     106           0 :   return ret;
     107             : }
     108             : 
     109             : #include <tlsopenssl/tls_openssl.api_test.c>
     110             : 
     111             : /*
     112             :  * fd.io coding-style-patch-verification: ON
     113             :  *
     114             :  * Local Variables:
     115             :  * eval: (c-set-style "gnu")
     116             :  * End:
     117             :  */

Generated by: LCOV version 1.14