-#define TCP_KEEPIDLE(tp) \
- (tp->t_keepidle && (tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE) ? \
- tp->t_keepidle : tcp_keepidle)
+#define TCP_CONN_KEEPIDLE(tp) \
+ ((tp)->t_keepidle && \
+ ((tp)->t_inpcb->inp_socket->so_options & SO_KEEPALIVE) ? \
+ (tp)->t_keepidle : tcp_keepidle)
+#define TCP_CONN_KEEPINIT(tp) \
+ (((tp)->t_keepinit > 0) ? (tp)->t_keepinit : tcp_keepinit)
+#define TCP_CONN_KEEPCNT(tp) \
+ (((tp)->t_keepcnt > 0) ? (tp)->t_keepcnt : tcp_keepcnt)
+#define TCP_CONN_KEEPINTVL(tp) \
+ (((tp)->t_keepintvl > 0) ? (tp)->t_keepintvl : tcp_keepintvl)
+#define TCP_CONN_MAXIDLE(tp) \
+ (TCP_CONN_KEEPCNT(tp) * TCP_CONN_KEEPINTVL(tp))