* PIM sparse mode hook * Receives the pim control messages, and passes them up to the listening * socket, using rip6_input. * The only message processed is the REGISTER pim message; the pim header * is stripped off, and the inner packet is passed to register_mforward. */
| 1703 | * is stripped off, and the inner packet is passed to register_mforward. |
| 1704 | */ |
| 1705 | static int |
| 1706 | pim6_input(struct mbuf *m, int off, int proto, void *arg __unused) |
| 1707 | { |
| 1708 | struct pim *pim; /* pointer to a pim struct */ |
| 1709 | struct ip6_hdr *ip6; |
| 1710 | int pimlen; |
| 1711 | int minlen; |
| 1712 | |
| 1713 | PIM6STAT_INC(pim6s_rcv_total); |
| 1714 | |
| 1715 | /* |
| 1716 | * Validate lengths |
| 1717 | */ |
| 1718 | pimlen = m->m_pkthdr.len - off; |
| 1719 | if (pimlen < PIM_MINLEN) { |
| 1720 | PIM6STAT_INC(pim6s_rcv_tooshort); |
| 1721 | MRT6_DLOG(DEBUG_PIM, "PIM packet too short"); |
| 1722 | m_freem(m); |
| 1723 | return (IPPROTO_DONE); |
| 1724 | } |
| 1725 | |
| 1726 | /* |
| 1727 | * if the packet is at least as big as a REGISTER, go ahead |
| 1728 | * and grab the PIM REGISTER header size, to avoid another |
| 1729 | * possible m_pullup() later. |
| 1730 | * |
| 1731 | * PIM_MINLEN == pimhdr + u_int32 == 8 |
| 1732 | * PIM6_REG_MINLEN == pimhdr + reghdr + eip6hdr == 4 + 4 + 40 |
| 1733 | */ |
| 1734 | minlen = (pimlen >= PIM6_REG_MINLEN) ? PIM6_REG_MINLEN : PIM_MINLEN; |
| 1735 | |
| 1736 | /* |
| 1737 | * Make sure that the IP6 and PIM headers in contiguous memory, and |
| 1738 | * possibly the PIM REGISTER header |
| 1739 | */ |
| 1740 | if (m->m_len < off + minlen) { |
| 1741 | m = m_pullup(m, off + minlen); |
| 1742 | if (m == NULL) { |
| 1743 | IP6STAT_INC(ip6s_exthdrtoolong); |
| 1744 | return (IPPROTO_DONE); |
| 1745 | } |
| 1746 | } |
| 1747 | ip6 = mtod(m, struct ip6_hdr *); |
| 1748 | pim = (struct pim *)((caddr_t)ip6 + off); |
| 1749 | |
| 1750 | #define PIM6_CHECKSUM |
| 1751 | #ifdef PIM6_CHECKSUM |
| 1752 | { |
| 1753 | int cksumlen; |
| 1754 | |
| 1755 | /* |
| 1756 | * Validate checksum. |
| 1757 | * If PIM REGISTER, exclude the data packet |
| 1758 | */ |
| 1759 | if (pim->pim_type == PIM_REGISTER) |
| 1760 | cksumlen = PIM_MINLEN; |
| 1761 | else |
| 1762 | cksumlen = pimlen; |
nothing calls this directly
no test coverage detected