]>
git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_br.c
3 * Copyright (C) 2015 Cumulus Networks, Inc.
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.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
33 struct in_addr source
;
38 struct in_addr pim_br_unknown
= { .s_addr
= 0 };
40 static struct list
*pim_br_list
= NULL
;
43 pim_br_get_pmbr (struct in_addr source
, struct in_addr group
)
45 struct listnode
*node
;
46 struct pim_br
*pim_br
;
48 for (ALL_LIST_ELEMENTS_RO (pim_br_list
, node
, pim_br
)) {
49 if (source
.s_addr
== pim_br
->source
.s_addr
&&
50 group
.s_addr
== pim_br
->group
.s_addr
)
54 return pim_br_unknown
;
58 pim_br_set_pmbr (struct in_addr source
, struct in_addr group
, struct in_addr br
)
60 struct listnode
*node
, *next
;
61 struct pim_br
*pim_br
;
63 for (ALL_LIST_ELEMENTS (pim_br_list
, node
, next
, pim_br
)) {
64 if (source
.s_addr
== pim_br
->source
.s_addr
&&
65 group
.s_addr
== pim_br
->group
.s_addr
)
70 pim_br
= XCALLOC(MTYPE_PIM_BR
, sizeof (*pim_br
));
72 zlog_err("PIM XCALLOC(%zu) failure", sizeof(*pim_br
));
76 pim_br
->source
= source
;
77 pim_br
->group
= group
;
79 listnode_add(pim_br_list
, pim_br
);
86 * Remove the (S,G) from the stored values
89 pim_br_clear_pmbr (struct in_addr source
, struct in_addr group
)
91 struct listnode
*node
, *next
;
92 struct pim_br
*pim_br
;
94 for (ALL_LIST_ELEMENTS (pim_br_list
, node
, next
, pim_br
)) {
95 if (source
.s_addr
== pim_br
->source
.s_addr
&&
96 group
.s_addr
== pim_br
->group
.s_addr
)
103 listnode_delete (pim_br_list
, pim_br
);
106 void pim_br_init (void)
108 pim_br_list
= list_new();
110 zlog_err("%s: Failure to create pim_br_list",
111 __PRETTY_FUNCTION__
);