]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proxy: make pr_mode enum bitfield compatible
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 5 Mar 2025 15:53:56 +0000 (16:53 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 6 Mar 2025 08:30:11 +0000 (09:30 +0100)
Current pr_mode enum is a regular enum because a proxy only supports one
mode at a time. However it can be handy for a function to be given a
list of compatible modes for a proxy, and we can't do that using a
bitfield because pr_mode is not bitfield compatible (values share
the same bits).

In this patch we manually define pr_mode values so that they are all
using separate bits and allows a function to take a bitfield of
compatible modes as parameter.

include/haproxy/proxy-t.h

index d243d072e874b4202f9418b70b3669d5f7628eb7..407a999472ce6826a9a24d6eac9a78d4426a54af 100644 (file)
 #include <haproxy/uri_auth-t.h>
 #include <haproxy/http_ext-t.h>
 
-/* values for proxy->mode */
+/* values for proxy->mode, only one value per proxy.
+ *
+ * values are bitfield compatible so that functions may
+ * take a bitfield of compatible modes as parameter
+ */
 enum pr_mode {
-       PR_MODE_TCP = 0,
-       PR_MODE_HTTP,
-       PR_MODE_CLI,
-       PR_MODE_SYSLOG,
-       PR_MODE_PEERS,
-       PR_MODE_SPOP,
-       PR_MODES
+       PR_MODES       = 0x00,
+       PR_MODE_TCP    = 0x01,
+       PR_MODE_HTTP   = 0x02,
+       PR_MODE_CLI    = 0x04,
+       PR_MODE_SYSLOG = 0x08,
+       PR_MODE_PEERS  = 0x10,
+       PR_MODE_SPOP   = 0x20,
 } __attribute__((packed));
 
 enum PR_SRV_STATE_FILE {