* Pull up the full IP and TCP headers of a packet. If packet is not * a TCP packet, just pull up the IP header. */
| 588 | * a TCP packet, just pull up the IP header. |
| 589 | */ |
| 590 | static struct mbuf * |
| 591 | ng_vjc_pulluphdrs(struct mbuf *m, int knownTCP) |
| 592 | { |
| 593 | struct ip *ip; |
| 594 | struct tcphdr *tcp; |
| 595 | int ihlen, thlen; |
| 596 | |
| 597 | if (m->m_len < sizeof(*ip) && (m = m_pullup(m, sizeof(*ip))) == NULL) |
| 598 | return (NULL); |
| 599 | ip = mtod(m, struct ip *); |
| 600 | if (!knownTCP && ip->ip_p != IPPROTO_TCP) |
| 601 | return (m); |
| 602 | ihlen = ip->ip_hl << 2; |
| 603 | if (m->m_len < ihlen + sizeof(*tcp)) { |
| 604 | if ((m = m_pullup(m, ihlen + sizeof(*tcp))) == NULL) |
| 605 | return (NULL); |
| 606 | ip = mtod(m, struct ip *); |
| 607 | } |
| 608 | tcp = (struct tcphdr *)((u_char *)ip + ihlen); |
| 609 | thlen = tcp->th_off << 2; |
| 610 | if (m->m_len < ihlen + thlen) |
| 611 | m = m_pullup(m, ihlen + thlen); |
| 612 | return (m); |
| 613 | } |
no test coverage detected