Lines Matching defs:th
290 tcp_setup_ack(struct tcpcb *tp, const struct tcphdr *th)
294 (tcp_ack_on_push && th->th_flags & TH_PUSH))
301 icmp_check(struct tcpcb *tp, const struct tcphdr *th, int acked)
309 SEQ_GT(th->th_ack, tp->t_pmtud_th_seq))
324 tcp_fields_to_host(struct tcphdr *th)
327 NTOHL(th->th_seq);
328 NTOHL(th->th_ack);
329 NTOHS(th->th_win);
330 NTOHS(th->th_urp);
337 tcp_fields_to_net(struct tcphdr *th)
340 HTONL(th->th_seq);
341 HTONL(th->th_ack);
342 HTONS(th->th_win);
343 HTONS(th->th_urp);
347 tcp_urp_drop(struct tcphdr *th, int todrop, int *tiflags)
349 if (th->th_urp > todrop) {
350 th->th_urp -= todrop;
353 th->th_urp = 0;
455 tcp_reass(struct tcpcb *tp, const struct tcphdr *th, struct mbuf *m, int tlen)
474 * Call with th==NULL after become established to
477 if (th == NULL)
487 pkt_seq = th->th_seq;
489 pkt_flags = th->th_flags;
833 tcp4_log_refused(const struct ip *ip, const struct tcphdr *th)
847 dst, ntohs(th->th_dport),
848 src, ntohs(th->th_sport));
853 tcp6_log_refused(const struct ip6_hdr *ip6, const struct tcphdr *th)
867 dst, ntohs(th->th_dport),
868 src, ntohs(th->th_sport));
876 tcp_input_checksum(int af, struct mbuf *m, const struct tcphdr *th,
988 static void tcp_vtw_input(struct tcphdr *th, vestigial_inpcb_t *vp,
996 tiflags = th->th_flags;
997 todrop = vp->rcv_nxt - th->th_seq;
1002 th->th_seq++;
1003 tcp_urp_drop(th, 1, &tiflags);
1028 th->th_seq != vp->rcv_nxt) {
1042 // tcp_new_dsack(tp, th->th_seq, todrop);
1045 th->th_seq += todrop;
1047 tcp_urp_drop(th, todrop, &tiflags);
1063 todrop = (th->th_seq + tlen) - (vp->rcv_nxt + vp->rcv_wnd);
1070 * th->th_seq + tlen - vp->rcv_nxt - vp->rcv_wnd >= tlen
1071 * th->th_seq - vp->rcv_nxt - vp->rcv_wnd >= 0
1072 * th->th_seq >= vp->rcv_nxt + vp->rcv_wnd
1083 SEQ_GT(th->th_seq, vp->rcv_nxt)) {
1098 if (vp->rcv_wnd == 0 && th->th_seq == vp->rcv_nxt) {
1113 if (th->th_seq != vp->rcv_nxt)
1158 (void)tcp_respond(0, m, m, th, th->th_seq + tlen, th->th_ack, TH_ACK);
1170 tcp_respond(0, m, m, th, (tcp_seq)0, th->th_ack, TH_RST);
1174 (void)tcp_respond(0, m, m, th, th->th_seq + tlen, (tcp_seq)0,
1188 struct tcphdr *th;
1245 M_REGION_GET(th, struct tcphdr *, m, off, sizeof(struct tcphdr));
1246 if (th == NULL) {
1255 if (ACCESSIBLE_POINTER(th, struct tcphdr) == 0) {
1261 th = (struct tcphdr *)(mtod(m, char *) + off);
1263 KASSERT(ACCESSIBLE_POINTER(th, struct tcphdr));
1330 thlen = th->th_off << 2;
1338 M_REGION_GET(th, struct tcphdr *, m, off, thlen);
1339 if (th == NULL) {
1343 KASSERT(ACCESSIBLE_POINTER(th, struct tcphdr));
1345 optp = ((u_int8_t *)th) + sizeof(struct tcphdr);
1359 (th->th_flags & TH_SYN) == 0) {
1366 tiflags = th->th_flags;
1371 if (tcp_input_checksum(af, m, th, off, thlen, tlen))
1381 inp = inpcb_lookup(&tcbtable, ip->ip_src, th->th_sport,
1382 ip->ip_dst, th->th_dport, &vestige);
1386 th->th_dport);
1396 th->th_sport, &d, th->th_dport, 0, &vestige);
1400 th->th_dport, 0);
1408 tcp4_log_refused(ip, th);
1410 tcp_fields_to_host(th);
1431 th->th_sport, &ip6->ip6_dst, th->th_dport, faith, &vestige);
1435 th->th_dport, faith);
1441 tcp6_log_refused(ip6, th);
1443 tcp_fields_to_host(th);
1455 tcp_fields_to_host(th);
1474 tcp_vtw_input(th, &vestige, m, tlen);
1489 tiwin = th->th_win << tp->snd_scale;
1491 tiwin = th->th_win;
1530 memcpy(mtod(tcp_saveti, char *) + iphlen, th,
1549 src.sin.sin_port = th->th_sport;
1554 dst.sin.sin_port = th->th_dport;
1561 src.sin6.sin6_port = th->th_sport;
1566 dst.sin6.sin6_port = th->th_dport;
1573 syn_cache_reset(&src.sa, &dst.sa, th);
1582 so = syn_cache_get(&src.sa, &dst.sa, th, so, m);
1681 if (th->th_sport == th->th_dport) {
1706 syn_cache_add(&src.sa, &dst.sa, th, off,
1736 if (tcp_dooptions(tp, optp, optlen, th, m, off, &opti) < 0)
1740 tcp_del_sackholes(tp, th);
1818 th->th_seq == tp->rcv_nxt &&
1831 if (opti.ts_present && SEQ_LEQ(th->th_seq, tp->last_ack_sent)) {
1838 if (SEQ_GT(th->th_ack, tp->snd_una) &&
1839 SEQ_LEQ(th->th_ack, tp->snd_max) &&
1848 SEQ_GT(th->th_ack, tp->t_rtseq))
1851 acked = th->th_ack - tp->snd_una;
1865 icmp_check(tp, th, acked);
1867 tp->snd_una = th->th_ack;
1911 } else if (th->th_ack == tp->snd_una &&
1933 tp->snd_wl1 = th->th_seq;
2012 tcp_setup_ack(tp, th);
2062 (SEQ_LEQ(th->th_ack, tp->iss) ||
2063 SEQ_GT(th->th_ack, tp->snd_max)))
2073 tp->snd_una = th->th_ack;
2085 tp->irs = th->th_seq;
2139 * Advance th->th_seq to correspond to first data byte.
2143 th->th_seq++;
2155 tp->snd_wl1 = th->th_seq - 1;
2156 tp->rcv_up = th->th_seq;
2166 (SEQ_LEQ(th->th_ack, tp->iss) ||
2167 SEQ_GT(th->th_ack, tp->snd_max)))
2204 tcp_new_dsack(tp, th->th_seq, tlen);
2214 todrop = tp->rcv_nxt - th->th_seq;
2219 th->th_seq++;
2220 tcp_urp_drop(th, 1, &tiflags);
2245 } else if ((tiflags & TH_RST) && th->th_seq != tp->rcv_nxt) {
2258 tcp_new_dsack(tp, th->th_seq, todrop);
2260 th->th_seq += todrop;
2262 tcp_urp_drop(th, todrop, &tiflags);
2280 todrop = (th->th_seq + tlen) - (tp->rcv_nxt + tp->rcv_wnd);
2286 * th->th_seq + tlen - tp->rcv_nxt - tp->rcv_wnd >= tlen
2287 * th->th_seq - tp->rcv_nxt - tp->rcv_wnd >= 0
2288 * th->th_seq >= tp->rcv_nxt + tp->rcv_wnd
2303 SEQ_GT(th->th_seq, tp->rcv_nxt)) {
2305 tcp_fields_to_net(th);
2318 if (tp->rcv_wnd == 0 && th->th_seq == tp->rcv_nxt) {
2352 SEQ_LEQ(th->th_seq, tp->last_ack_sent) &&
2353 SEQ_LEQ(tp->last_ack_sent, th->th_seq + tlen +
2370 if (th->th_seq != tp->rcv_nxt)
2406 if (tp->rcv_nxt == th->th_seq) {
2407 tcp_respond(tp, m, m, th, (tcp_seq)0, th->th_ack - 1,
2436 if (SEQ_GT(tp->snd_una, th->th_ack) ||
2437 SEQ_GT(th->th_ack, tp->snd_max))
2450 tp->snd_wl1 = th->th_seq - 1;
2456 * tp->snd_una < th->th_ack <= tp->snd_max
2457 * then advance tp->snd_una to th->th_ack and drop
2468 if (SEQ_LEQ(th->th_ack, tp->snd_una)) {
2484 th->th_ack != tp->snd_una)
2493 if (tp->t_congctl->fast_retransmit(tp, th)) {
2514 if (tlen && th->th_seq != tp->rcv_nxt &&
2515 SEQ_LT(th->th_ack,
2525 tp->t_congctl->fast_retransmit_newack(tp, th);
2527 if (SEQ_GT(th->th_ack, tp->snd_max)) {
2531 acked = th->th_ack - tp->snd_una;
2548 else if (tp->t_rtttime && SEQ_GT(th->th_ack, tp->t_rtseq))
2557 if (th->th_ack == tp->snd_max) {
2566 tp->t_congctl->newack(tp, th);
2586 icmp_check(tp, th, acked);
2588 tp->snd_una = th->th_ack;
2666 if ((tiflags & TH_ACK) && (SEQ_LT(tp->snd_wl1, th->th_seq) ||
2667 (tp->snd_wl1 == th->th_seq && (SEQ_LT(tp->snd_wl2, th->th_ack) ||
2668 (tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd))))) {
2671 tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd)
2674 tp->snd_wl1 = th->th_seq;
2675 tp->snd_wl2 = th->th_ack;
2684 if ((tiflags & TH_URG) && th->th_urp &&
2692 if (th->th_urp + so->so_rcv.sb_cc > sb_max) {
2693 th->th_urp = 0; /* XXX */
2712 if (SEQ_GT(th->th_seq+th->th_urp, tp->rcv_up)) {
2713 tp->rcv_up = th->th_seq + th->th_urp;
2728 if (th->th_urp <= (u_int16_t)tlen &&
2730 tcp_pulloutofband(so, th, m, hdroptlen);
2764 if (th->th_seq == tp->rcv_nxt &&
2767 tcp_setup_ack(tp, th);
2769 tiflags = th->th_flags & TH_FIN;
2785 tiflags = tcp_reass(tp, th, m, tlen);
2931 (void)tcp_respond(tp, m, m, th, (tcp_seq)0, th->th_ack, TH_RST);
2935 (void)tcp_respond(tp, m, m, th, th->th_seq + tlen, (tcp_seq)0,
3012 tcp_signature(struct mbuf *m, struct tcphdr *th, int thoff,
3029 tcphdrlen = th->th_off * 4;
3062 th0 = *th;
3086 tcp_dooptions(struct tcpcb *tp, const u_char *cp, int cnt, struct tcphdr *th,
3118 if (!(th->th_flags & TH_SYN))
3129 if (!(th->th_flags & TH_SYN))
3175 if (!(th->th_flags & TH_SYN))
3191 if (!(th->th_flags & TH_SYN))
3202 tcp_sack_option(tp, th, cp, optlen);
3235 tcp_fields_to_net(th);
3236 if (tcp_signature(m, th, toff, sav, sig) < 0) {
3237 tcp_fields_to_host(th);
3240 tcp_fields_to_host(th);
3266 tcp_pulloutofband(struct socket *so, struct tcphdr *th,
3269 int cnt = off + th->th_urp - 1;