LCOV - code coverage report
Current view: top level - vnet/srmpls - sr_mpls_test.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 0 54 0.0 %
Date: 2023-07-05 22:20:52 Functions: 0 5 0.0 %

          Line data    Source code
       1             : /*
       2             :  *------------------------------------------------------------------
       3             :  * Copyright (c) 2021 Cisco and/or its affiliates.
       4             :  * Licensed under the Apache License, Version 2.0 (the "License");
       5             :  * you may not use this file except in compliance with the License.
       6             :  * You may obtain a copy of the License at:
       7             :  *
       8             :  *     http://www.apache.org/licenses/LICENSE-2.0
       9             :  *
      10             :  * Unless required by applicable law or agreed to in writing, software
      11             :  * distributed under the License is distributed on an "AS IS" BASIS,
      12             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13             :  * See the License for the specific language governing permissions and
      14             :  * limitations under the License.
      15             :  *------------------------------------------------------------------
      16             :  */
      17             : #include <vat/vat.h>
      18             : #include <vlibapi/api.h>
      19             : #include <vlibmemory/api.h>
      20             : #include <vppinfra/error.h>
      21             : #include <vpp/api/types.h>
      22             : 
      23             : #define __plugin_msg_base sr_mpls_test_main.msg_id_base
      24             : #include <vlibapi/vat_helper_macros.h>
      25             : 
      26             : /* Declare message IDs */
      27             : #include <vnet/format_fns.h>
      28             : #include <vnet/srmpls/sr_mpls.api_enum.h>
      29             : #include <vnet/srmpls/sr_mpls.api_types.h>
      30             : 
      31             : #define vl_endianfun /* define message structures */
      32             : #include <vnet/srmpls/sr_mpls.api.h>
      33             : #undef vl_endianfun
      34             : 
      35             : typedef struct
      36             : {
      37             :   /* API message ID base */
      38             :   u16 msg_id_base;
      39             :   u32 ping_id;
      40             :   vat_main_t *vat_main;
      41             : } sr_mpls_test_main_t;
      42             : 
      43             : static sr_mpls_test_main_t sr_mpls_test_main;
      44             : 
      45             : static int
      46           0 : api_sr_mpls_policy_mod (vat_main_t *vam)
      47             : {
      48           0 :   return -1;
      49             : }
      50             : 
      51             : static int
      52           0 : api_sr_mpls_steering_add_del (vat_main_t *vam)
      53             : {
      54           0 :   return -1;
      55             : }
      56             : 
      57             : static int
      58           0 : api_sr_mpls_policy_assign_endpoint_color (vat_main_t *vam)
      59             : {
      60           0 :   return -1;
      61             : }
      62             : 
      63             : static int
      64           0 : api_sr_mpls_policy_add (vat_main_t *vam)
      65             : {
      66           0 :   unformat_input_t *i = vam->input;
      67             :   vl_api_sr_mpls_policy_add_t *mp;
      68           0 :   u32 bsid = 0;
      69           0 :   u32 weight = 1;
      70           0 :   u8 type = 0;
      71           0 :   u8 n_segments = 0;
      72             :   u32 sid;
      73           0 :   u32 *segments = NULL;
      74             :   int ret;
      75             : 
      76             :   /* Parse args required to build the message */
      77           0 :   while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
      78             :     {
      79           0 :       if (unformat (i, "bsid %d", &bsid))
      80             :         ;
      81           0 :       else if (unformat (i, "weight %d", &weight))
      82             :         ;
      83           0 :       else if (unformat (i, "spray"))
      84           0 :         type = 1;
      85           0 :       else if (unformat (i, "next %d", &sid))
      86             :         {
      87           0 :           n_segments += 1;
      88           0 :           vec_add1 (segments, htonl (sid));
      89             :         }
      90             :       else
      91             :         {
      92           0 :           clib_warning ("parse error '%U'", format_unformat_error, i);
      93           0 :           return -99;
      94             :         }
      95             :     }
      96             : 
      97           0 :   if (bsid == 0)
      98             :     {
      99           0 :       errmsg ("bsid not set");
     100           0 :       return -99;
     101             :     }
     102             : 
     103           0 :   if (n_segments == 0)
     104             :     {
     105           0 :       errmsg ("no sid in segment stack");
     106           0 :       return -99;
     107             :     }
     108             : 
     109             :   /* Construct the API message */
     110           0 :   M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
     111             : 
     112           0 :   mp->bsid = htonl (bsid);
     113           0 :   mp->weight = htonl (weight);
     114           0 :   mp->is_spray = type;
     115           0 :   mp->n_segments = n_segments;
     116           0 :   memcpy (mp->segments, segments, sizeof (u32) * n_segments);
     117           0 :   vec_free (segments);
     118             : 
     119             :   /* send it... */
     120           0 :   S (mp);
     121             : 
     122             :   /* Wait for a reply... */
     123           0 :   W (ret);
     124           0 :   return ret;
     125             : }
     126             : 
     127             : static int
     128           0 : api_sr_mpls_policy_del (vat_main_t *vam)
     129             : {
     130           0 :   unformat_input_t *i = vam->input;
     131             :   vl_api_sr_mpls_policy_del_t *mp;
     132           0 :   u32 bsid = 0;
     133             :   int ret;
     134             : 
     135             :   /* Parse args required to build the message */
     136           0 :   while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
     137             :     {
     138           0 :       if (unformat (i, "bsid %d", &bsid))
     139             :         ;
     140             :       else
     141             :         {
     142           0 :           clib_warning ("parse error '%U'", format_unformat_error, i);
     143           0 :           return -99;
     144             :         }
     145             :     }
     146             : 
     147           0 :   if (bsid == 0)
     148             :     {
     149           0 :       errmsg ("bsid not set");
     150           0 :       return -99;
     151             :     }
     152             : 
     153             :   /* Construct the API message */
     154           0 :   M (SR_MPLS_POLICY_DEL, mp);
     155             : 
     156           0 :   mp->bsid = htonl (bsid);
     157             : 
     158             :   /* send it... */
     159           0 :   S (mp);
     160             : 
     161             :   /* Wait for a reply... */
     162           0 :   W (ret);
     163           0 :   return ret;
     164             : }
     165             : 
     166             : #include <vnet/srmpls/sr_mpls.api_test.c>
     167             : 
     168             : /*
     169             :  * fd.io coding-style-patch-verification: ON
     170             :  *
     171             :  * Local Variables:
     172             :  * eval: (c-set-style "gnu")
     173             :  * End:
     174             :  */

Generated by: LCOV version 1.14