diff --git a/contrib/spoa_example/spoa.c b/contrib/spoa_example/spoa.c index bf2dbe9a9..71a36f072 100644 --- a/contrib/spoa_example/spoa.c +++ b/contrib/spoa_example/spoa.c @@ -514,6 +514,7 @@ handle_hahello(struct spoe_frame *frame) /* Retrieve flags */ memcpy((char *)&(frame->flags), p, 4); + frame->flags = ntohl(frame->flags); p += 4; /* Fragmentation is not supported for HELLO frame */ @@ -621,6 +622,7 @@ handle_hadiscon(struct spoe_frame *frame) /* Retrieve flags */ memcpy((char *)&(frame->flags), p, 4); + frame->flags = ntohl(frame->flags); p += 4; /* Fragmentation is not supported for DISCONNECT frame */ @@ -702,6 +704,7 @@ handle_hanotify(struct spoe_frame *frame) /* Retrieve flags */ memcpy((char *)&(frame->flags), p, 4); + frame->flags = ntohl(frame->flags); p += 4; /* Fragmentation is not supported */ @@ -764,6 +767,7 @@ handle_hafrag(struct spoe_frame *frame) /* Retrieve flags */ memcpy((char *)&(frame->flags), p, 4); + frame->flags = ntohl(frame->flags); p+= 4; /* Read the stream-id and frame-id */ @@ -826,6 +830,7 @@ prepare_agenthello(struct spoe_frame *frame) *p++ = SPOE_FRM_T_AGENT_HELLO; /* Set flags */ + flags = htonl(flags); memcpy(p, (char *)&flags, 4); p += 4; @@ -907,6 +912,7 @@ prepare_agentdicon(struct spoe_frame *frame) *p++ = SPOE_FRM_T_AGENT_DISCON; /* Set flags */ + flags = htonl(flags); memcpy(p, (char *)&flags, 4); p += 4; @@ -954,6 +960,7 @@ prepare_agentack(struct spoe_frame *frame) *p++ = SPOE_FRM_T_AGENT_ACK; /* Set flags */ + flags = htonl(flags); memcpy(p, (char *)&flags, 4); p += 4; diff --git a/doc/SPOE.txt b/doc/SPOE.txt index 756988f68..c34102a67 100644 --- a/doc/SPOE.txt +++ b/doc/SPOE.txt @@ -694,7 +694,12 @@ actions. KV-NAME : KV-VALUE : - FLAGS : 0 1 2-31 + FLAGS : + + Flags are a 32 bits field. They are encoded on 4 bytes in network byte + order, where the bit 0 is the LSB. + + 0 1 2-31 +---+---+----------+ | | A | | | F | B | | diff --git a/src/flt_spoe.c b/src/flt_spoe.c index cc6c55e29..4e27c63b2 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -399,6 +399,7 @@ spoe_prepare_hahello_frame(struct appctx *appctx, char *frame, size_t size) *p++ = SPOE_FRM_T_HAPROXY_HELLO; /* Set flags */ + flags = htonl(flags); memcpy(p, (char *)&flags, 4); p += 4; @@ -488,6 +489,7 @@ spoe_prepare_hadiscon_frame(struct appctx *appctx, char *frame, size_t size) *p++ = SPOE_FRM_T_HAPROXY_DISCON; /* Set flags */ + flags = htonl(flags); memcpy(p, (char *)&flags, 4); p += 4; @@ -559,6 +561,7 @@ spoe_prepare_hanotify_frame(struct appctx *appctx, struct spoe_context *ctx, *p++ = SPOE_FRM_T_HAPROXY_NOTIFY; /* Set flags */ + flags = htonl(flags); memcpy(p, (char *)&flags, 4); p += 4; @@ -615,6 +618,7 @@ spoe_prepare_hafrag_frame(struct appctx *appctx, struct spoe_context *ctx, *p++ = SPOE_FRM_T_UNSET; /* Set flags */ + flags = htonl(flags); memcpy(p, (char *)&flags, 4); p += 4; @@ -669,6 +673,7 @@ spoe_handle_agenthello_frame(struct appctx *appctx, char *frame, size_t size) /* Retrieve flags */ memcpy((char *)&flags, p, 4); + flags = ntohl(flags); p += 4; /* Fragmentation is not supported for HELLO frame */ @@ -852,6 +857,7 @@ spoe_handle_agentdiscon_frame(struct appctx *appctx, char *frame, size_t size) /* Retrieve flags */ memcpy((char *)&flags, p, 4); + flags = ntohl(flags); p += 4; /* Fragmentation is not supported for DISCONNECT frame */ @@ -962,6 +968,7 @@ spoe_handle_agentack_frame(struct appctx *appctx, struct spoe_context **ctx, /* Retrieve flags */ memcpy((char *)&flags, p, 4); + flags = ntohl(flags); p += 4; /* Fragmentation is not supported for now */