back to topotato report
topotato coverage report
Current view: top level - pimd - pim_addr.c (source / functions) Hit Total Coverage
Test: test_pim_basic2.py::PIMTopo2Test Lines: 11 18 61.1 %
Date: 2023-02-24 18:39:36 Functions: 3 4 75.0 %

          Line data    Source code
       1             : /*
       2             :  * PIM address generalizations
       3             :  * Copyright (C) 2022  David Lamparter for NetDEF, Inc.
       4             :  *
       5             :  * This program is free software; you can redistribute it and/or modify it
       6             :  * under the terms of the GNU General Public License as published by the Free
       7             :  * Software Foundation; either version 2 of the License, or (at your option)
       8             :  * any later version.
       9             :  *
      10             :  * This program is distributed in the hope that it will be useful, but WITHOUT
      11             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             :  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
      13             :  * more details.
      14             :  *
      15             :  * You should have received a copy of the GNU General Public License along
      16             :  * with this program; see the file COPYING; if not, write to the Free Software
      17             :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
      18             :  */
      19             : 
      20             : #include <zebra.h>
      21             : 
      22             : #include "pim_addr.h"
      23             : #include "printfrr.h"
      24             : #include "prefix.h"
      25             : 
      26             : 
      27           4 : printfrr_ext_autoreg_p("PA", printfrr_pimaddr);
      28          29 : static ssize_t printfrr_pimaddr(struct fbuf *buf, struct printfrr_eargs *ea,
      29             :                                 const void *vptr)
      30             : {
      31          29 :         const pim_addr *addr = vptr;
      32          29 :         bool use_star = false;
      33             : 
      34          29 :         if (ea->fmt[0] == 's') {
      35          13 :                 use_star = true;
      36          13 :                 ea->fmt++;
      37             :         }
      38             : 
      39          29 :         if (!addr)
      40           0 :                 return bputs(buf, "(null)");
      41             : 
      42          29 :         if (use_star && pim_addr_is_any(*addr))
      43           0 :                 return bputch(buf, '*');
      44             : 
      45             : #if PIM_IPV == 4
      46          29 :         return bprintfrr(buf, "%pI4", addr);
      47             : #else
      48             :         return bprintfrr(buf, "%pI6", addr);
      49             : #endif
      50             : }
      51             : 
      52           4 : printfrr_ext_autoreg_p("SG", printfrr_sgaddr);
      53           0 : static ssize_t printfrr_sgaddr(struct fbuf *buf, struct printfrr_eargs *ea,
      54             :                                const void *vptr)
      55             : {
      56           0 :         const pim_sgaddr *sga = vptr;
      57             : 
      58           0 :         if (!sga)
      59           0 :                 return bputs(buf, "(null)");
      60             : 
      61           0 :         return bprintfrr(buf, "(%pPAs,%pPAs)", &sga->src, &sga->grp);
      62             : }

Generated by: LCOV version v1.16-topotato