diff options
author | saravanank <saravanank@vmware.com> | 2019-05-04 14:07:39 +0200 |
---|---|---|
committer | saravanank <saravanank@vmware.com> | 2019-05-15 06:40:50 +0200 |
commit | d57a8bbf4591ae00dcaa0f9dac29cc936cce505d (patch) | |
tree | 6baeb96f2f4ea3e325a5d6dd107fb96fa7fe66c7 /pimd | |
parent | pimd: PIM BSM Processing bootstrap timer expiry handling (diff) | |
download | frr-d57a8bbf4591ae00dcaa0f9dac29cc936cce505d.tar.xz frr-d57a8bbf4591ae00dcaa0f9dac29cc936cce505d.zip |
pimd: PIM Msg header includes N bit as defined by RFC
This commit includes parsing of Nbit and contructing pim hdr with Nbit
Adding Nbit to PIm hdr structure
Adding Scope zone bit and Bidir bit to Encoded IPv4 Group Address
Signed-off-by: Saravanan K <saravanank@vmware.com>
Diffstat (limited to 'pimd')
-rw-r--r-- | pimd/pim_assert.c | 2 | ||||
-rw-r--r-- | pimd/pim_join.c | 6 | ||||
-rw-r--r-- | pimd/pim_msg.c | 3 | ||||
-rw-r--r-- | pimd/pim_msg.h | 19 | ||||
-rw-r--r-- | pimd/pim_pim.c | 4 | ||||
-rw-r--r-- | pimd/pim_register.c | 4 |
6 files changed, 27 insertions, 11 deletions
diff --git a/pimd/pim_assert.c b/pimd/pim_assert.c index 0a450834e..438a0c9b6 100644 --- a/pimd/pim_assert.c +++ b/pimd/pim_assert.c @@ -418,7 +418,7 @@ int pim_assert_build_msg(uint8_t *pim_msg, int buf_size, struct interface *ifp, Add PIM header */ pim_msg_size = pim_msg_curr - pim_msg; - pim_msg_build_header(pim_msg, pim_msg_size, PIM_MSG_TYPE_ASSERT); + pim_msg_build_header(pim_msg, pim_msg_size, PIM_MSG_TYPE_ASSERT, false); return pim_msg_size; } diff --git a/pimd/pim_join.c b/pimd/pim_join.c index cbacaf3ea..5e1a4f0c5 100644 --- a/pimd/pim_join.c +++ b/pimd/pim_join.c @@ -519,7 +519,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups) group_size = pim_msg_get_jp_group_size(group->sources); if (group_size > packet_left) { pim_msg_build_header(pim_msg, packet_size, - PIM_MSG_TYPE_JOIN_PRUNE); + PIM_MSG_TYPE_JOIN_PRUNE, false); if (pim_msg_send(pim_ifp->pim_sock_fd, pim_ifp->primary_address, qpim_all_pim_routers_addr, pim_msg, @@ -576,7 +576,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups) if (packet_left < sizeof(struct pim_jp_groups) || msg->num_groups == 255) { pim_msg_build_header(pim_msg, packet_size, - PIM_MSG_TYPE_JOIN_PRUNE); + PIM_MSG_TYPE_JOIN_PRUNE, false); if (pim_msg_send(pim_ifp->pim_sock_fd, pim_ifp->primary_address, qpim_all_pim_routers_addr, pim_msg, @@ -596,7 +596,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups) if (!new_packet) { // msg->num_groups = htons (msg->num_groups); pim_msg_build_header(pim_msg, packet_size, - PIM_MSG_TYPE_JOIN_PRUNE); + PIM_MSG_TYPE_JOIN_PRUNE, false); if (pim_msg_send(pim_ifp->pim_sock_fd, pim_ifp->primary_address, qpim_all_pim_routers_addr, pim_msg, packet_size, diff --git a/pimd/pim_msg.c b/pimd/pim_msg.c index 63688f87e..2e467502b 100644 --- a/pimd/pim_msg.c +++ b/pimd/pim_msg.c @@ -39,7 +39,7 @@ #include "pim_oil.h" void pim_msg_build_header(uint8_t *pim_msg, size_t pim_msg_size, - uint8_t pim_msg_type) + uint8_t pim_msg_type, bool no_fwd) { struct pim_msg_header *header = (struct pim_msg_header *)pim_msg; @@ -48,6 +48,7 @@ void pim_msg_build_header(uint8_t *pim_msg, size_t pim_msg_size, */ header->ver = PIM_PROTO_VERSION; header->type = pim_msg_type; + header->Nbit = no_fwd; header->reserved = 0; diff --git a/pimd/pim_msg.h b/pimd/pim_msg.h index ad9b5d9c0..5f5030396 100644 --- a/pimd/pim_msg.h +++ b/pimd/pim_msg.h @@ -23,6 +23,8 @@ #include <netinet/in.h> #include "pim_jp_agg.h" + +#define PIM_HDR_LEN sizeof(struct pim_msg_header) /* Number Description ---------- ------------------ @@ -41,11 +43,20 @@ enum pim_msg_address_family { /* * Network Order pim_msg_hdr + * ========================= + * PIM Header definition as per RFC 5059. N bit introduced to indicate + * do-not-forward option in PIM Boot strap Message. + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |PIM Ver| Type |N| Reserved | Checksum | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct pim_msg_header { uint8_t type : 4; uint8_t ver : 4; - uint8_t reserved; + uint8_t Nbit : 1; /* No Fwd Bit */ + uint8_t reserved : 7; uint16_t checksum; } __attribute__((packed)); @@ -58,7 +69,9 @@ struct pim_encoded_ipv4_unicast { struct pim_encoded_group_ipv4 { uint8_t ne; uint8_t family; - uint8_t reserved; + uint8_t bidir : 1; /* Bidir bit */ + uint8_t reserved : 6; /* Reserved */ + uint8_t sz : 1; /* scope zone bit */ uint8_t mask; struct in_addr addr; } __attribute__((packed)); @@ -88,7 +101,7 @@ struct pim_jp { } __attribute__((packed)); void pim_msg_build_header(uint8_t *pim_msg, size_t pim_msg_size, - uint8_t pim_msg_type); + uint8_t pim_msg_type, bool no_fwd); uint8_t *pim_msg_addr_encode_ipv4_ucast(uint8_t *buf, struct in_addr addr); uint8_t *pim_msg_addr_encode_ipv4_group(uint8_t *buf, struct in_addr addr); diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c index 71b0d4792..e9d44b9c3 100644 --- a/pimd/pim_pim.c +++ b/pimd/pim_pim.c @@ -39,6 +39,7 @@ #include "pim_msg.h" #include "pim_register.h" #include "pim_errors.h" +#include "pim_bsm.h" static int on_pim_hello_send(struct thread *t); static int pim_hello_send(struct interface *ifp, uint16_t holdtime); @@ -273,6 +274,7 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len) pim_msg + PIM_MSG_HEADER_LEN, pim_msg_len - PIM_MSG_HEADER_LEN); break; + default: if (PIM_DEBUG_PIM_PACKETS) { zlog_debug( @@ -634,7 +636,7 @@ static int hello_send(struct interface *ifp, uint16_t holdtime) zassert(pim_msg_size >= PIM_PIM_MIN_LEN); zassert(pim_msg_size <= PIM_PIM_BUFSIZE_WRITE); - pim_msg_build_header(pim_msg, pim_msg_size, PIM_MSG_TYPE_HELLO); + pim_msg_build_header(pim_msg, pim_msg_size, PIM_MSG_TYPE_HELLO, false); if (pim_msg_send(pim_ifp->pim_sock_fd, pim_ifp->primary_address, qpim_all_pim_routers_addr, pim_msg, pim_msg_size, diff --git a/pimd/pim_register.c b/pimd/pim_register.c index 431236eeb..3fe7e8bf6 100644 --- a/pimd/pim_register.c +++ b/pimd/pim_register.c @@ -94,7 +94,7 @@ void pim_register_stop_send(struct interface *ifp, struct prefix_sg *sg, b1length += length; pim_msg_build_header(buffer, b1length + PIM_MSG_REGISTER_STOP_LEN, - PIM_MSG_TYPE_REG_STOP); + PIM_MSG_TYPE_REG_STOP, false); pinfo = (struct pim_interface *)ifp->info; if (!pinfo) { @@ -208,7 +208,7 @@ void pim_register_send(const uint8_t *buf, int buf_size, struct in_addr src, memcpy(b1, (const unsigned char *)buf, buf_size); pim_msg_build_header(buffer, buf_size + PIM_MSG_REGISTER_LEN, - PIM_MSG_TYPE_REGISTER); + PIM_MSG_TYPE_REGISTER, false); ++pinfo->pim_ifstat_reg_send; |