Hi David,

On Thu, Apr 17, 2014 at 01:51:36PM -0400, David S wrote:
> On Wed, Apr 16, 2014 at 5:44 PM, Willy Tarreau <[email protected]> wrote:
> 
> > (...)
> > We can also decide that we don't implement the extensions in v1 which
> > will motivate adoption for the new v2.
> > (...)
> >
> > What's your opinion ?
> >
> > Willy
> >
> I prefer to make the extension v2 only, mostly because I don't want to
> write the code twice. :-)
> If no one else has work in progress, I'll start implementing v2.
> Which bit shall we use in the header to indicate the presence of an
> extension?
> Unfortunately, the length field is only one byte, which will not be big
> enough for us.
> Since no one has implemented a v2 sender yet, are we free to change v2?
> 
> 
>     struct proxy_hdr_v2 {
>         uint8_t sig[12];  /* hex 0D 0A 0D 0A 00 0D 0A 51 55 49 54 0A */
>         uint8_t ver;      /* hex 02 */
>         uint8_t cmd;      /* hex 00 or 01 */
>         uint8_t fam;      /* protocol family and address */
>         uint8_t len;      /* number of following bytes part of the header */
>     };

Hmmm that's not trivial. Let's try by merging ver and cmd into a single byte :

     struct proxy_hdr_v2 {
         uint8_t sig[12];  /* hex 0D 0A 0D 0A 00 0D 0A 51 55 49 54 0A */
         uint8_t ver:4;    /* hex 2 */
         uint8_t cmd:4;    /* hex 0 or 1 */
         uint8_t fam;      /* protocol family and address */
         uint16_t len;     /* number of following bytes part of the header 
(network order) */
    };

Note that we don't need a bit to say "there's an extension", it'll be deduced
from the length : once all of the protocol info are parsed, there are bytes
left so by definition they're part of an extension.

Thus the dumbest implementation needed to only skip the protocol header consists
in reading 16 bytes into this structure, converting len via ntohs() and skipping
that extra amount of bytes.

Willy


Reply via email to