Home | History | Annotate | Download | only in slirp

Lines Matching refs:tp

59  * control block tp.  Return TH_FIN if reassembly now includes
68 #define TCP_REASS(tp, ti, m, so, flags) {\
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) { \
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,
120 struct socket *so = tp->t_socket;
133 for (q = tcpfrag_list_first(tp); !tcpfrag_list_end(q, tp);
143 if (!tcpfrag_list_end(tcpiphdr_prev(q), tp)) {
175 while (!tcpfrag_list_end(q, tp)) {
201 if (!TCPS_HAVEESTABLISHED(tp->t_state))
203 ti = tcpfrag_list_first(tp);
204 if (tcpfrag_list_end(ti, tp) || ti->ti_seq != tp->rcv_nxt)
206 if (tp->t_state == TCPS_SYN_RECEIVED && ti->ti_len)
209 tp->rcv_nxt += ti->ti_len;
223 } while (ti != (struct tcpiphdr *)tp && ti->ti_seq == tp->rcv_nxt);
240 register struct tcpcb *tp = NULL;
262 tp = sototcpcb(so);
414 /* tp = sototcpcb(so); */
424 tp = sototcpcb(so);
425 tp->t_state = TCPS_LISTEN;
436 tp = sototcpcb(so);
439 if (tp == NULL)
441 if (tp->t_state == TCPS_CLOSED)
446 * tiwin = ti->ti_win << tp->snd_scale;
455 tp->t_idle = 0;
457 tp->t_timer[TCPT_KEEP] = TCPTV_KEEPINTVL;
459 tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_IDLE;
465 if (optp && tp->t_state != TCPS_LISTEN)
466 tcp_dooptions(tp, (u_char *)optp, optlen, ti);
485 * eg: the tiwin == tp->snd_wnd prevents many more
488 if (tp->t_state == TCPS_ESTABLISHED &&
490 /* (!ts_present || TSTMP_GEQ(ts_val, tp->ts_recent)) && */
491 ti->ti_seq == tp->rcv_nxt &&
492 tiwin && tiwin == tp->snd_wnd &&
493 tp->snd_nxt == tp->snd_max) {
498 /* if (ts_present && SEQ_LEQ(ti->ti_seq, tp->last_ack_sent) &&
499 * SEQ_LT(tp->last_ack_sent, ti->ti_seq + ti->ti_len)) {
500 * tp->ts_recent_age = tcp_now;
501 * tp->ts_recent = ts_val;
505 if (SEQ_GT(ti->ti_ack, tp->snd_una) &&
506 SEQ_LEQ(ti->ti_ack, tp->snd_max) &&
507 tp->snd_cwnd >= tp->snd_wnd) {
513 * tcp_xmit_timer(tp, tcp_now-ts_ecr+1);
515 */ if (tp->t_rtt &&
516 SEQ_GT(ti->ti_ack, tp->t_rtseq))
517 tcp_xmit_timer(tp, tp->t_rtt);
518 acked = ti->ti_ack - tp->snd_una;
522 tp->snd_una = ti->ti_ack;
534 if (tp->snd_una == tp->snd_max)
535 tp->t_timer[TCPT_REXMT] = 0;
536 else if (tp->t_timer[TCPT_PERSIST] == 0)
537 tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
552 (void) tcp_output(tp);
556 } else if (ti->ti_ack == tp->snd_una &&
557 tcpfrag_list_empty(tp) &&
565 tp->rcv_nxt += ti->ti_len;
591 tp->t_flags |= TF_ACKNOW;
592 tcp_output(tp);
606 tp->rcv_wnd = max(win, (int)(tp->rcv_adv - tp->rcv_nxt));
609 switch (tp->t_state) {
616 * Otherwise initialize tp->rcv_nxt, and tp->irs, select an initial
617 * tp->iss, and send a segment:
619 * Also initialize tp->snd_nxt to tp->iss+1 and tp->snd_una to tp->iss.
677 tcp_respond(tp, ti, m, ti->ti_seq+1, (tcp_seq)0,
690 tp = tcp_close(tp);
701 tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
702 tp->t_state = TCPS_SYN_RECEIVED;
711 tp = tcp_close(tp);
715 tcp_template(tp);
718 tcp_dooptions(tp, (u_char *)optp, optlen, ti);
723 tp->iss = iss;
725 tp->iss = tcp_iss;
727 tp->irs = ti->ti_seq;
728 tcp_sendseqinit(tp);
729 tcp_rcvseqinit(tp);
730 tp->t_flags |= TF_ACKNOW;
731 tp->t_state = TCPS_SYN_RECEIVED;
732 tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
743 * initialize tp->rcv_nxt and tp->irs
744 * if seg contains ack then advance tp->snd_una
751 (SEQ_LEQ(ti->ti_ack, tp->iss) ||
752 SEQ_GT(ti->ti_ack, tp->snd_max)))
757 tp = tcp_drop(tp,0); /* XXX Check t_softerror! */
764 tp->snd_una = ti->ti_ack;
765 if (SEQ_LT(tp->snd_nxt, tp->snd_una))
766 tp->snd_nxt = tp->snd_una;
769 tp->t_timer[TCPT_REXMT] = 0;
770 tp->irs = ti->ti_seq;
771 tcp_rcvseqinit(tp);
772 tp->t_flags |= TF_ACKNOW;
773 if (tiflags & TH_ACK && SEQ_GT(tp->snd_una, tp->iss)) {
776 tp->t_state = TCPS_ESTABLISHED;
779 /* if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
781 * tp->snd_scale = tp->requested_s_scale;
782 * tp->rcv_scale = tp->request_r_scale;
785 (void) tcp_reass(tp, (struct tcpiphdr *)0,
791 if (tp->t_rtt)
792 tcp_xmit_timer(tp, tp->t_rtt);
794 tp->t_state = TCPS_SYN_RECEIVED;
803 if (ti->ti_len > tp->rcv_wnd) {
804 todrop = ti->ti_len - tp->rcv_wnd;
806 ti->ti_len = tp->rcv_wnd;
811 tp->snd_wl1 = ti->ti_seq - 1;
812 tp->rcv_up = ti->ti_seq;
814 } /* switch tp->t_state */
825 /* if (ts_present && (tiflags & TH_RST) == 0 && tp->ts_recent &&
826 * TSTMP_LT(ts_val, tp->ts_recent)) {
829 /* if ((int)(tcp_now - tp->ts_recent_age) > TCP_PAWS_IDLE) {
841 /* tp->ts_recent = 0;
851 todrop = tp->rcv_nxt - ti->ti_seq;
878 tp->t_flags |= TF_ACKNOW;
901 tp->t_state > TCPS_CLOSE_WAIT && ti->ti_len) {
902 tp = tcp_close(tp);
911 todrop = (ti->ti_seq+ti->ti_len) - (tp->rcv_nxt+tp->rcv_wnd);
923 tp->t_state == TCPS_TIME_WAIT &&
924 SEQ_GT(ti->ti_seq, tp->rcv_nxt)) {
925 iss = tp->rcv_nxt + TCP_ISSINCR;
926 tp = tcp_close(tp);
936 if (tp->rcv_wnd == 0 && ti->ti_seq == tp->rcv_nxt) {
937 tp->t_flags |= TF_ACKNOW;
952 /* if (ts_present && SEQ_LEQ(ti->ti_seq, tp->last_ack_sent) &&
953 * SEQ_LT(tp->last_ack_sent, ti->ti_seq + ti->ti_len +
955 * tp->ts_recent_age = tcp_now;
956 * tp->ts_recent = ts_val;
970 if (tiflags&TH_RST) switch (tp->t_state) {
982 tp->t_state = TCPS_CLOSED;
984 tp = tcp_close(tp);
990 tp = tcp_close(tp);
999 tp = tcp_drop(tp,0);
1011 switch (tp->t_state) {
1019 if (SEQ_GT(tp->snd_una, ti->ti_ack) ||
1020 SEQ_GT(ti->ti_ack, tp->snd_max))
1023 tp->t_state = TCPS_ESTABLISHED;
1029 * tp->snd_una++; or:
1031 tp->snd_una=ti->ti_ack;
1042 tp->t_state = TCPS_FIN_WAIT_1;
1049 /* if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
1051 * tp->snd_scale = tp->requested_s_scale;
1052 * tp->rcv_scale = tp->request_r_scale;
1055 (void) tcp_reass(tp, (struct tcpiphdr *)0, (struct mbuf *)0);
1056 tp->snd_wl1 = ti->ti_seq - 1;
1064 * tp->snd_una < ti->ti_ack <= tp->snd_max
1065 * then advance tp->snd_una to ti->ti_ack and drop
1077 if (SEQ_LEQ(ti->ti_ack, tp->snd_una)) {
1078 if (ti->ti_len == 0 && tiwin == tp->snd_wnd) {
1106 if (tp->t_timer[TCPT_REXMT] == 0 ||
1107 ti->ti_ack != tp->snd_una)
1108 tp->t_dupacks = 0;
1109 else if (++tp->t_dupacks == TCPREXMTTHRESH) {
1110 tcp_seq onxt = tp->snd_nxt;
1112 min(tp->snd_wnd, tp->snd_cwnd) / 2 /
1113 tp->t_maxseg;
1117 tp->snd_ssthresh = win * tp->t_maxseg;
1118 tp->t_timer[TCPT_REXMT] = 0;
1119 tp->t_rtt = 0;
1120 tp->snd_nxt = ti->ti_ack;
1121 tp->snd_cwnd = tp->t_maxseg;
1122 (void) tcp_output(tp
1123 tp->snd_cwnd = tp->snd_ssthresh +
1124 tp->t_maxseg * tp->t_dupacks;
1125 if (SEQ_GT(onxt, tp->snd_nxt))
1126 tp->snd_nxt = onxt;
1128 } else if (tp->t_dupacks > TCPREXMTTHRESH) {
1129 tp->snd_cwnd += tp->t_maxseg;
1130 (void) tcp_output(tp);
1134 tp->t_dupacks = 0;
1142 if (tp->t_dupacks > TCPREXMTTHRESH &&
1143 tp->snd_cwnd > tp->snd_ssthresh)
1144 tp->snd_cwnd = tp->snd_ssthresh;
1145 tp->t_dupacks = 0;
1146 if (SEQ_GT(ti->ti_ack, tp->snd_max)) {
1150 acked = ti->ti_ack - tp->snd_una;
1164 * tcp_xmit_timer(tp, tcp_now-ts_ecr+1);
1167 if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq))
1168 tcp_xmit_timer(tp,tp->t_rtt);
1176 if (ti->ti_ack == tp->snd_max) {
1177 tp->t_timer[TCPT_REXMT] = 0;
1179 } else if (tp->t_timer[TCPT_PERSIST] == 0)
1180 tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
1189 register u_int cw = tp->snd_cwnd;
1190 register u_int incr = tp->t_maxseg;
1192 if (cw > tp->snd_ssthresh)
1194 tp->snd_cwnd = min(cw + incr, TCP_MAXWIN<<tp->snd_scale);
1197 tp->snd_wnd -= so->so_snd.sb_cc;
1202 tp->snd_wnd -= acked;
1212 tp->snd_una = ti->ti_ack;
1213 if (SEQ_LT(tp->snd_nxt, tp->snd_una))
1214 tp->snd_nxt = tp->snd_una;
1216 switch (tp->t_state) {
1234 tp->t_timer[TCPT_2MSL] = TCP_MAXIDLE;
1236 tp->t_state = TCPS_FIN_WAIT_2;
1248 tp->t_state = TCPS_TIME_WAIT;
1249 tcp_canceltimers(tp);
1250 tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
1263 tp = tcp_close(tp);
1274 tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
1277 } /* switch(tp->t_state) */
1285 (SEQ_LT(tp->snd_wl1, ti->ti_seq) ||
1286 (tp->snd_wl1 == ti->ti_seq && (SEQ_LT(tp->snd_wl2, ti->ti_ack) ||
1287 (tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd))))) {
1290 tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd)
1292 tp->snd_wnd = tiwin;
1293 tp->snd_wl1 = ti->ti_seq;
1294 tp->snd_wl2 = ti->ti_ack;
1295 if (tp->snd_wnd > tp->max_sndwnd)
1296 tp->max_sndwnd = tp->snd_wnd;
1304 TCPS_HAVERCVDFIN(tp->t_state) == 0) {
1330 if (SEQ_GT(ti->ti_seq+ti->ti_urp, tp->rcv_up)) {
1331 tp->rcv_up = ti->ti_seq + ti->ti_urp;
1333 (tp->rcv_up - tp->rcv_nxt); /* -1; */
1334 tp->rcv_up = ti->ti_seq + ti->ti_urp;
1343 if (SEQ_GT(tp->rcv_nxt, tp->rcv_up))
1344 tp->rcv_up = tp->rcv_nxt;
1350 * This process logically involves adjusting tp->rcv_wnd as data
1356 TCPS_HAVERCVDFIN(tp->t_state) == 0) {
1357 TCP_REASS(tp, ti, m, so, tiflags);
1363 len = so->so_rcv.sb_datalen - (tp->rcv_adv - tp->rcv_nxt);
1374 if (TCPS_HAVERCVDFIN(tp->t_state) == 0) {
1387 tp->t_flags |= TF_ACKNOW;
1388 tp->rcv_nxt++;
1390 switch (tp->t_state) {
1399 tp->t_state = TCPS_LAST_ACK;
1401 tp->t_state = TCPS_CLOSE_WAIT;
1409 tp->t_state = TCPS_CLOSING;
1418 tp->t_state = TCPS_TIME_WAIT;
1419 tcp_canceltimers(tp);
1420 tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
1428 tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
1440 /* if (ti->ti_len && (unsigned)ti->ti_len < tp->t_maxseg) {
1442 /* if ((ti->ti_len && (unsigned)ti->ti_len < tp->t_maxseg &&
1449 tp->t_flags |= TF_ACKNOW;
1455 if (needoutput || (tp->t_flags & TF_ACKNOW)) {
1456 (void) tcp_output(tp);
1468 tp->t_flags |= TF_ACKNOW;
1469 (void) tcp_output(tp);
1475 tcp_respond(tp, ti, m, (tcp_seq)0, ti->ti_ack, TH_RST);
1478 tcp_respond(tp, ti, m, ti->ti_seq+ti->ti_len, (tcp_seq)0,
1498 tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti)
1504 DEBUG_ARGS((dfd," tp = %lx cnt=%i \n", (long )tp, cnt));
1529 (void) tcp_mss(tp, mss); /* sets t_maxseg */
1537 * tp->t_flags |= TF_RCVD_SCALE;
1538 * tp->requested_s_scale = min(cp[2], TCP_MAX_WINSHIFT);
1555 * tp->t_flags |= TF_RCVD_TSTMP;
1556 * tp->ts_recent = *ts_val;
1557 * tp->ts_recent_age = tcp_now;
1585 struct tcpcb *tp = sototcpcb(so);
1587 tp->t_iobc = *cp;
1588 tp->t_oobflags |= TCPOOB_HAVEDATA;
1609 tcp_xmit_timer(register struct tcpcb *tp, int rtt)
1614 DEBUG_ARG("tp = %lx", (long)tp);
1618 if (tp->t_srtt != 0) {
1626 delta = rtt - 1 - (tp->t_srtt >> TCP_RTT_SHIFT);
1627 if ((tp->t_srtt += delta) <= 0)
1628 tp->t_srtt = 1;
1641 delta -= (tp->t_rttvar >> TCP_RTTVAR_SHIFT);
1642 if ((tp->t_rttvar += delta) <= 0)
1643 tp->t_rttvar = 1;
1650 tp->t_srtt = rtt << TCP_RTT_SHIFT;
1651 tp->t_rttvar = rtt << (TCP_RTTVAR_SHIFT - 1);
1653 tp->t_rtt = 0;
1654 tp->t_rxtshift = 0;
1667 TCPT_RANGESET(tp->t_rxtcur, TCP_REXMTVAL(tp),
1668 (short)tp->t_rttmin, TCPTV_REXMTMAX); /* XXX */
1677 tp->t_softerror = 0;
1697 tcp_mss(struct tcpcb *tp, u_int offer)
1699 struct socket *so = tp->t_socket;
1703 DEBUG_ARG("tp = %lx", (long)tp);
1710 if (mss < tp->t_maxseg || offer != 0)
1711 tp->t_maxseg = mss;
1713 tp->snd_cwnd = mss;