• Home
  • Raw
  • Download

Lines Matching refs:tp

68 #define TCP_REASS(tp, ti, m, so, flags) {\  argument
69 if ((ti)->ti_seq == (tp)->rcv_nxt && \
70 tcpfrag_list_empty(tp) && \
71 (tp)->t_state == TCPS_ESTABLISHED) {\
73 tp->t_flags |= TF_ACKNOW; \
75 tp->t_flags |= TF_DELACK; \
76 (tp)->rcv_nxt += (ti)->ti_len; \
86 (flags) = tcp_reass((tp), (ti), (m)); \
87 tp->t_flags |= TF_ACKNOW; \
91 #define TCP_REASS(tp, ti, m, so, flags) { \ argument
92 if ((ti)->ti_seq == (tp)->rcv_nxt && \
93 tcpfrag_list_empty(tp) && \
94 (tp)->t_state == TCPS_ESTABLISHED) { \
95 tp->t_flags |= TF_DELACK; \
96 (tp)->rcv_nxt += (ti)->ti_len; \
106 (flags) = tcp_reass((tp), (ti), (m)); \
107 tp->t_flags |= TF_ACKNOW; \
111 static void tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt,
113 static void tcp_xmit_timer(register struct tcpcb *tp, int rtt);
116 tcp_reass(register struct tcpcb *tp, register struct tcpiphdr *ti, in tcp_reass() argument
120 struct socket *so = tp->t_socket; in tcp_reass()
133 for (q = tcpfrag_list_first(tp); !tcpfrag_list_end(q, tp); in tcp_reass()
143 if (!tcpfrag_list_end(tcpiphdr_prev(q), tp)) { in tcp_reass()
175 while (!tcpfrag_list_end(q, tp)) { in tcp_reass()
201 if (!TCPS_HAVEESTABLISHED(tp->t_state)) in tcp_reass()
203 ti = tcpfrag_list_first(tp); in tcp_reass()
204 if (tcpfrag_list_end(ti, tp) || ti->ti_seq != tp->rcv_nxt) in tcp_reass()
206 if (tp->t_state == TCPS_SYN_RECEIVED && ti->ti_len) in tcp_reass()
209 tp->rcv_nxt += ti->ti_len; in tcp_reass()
223 } while (ti != (struct tcpiphdr *)tp && ti->ti_seq == tp->rcv_nxt); in tcp_reass()
240 register struct tcpcb *tp = NULL; in tcp_input() local
262 tp = sototcpcb(so); in tcp_input()
429 tp = sototcpcb(so); in tcp_input()
430 tp->t_state = TCPS_LISTEN; in tcp_input()
441 tp = sototcpcb(so); in tcp_input()
444 if (tp == NULL) in tcp_input()
446 if (tp->t_state == TCPS_CLOSED) in tcp_input()
460 tp->t_idle = 0; in tcp_input()
462 tp->t_timer[TCPT_KEEP] = TCPTV_KEEPINTVL; in tcp_input()
464 tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_IDLE; in tcp_input()
470 if (optp && tp->t_state != TCPS_LISTEN) in tcp_input()
471 tcp_dooptions(tp, (u_char *)optp, optlen, ti); in tcp_input()
493 if (tp->t_state == TCPS_ESTABLISHED && in tcp_input()
496 ti->ti_seq == tp->rcv_nxt && in tcp_input()
497 tiwin && tiwin == tp->snd_wnd && in tcp_input()
498 tp->snd_nxt == tp->snd_max) { in tcp_input()
510 if (SEQ_GT(ti->ti_ack, tp->snd_una) && in tcp_input()
511 SEQ_LEQ(ti->ti_ack, tp->snd_max) && in tcp_input()
512 tp->snd_cwnd >= tp->snd_wnd) { in tcp_input()
520 */ if (tp->t_rtt && in tcp_input()
521 SEQ_GT(ti->ti_ack, tp->t_rtseq)) in tcp_input()
522 tcp_xmit_timer(tp, tp->t_rtt); in tcp_input()
523 acked = ti->ti_ack - tp->snd_una; in tcp_input()
527 tp->snd_una = ti->ti_ack; in tcp_input()
539 if (tp->snd_una == tp->snd_max) in tcp_input()
540 tp->t_timer[TCPT_REXMT] = 0; in tcp_input()
541 else if (tp->t_timer[TCPT_PERSIST] == 0) in tcp_input()
542 tp->t_timer[TCPT_REXMT] = tp->t_rxtcur; in tcp_input()
557 (void) tcp_output(tp); in tcp_input()
561 } else if (ti->ti_ack == tp->snd_una && in tcp_input()
562 tcpfrag_list_empty(tp) && in tcp_input()
570 tp->rcv_nxt += ti->ti_len; in tcp_input()
596 tp->t_flags |= TF_ACKNOW; in tcp_input()
597 tcp_output(tp); in tcp_input()
611 tp->rcv_wnd = max(win, (int)(tp->rcv_adv - tp->rcv_nxt)); in tcp_input()
614 switch (tp->t_state) { in tcp_input()
683 tcp_respond(tp, ti, m, ti->ti_seq+1, (tcp_seq)0, in tcp_input()
696 tp = tcp_close(tp); in tcp_input()
707 tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; in tcp_input()
708 tp->t_state = TCPS_SYN_RECEIVED; in tcp_input()
717 tp = tcp_close(tp); in tcp_input()
721 tcp_template(tp); in tcp_input()
724 tcp_dooptions(tp, (u_char *)optp, optlen, ti); in tcp_input()
729 tp->iss = iss; in tcp_input()
731 tp->iss = tcp_iss; in tcp_input()
733 tp->irs = ti->ti_seq; in tcp_input()
734 tcp_sendseqinit(tp); in tcp_input()
735 tcp_rcvseqinit(tp); in tcp_input()
736 tp->t_flags |= TF_ACKNOW; in tcp_input()
737 tp->t_state = TCPS_SYN_RECEIVED; in tcp_input()
738 tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; in tcp_input()
757 (SEQ_LEQ(ti->ti_ack, tp->iss) || in tcp_input()
758 SEQ_GT(ti->ti_ack, tp->snd_max))) in tcp_input()
763 tp = tcp_drop(tp,0); /* XXX Check t_softerror! */ in tcp_input()
770 tp->snd_una = ti->ti_ack; in tcp_input()
771 if (SEQ_LT(tp->snd_nxt, tp->snd_una)) in tcp_input()
772 tp->snd_nxt = tp->snd_una; in tcp_input()
775 tp->t_timer[TCPT_REXMT] = 0; in tcp_input()
776 tp->irs = ti->ti_seq; in tcp_input()
777 tcp_rcvseqinit(tp); in tcp_input()
778 tp->t_flags |= TF_ACKNOW; in tcp_input()
779 if (tiflags & TH_ACK && SEQ_GT(tp->snd_una, tp->iss)) { in tcp_input()
782 tp->t_state = TCPS_ESTABLISHED; in tcp_input()
791 (void) tcp_reass(tp, (struct tcpiphdr *)0, in tcp_input()
797 if (tp->t_rtt) in tcp_input()
798 tcp_xmit_timer(tp, tp->t_rtt); in tcp_input()
800 tp->t_state = TCPS_SYN_RECEIVED; in tcp_input()
809 if (ti->ti_len > tp->rcv_wnd) { in tcp_input()
810 todrop = ti->ti_len - tp->rcv_wnd; in tcp_input()
812 ti->ti_len = tp->rcv_wnd; in tcp_input()
817 tp->snd_wl1 = ti->ti_seq - 1; in tcp_input()
818 tp->rcv_up = ti->ti_seq; in tcp_input()
857 todrop = tp->rcv_nxt - ti->ti_seq; in tcp_input()
884 tp->t_flags |= TF_ACKNOW; in tcp_input()
907 tp->t_state > TCPS_CLOSE_WAIT && ti->ti_len) { in tcp_input()
908 tp = tcp_close(tp); in tcp_input()
917 todrop = (ti->ti_seq+ti->ti_len) - (tp->rcv_nxt+tp->rcv_wnd); in tcp_input()
929 tp->t_state == TCPS_TIME_WAIT && in tcp_input()
930 SEQ_GT(ti->ti_seq, tp->rcv_nxt)) { in tcp_input()
931 iss = tp->rcv_nxt + TCP_ISSINCR; in tcp_input()
932 tp = tcp_close(tp); in tcp_input()
942 if (tp->rcv_wnd == 0 && ti->ti_seq == tp->rcv_nxt) { in tcp_input()
943 tp->t_flags |= TF_ACKNOW; in tcp_input()
976 if (tiflags&TH_RST) switch (tp->t_state) { in tcp_input()
988 tp->t_state = TCPS_CLOSED; in tcp_input()
990 tp = tcp_close(tp); in tcp_input()
996 tp = tcp_close(tp); in tcp_input()
1005 tp = tcp_drop(tp,0); in tcp_input()
1017 switch (tp->t_state) { in tcp_input()
1025 if (SEQ_GT(tp->snd_una, ti->ti_ack) || in tcp_input()
1026 SEQ_GT(ti->ti_ack, tp->snd_max)) in tcp_input()
1029 tp->t_state = TCPS_ESTABLISHED; in tcp_input()
1037 tp->snd_una=ti->ti_ack; in tcp_input()
1048 tp->t_state = TCPS_FIN_WAIT_1; in tcp_input()
1061 (void) tcp_reass(tp, (struct tcpiphdr *)0, (struct mbuf *)0); in tcp_input()
1062 tp->snd_wl1 = ti->ti_seq - 1; in tcp_input()
1083 if (SEQ_LEQ(ti->ti_ack, tp->snd_una)) { in tcp_input()
1084 if (ti->ti_len == 0 && tiwin == tp->snd_wnd) { in tcp_input()
1112 if (tp->t_timer[TCPT_REXMT] == 0 || in tcp_input()
1113 ti->ti_ack != tp->snd_una) in tcp_input()
1114 tp->t_dupacks = 0; in tcp_input()
1115 else if (++tp->t_dupacks == TCPREXMTTHRESH) { in tcp_input()
1116 tcp_seq onxt = tp->snd_nxt; in tcp_input()
1118 min(tp->snd_wnd, tp->snd_cwnd) / 2 / in tcp_input()
1119 tp->t_maxseg; in tcp_input()
1123 tp->snd_ssthresh = win * tp->t_maxseg; in tcp_input()
1124 tp->t_timer[TCPT_REXMT] = 0; in tcp_input()
1125 tp->t_rtt = 0; in tcp_input()
1126 tp->snd_nxt = ti->ti_ack; in tcp_input()
1127 tp->snd_cwnd = tp->t_maxseg; in tcp_input()
1128 (void) tcp_output(tp); in tcp_input()
1129 tp->snd_cwnd = tp->snd_ssthresh + in tcp_input()
1130 tp->t_maxseg * tp->t_dupacks; in tcp_input()
1131 if (SEQ_GT(onxt, tp->snd_nxt)) in tcp_input()
1132 tp->snd_nxt = onxt; in tcp_input()
1134 } else if (tp->t_dupacks > TCPREXMTTHRESH) { in tcp_input()
1135 tp->snd_cwnd += tp->t_maxseg; in tcp_input()
1136 (void) tcp_output(tp); in tcp_input()
1140 tp->t_dupacks = 0; in tcp_input()
1148 if (tp->t_dupacks > TCPREXMTTHRESH && in tcp_input()
1149 tp->snd_cwnd > tp->snd_ssthresh) in tcp_input()
1150 tp->snd_cwnd = tp->snd_ssthresh; in tcp_input()
1151 tp->t_dupacks = 0; in tcp_input()
1152 if (SEQ_GT(ti->ti_ack, tp->snd_max)) { in tcp_input()
1156 acked = ti->ti_ack - tp->snd_una; in tcp_input()
1173 if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq)) in tcp_input()
1174 tcp_xmit_timer(tp,tp->t_rtt); in tcp_input()
1182 if (ti->ti_ack == tp->snd_max) { in tcp_input()
1183 tp->t_timer[TCPT_REXMT] = 0; in tcp_input()
1185 } else if (tp->t_timer[TCPT_PERSIST] == 0) in tcp_input()
1186 tp->t_timer[TCPT_REXMT] = tp->t_rxtcur; in tcp_input()
1195 register u_int cw = tp->snd_cwnd; in tcp_input()
1196 register u_int incr = tp->t_maxseg; in tcp_input()
1198 if (cw > tp->snd_ssthresh) in tcp_input()
1200 tp->snd_cwnd = min(cw + incr, TCP_MAXWIN<<tp->snd_scale); in tcp_input()
1203 tp->snd_wnd -= so->so_snd.sb_cc; in tcp_input()
1208 tp->snd_wnd -= acked; in tcp_input()
1218 tp->snd_una = ti->ti_ack; in tcp_input()
1219 if (SEQ_LT(tp->snd_nxt, tp->snd_una)) in tcp_input()
1220 tp->snd_nxt = tp->snd_una; in tcp_input()
1222 switch (tp->t_state) { in tcp_input()
1240 tp->t_timer[TCPT_2MSL] = TCP_MAXIDLE; in tcp_input()
1242 tp->t_state = TCPS_FIN_WAIT_2; in tcp_input()
1254 tp->t_state = TCPS_TIME_WAIT; in tcp_input()
1255 tcp_canceltimers(tp); in tcp_input()
1256 tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; in tcp_input()
1269 tp = tcp_close(tp); in tcp_input()
1280 tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; in tcp_input()
1291 (SEQ_LT(tp->snd_wl1, ti->ti_seq) || in tcp_input()
1292 (tp->snd_wl1 == ti->ti_seq && (SEQ_LT(tp->snd_wl2, ti->ti_ack) || in tcp_input()
1293 (tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd))))) { in tcp_input()
1296 tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd) in tcp_input()
1298 tp->snd_wnd = tiwin; in tcp_input()
1299 tp->snd_wl1 = ti->ti_seq; in tcp_input()
1300 tp->snd_wl2 = ti->ti_ack; in tcp_input()
1301 if (tp->snd_wnd > tp->max_sndwnd) in tcp_input()
1302 tp->max_sndwnd = tp->snd_wnd; in tcp_input()
1310 TCPS_HAVERCVDFIN(tp->t_state) == 0) { in tcp_input()
1336 if (SEQ_GT(ti->ti_seq+ti->ti_urp, tp->rcv_up)) { in tcp_input()
1337 tp->rcv_up = ti->ti_seq + ti->ti_urp; in tcp_input()
1339 (tp->rcv_up - tp->rcv_nxt); /* -1; */ in tcp_input()
1340 tp->rcv_up = ti->ti_seq + ti->ti_urp; in tcp_input()
1349 if (SEQ_GT(tp->rcv_nxt, tp->rcv_up)) in tcp_input()
1350 tp->rcv_up = tp->rcv_nxt; in tcp_input()
1362 TCPS_HAVERCVDFIN(tp->t_state) == 0) { in tcp_input()
1363 TCP_REASS(tp, ti, m, so, tiflags); in tcp_input()
1369 len = so->so_rcv.sb_datalen - (tp->rcv_adv - tp->rcv_nxt); in tcp_input()
1380 if (TCPS_HAVERCVDFIN(tp->t_state) == 0) { in tcp_input()
1393 tp->t_flags |= TF_ACKNOW; in tcp_input()
1394 tp->rcv_nxt++; in tcp_input()
1396 switch (tp->t_state) { in tcp_input()
1405 tp->t_state = TCPS_LAST_ACK; in tcp_input()
1407 tp->t_state = TCPS_CLOSE_WAIT; in tcp_input()
1415 tp->t_state = TCPS_CLOSING; in tcp_input()
1424 tp->t_state = TCPS_TIME_WAIT; in tcp_input()
1425 tcp_canceltimers(tp); in tcp_input()
1426 tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; in tcp_input()
1434 tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; in tcp_input()
1455 tp->t_flags |= TF_ACKNOW; in tcp_input()
1461 if (needoutput || (tp->t_flags & TF_ACKNOW)) { in tcp_input()
1462 (void) tcp_output(tp); in tcp_input()
1474 tp->t_flags |= TF_ACKNOW; in tcp_input()
1475 (void) tcp_output(tp); in tcp_input()
1481 tcp_respond(tp, ti, m, (tcp_seq)0, ti->ti_ack, TH_RST); in tcp_input()
1484 tcp_respond(tp, ti, m, ti->ti_seq+ti->ti_len, (tcp_seq)0, in tcp_input()
1504 tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti) in tcp_dooptions() argument
1510 DEBUG_ARGS((dfd," tp = %lx cnt=%i \n", (long )tp, cnt)); in tcp_dooptions()
1535 (void) tcp_mss(tp, mss); /* sets t_maxseg */ in tcp_dooptions()
1591 struct tcpcb *tp = sototcpcb(so); local
1593 tp->t_iobc = *cp;
1594 tp->t_oobflags |= TCPOOB_HAVEDATA;
1615 tcp_xmit_timer(register struct tcpcb *tp, int rtt) in tcp_xmit_timer() argument
1620 DEBUG_ARG("tp = %lx", (long)tp); in tcp_xmit_timer()
1624 if (tp->t_srtt != 0) { in tcp_xmit_timer()
1632 delta = rtt - 1 - (tp->t_srtt >> TCP_RTT_SHIFT); in tcp_xmit_timer()
1633 if ((tp->t_srtt += delta) <= 0) in tcp_xmit_timer()
1634 tp->t_srtt = 1; in tcp_xmit_timer()
1647 delta -= (tp->t_rttvar >> TCP_RTTVAR_SHIFT); in tcp_xmit_timer()
1648 if ((tp->t_rttvar += delta) <= 0) in tcp_xmit_timer()
1649 tp->t_rttvar = 1; in tcp_xmit_timer()
1656 tp->t_srtt = rtt << TCP_RTT_SHIFT; in tcp_xmit_timer()
1657 tp->t_rttvar = rtt << (TCP_RTTVAR_SHIFT - 1); in tcp_xmit_timer()
1659 tp->t_rtt = 0; in tcp_xmit_timer()
1660 tp->t_rxtshift = 0; in tcp_xmit_timer()
1673 TCPT_RANGESET(tp->t_rxtcur, TCP_REXMTVAL(tp), in tcp_xmit_timer()
1674 (short)tp->t_rttmin, TCPTV_REXMTMAX); /* XXX */ in tcp_xmit_timer()
1683 tp->t_softerror = 0; in tcp_xmit_timer()
1703 tcp_mss(struct tcpcb *tp, u_int offer) in tcp_mss() argument
1705 struct socket *so = tp->t_socket; in tcp_mss()
1709 DEBUG_ARG("tp = %lx", (long)tp); in tcp_mss()
1716 if (mss < tp->t_maxseg || offer != 0) in tcp_mss()
1717 tp->t_maxseg = mss; in tcp_mss()
1719 tp->snd_cwnd = mss; in tcp_mss()