From: Aurelien DARRAGON Date: Wed, 5 Mar 2025 15:53:56 +0000 (+0100) Subject: MINOR: proxy: make pr_mode enum bitfield compatible X-Git-Tag: v3.2-dev7~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d9aa1991006a6d7348e24af0ea781337d5b1c722;p=thirdparty%2Fhaproxy.git MINOR: proxy: make pr_mode enum bitfield compatible 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. --- diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h index d243d072e..407a99947 100644 --- a/include/haproxy/proxy-t.h +++ b/include/haproxy/proxy-t.h @@ -45,15 +45,19 @@ #include #include -/* 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 {