*/
#include <zebra.h>
+#include "log.h"
#include "network.h"
#include "pimd.h"
+#include "pim_str.h"
#include "pim_rp.h"
+static int i_am_rp = 0;
+
+/*
+ * Checks to see if we should elect ourself the actual RP
+ */
+void
+pim_rp_check_rp (struct in_addr old, struct in_addr new)
+{
+ if (PIM_DEBUG_ZEBRA) {
+ char sold[100];
+ char snew[100];
+ char rp[100];
+ pim_inet4_dump("<rp?>", qpim_rp, rp, sizeof(rp));
+ pim_inet4_dump("<old?>", old, sold, sizeof(sold));
+ pim_inet4_dump("<new?>", new, snew, sizeof(snew));
+ zlog_debug("%s: %s for old %s new %s", __func__, rp, sold, snew );
+ }
+
+ if (qpim_rp.s_addr == 0)
+ return;
+
+ if (new.s_addr == qpim_rp.s_addr)
+ {
+ i_am_rp = 1;
+ return;
+ }
+
+ if (old.s_addr == qpim_rp.s_addr)
+ {
+ i_am_rp = 0;
+ return;
+ }
+}
+
+/*
+ * I_am_RP(G) is true if the group-to-RP mapping indicates that
+ * this router is the RP for the group.
+ *
+ * Since we only have static RP, all groups are part of this RP
+ */
+int
+pim_rp_i_am_rp (struct in_addr group)
+{
+ return i_am_rp;
+}
+
/*
* Set the upstream IP address we want to talk to based upon
* the rp configured and the source address
#ifndef PIM_RP_H
#define PIM_RP_H
+void pim_rp_check_rp (struct in_addr old, struct in_addr new);
+int pim_rp_i_am_rp (struct in_addr group);
int pim_rp_set_upstream_addr (struct in_addr *up, struct in_addr source);
#endif