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

          Line data    Source code
       1             : /*
       2             :  * pg.c: packet generator mpls interface
       3             :  *
       4             :  * Copyright (c) 2012 Cisco and/or its affiliates.
       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             : 
      18             : #include <vlib/vlib.h>
      19             : #include <vnet/pg/pg.h>
      20             : #include <vnet/mpls/mpls.h>
      21             : 
      22             : typedef struct {
      23             :   pg_edit_t label;
      24             : } pg_mpls_header_t;
      25             : 
      26             : static inline void
      27           0 : pg_mpls_header_init (pg_mpls_header_t * e)
      28             : {
      29           0 :   pg_edit_init (&e->label, mpls_unicast_header_t, label_exp_s_ttl);
      30           0 : }
      31             : 
      32             : uword
      33           0 : unformat_pg_mpls_header (unformat_input_t * input, va_list * args)
      34             : {
      35           0 :   pg_stream_t * s = va_arg (*args, pg_stream_t *);
      36             :   pg_mpls_header_t * h;
      37           0 :   vlib_main_t * vm = vlib_get_main();
      38             :   u32 group_index, error;
      39             :   
      40           0 :   h = pg_create_edit_group (s, sizeof (h[0]), sizeof (mpls_unicast_header_t),
      41             :                             &group_index);
      42           0 :   pg_mpls_header_init (h);
      43             : 
      44           0 :   error = 1;
      45           0 :   if (! unformat (input, "%U",
      46             :                   unformat_pg_edit,
      47             :                   unformat_mpls_label_net_byte_order, &h->label))
      48           0 :     goto done;
      49             : 
      50             :   {
      51           0 :     pg_node_t * pg_node = 0;
      52             :     vlib_node_t * ip_lookup_node;
      53             : 
      54           0 :     ip_lookup_node = vlib_get_node_by_name (vm, (u8 *)"ip4-input");
      55           0 :     ASSERT (ip_lookup_node);
      56             : 
      57           0 :     pg_node = pg_get_node (ip_lookup_node->index);
      58             : 
      59           0 :     if (pg_node && pg_node->unformat_edit
      60           0 :         && unformat_user (input, pg_node->unformat_edit, s))
      61             :       ;
      62             :   }
      63             : 
      64           0 :   error = 0;
      65           0 :  done:
      66           0 :   if (error)
      67           0 :     pg_free_edit_group (s);
      68           0 :   return error == 0;
      69             : }
      70             : 

Generated by: LCOV version 1.14