MINOR: connection: add a few functions to report the data and xprt layers' names
These functions will be needed by "show sess" on the CLI, let's make them
globally available. It's important to note that due to the fact that we
still do not set the data and transport layers' names in the structures,
we still have to rely on some exports just to match the pointers. This is
ugly but is preferable to adding many includes since the short-term goal
is to get rid of these tests by having proper names in place.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index 8921a06..0724512 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -598,6 +598,57 @@
return NULL;
}
+static inline const char *conn_get_ctrl_name(const struct connection *conn)
+{
+ if (!conn_ctrl_ready(conn))
+ return "NONE";
+ return conn->ctrl->name;
+}
+
+static inline const char *conn_get_xprt_name(const struct connection *conn)
+{
+ static char ptr[19]; /* 0x... */
+ extern struct xprt_ops raw_sock; // should theorically not be exported
+ extern struct xprt_ops ssl_sock; // should theorically not be exported
+
+ if (!conn_xprt_ready(conn))
+ return "NONE";
+
+ if (conn->xprt == &raw_sock)
+ return "RAW";
+
+#ifdef USE_OPENSSL
+ if (conn->xprt == &ssl_sock)
+ return "SSL";
+#endif
+ snprintf(ptr, sizeof(ptr), "%p", conn->xprt);
+ return ptr;
+}
+
+static inline const char *conn_get_data_name(const struct connection *conn)
+{
+ static char ptr[19]; /* 0x... */
+ extern struct data_cb sess_conn_cb; // should theorically not be exported
+ extern struct data_cb si_conn_cb; // should theorically not be exported
+ extern struct data_cb check_conn_cb; // should theorically not be exported
+
+ if (!conn->data)
+ return "NONE";
+
+ if (conn->data == &sess_conn_cb)
+ return "SESS";
+
+ if (conn->data == &si_conn_cb)
+ return "STRM";
+
+ if (conn->data == &check_conn_cb)
+ return "CHCK";
+
+ snprintf(ptr, sizeof(ptr), "%p", conn->data);
+ return ptr;
+}
+
+
#endif /* _PROTO_CONNECTION_H */
/*