mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 17:18:56 +00:00
pim6d: Abstract api to get src and dst from ip hdr
IPv4 uses "struct ip" and IPv6 uses "struct ip6_hdr" as headers. Get the src and dst in pim_sgaddr. Added api pim_sgaddr_from_iphdr to do so. Signed-off-by: Mobashshera Rasool <mrasool@vmwaer.com>
This commit is contained in:
parent
5aad2b6a82
commit
d1fd950aa0
@ -21,6 +21,9 @@
|
|||||||
#define PIM_MSG_H
|
#define PIM_MSG_H
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#if PIM_IPV == 6
|
||||||
|
#include <netinet/ip6.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "pim_jp_agg.h"
|
#include "pim_jp_agg.h"
|
||||||
|
|
||||||
@ -181,6 +184,30 @@ struct pim_jp {
|
|||||||
struct pim_jp_groups groups[1];
|
struct pim_jp_groups groups[1];
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
#if PIM_IPV == 4
|
||||||
|
static inline pim_sgaddr pim_sgaddr_from_iphdr(const void *iphdr)
|
||||||
|
{
|
||||||
|
const struct ip *ipv4_hdr = iphdr;
|
||||||
|
pim_sgaddr sg;
|
||||||
|
|
||||||
|
sg.src = ipv4_hdr->ip_src;
|
||||||
|
sg.grp = ipv4_hdr->ip_dst;
|
||||||
|
|
||||||
|
return sg;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static inline pim_sgaddr pim_sgaddr_from_iphdr(const void *iphdr)
|
||||||
|
{
|
||||||
|
const struct ip6_hdr *ipv6_hdr = iphdr;
|
||||||
|
pim_sgaddr sg;
|
||||||
|
|
||||||
|
sg.src = ipv6_hdr->ip6_src;
|
||||||
|
sg.grp = ipv6_hdr->ip6_dst;
|
||||||
|
|
||||||
|
return sg;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void pim_msg_build_header(uint8_t *pim_msg, size_t pim_msg_size,
|
void pim_msg_build_header(uint8_t *pim_msg, size_t pim_msg_size,
|
||||||
uint8_t pim_msg_type, bool no_fwd);
|
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_ucast(uint8_t *buf, struct in_addr addr);
|
||||||
|
Loading…
Reference in New Issue
Block a user