mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-26 07:30:34 +00:00
DOC: fix proxy protocol v2 decoder example
Richard Russo reported that the example code in the PP spec is wrong now that we slightly changed the format to merge <ver> and <cmd>. Also rename the field <ver_cmd> to avoid any ambiguity on the usage.
This commit is contained in:
parent
1b48cc9c6f
commit
0f6093a9b2
@ -441,7 +441,7 @@ So the 16-byte version 2 header can be described this way :
|
||||
|
||||
struct proxy_hdr_v2 {
|
||||
uint8_t sig[12]; /* hex 0D 0A 0D 0A 00 0D 0A 51 55 49 54 0A */
|
||||
uint8_t ver; /* protocol version and command */
|
||||
uint8_t ver_cmd; /* protocol version and command */
|
||||
uint8_t fam; /* protocol family and address */
|
||||
uint16_t len; /* number of following bytes part of the header */
|
||||
};
|
||||
@ -762,10 +762,9 @@ side is even simpler and can easily be deduced from this sample code.
|
||||
} v1;
|
||||
struct {
|
||||
uint8_t sig[12];
|
||||
uint8_t ver;
|
||||
uint8_t cmd;
|
||||
uint8_t ver_cmd;
|
||||
uint8_t fam;
|
||||
uint8_t len;
|
||||
uint16_t len;
|
||||
union {
|
||||
struct { /* for TCP/UDP over IPv4, len = 12 */
|
||||
uint32_t src_addr;
|
||||
@ -801,7 +800,7 @@ side is even simpler and can easily be deduced from this sample code.
|
||||
if (ret < size)
|
||||
return -1; /* truncated or too large header */
|
||||
|
||||
switch (hdr.v2.cmd) {
|
||||
switch (hdr.v2.ver_cmd & 0xF) {
|
||||
case 0x01: /* PROXY command */
|
||||
switch (hdr.v2.fam) {
|
||||
case 0x11: /* TCPv4 */
|
||||
|
Loading…
Reference in New Issue
Block a user