[0001]
[0002]
[0003]
[0004]
[0005]
[0006]
[0007]
[0008]
[0009]
[0010]
[0011]
[0012]
[0013]
[0014]
[0015]
[0016]
[0017]
[0018]
[0019]
[0020]
[0021]
[0022]
[0023]
[0024]
[0025]
[0026]
[0027]
[0028]
[0029]
[0030]
[0031]
[0032]
[0033]
[0034]
[0035]
[0036]
[0037]
[0038]
[0039]
[0040]
[0041]
[0042]
[0043]
[0044]
[0045]
[0046]
[0047]
[0048]
[0049]
[0050]
[0051]
[0052]
[0053]
[0054]
[0055]
[0056]
[0057]
[0058]
[0059]
[0060]
[0061]
[0062]
[0063]
[0064]
[0065]
[0066]
[0067]
[0068]
[0069]
[0070]
[0071]
[0072]
[0073]
[0074]
[0075]
[0076]
[0077]
[0078]
[0079]
[0080]
[0081]
[0082]
/*****************************************************************************/
/*
                                  HPACK.h
*/
/*****************************************************************************/

#ifndef HPACK_H_LOADED
#define HPACK_H_LOADED 1

#include "wasd.h"
#include "types.h"

#define HPACK_STATIC_TABLE_COUNT 61

/**************/
/* structures */
/**************/

/* required forward declaration */
typedef struct Http2Struct HTTP2_STRUCT;

#pragma member_alignment __save
#pragma member_alignment

typedef struct HpackEntryStruct HPACK_ENTRY_STRUCT;
typedef struct HpackTableStruct HPACK_TABLE_STRUCT;

/* doesn't have to be 32 bytes, just makes it a little more intuitive */
/* 32 bit everything so 7 x 4 := 28 bytes plus 4 byte "buffer" := 32 bytes */
struct HpackEntryStruct
{
   void  *flink,
         *blink;

   uint  hits,
         nlen,
         vlen;

   uchar  *name,
          *value;

   /* "buffer" space also allows for terminating nulls on the two strings */
   uchar  buffer [4];
   /* the actual buffer space used continues with allocated memory */
};

struct HpackTableStruct
{
   HPACK_ENTRY_STRUCT  *head,
                       *tail;
   uint  baseline,
         count,
         max,
         size;

   HTTP2_STRUCT  *h2ptr;
};

#pragma member_alignment __restore

/***********************/
/* function prototypes */
/***********************/

int HpackAddToTable (HPACK_TABLE_STRUCT*, uchar*, uint, uchar*, uint);
uchar* HpackDecodeHuff4 (uchar*, uchar, uchar*, int*);
int HpackDecodeInt32 (HTTP2_STRUCT*, uchar**, uchar*, uint, uint*);
int HpackDecodeString (HTTP2_STRUCT*, uchar**, uchar*, uchar**, uint**);
int HpackEncodeInt32 (HTTP2_STRUCT*, uchar**, uchar*, uint, uint);
int HpackEncodeString (HTTP2_STRUCT*, uchar**, uchar*, uchar*, uint);
int HpackFindInTable (HPACK_TABLE_STRUCT*, uchar*, uint, uchar*, uint);
int HpackGetIndex (HPACK_TABLE_STRUCT*, uint, uchar**, uint**, uchar**, uint**);
void HpackInit ();
int HpackHeadersFrame (HPACK_TABLE_STRUCT*, uint, uint, uchar*, uint);
void HpackTrimTable (HPACK_TABLE_STRUCT*);
void HpackReport (REQUEST_STRUCT*, uchar*);
void HpackWatchTable (HPACK_TABLE_STRUCT*);

#endif /* HPACK_H_LOADED */

/*****************************************************************************/