diff options
Diffstat (limited to 'pimd/pim_msg.h')
| -rw-r--r-- | pimd/pim_msg.h | 70 |
1 files changed, 60 insertions, 10 deletions
diff --git a/pimd/pim_msg.h b/pimd/pim_msg.h index 96a89659e6..9774ef3ed0 100644 --- a/pimd/pim_msg.h +++ b/pimd/pim_msg.h @@ -23,6 +23,7 @@ #include <netinet/in.h> +#include "pim_jp_agg.h" /* Number Description ---------- ------------------ @@ -35,16 +36,65 @@ */ #define PIM_MSG_ADDRESS_FAMILY_IPV4 (1) -void pim_msg_build_header(uint8_t *pim_msg, int pim_msg_size, - uint8_t pim_msg_type); -uint8_t *pim_msg_addr_encode_ipv4_ucast(uint8_t *buf, - int buf_size, - struct in_addr addr); -uint8_t *pim_msg_addr_encode_ipv4_group(uint8_t *buf, - int buf_size, - struct in_addr addr); +/* + * Network Order pim_msg_hdr + */ +struct pim_msg_header { + uint8_t type:4; + uint8_t ver:4; + uint8_t reserved; + uint16_t checksum; +} __attribute__ ((packed)); + +struct pim_encoded_ipv4_unicast { + uint8_t family; + uint8_t reserved; + struct in_addr addr; +} __attribute__ ((packed)); + +struct pim_encoded_group_ipv4 { + uint8_t ne; + uint8_t family; + uint8_t reserved; + uint8_t mask; + struct in_addr addr; +} __attribute__ ((packed)); + +struct pim_encoded_source_ipv4 { + uint8_t ne; + uint8_t family; + uint8_t bits; + uint8_t mask; + struct in_addr addr; +} __attribute__ ((packed)); + +struct pim_jp_groups { + struct pim_encoded_group_ipv4 g; + uint16_t joins; + uint16_t prunes; + struct pim_encoded_source_ipv4 s[1]; +} __attribute__ ((packed)); + +struct pim_jp { + struct pim_msg_header header; + struct pim_encoded_ipv4_unicast addr; + uint8_t reserved; + uint8_t num_groups; + uint16_t holdtime; + struct pim_jp_groups groups[1]; +} __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_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); + +#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); + +size_t pim_msg_get_jp_group_size (struct list *sources); +size_t pim_msg_build_jp_groups (struct pim_jp_groups *grp, struct pim_jp_agg_group *sgs); #endif /* PIM_MSG_H */ |
