Lines Matching defs:th

339 static void tcp_bad_rexmt_restore_state(struct tcpcb *tp, struct tcphdr *th);
342 struct tcphdr *th);
385 #define DELAY_ACK(tp, th) \
386 (CC_ALGO(tp)->delay_ack != NULL && CC_ALGO(tp)->delay_ack(tp, th))
389 static void tcp_newreno_partial_ack(struct tcpcb *tp, struct tcphdr *th);
587 tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m,
604 * Call with th==0 after become established to
607 if (th == NULL)
638 if (th->th_seq != tp->rcv_nxt &&
660 if (SEQ_GT(q->tqe_th->th_seq, th->th_seq))
673 i = p->tqe_th->th_seq + p->tqe_len - th->th_seq;
698 th->th_seq += i;
715 register int i = (th->th_seq + *tlenp) - q->tqe_th->th_seq;
735 te->tqe_th = th;
765 th->th_dport, th->th_sport);
806 th->th_dport, th->th_sport);
1273 tcp_bad_rexmt_restore_state(struct tcpcb *tp, struct tcphdr *th)
1277 fsize = tp->snd_max - th->th_ack;
1278 acked = BYTES_ACKED(th, tp);
1323 register struct tcphdr *th;
1407 th = (struct tcphdr *)(void *)((caddr_t)ip6 + off0);
1409 if (tcp_input_checksum(AF_INET6, m, th, off0, tlen))
1412 KERNEL_DEBUG(DBG_LAYER_BEG, ((th->th_dport << 16) | th->th_sport),
1414 th->th_seq, th->th_ack, th->th_win);
1430 struct tcphdr *, th);
1455 th = (struct tcphdr *)(void *)((caddr_t)ip + off0);
1458 if (tcp_input_checksum(AF_INET, m, th, off0, tlen))
1468 struct ip *, ip, struct tcpcb *, NULL, struct tcphdr *, th);
1470 KERNEL_DEBUG(DBG_LAYER_BEG, ((th->th_dport << 16) | th->th_sport),
1472 th->th_seq, th->th_ack, th->th_win);
1480 off = th->th_off << 2;
1492 th = (struct tcphdr *)(void *)((caddr_t)ip6 + off0);
1502 th = (struct tcphdr *)(void *)((caddr_t)ip + off0);
1506 optp = (u_char *)(th + 1);
1518 (th->th_flags & TH_SYN) == 0) {
1525 thflags = th->th_flags;
1573 NTOHL(th->th_seq);
1574 NTOHL(th->th_ack);
1575 NTOHS(th->th_win);
1576 NTOHS(th->th_urp);
1597 inp = in_pcblookup_hash(&tcbinfo, ip->ip_src, th->th_sport,
1598 ip->ip_dst, th->th_dport, 0, m->m_pkthdr.rcvif);
1605 th->th_sport, next_hop->sin_addr,
1606 th->th_dport, 1, m->m_pkthdr.rcvif);
1609 ip->ip_src, th->th_sport,
1620 inp = in6_pcblookup_hash(&tcbinfo, &ip6->ip6_src, th->th_sport,
1621 &ip6->ip6_dst, th->th_dport, 1,
1625 inp = in_pcblookup_hash(&tcbinfo, ip->ip_src, th->th_sport,
1626 ip->ip_dst, th->th_dport, 1, m->m_pkthdr.rcvif);
1701 dbuf, ntohs(th->th_dport),
1703 ntohs(th->th_sport));
1708 dbuf, ntohs(th->th_dport), sbuf,
1709 ntohs(th->th_sport), thflags);
1724 dbuf, ntohs(th->th_dport),
1726 ntohs(th->th_sport)));
1782 tiwin = th->th_win << tp->snd_scale;
1784 tiwin = th->th_win;
1807 tcp_savetcp = *th;
1853 if (th->th_dport == th->th_sport) {
1925 sin6->sin6_port = th->th_sport;
1937 sin->sin_port = th->th_sport;
2013 inp->inp_lport = th->th_dport;
2135 SEQ_GEQ(th->th_seq, tp->last_ack_sent) &&
2136 SEQ_LT(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) {
2185 tcp_dooptions(tp, optp, optlen, th, &to, ifscope);
2234 th->th_seq == tp->rcv_nxt &&
2307 th->th_seq == tp->rcv_nxt &&
2318 SEQ_LEQ(th->th_seq, tp->last_ack_sent)) {
2329 if (SEQ_GT(th->th_ack, tp->snd_una) &&
2330 SEQ_LEQ(th->th_ack, tp->snd_max) &&
2347 tcp_bad_rexmt_restore_state(tp, th);
2351 struct tcpcb *, tp, struct tcphdr *, th,
2356 tcp_compute_rtt(tp, &to, th);
2358 acked = BYTES_ACKED(th, tp);
2367 CC_ALGO(tp)->inseq_ack_rcvd(tp, th);
2370 struct tcpcb *, tp, struct tcphdr *, th,
2381 SEQ_LEQ(th->th_ack, tp->snd_recover))
2382 tp->snd_recover = th->th_ack - 1;
2383 tp->snd_una = th->th_ack;
2389 tp->snd_wl2 = th->th_ack;
2425 } else if (th->th_ack == tp->snd_una &&
2449 ((th->th_seq - tp->irs) >
2451 ((tp->t_idleat == 0) || ((th->th_seq -
2454 tcp_start_coalescing(ip, th, tlen);
2467 tp->snd_wl1 = th->th_seq;
2492 tcp_compute_rtt(tp, &to, th);
2508 th->th_seq - (tp->irs + 1), 0)) {
2513 KERNEL_DEBUG(DBG_LAYER_END, ((th->th_dport << 16) | th->th_sport),
2515 th->th_seq, th->th_ack, th->th_win);
2520 KERNEL_DEBUG(DBG_LAYER_END, ((th->th_dport << 16) | th->th_sport),
2522 th->th_seq, th->th_ack, th->th_win);
2525 if (DELAY_ACK(tp, th)) {
2603 sin6->sin6_port = th->th_sport;
2625 sin->sin_port = th->th_sport;
2639 tcp_dooptions(tp, optp, optlen, th, &to, ifscope);
2653 tp->irs = th->th_seq;
2708 (SEQ_LEQ(th->th_ack, tp->snd_una) ||
2709 SEQ_GT(th->th_ack, tp->snd_max))) {
2740 (SEQ_LEQ(th->th_ack, tp->iss) ||
2741 SEQ_GT(th->th_ack, tp->snd_max))) {
2758 tp->snd_wnd = th->th_win; /* initial send window */
2760 tp->irs = th->th_seq;
2792 if (DELAY_ACK(tp, th) && tlen != 0 ) {
2854 * Advance th->th_seq to correspond to first data byte.
2858 th->th_seq++;
2867 tp->snd_wl1 = th->th_seq - 1;
2868 tp->rcv_up = th->th_seq;
2970 if ((SEQ_GEQ(th->th_seq, tp->last_ack_sent) &&
2971 SEQ_LT(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) ||
2973 ((tp->last_ack_sent == th->th_seq) ||
2974 ((tp->last_ack_sent -1) == th->th_seq)))) {
2983 if (tp->last_ack_sent != th->th_seq) {
3061 if (tp->t_state == TCPS_SYN_RECEIVED && SEQ_LT(th->th_seq, tp->irs)) {
3067 todrop = tp->rcv_nxt - th->th_seq;
3071 th->th_seq++;
3072 if (th->th_urp > 1)
3073 th->th_urp--;
3115 th->th_seq += todrop;
3117 if (th->th_urp > todrop)
3118 th->th_urp -= todrop;
3121 th->th_urp = 0;
3146 todrop = (th->th_seq+tlen) - (tp->rcv_nxt+tp->rcv_wnd);
3159 SEQ_GT(th->th_seq, tp->rcv_nxt)) {
3172 if (tp->rcv_wnd == 0 && th->th_seq == tp->rcv_nxt) {
3203 SEQ_LEQ(th->th_seq, tp->last_ack_sent) &&
3204 SEQ_LEQ(tp->last_ack_sent, th->th_seq + tlen +
3257 tp->snd_wnd = th->th_win << tp->snd_scale;
3288 tp->snd_wl1 = th->th_seq - 1;
3306 * tp->snd_una < th->th_ack <= tp->snd_max
3307 * then advance tp->snd_una to th->th_ack and drop
3318 if (SEQ_GT(th->th_ack, tp->snd_max)) {
3324 tcp_sack_doack(tp, &to, th->th_ack, &sack_bytes_acked);
3326 if ((tp->t_mpuna) && (SEQ_GEQ(th->th_ack, tp->t_mpuna))) {
3331 th->th_ack, tp->t_mpuna);
3368 if (SEQ_LEQ(th->th_ack, tp->snd_una)) {
3380 (th->th_ack + 1) == tp->snd_max) {
3473 struct tcpcb *, tp, struct tcphdr *, th,
3502 (th->th_ack != tp->snd_una && sack_bytes_acked == 0)) {
3527 struct tcpcb *, tp, struct tcphdr *, th,
3548 if (SEQ_LEQ(th->th_ack,
3575 struct tcpcb *, tp, struct tcphdr *, th,
3581 tp->snd_nxt = th->th_ack;
3589 struct tcpcb *, tp, struct tcphdr *, th,
3606 struct tcpcb *, tp, struct tcphdr *, th,
3623 if (SEQ_LT(th->th_ack, tp->snd_recover)) {
3625 tcp_sack_partialack(tp, th);
3627 tcp_newreno_partial_ack(tp, th);
3630 struct tcpcb *, tp, struct tcphdr *, th,
3635 CC_ALGO(tp)->post_fr(tp, th);
3637 struct tcpcb *, tp, struct tcphdr *, th,
3673 acked = BYTES_ACKED(th, tp);
3688 tcp_bad_rexmt_restore_state(tp, th);
3691 struct tcpcb *, tp, struct tcphdr *, th,
3696 tcp_compute_rtt(tp, &to, th);
3704 if (th->th_ack == tp->snd_max) {
3723 SEQ_GEQ(th->th_ack, tp->snd_recover)) {
3726 struct tcpcb *, tp, struct tcphdr *, th,
3741 CC_ALGO(tp)->ack_rcvd(tp, th);
3744 struct tcpcb *, tp, struct tcphdr *, th,
3768 SEQ_LEQ(th->th_ack, tp->snd_recover))
3769 tp->snd_recover = th->th_ack - 1;
3772 SEQ_GEQ(th->th_ack, tp->snd_recover))
3775 tp->snd_una = th->th_ack;
3885 SEQ_LEQ(th->th_ack, tp->snd_una) && tlen == 0) {
3897 (SEQ_LT(tp->snd_wl1, th->th_seq) ||
3898 (tp->snd_wl1 == th->th_seq && (SEQ_LT(tp->snd_wl2, th->th_ack) ||
3899 (tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd))))) {
3902 tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd)
3905 tp->snd_wl1 = th->th_seq;
3906 tp->snd_wl2 = th->th_ack;
3915 if ((thflags & TH_URG) && th->th_urp &&
3923 if (th->th_urp + so->so_rcv.sb_cc > sb_max) {
3924 th->th_urp = 0; /* XXX */
3942 if (SEQ_GT(th->th_seq+th->th_urp, tp->rcv_up)) {
3943 tp->rcv_up = th->th_seq + th->th_urp;
3959 if (th->th_urp <= (u_int32_t)tlen
3964 tcp_pulloutofband(so, th, m,
4005 tcp_seq save_start = th->th_seq;
4006 tcp_seq save_end = th->th_seq + tlen;
4009 * Insert segment which includes th into TCP reassembly queue
4020 if (th->th_seq == tp->rcv_nxt &&
4031 tcp_compute_rtt(tp, &to, th);
4033 if (DELAY_ACK(tp, th) &&
4045 thflags = th->th_flags & TH_FIN;
4061 th->th_seq - (tp->irs + 1), 0)) {
4065 thflags = tcp_reass(tp, th, &tlen, m, ifp);
4078 KERNEL_DEBUG(DBG_LAYER_END, ((th->th_dport << 16) | th->th_sport),
4080 th->th_seq, th->th_ack, th->th_win);
4085 KERNEL_DEBUG(DBG_LAYER_END, ((th->th_dport << 16) | th->th_sport),
4087 th->th_seq, th->th_ack, th->th_win);
4112 if (DELAY_ACK(tp, th) && (tp->t_flags & TF_NEEDSYN)) {
4214 (SEQ_GT(tp->snd_una, th->th_ack) ||
4215 SEQ_GT(th->th_ack, tp->snd_max)) ) {
4272 tcp_respond(tp, mtod(m, void *), th, m, (tcp_seq)0, th->th_ack,
4278 tcp_respond(tp, mtod(m, void *), th, m, th->th_seq+tlen,
4315 tcp_dooptions(tp, cp, cnt, th, to, input_ifscope)
4322 struct tcphdr *th;
4350 if (!(th->th_flags & TH_SYN))
4359 if (!(th->th_flags & TH_SYN))
4380 if (th->th_flags & TH_SYN) {
4390 if (th->th_flags & TH_SYN)
4404 tcp_do_mptcp_options(tp, cp, th, to, optlen);
4409 if (th->th_flags & TH_SYN)
4420 tcp_pulloutofband(so, th, m, off)
4422 struct tcphdr *th;
4426 int cnt = off + th->th_urp - 1;
4508 tcp_compute_rtt(struct tcpcb *tp, struct tcpopt *to, struct tcphdr *th)
4510 VERIFY(to != NULL && th != NULL);
4515 to->to_tsecr, th->th_ack);
4516 } else if (tp->t_rtttime && SEQ_GT(th->th_ack, tp->t_rtseq)) {
4518 th->th_ack);
4991 tcp_newreno_partial_ack(tp, th)
4993 struct tcphdr *th;
4999 tp->snd_nxt = th->th_ack;
5005 tp->snd_cwnd = tp->t_maxseg + BYTES_ACKED(th, tp);
5015 if (tp->snd_cwnd > BYTES_ACKED(th, tp))
5016 tp->snd_cwnd -= BYTES_ACKED(th, tp);
5377 tcp_input_checksum(int af, struct mbuf *m, struct tcphdr *th, int off, int tlen)
5393 th->th_sum = m->m_pkthdr.csum_rx_val;
5425 th->th_sum = in_pseudo(ip->ip_src.s_addr,
5429 th->th_sum ^= 0xffff;
5443 th->th_sum = in_cksum(m, len);
5462 th->th_sum = m->m_pkthdr.csum_rx_val;
5494 th->th_sum = in6_pseudo(
5498 th->th_sum ^= 0xffff;
5501 th->th_sum = in6_cksum(m, IPPROTO_TCP, off, tlen);
5511 if (th->th_sum != 0) {