MINOR: connection: add simple functions to report connection readiness

conn_xprt_ready() reports if the transport layer is ready.
conn_ctrl_ready() reports if the control layer is ready.

The stream interface uses si_conn_ready() to report that the
underlying connection is ready. This will be used for connection
reuse in keep-alive mode.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index a642960..a36906d 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -43,6 +43,18 @@
 int conn_recv_proxy(struct connection *conn, int flag);
 int make_proxy_line(char *buf, int buf_len, struct sockaddr_storage *src, struct sockaddr_storage *dst);
 
+/* returns true is the transport layer is ready */
+static inline int conn_xprt_ready(struct connection *conn)
+{
+	return (conn->flags & CO_FL_XPRT_READY) && conn->xprt;
+}
+
+/* returns true is the control layer is ready */
+static inline int conn_ctrl_ready(struct connection *conn)
+{
+	return (conn->flags & CO_FL_CTRL_READY);
+}
+
 /* Calls the init() function of the transport layer if any and if not done yet,
  * and sets the CO_FL_XPRT_READY flag to indicate it was properly initialized.
  * Returns <0 in case of error.
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index 7ab72ce..5408f1e 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -149,6 +149,16 @@
 	conn_attach(conn, si, &si_conn_cb);
 }
 
+/* Returns true if a connection is attached to the stream interface <si> and
+ * if this connection is ready.
+ */
+static inline int si_conn_ready(struct stream_interface *si)
+{
+	struct connection *conn = objt_conn(si->end);
+
+	return conn && conn_ctrl_ready(conn) && conn_xprt_ready(conn);
+}
+
 /* Attach appctx <appctx> to the stream interface <si>. The stream interface
  * is configured to work with an applet context. It is left to the caller to
  * call appctx_set_applet() to assign an applet to this context.