]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_br.c
Merge pull request #11909 from opensourcerouting/fix/a_couple_nits
[mirror_frr.git] / pimd / pim_br.c
CommitLineData
2bd9e1bc
DS
1/*
2 * PIM for Quagga
3 * Copyright (C) 2015 Cumulus Networks, Inc.
4 * Donald Sharp
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
896014f4
DL
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2bd9e1bc
DS
19 */
20#include <zebra.h>
21
22#include "memory.h"
23#include "log.h"
744d91b3 24#include "if.h"
2bd9e1bc
DS
25
26#include "pimd.h"
27#include "pim_str.h"
28#include "pim_br.h"
29#include "linklist.h"
30
31struct pim_br {
6fff2cc6 32 pim_sgaddr sg;
a141ea61 33 pim_addr pmbr;
2bd9e1bc
DS
34};
35
2bd9e1bc
DS
36static struct list *pim_br_list = NULL;
37
a141ea61 38pim_addr pim_br_get_pmbr(pim_sgaddr *sg)
2bd9e1bc 39{
d62a17ae 40 struct listnode *node;
41 struct pim_br *pim_br;
2bd9e1bc 42
d62a17ae 43 for (ALL_LIST_ELEMENTS_RO(pim_br_list, node, pim_br)) {
62f59b58 44 if (!pim_sgaddr_cmp(*sg, pim_br->sg))
d62a17ae 45 return pim_br->pmbr;
46 }
2bd9e1bc 47
e782863d 48 return PIMADDR_ANY;
2bd9e1bc
DS
49}
50
a141ea61 51void pim_br_set_pmbr(pim_sgaddr *sg, pim_addr br)
2bd9e1bc 52{
d62a17ae 53 struct listnode *node, *next;
54 struct pim_br *pim_br;
2bd9e1bc 55
d62a17ae 56 for (ALL_LIST_ELEMENTS(pim_br_list, node, next, pim_br)) {
62f59b58 57 if (!pim_sgaddr_cmp(*sg, pim_br->sg))
d62a17ae 58 break;
59 }
2bd9e1bc 60
d62a17ae 61 if (!pim_br) {
62 pim_br = XCALLOC(MTYPE_PIM_BR, sizeof(*pim_br));
d62a17ae 63 pim_br->sg = *sg;
2bd9e1bc 64
d62a17ae 65 listnode_add(pim_br_list, pim_br);
66 }
2bd9e1bc 67
d62a17ae 68 pim_br->pmbr = br;
2bd9e1bc
DS
69}
70
f14248dd
DS
71/*
72 * Remove the (S,G) from the stored values
73 */
6fff2cc6 74void pim_br_clear_pmbr(pim_sgaddr *sg)
f14248dd 75{
d62a17ae 76 struct listnode *node, *next;
77 struct pim_br *pim_br;
f14248dd 78
d62a17ae 79 for (ALL_LIST_ELEMENTS(pim_br_list, node, next, pim_br)) {
62f59b58 80 if (!pim_sgaddr_cmp(*sg, pim_br->sg))
d62a17ae 81 break;
82 }
f14248dd 83
d62a17ae 84 if (!pim_br)
85 return;
f14248dd 86
d62a17ae 87 listnode_delete(pim_br_list, pim_br);
f14248dd 88}
2bd9e1bc 89
d62a17ae 90void pim_br_init(void)
2bd9e1bc 91{
d62a17ae 92 pim_br_list = list_new();
2bd9e1bc 93}