Lines Matching refs:ti
68 #define TCP_REASS(tp, ti, m, so, flags) {\ argument
69 if ((ti)->ti_seq == (tp)->rcv_nxt && \
72 if (ti->ti_flags & TH_PUSH) \
76 (tp)->rcv_nxt += (ti)->ti_len; \
77 flags = (ti)->ti_flags & TH_FIN; \
79 STAT(tcpstat.tcps_rcvbyte += (ti)->ti_len); \
86 (flags) = tcp_reass((tp), (ti), (m)); \
91 #define TCP_REASS(tp, ti, m, so, flags) { \ argument
92 if ((ti)->ti_seq == (tp)->rcv_nxt && \
96 (tp)->rcv_nxt += (ti)->ti_len; \
97 flags = (ti)->ti_flags & TH_FIN; \
99 STAT(tcpstat.tcps_rcvbyte += (ti)->ti_len); \
106 (flags) = tcp_reass((tp), (ti), (m)); \
112 struct tcpiphdr *ti);
116 tcp_reass(register struct tcpcb *tp, register struct tcpiphdr *ti, in tcp_reass() argument
127 if (ti == NULL) in tcp_reass()
135 if (SEQ_GT(q->ti_seq, ti->ti_seq)) in tcp_reass()
147 i = q->ti_seq + q->ti_len - ti->ti_seq; in tcp_reass()
149 if (i >= ti->ti_len) { in tcp_reass()
151 STAT(tcpstat.tcps_rcvdupbyte += ti->ti_len); in tcp_reass()
162 ti->ti_len -= i; in tcp_reass()
163 ti->ti_seq += i; in tcp_reass()
168 STAT(tcpstat.tcps_rcvoobyte += ti->ti_len); in tcp_reass()
169 ti->ti_mbuf = m; in tcp_reass()
176 register int i = (ti->ti_seq + ti->ti_len) - q->ti_seq; in tcp_reass()
194 insque(tcpiphdr2qlink(ti), tcpiphdr2qlink(tcpiphdr_prev(q))); 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()
210 flags = ti->ti_flags & TH_FIN; in tcp_reass()
211 remque(tcpiphdr2qlink(ti)); in tcp_reass()
212 m = ti->ti_mbuf; in tcp_reass()
213 ti = tcpiphdr_next(ti); in tcp_reass()
223 } while (ti != (struct tcpiphdr *)tp && ti->ti_seq == tp->rcv_nxt); in tcp_reass()
236 register struct tcpiphdr *ti; in tcp_input() local
265 ti = so->so_ti; in tcp_input()
266 tiwin = ti->ti_win; in tcp_input()
267 tiflags = ti->ti_flags; in tcp_input()
278 ti = mtod(m, struct tcpiphdr *); in tcp_input()
297 tlen = ((struct ip *)ti)->ip_len; in tcp_input()
298 tcpiphdr2qlink(ti)->next = tcpiphdr2qlink(ti)->prev = NULL; in tcp_input()
299 memset(&ti->ti_i.ih_mbuf, 0 , sizeof(struct mbuf_ptr)); in tcp_input()
300 ti->ti_x1 = 0; in tcp_input()
301 ti->ti_len = htons((u_int16_t)tlen); in tcp_input()
315 off = ti->ti_off << 2; in tcp_input()
321 ti->ti_len = tlen; in tcp_input()
345 tiflags = ti->ti_flags; in tcp_input()
350 NTOHL(ti->ti_seq); in tcp_input()
351 NTOHL(ti->ti_ack); in tcp_input()
352 NTOHS(ti->ti_win); in tcp_input()
353 NTOHS(ti->ti_urp); in tcp_input()
363 if (ex_ptr->ex_fport == port_geth(ti->ti_dport) && in tcp_input()
364 (ip_geth(ti->ti_dst) & 0xff) == ex_ptr->ex_addr) in tcp_input()
376 uint32_t srcip = ip_geth(ti->ti_src); in tcp_input()
377 uint32_t dstip = ip_geth(ti->ti_dst); in tcp_input()
378 uint16_t dstport = port_geth(ti->ti_dport); in tcp_input()
379 uint16_t srcport = port_geth(ti->ti_sport); in tcp_input()
421 so->so_laddr_ip = ip_geth(ti->ti_src); in tcp_input()
422 so->so_laddr_port = port_geth(ti->ti_sport); in tcp_input()
423 so->so_faddr_ip = ip_geth(ti->ti_dst); in tcp_input()
424 so->so_faddr_port = port_geth(ti->ti_dport); in tcp_input()
427 so->so_iptos = ((struct ip *)ti)->ip_tos; in tcp_input()
454 tiwin = ti->ti_win; in tcp_input()
471 tcp_dooptions(tp, (u_char *)optp, optlen, ti); in tcp_input()
496 ti->ti_seq == tp->rcv_nxt && in tcp_input()
509 if (ti->ti_len == 0) { 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()
521 SEQ_GT(ti->ti_ack, tp->t_rtseq)) in tcp_input()
523 acked = ti->ti_ack - tp->snd_una; in tcp_input()
527 tp->snd_una = ti->ti_ack; in tcp_input()
561 } else if (ti->ti_ack == tp->snd_una && in tcp_input()
563 ti->ti_len <= sbspace(&so->so_rcv)) { in tcp_input()
570 tp->rcv_nxt += ti->ti_len; in tcp_input()
572 STAT(tcpstat.tcps_rcvbyte += ti->ti_len); in tcp_input()
683 tcp_respond(tp, ti, m, ti->ti_seq+1, (tcp_seq)0, in tcp_input()
687 HTONL(ti->ti_seq); /* restore tcp header */ in tcp_input()
688 HTONL(ti->ti_ack); in tcp_input()
689 HTONS(ti->ti_win); in tcp_input()
690 HTONS(ti->ti_urp); in tcp_input()
706 so->so_ti = ti; in tcp_input()
724 tcp_dooptions(tp, (u_char *)optp, optlen, ti); in tcp_input()
733 tp->irs = ti->ti_seq; 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()
770 tp->snd_una = ti->ti_ack; in tcp_input()
776 tp->irs = ti->ti_seq; in tcp_input()
808 ti->ti_seq++; 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()
861 ti->ti_seq++; in tcp_input()
862 if (ti->ti_urp > 1) in tcp_input()
863 ti->ti_urp--; in tcp_input()
871 if (todrop > ti->ti_len in tcp_input()
872 || (todrop == ti->ti_len && (tiflags & TH_FIN) == 0)) { in tcp_input()
885 todrop = ti->ti_len; in tcp_input()
893 ti->ti_seq += todrop; in tcp_input()
894 ti->ti_len -= todrop; in tcp_input()
895 if (ti->ti_urp > todrop) in tcp_input()
896 ti->ti_urp -= todrop; in tcp_input()
899 ti->ti_urp = 0; in tcp_input()
907 tp->t_state > TCPS_CLOSE_WAIT && ti->ti_len) { in tcp_input()
917 todrop = (ti->ti_seq+ti->ti_len) - (tp->rcv_nxt+tp->rcv_wnd); in tcp_input()
920 if (todrop >= ti->ti_len) { in tcp_input()
921 STAT(tcpstat.tcps_rcvbyteafterwin += ti->ti_len); in tcp_input()
930 SEQ_GT(ti->ti_seq, tp->rcv_nxt)) { in tcp_input()
942 if (tp->rcv_wnd == 0 && ti->ti_seq == tp->rcv_nxt) { in tcp_input()
950 ti->ti_len -= todrop; 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()
1037 tp->snd_una=ti->ti_ack; 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()
1113 ti->ti_ack != tp->snd_una) in tcp_input()
1126 tp->snd_nxt = ti->ti_ack; 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()
1182 if (ti->ti_ack == tp->snd_max) { in tcp_input()
1218 tp->snd_una = ti->ti_ack; 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()
1295 if (ti->ti_len == 0 && in tcp_input()
1296 tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd) in tcp_input()
1299 tp->snd_wl1 = ti->ti_seq; in tcp_input()
1300 tp->snd_wl2 = ti->ti_ack; in tcp_input()
1309 if ((tiflags & TH_URG) && ti->ti_urp && in tcp_input()
1317 if (ti->ti_urp + so->so_rcv.sb_cc > so->so_rcv.sb_datalen) { in tcp_input()
1318 ti->ti_urp = 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()
1340 tp->rcv_up = ti->ti_seq + ti->ti_urp; in tcp_input()
1361 if ((ti->ti_len || (tiflags&TH_FIN)) && in tcp_input()
1363 TCP_REASS(tp, ti, m, so, tiflags); in tcp_input()
1453 if (ti->ti_len && (unsigned)ti->ti_len <= 5 && in tcp_input()
1454 ((struct tcpiphdr_2 *)ti)->first_char == (char)27) { in tcp_input()
1481 tcp_respond(tp, ti, m, (tcp_seq)0, ti->ti_ack, TH_RST); in tcp_input()
1483 if (tiflags & TH_SYN) ti->ti_len++; 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
1531 if (!(ti->ti_flags & TH_SYN)) in tcp_dooptions()
1581 tcp_pulloutofband(so, ti, m) in tcp_pulloutofband() argument
1583 struct tcpiphdr *ti;
1586 int cnt = ti->ti_urp - 1;