* get offset for the last header in the chain. m will be kept untainted. */
| 1700 | * get offset for the last header in the chain. m will be kept untainted. |
| 1701 | */ |
| 1702 | int |
| 1703 | ip6_lasthdr(const struct mbuf *m, int off, int proto, int *nxtp) |
| 1704 | { |
| 1705 | int newoff; |
| 1706 | int nxt; |
| 1707 | |
| 1708 | if (!nxtp) { |
| 1709 | nxt = -1; |
| 1710 | nxtp = &nxt; |
| 1711 | } |
| 1712 | while (1) { |
| 1713 | newoff = ip6_nexthdr(m, off, proto, nxtp); |
| 1714 | if (newoff < 0) |
| 1715 | return off; |
| 1716 | else if (newoff < off) |
| 1717 | return -1; /* invalid */ |
| 1718 | else if (newoff == off) |
| 1719 | return newoff; |
| 1720 | |
| 1721 | off = newoff; |
| 1722 | proto = *nxtp; |
| 1723 | } |
| 1724 | } |
| 1725 | |
| 1726 | /* |
| 1727 | * System control for IP6 |
no test coverage detected