* HTTP). <mux_proto> can be empty. Will fall back to the first compatible mux
* with exactly the same <proto_mode> or with an empty name. May return
* null if the code improperly registered the default mux to use as a fallback.
+ *
+ * <proto_mode> expects PROTO_MODE_* value only: PROXY_MODE_* values should
+ * never be used directly here (but you may use conn_pr_mode_to_proto_mode()
+ * to map proxy mode to corresponding proto mode before calling the function).
*/
static inline const struct mux_proto_list *conn_get_best_mux_entry(
const struct ist mux_proto,
tlv_arg->data.sint = tlv_type;
}
+/*
+ * Map proxy mode (PR_MODE_*) to equivalent proto_proxy_mode (PROTO_MODE_*)
+ */
+static inline int conn_pr_mode_to_proto_mode(int proxy_mode)
+{
+ int mode;
+
+ /* for now we only support TCP and HTTP proto_modes, so we
+ * consider that if it's not HTTP, then it's TCP
+ */
+ mode = 1 << (proxy_mode == PR_MODE_HTTP);
+
+ return mode;
+}
+
#endif /* _HAPROXY_CONNECTION_H */
/*
/* Check the mux protocols, if any, for each listener and server
* attached to the current proxy */
list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
- int mode = (1 << (curproxy->mode == PR_MODE_HTTP));
+ int mode = conn_pr_mode_to_proto_mode(curproxy->mode);
const struct mux_proto_list *mux_ent;
if (!bind_conf->mux_proto) {
bind_conf->mux_proto = mux_ent;
}
for (newsrv = curproxy->srv; newsrv; newsrv = newsrv->next) {
- int mode = (1 << (curproxy->mode == PR_MODE_HTTP));
+ int mode = conn_pr_mode_to_proto_mode(curproxy->mode);
const struct mux_proto_list *mux_ent;
if (!newsrv->mux_proto)
const struct mux_proto_list *mux_ent;
const struct mux_proto_list *mux_proto = rule->arg.act.p[1];
enum pr_mode pr_mode = (uintptr_t)rule->arg.act.p[0];
- enum proto_proxy_mode mode = (1 << (pr_mode == PR_MODE_HTTP));
+ enum proto_proxy_mode mode = conn_pr_mode_to_proto_mode(pr_mode);
if (pr_mode == PR_MODE_HTTP)
px->options |= PR_O_HTTP_UPG;