LCOV - code coverage report
Current view: top level - vnet/fib - fib_entry_src_lisp.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 17 36 47.2 %
Date: 2023-07-05 22:20:52 Functions: 6 10 60.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2016 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 "fib_entry.h"
      17             : #include "fib_entry_src.h"
      18             : #include "fib_path_list.h"
      19             : 
      20             : /**
      21             :  * Source initialisation Function 
      22             :  */
      23             : static void
      24           3 : fib_entry_src_lisp_init (fib_entry_src_t *src)
      25             : {
      26           3 : }
      27             : 
      28             : /**
      29             :  * Source deinitialisation Function 
      30             :  */
      31             : static void
      32           1 : fib_entry_src_lisp_deinit (fib_entry_src_t *src)
      33             : {
      34           1 : }
      35             : 
      36             : static void
      37           1 : fib_entry_src_lisp_path_swap (fib_entry_src_t *src,
      38             :                               const fib_entry_t *entry,
      39             :                               fib_path_list_flags_t pl_flags,
      40             :                              const fib_route_path_t *paths)
      41             : {
      42           1 :     src->fes_pl = fib_path_list_create((FIB_PATH_LIST_FLAG_SHARED | pl_flags),
      43             :                                        paths);
      44           1 : }
      45             : 
      46             : static void
      47           0 : fib_entry_src_lisp_path_add (fib_entry_src_t *src,
      48             :                             const fib_entry_t *entry,
      49             :                             fib_path_list_flags_t pl_flags,
      50             :                             const fib_route_path_t *paths)
      51             : {
      52           0 :     if (FIB_NODE_INDEX_INVALID == src->fes_pl)
      53             :     {   
      54           0 :         src->fes_pl =
      55           0 :             fib_path_list_create((FIB_PATH_LIST_FLAG_SHARED | pl_flags), paths);
      56             :     }
      57             :     else
      58             :     {
      59           0 :         src->fes_pl =
      60           0 :             fib_path_list_copy_and_path_add(src->fes_pl,
      61           0 :                                             (FIB_PATH_LIST_FLAG_SHARED | pl_flags),
      62             :                                             paths);
      63             :     }
      64           0 : }
      65             : 
      66             : static void
      67           0 : fib_entry_src_lisp_path_remove (fib_entry_src_t *src,
      68             :                                fib_path_list_flags_t pl_flags,
      69             :                                const fib_route_path_t *paths)
      70             : {
      71           0 :     if (FIB_NODE_INDEX_INVALID != src->fes_pl)
      72             :     {
      73           0 :         src->fes_pl =
      74           0 :             fib_path_list_copy_and_path_remove(src->fes_pl,
      75           0 :                                                (FIB_PATH_LIST_FLAG_SHARED | pl_flags),
      76             :                                                paths);
      77             :     }
      78           0 : }
      79             : 
      80             : static void
      81           3 : fib_entry_src_lisp_add (fib_entry_src_t *src,
      82             :                         const fib_entry_t *entry,
      83             :                         fib_entry_flag_t flags,
      84             :                         dpo_proto_t proto,
      85             :                         const dpo_id_t *dpo)
      86             : {
      87           3 :     if (FIB_ENTRY_FLAG_NONE != flags)
      88             :     {
      89           2 :         src->fes_pl = fib_path_list_create_special(
      90             :                           proto,
      91             :                           fib_entry_src_flags_2_path_list_flags(flags),
      92             :                           dpo);
      93             :     }
      94           3 : }
      95             : 
      96             : static void
      97           1 : fib_entry_src_lisp_remove (fib_entry_src_t *src)
      98             : {
      99           1 :     src->fes_pl = FIB_NODE_INDEX_INVALID;
     100           1 : }
     101             : 
     102             : static void
     103           0 : fib_entry_src_lisp_set_data (fib_entry_src_t *src,
     104             :                              const fib_entry_t *entry,
     105             :                              const void *data)
     106             : {
     107           0 :     src->u.lisp.fesl_fib_index = *(u32*)data;
     108           0 : }
     109             : 
     110             : static const void*
     111           0 : fib_entry_src_lisp_get_data (fib_entry_src_t *src,
     112             :                              const fib_entry_t *entry)
     113             : {
     114           0 :     return (&(src->u.lisp.fesl_fib_index));
     115             : }
     116             : 
     117             : const static fib_entry_src_vft_t lisp_src_vft = {
     118             :     .fesv_init = fib_entry_src_lisp_init,
     119             :     .fesv_deinit = fib_entry_src_lisp_deinit,
     120             :     .fesv_add = fib_entry_src_lisp_add,
     121             :     .fesv_remove = fib_entry_src_lisp_remove,
     122             :     .fesv_path_add = fib_entry_src_lisp_path_add,
     123             :     .fesv_path_swap = fib_entry_src_lisp_path_swap,
     124             :     .fesv_path_remove = fib_entry_src_lisp_path_remove,
     125             :     .fesv_set_data = fib_entry_src_lisp_set_data,
     126             :     .fesv_get_data = fib_entry_src_lisp_get_data,
     127             : };
     128             : 
     129             : void
     130         559 : fib_entry_src_lisp_register (void)
     131             : {
     132         559 :     fib_entry_src_behaviour_register(FIB_SOURCE_BH_LISP,
     133             :                                      &lisp_src_vft);
     134         559 : }

Generated by: LCOV version 1.14