]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Start adding the ability to handle the Bridge Router
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 15 Oct 2015 13:19:31 +0000 (06:19 -0700)
committerDonald Sharp <sharpd@cumulusnetwroks.com>
Thu, 26 May 2016 00:38:34 +0000 (20:38 -0400)
Add code to allow the check and set the PMBR(S,G) if the register.borderbit
is set.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/memtypes.c
pimd/Makefile.am
pimd/pim_br.c [new file with mode: 0644]
pimd/pim_br.h [new file with mode: 0644]

index d0db1bc996eef7eb22a02e52dd07887a727a1d3b..7d75f31a3d8848279d738a15211913de4101f21f 100644 (file)
@@ -284,6 +284,7 @@ struct memory_list memory_list_pim[] =
   { MTYPE_PIM_UPSTREAM,          "PIM upstream (S,G) state"       },
   { MTYPE_PIM_SSMPINGD,          "PIM sspimgd socket"             },
   { MTYPE_PIM_STATIC_ROUTE,      "PIM Static Route"               },
+  { MTYPE_PIM_BR,                "PIM Bridge Router info"         },
   { -1, NULL },
 };
 
index 8e0f5e91ddcd809e0c50a41f9e41b679b31f0aba..3e2d992cdb5bba3a7d2191e001ee04b0813ae64b 100644 (file)
@@ -53,7 +53,8 @@ libpim_a_SOURCES = \
        pim_oil.c pim_zlookup.c pim_pim.c pim_tlv.c pim_neighbor.c \
        pim_hello.c pim_ifchannel.c pim_join.c pim_assert.c \
        pim_msg.c pim_upstream.c pim_rpf.c pim_macro.c \
-       pim_igmp_join.c pim_ssmpingd.c pim_int.c pim_rp.c pim_static.c
+       pim_igmp_join.c pim_ssmpingd.c pim_int.c pim_rp.c \
+       pim_static.c pim_br.c
 
 noinst_HEADERS = \
        pimd.h pim_version.h pim_cmd.h pim_signals.h pim_iface.h \
@@ -62,7 +63,8 @@ noinst_HEADERS = \
        pim_oil.h pim_zlookup.h pim_pim.h pim_tlv.h pim_neighbor.h \
        pim_hello.h pim_ifchannel.h pim_join.h pim_assert.h \
        pim_msg.h pim_upstream.h pim_rpf.h pim_macro.h \
-       pim_igmp_join.h pim_ssmpingd.h pim_int.h pim_rp.h pim_static.h
+       pim_igmp_join.h pim_ssmpingd.h pim_int.h pim_rp.h \
+       pim_static.h pim_br.h
 
 pimd_SOURCES = \
        pim_main.c $(libpim_a_SOURCES)
diff --git a/pimd/pim_br.c b/pimd/pim_br.c
new file mode 100644 (file)
index 0000000..db4aa3e
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * PIM for Quagga
+ * Copyright (C) 2015 Cumulus Networks, Inc.
+ * Donald Sharp
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+#include <zebra.h>
+
+#include "memory.h"
+#include "log.h"
+
+#include "pimd.h"
+#include "pim_str.h"
+#include "pim_br.h"
+#include "linklist.h"
+
+struct pim_br {
+  struct in_addr source;
+  struct in_addr group;
+  struct in_addr pmbr;
+};
+
+struct in_addr pim_br_unknown = { .s_addr = 0 };
+
+static struct list *pim_br_list = NULL;
+
+struct in_addr
+pim_br_get_pmbr (struct in_addr source, struct in_addr group)
+{
+  struct listnode *node;
+  struct pim_br   *pim_br;
+
+  for (ALL_LIST_ELEMENTS_RO (pim_br_list, node, pim_br)) {
+    if (source.s_addr == pim_br->source.s_addr &&
+       group.s_addr == pim_br->group.s_addr)
+      return pim_br->pmbr;
+  }
+
+  return pim_br_unknown;
+}
+
+void
+pim_br_set_pmbr (struct in_addr source, struct in_addr group, struct in_addr br)
+{
+  struct listnode *node, *next;
+  struct pim_br *pim_br;
+
+  for (ALL_LIST_ELEMENTS (pim_br_list, node, next, pim_br)) {
+    if (source.s_addr == pim_br->source.s_addr &&
+       group.s_addr == pim_br->group.s_addr)
+      break;
+  }
+
+  if (!pim_br) {
+    pim_br = XCALLOC(MTYPE_PIM_BR, sizeof (*pim_br));
+    if (!pim_br) {
+      zlog_err("PIM XCALLOC(%zu) failure", sizeof(*pim_br));
+      return;
+    }
+
+    pim_br->source = source;
+    pim_br->group = group;
+
+    listnode_add(pim_br_list, pim_br);
+  }
+
+  pim_br->pmbr = br;
+}
+
+
+void pim_br_init (void)
+{
+  pim_br_list = list_new();
+  if (!pim_br_list) {
+    zlog_err("%s: Failure to create pim_br_list",
+            __PRETTY_FUNCTION__);
+    return;
+  }
+}
diff --git a/pimd/pim_br.h b/pimd/pim_br.h
new file mode 100644 (file)
index 0000000..8986d01
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * PIM for Quagga
+ * Copyright (C) 2015 Cumulus Networks, Inc.
+ * Donald Sharp
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+#ifndef PIM_BR_H
+#define PIM_BR_H
+
+struct in_addr pim_br_get_pmbr (struct in_addr source, struct in_addr group);
+
+void pim_br_set_pmbr (struct in_addr source, struct in_addr group, struct in_addr value);
+
+void pim_br_init (void);
+
+extern struct in_addr pim_br_unknown;
+
+#endif