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);
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));
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;
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));
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 */
#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)
{