]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: peers: Replace hard-coded values for peer protocol messaging by macros.
authorFrédéric Lécaille <flecaille@haproxy.com>
Tue, 4 Jun 2019 06:28:19 +0000 (08:28 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 5 Jun 2019 06:42:36 +0000 (08:42 +0200)
Simple patch to replace hard-coded values in relation with bytes identifiers used
for stick-table messages by macros.

src/peers.c

index 039a625a1fb43bb6f215c276ed9f7641067d5330..bece5a6a58d9c9d277d732bab836b191b807f654 100644 (file)
@@ -168,6 +168,9 @@ struct peer_prep_params {
 #define PEER_MSG_STKT_ACK              0x84
 #define PEER_MSG_STKT_UPDATE_TIMED     0x85
 #define PEER_MSG_STKT_INCUPDATE_TIMED  0x86
+/* All the stick-table message identifiers abova have the #7 bit set */
+#define PEER_MSG_STKT_BIT                 7
+#define PEER_MSG_STKT_BIT_MASK         (1 << PEER_MSG_STKT_BIT)
 
 /* The maximum length of an encoded data length. */
 #define PEER_MSG_ENC_LENGTH_MAXLEN    5
@@ -1668,7 +1671,7 @@ static inline int peer_recv_msg(struct appctx *appctx, char *msg_head, size_t ms
 
        *totl += reql;
 
-       if ((unsigned int)msg_head[1] < 128)
+       if (!(msg_head[1] & PEER_MSG_STKT_BIT_MASK))
                return 1;
 
        /* Read and Decode message length */
@@ -1693,7 +1696,7 @@ static inline int peer_recv_msg(struct appctx *appctx, char *msg_head, size_t ms
 
                        *totl += reql;
 
-                       if (!(msg_head[i] & 0x80))
+                       if (!(msg_head[i] & PEER_MSG_STKT_BIT_MASK))
                                break;
                }