]> git.proxmox.com Git - mirror_frr.git/commitdiff
Pimd: pim register send is being sent and received at the RP
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 29 Oct 2015 18:27:39 +0000 (11:27 -0700)
committerDonald Sharp <sharpd@cumulusnetwroks.com>
Thu, 26 May 2016 00:38:35 +0000 (20:38 -0400)
Modify the code to send a register packet upstream to the RP.
Packet is currently being received but not properly decoded
currently.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_mroute.c
pimd/pim_register.c
pimd/pim_register.h

index 55ef44b3f07820e7671b207d33139f059ecf7500..eefa392799b57f39d907b9b0ae7008e8742f7565 100644 (file)
@@ -33,6 +33,7 @@
 #include "pim_macro.h"
 #include "pim_rp.h"
 #include "pim_oil.h"
+#include "pim_register.h"
 
 /* GLOBAL VARS */
 extern struct zebra_privs_t pimd_privs;
@@ -133,7 +134,6 @@ pim_mroute_msg_wholepkt (int fd, struct interface *ifp, const char *buf,
   const struct ip *ip_hdr;
   struct pim_upstream *up;
 
-  zlog_debug("%s:", __PRETTY_FUNCTION__);
   ip_hdr = (const struct ip *)buf;
 
   src = ip_hdr->ip_src;
@@ -148,16 +148,21 @@ pim_mroute_msg_wholepkt (int fd, struct interface *ifp, const char *buf,
     return 0;
   }
 
+  pim_ifp = up->rpf.source_nexthop.interface->info;
+
   rpg = RP(group);
 
   if ((rpg->rpf_addr.s_addr == INADDR_NONE) ||
       (!pim_ifp) ||
       (!PIM_I_am_DR(pim_ifp)) ||
       (pim_ifp->itype == PIM_INTERFACE_SSM)) {
+    if (PIM_DEBUG_PIM_TRACE) {
+      zlog_debug("%s: Failed Check send packet", __PRETTY_FUNCTION__);
+    }
     return 0;
   }
 
-  //pim_register_send(buf, rpg);
+  pim_register_send((const struct ip *)(buf + sizeof(struct ip)), rpg);
   return 0;
 }
 
index a8ecbdf90e484e3bec736834a27e31754d2ca6c3..3fc4a61ae46f5e4c082823774f778fc06c691b70 100644 (file)
 #include "thread.h"
 
 #include "pimd.h"
+#include "pim_mroute.h"
+#include "pim_iface.h"
+#include "pim_msg.h"
+#include "pim_pim.h"
 #include "pim_str.h"
 #include "pim_rp.h"
 #include "pim_register.h"
@@ -62,6 +66,43 @@ pim_register_stop_send (struct in_addr src)
   return;
 }
 
+void
+pim_register_send (const struct ip *ip_hdr, struct pim_rpf *rpg)
+{
+  unsigned char buffer[3000];
+  unsigned char *b1;
+  struct pim_interface *pinfo;
+  struct interface *ifp;
+  uint32_t plen;
+
+  ifp = rpg->source_nexthop.interface;
+  pinfo = (struct pim_interface *)ifp->info;
+  if (!pinfo) {
+    zlog_debug("%s: No pinfo!\n", __PRETTY_FUNCTION__);
+    return;
+  }
+
+  memset(buffer, 0, 3000);
+  b1 = buffer + PIM_MSG_REGISTER_LEN;
+
+  plen = ntohs(ip_hdr->ip_len);
+  memcpy(b1, (unsigned char *)ip_hdr, plen);
+
+  pim_msg_build_header(buffer, plen + PIM_MSG_HEADER_LEN, PIM_MSG_TYPE_REGISTER);
+
+  if (pim_msg_send(pinfo->pim_sock_fd,
+                  rpg->rpf_addr,
+                  buffer,
+                  plen + PIM_MSG_REGISTER_LEN,
+                  ifp->name)) {
+    if (PIM_DEBUG_PIM_TRACE) {
+      zlog_debug("%s: could not send PIM register message on interface %s",
+                __PRETTY_FUNCTION__, ifp->name);
+    }
+    return;
+  }
+}
+
 /*
  * 4.4.2 Receiving Register Messages at the RP
  *
index 76214ee1aad108f5e57a0d212cca8c185ead3b76..7f3cdea3a2a03ce3d50a177f5859bedf5d408ff1 100644 (file)
@@ -28,7 +28,7 @@
 #define PIM_REGISTER_BORDER_BIT 0x80000000
 #define PIM_REGISTER_NR_BIT     0x40000000
 
-#define PIM_MSG_REGISTER_LEN   (4)
+#define PIM_MSG_REGISTER_LEN   (8)
 
 void pim_register_send_test_packet_start (struct in_addr source,
                                          struct in_addr group,
@@ -39,4 +39,6 @@ int pim_register_recv (struct interface *ifp,
                       struct in_addr src_addr,
                       uint8_t *tlv_buf, int tlv_buf_size);
 
+void pim_register_send (const struct ip *msg, struct pim_rpf *rpg);
+
 #endif