MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ng_vjc_pulluphdrs

Function ng_vjc_pulluphdrs

freebsd/netgraph/ng_vjc.c:590–613  ·  view source on GitHub ↗

* Pull up the full IP and TCP headers of a packet. If packet is not * a TCP packet, just pull up the IP header. */

Source from the content-addressed store, hash-verified

588 * a TCP packet, just pull up the IP header.
589 */
590static struct mbuf *
591ng_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}

Callers 1

ng_vjc_rcvdataFunction · 0.85

Calls 1

m_pullupFunction · 0.85

Tested by

no test coverage detected