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.
diff --git a/doc/proxy-protocol.txt b/doc/proxy-protocol.txt
index 29196c1..b8d4379 100644
--- a/doc/proxy-protocol.txt
+++ b/doc/proxy-protocol.txt
@@ -441,7 +441,7 @@
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 @@
} 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 @@
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 */