return true;
}
-int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)
+int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len,
+ pim_sgaddr sg)
{
+#if PIM_IPV == 4
struct ip *ip_hdr = (struct ip *)buf;
size_t ip_hlen; /* ip header length in bytes */
+#endif
uint8_t *pim_msg;
uint32_t pim_msg_len = 0;
uint16_t pim_checksum; /* received checksum */
struct pim_neighbor *neigh;
struct pim_msg_header *header;
bool no_fwd;
- pim_sgaddr sg;
+#if PIM_IPV == 4
if (len < sizeof(*ip_hdr)) {
if (PIM_DEBUG_PIM_PACKETS)
zlog_debug(
}
ip_hlen = ip_hdr->ip_hl << 2; /* ip_hl gives length in 4-byte words */
- sg = pim_sgaddr_from_iphdr(buf);
+ sg = pim_sgaddr_from_iphdr(ip_hdr);
pim_msg = buf + ip_hlen;
pim_msg_len = len - ip_hlen;
+#else
+ /* NB: header is not included in IPv6 RX */
+ pim_msg = buf;
+ pim_msg_len = len;
+#endif
header = (struct pim_msg_header *)pim_msg;
if (pim_msg_len < PIM_PIM_MIN_LEN) {
pim_ifp = ifp->info;
while (cont) {
+ pim_sgaddr sg;
+
len = pim_socket_recvfromto(fd, buf, sizeof(buf), &from,
&fromlen, &to, &tolen, &ifindex);
if (len < 0) {
ifindex);
goto done;
}
- int fail = pim_pim_packet(ifp, buf, len);
+#if PIM_IPV == 4
+ sg.src = ((struct sockaddr_in *)&from)->sin_addr;
+ sg.grp = ((struct sockaddr_in *)&to)->sin_addr;
+#else
+ sg.src = ((struct sockaddr_in6 *)&from)->sin6_addr;
+ sg.grp = ((struct sockaddr_in6 *)&to)->sin6_addr;
+#endif
+
+ int fail = pim_pim_packet(ifp, buf, len, sg);
if (fail) {
if (PIM_DEBUG_PIM_PACKETS)
zlog_debug("%s: pim_pim_packet() return=%d",
void pim_hello_restart_now(struct interface *ifp);
void pim_hello_restart_triggered(struct interface *ifp);
-int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len);
+int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len,
+ pim_sgaddr sg);
int pim_msg_send(int fd, pim_addr src, pim_addr dst, uint8_t *pim_msg,
int pim_msg_size, const char *ifname);