The flags are direct copy of the "unsigned int" in the network stream,
so the stream contains a 32 bits field encoded with the host endian.
- This is not reliable for stream betwen different architecture host
- For x86, the bits doesn't correspond to the documentation.
This patch add some precision in the documentation and put the bitfield
in the stream usig network butes order.
Warning: this patch can break compatibility with existing agents.
This patch should be backported in all version supporing SPOE
Original network capture:
12:28:16.181343 IP 127.0.0.1.46782 > 127.0.0.1.12345: Flags [P.], seq 134:168, ack 59, win 342, options [nop,nop,TS val
2855241281 ecr
2855241281], length 34
0x0000: 4500 0056 6b94 4000 4006 d10b 7f00 0001 E..Vk.@.@.......
0x0010: 7f00 0001 b6be 3039 a3d1 ee54 7d61 d6f7 ......09...T}a..
0x0020: 8018 0156 fe4a 0000 0101 080a aa2f 8641 ...V.J......./.A
0x0030: aa2f 8641 0000 001e 0301 0000 0000 010f ./.A............
^^^^^^^^^^
0x0040: 6368 6563 6b2d 636c 6965 6e74 2d69 7001 check-client-ip.
0x0050: 0006 7f00 0001 ......
Fixed network capture:
12:24:26.948165 IP 127.0.0.1.46706 > 127.0.0.1.12345: Flags [P.], seq
4066280627:
4066280661, ack
3148908096, win 342, options [nop,nop,TS val
2855183972 ecr
2855177690], length 34
0x0000: 4500 0056 0538 4000 4006 3768 7f00 0001 E..V.8@.@.7h....
0x0010: 7f00 0001 b672 3039 f25e 84b3 bbb0 8640 .....r09.^.....@
0x0020: 8018 0156 fe4a 0000 0101 080a aa2e a664 ...V.J.........d
0x0030: aa2e 8dda 0000 001e 0300 0000 0114 010f ................
^^^^^^^^^^
0x0040: 6368 6563 6b2d 636c 6965 6e74 2d69 7001 check-client-ip.
0x0050: 0006 7f00 0001 ......
/* Retrieve flags */
memcpy((char *)&(frame->flags), p, 4);
+ frame->flags = ntohl(frame->flags);
p += 4;
/* Fragmentation is not supported for HELLO frame */
/* Retrieve flags */
memcpy((char *)&(frame->flags), p, 4);
+ frame->flags = ntohl(frame->flags);
p += 4;
/* Fragmentation is not supported for DISCONNECT frame */
/* Retrieve flags */
memcpy((char *)&(frame->flags), p, 4);
+ frame->flags = ntohl(frame->flags);
p += 4;
/* Fragmentation is not supported */
/* Retrieve flags */
memcpy((char *)&(frame->flags), p, 4);
+ frame->flags = ntohl(frame->flags);
p+= 4;
/* Read the stream-id and frame-id */
*p++ = SPOE_FRM_T_AGENT_HELLO;
/* Set flags */
+ flags = htonl(flags);
memcpy(p, (char *)&flags, 4);
p += 4;
*p++ = SPOE_FRM_T_AGENT_DISCON;
/* Set flags */
+ flags = htonl(flags);
memcpy(p, (char *)&flags, 4);
p += 4;
*p++ = SPOE_FRM_T_AGENT_ACK;
/* Set flags */
+ flags = htonl(flags);
memcpy(p, (char *)&flags, 4);
p += 4;
KV-NAME : <STRING>
KV-VALUE : <TYPED-DATA>
- 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 | |
*p++ = SPOE_FRM_T_HAPROXY_HELLO;
/* Set flags */
+ flags = htonl(flags);
memcpy(p, (char *)&flags, 4);
p += 4;
*p++ = SPOE_FRM_T_HAPROXY_DISCON;
/* Set flags */
+ flags = htonl(flags);
memcpy(p, (char *)&flags, 4);
p += 4;
*p++ = SPOE_FRM_T_HAPROXY_NOTIFY;
/* Set flags */
+ flags = htonl(flags);
memcpy(p, (char *)&flags, 4);
p += 4;
*p++ = SPOE_FRM_T_UNSET;
/* Set flags */
+ flags = htonl(flags);
memcpy(p, (char *)&flags, 4);
p += 4;
/* Retrieve flags */
memcpy((char *)&flags, p, 4);
+ flags = ntohl(flags);
p += 4;
/* Fragmentation is not supported for HELLO frame */
/* Retrieve flags */
memcpy((char *)&flags, p, 4);
+ flags = ntohl(flags);
p += 4;
/* Fragmentation is not supported for DISCONNECT frame */
/* Retrieve flags */
memcpy((char *)&flags, p, 4);
+ flags = ntohl(flags);
p += 4;
/* Fragmentation is not supported for now */