+static void
+tcp_connection_fill_info(struct tcpcb *tp, struct tcp_connection_info *tci)
+{
+ struct inpcb *inp = tp->t_inpcb;
+
+ bzero(tci, sizeof(*tci));
+ tci->tcpi_state = tp->t_state;
+ if (tp->t_state > TCPS_LISTEN) {
+ if (TSTMP_SUPPORTED(tp))
+ tci->tcpi_options |= TCPCI_OPT_TIMESTAMPS;
+ if (SACK_ENABLED(tp))
+ tci->tcpi_options |= TCPCI_OPT_SACK;
+ if (TCP_WINDOW_SCALE_ENABLED(tp)) {
+ tci->tcpi_options |= TCPCI_OPT_WSCALE;
+ tci->tcpi_snd_wscale = tp->snd_scale;
+ tci->tcpi_rcv_wscale = tp->rcv_scale;
+ }
+ if (TCP_ECN_ENABLED(tp))
+ tci->tcpi_options |= TCPCI_OPT_ECN;
+ if (IN_FASTRECOVERY(tp) || tp->t_rxtshift > 0)
+ tci->tcpi_flags |= TCPCI_FLAG_LOSSRECOVERY;
+ if (tp->t_flagsext & TF_PKTS_REORDERED)
+ tci->tcpi_flags |= TCPCI_FLAG_REORDERING_DETECTED;
+ tci->tcpi_rto = (tp->t_timer[TCPT_REXMT] > 0) ?
+ tp->t_rxtcur : 0;
+ tci->tcpi_maxseg = tp->t_maxseg;
+ tci->tcpi_snd_ssthresh = tp->snd_ssthresh;
+ tci->tcpi_snd_cwnd = tp->snd_cwnd;
+ tci->tcpi_snd_wnd = tp->snd_wnd;
+ tci->tcpi_snd_sbbytes = inp->inp_socket->so_snd.sb_cc;
+ tci->tcpi_rcv_wnd = tp->rcv_wnd;
+ tci->tcpi_rttcur = tp->t_rttcur;
+ tci->tcpi_srtt = (tp->t_srtt >> TCP_RTT_SHIFT);
+ tci->tcpi_rttvar = (tp->t_rttvar >> TCP_RTTVAR_SHIFT);
+ tci->tcpi_txpackets = inp->inp_stat->txpackets;
+ tci->tcpi_txbytes = inp->inp_stat->txbytes;
+ tci->tcpi_txretransmitbytes = tp->t_stat.txretransmitbytes;
+ tci->tcpi_txretransmitpackets = tp->t_stat.rxmitpkts;
+ tci->tcpi_rxpackets = inp->inp_stat->rxpackets;
+ tci->tcpi_rxbytes = inp->inp_stat->rxbytes;
+ tci->tcpi_rxoutoforderbytes = tp->t_stat.rxoutoforderbytes;
+
+ tci->tcpi_tfo_syn_data_rcv = !!(tp->t_tfo_stats & TFO_S_SYNDATA_RCV);
+ tci->tcpi_tfo_cookie_req_rcv = !!(tp->t_tfo_stats & TFO_S_COOKIEREQ_RECV);
+ tci->tcpi_tfo_cookie_sent = !!(tp->t_tfo_stats & TFO_S_COOKIE_SENT);
+ tci->tcpi_tfo_cookie_invalid = !!(tp->t_tfo_stats & TFO_S_COOKIE_INVALID);
+ tci->tcpi_tfo_cookie_req = !!(tp->t_tfo_stats & TFO_S_COOKIE_REQ);
+ tci->tcpi_tfo_cookie_rcv = !!(tp->t_tfo_stats & TFO_S_COOKIE_RCV);
+ tci->tcpi_tfo_syn_data_sent = !!(tp->t_tfo_stats & TFO_S_SYN_DATA_SENT);
+ tci->tcpi_tfo_syn_data_acked = !!(tp->t_tfo_stats & TFO_S_SYN_DATA_ACKED);
+ tci->tcpi_tfo_syn_loss = !!(tp->t_tfo_stats & TFO_S_SYN_LOSS);
+ tci->tcpi_tfo_cookie_wrong = !!(tp->t_tfo_stats & TFO_S_COOKIE_WRONG);
+ tci->tcpi_tfo_no_cookie_rcv = !!(tp->t_tfo_stats & TFO_S_NO_COOKIE_RCV);
+ tci->tcpi_tfo_heuristics_disable = !!(tp->t_tfo_stats & TFO_S_HEURISTICS_DISABLE);
+ tci->tcpi_tfo_send_blackhole = !!(tp->t_tfo_stats & TFO_S_SEND_BLACKHOLE);
+ tci->tcpi_tfo_recv_blackhole = !!(tp->t_tfo_stats & TFO_S_RECV_BLACKHOLE);
+ tci->tcpi_tfo_onebyte_proxy = !!(tp->t_tfo_stats & TFO_S_ONE_BYTE_PROXY);
+ }
+}
+