| 610 | #endif /* INET6 */ |
| 611 | |
| 612 | int |
| 613 | tcp_input(struct mbuf **mp, int *offp, int proto) |
| 614 | { |
| 615 | struct mbuf *m = *mp; |
| 616 | struct tcphdr *th = NULL; |
| 617 | struct ip *ip = NULL; |
| 618 | struct inpcb *inp = NULL; |
| 619 | struct tcpcb *tp = NULL; |
| 620 | struct socket *so = NULL; |
| 621 | u_char *optp = NULL; |
| 622 | int off0; |
| 623 | int optlen = 0; |
| 624 | #ifdef INET |
| 625 | int len; |
| 626 | uint8_t ipttl; |
| 627 | #endif |
| 628 | int tlen = 0, off; |
| 629 | int drop_hdrlen; |
| 630 | int thflags; |
| 631 | int rstreason = 0; /* For badport_bandlim accounting purposes */ |
| 632 | uint8_t iptos; |
| 633 | struct m_tag *fwd_tag = NULL; |
| 634 | #ifdef INET6 |
| 635 | struct ip6_hdr *ip6 = NULL; |
| 636 | int isipv6; |
| 637 | #else |
| 638 | const void *ip6 = NULL; |
| 639 | #endif /* INET6 */ |
| 640 | struct tcpopt to; /* options in this segment */ |
| 641 | char *s = NULL; /* address and port logging */ |
| 642 | #ifdef TCPDEBUG |
| 643 | /* |
| 644 | * The size of tcp_saveipgen must be the size of the max ip header, |
| 645 | * now IPv6. |
| 646 | */ |
| 647 | u_char tcp_saveipgen[IP6_HDR_LEN]; |
| 648 | struct tcphdr tcp_savetcp; |
| 649 | short ostate = 0; |
| 650 | #endif |
| 651 | |
| 652 | NET_EPOCH_ASSERT(); |
| 653 | |
| 654 | #ifdef INET6 |
| 655 | isipv6 = (mtod(m, struct ip *)->ip_v == 6) ? 1 : 0; |
| 656 | #endif |
| 657 | |
| 658 | off0 = *offp; |
| 659 | m = *mp; |
| 660 | *mp = NULL; |
| 661 | to.to_flags = 0; |
| 662 | TCPSTAT_INC(tcps_rcvtotal); |
| 663 | |
| 664 | #ifdef INET6 |
| 665 | if (isipv6) { |
| 666 | ip6 = mtod(m, struct ip6_hdr *); |
| 667 | th = (struct tcphdr *)((caddr_t)ip6 + off0); |
| 668 | tlen = sizeof(*ip6) + ntohs(ip6->ip6_plen) - off0; |
| 669 | if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID_IPV6) { |
no test coverage detected