]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DOC: fix proxy protocol v2 decoder example
authorWilly Tarreau <w@1wt.eu>
Wed, 11 Jun 2014 19:21:26 +0000 (21:21 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 11 Jun 2014 19:21:26 +0000 (21:21 +0200)
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.

doc/proxy-protocol.txt

index 29196c19d84106d824fb47e67c294ff516b1aa61..b8d4379171e2a3cea1b48fca4d6d9483cbb5edd4 100644 (file)
@@ -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 */