]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Start abstraction for WC and RPT bits
authorDonald Sharp <sharpd@cumulusnetwroks.com>
Wed, 27 Jul 2016 19:27:52 +0000 (15:27 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:04 +0000 (20:26 -0500)
Start the abstraction of the WC and RPT bits
so we can send the data as appropriate.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_cmd.c
pimd/pim_join.c
pimd/pim_msg.c
pimd/pim_msg.h
pimd/pim_tlv.c

index 68899d8c7c1fb65c1ae184193242e864f00efc61..c089a3fd3f132eef63a0c55784453541639144cf 100644 (file)
@@ -4624,7 +4624,8 @@ static int recv_joinprune(struct vty *vty,
   remain = buf_pastend - pim_msg_curr;
   pim_msg_curr = pim_msg_addr_encode_ipv4_source(pim_msg_curr,
                                                 remain,
-                                                source_addr);
+                                                source_addr,
+                                                PIM_ENCODE_SPARSE_BIT);
   if (!pim_msg_curr) {
     vty_out(vty, "Failure encoding source address %s: space left=%d%s",
            source_str, remain, VTY_NEWLINE);
index 5a2ff744e56a83061250d99ba2abbfd2fca1d90f..2806320c02acb9408c2fdb3c99a6da26dab746b6 100644 (file)
@@ -431,7 +431,8 @@ int pim_joinprune_send(struct interface *ifp,
   remain = pastend - pim_msg_curr;
   pim_msg_curr = pim_msg_addr_encode_ipv4_source(pim_msg_curr,
                                                 remain,
-                                                sg->u.sg.src);
+                                                sg->u.sg.src,
+                                                PIM_ENCODE_SPARSE_BIT);
   if (!pim_msg_curr) {
     char source_str[100];
     pim_inet4_dump("<src?>", sg->u.sg.src, source_str, sizeof(source_str));
index 92382ccc4d6e651403edb04bd372cf01be378fde..2027d42119add62439a161385f3d92ad24c42e25 100644 (file)
@@ -87,9 +87,9 @@ uint8_t *pim_msg_addr_encode_ipv4_group(uint8_t *buf,
   return buf + ENCODED_IPV4_GROUP_SIZE;
 }
 
-uint8_t *pim_msg_addr_encode_ipv4_source(uint8_t *buf,
-                                        int buf_size,
-                                        struct in_addr addr)
+uint8_t *
+pim_msg_addr_encode_ipv4_source(uint8_t *buf, int buf_size,
+                               struct in_addr addr, uint8_t bits)
 {
   const int ENCODED_IPV4_SOURCE_SIZE = 8;
 
@@ -99,7 +99,7 @@ uint8_t *pim_msg_addr_encode_ipv4_source(uint8_t *buf,
 
   buf[0] = PIM_MSG_ADDRESS_FAMILY_IPV4; /* addr family */
   buf[1] = '\0';    /* native encoding */
-  buf[2] = 4;       /* reserved = 0 | S bit = 1 | W bit = 0 | R bit = 0 */
+  buf[2] = bits;
   buf[3] = 32;      /* mask len */
   memcpy(buf+4, &addr, sizeof(struct in_addr));
 
index ece900db5f9ccb5b8c43f6d154952657c6234c04..4a13040af6b56efff9be02611f46d11baa6fb37a 100644 (file)
@@ -44,8 +44,13 @@ uint8_t *pim_msg_addr_encode_ipv4_ucast(uint8_t *buf,
 uint8_t *pim_msg_addr_encode_ipv4_group(uint8_t *buf,
                                        int buf_size,
                                        struct in_addr addr);
+
+#define PIM_ENCODE_SPARSE_BIT      0x04
+#define PIM_ENCODE_WC_BIT          0x02
+#define PIM_ENCODE_RPT_BIT         0x01
 uint8_t *pim_msg_addr_encode_ipv4_source(uint8_t *buf,
                                         int buf_size,
-                                        struct in_addr addr);
+                                        struct in_addr addr,
+                                        uint8_t bits);
 
 #endif /* PIM_MSG_H */
index 5269bb5efe88cb0dc285e2ada82ddeb65c1e14db..93227d633985a7e532db351a3f489805b40ff4db 100644 (file)
@@ -96,6 +96,33 @@ uint8_t *pim_tlv_append_uint32(uint8_t *buf,
 
 #define ucast_ipv4_encoding_len (2 + sizeof(struct in_addr))
 
+/*
+ * An Encoded-Unicast address takes the following format:
+ *
+ *   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
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *  |  Addr Family  | Encoding Type |     Unicast Address
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...
+ *
+ *  Addr Family
+ *       The PIM address family of the 'Unicast Address' field of this
+ *       address.
+ *
+ *       Values 0-127 are as assigned by the IANA for Internet Address   *       Families in [7].  Values 128-250 are reserved to be assigned by
+ *       the IANA for PIM-specific Address Families.  Values 251 though
+ *       255 are designated for private use.  As there is no assignment
+ *       authority for this space, collisions should be expected.
+ *
+ *  Encoding Type
+ *       The type of encoding used within a specific Address Family.  The
+ *       value '0' is reserved for this field and represents the native
+ *       encoding of the Address Family.
+ *
+ *  Unicast Address
+ *       The unicast address as represented by the given Address Family
+ *       and Encoding Type.
+ */
 int
 pim_encode_addr_ucast (uint8_t *buf, struct prefix *p)
 {