From: Donald Sharp Date: Mon, 18 Jul 2016 00:18:33 +0000 (-0400) Subject: pimd: Add null_register bit to pim_register_send X-Git-Tag: frr-3.0-branchpoint~64^2~10^2~378 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b100a4f5b943acd92b3166058b0a718afa27280c;p=matthieu%2Ffrr.git pimd: Add null_register bit to pim_register_send When sending a pim register message to an RP, we need the ability to set the null bit in the message. This adds the ability to do so. Additionally we need to switch the ip_hdr to a const uint8_t *buf because pim_register_send really shouldn't know or care about the fact it's a 'struct ip'. Signed-off-by: Donald Sharp --- diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c index bf996a738b..83a3b1045d 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -198,7 +198,7 @@ pim_mroute_msg_wholepkt (int fd, struct interface *ifp, const char *buf, * If we've received a register suppress */ if (!up->t_rs_timer) - pim_register_send((const struct ip *)(buf + sizeof(struct ip)), rpg); + pim_register_send((uint8_t *)buf + sizeof(struct ip), ntohs (ip_hdr->ip_len), rpg, 0); return 0; } diff --git a/pimd/pim_register.c b/pimd/pim_register.c index a3e63f0285..2876dec83f 100644 --- a/pimd/pim_register.c +++ b/pimd/pim_register.c @@ -119,13 +119,12 @@ pim_register_stop_recv (void) } void -pim_register_send (const struct ip *ip_hdr, struct pim_rpf *rpg) +pim_register_send (const uint8_t *buf, int buf_size, struct pim_rpf *rpg, int null_register) { 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; @@ -135,17 +134,18 @@ pim_register_send (const struct ip *ip_hdr, struct pim_rpf *rpg) } memset(buffer, 0, 3000); + b1 = buffer + PIM_MSG_HEADER_LEN; + *b1 |= null_register << 31; b1 = buffer + PIM_MSG_REGISTER_LEN; - plen = ntohs(ip_hdr->ip_len); - memcpy(b1, (const unsigned char *)ip_hdr, plen); + memcpy(b1, (const unsigned char *)buf, buf_size); - pim_msg_build_header(buffer, plen + PIM_MSG_REGISTER_LEN, PIM_MSG_TYPE_REGISTER); + pim_msg_build_header(buffer, buf_size + PIM_MSG_REGISTER_LEN, PIM_MSG_TYPE_REGISTER); if (pim_msg_send(pinfo->pim_sock_fd, rpg->rpf_addr, buffer, - plen + PIM_MSG_REGISTER_LEN, + buf_size + PIM_MSG_REGISTER_LEN, ifp->name)) { if (PIM_DEBUG_PIM_TRACE) { zlog_debug("%s: could not send PIM register message on interface %s", diff --git a/pimd/pim_register.h b/pimd/pim_register.h index 4749480b9d..3de1557966 100644 --- a/pimd/pim_register.h +++ b/pimd/pim_register.h @@ -41,6 +41,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); +void pim_register_send (const uint8_t *buf, int buf_size, struct pim_rpf *rpg, int null_register); #endif