Apache HTTPD
Classes | Macros | Typedefs | Functions | Variables
h2_push.c File Reference
#include <assert.h>
#include <stdio.h>
#include <apr_lib.h>
#include <apr_strings.h>
#include <apr_hash.h>
#include <apr_time.h>
#include <httpd.h>
#include <http_core.h>
#include <http_log.h>
#include <http_protocol.h>
#include "h2_private.h"
#include "h2_protocol.h"
#include "h2_util.h"
#include "h2_push.h"
#include "h2_request.h"
#include "h2_session.h"
#include "h2_stream.h"

Go to the source code of this file.

Classes

struct  link_ctx
 
struct  h2_push_diary_entry
 
struct  gset_encoder
 

Macros

#define GCSLOG_LEVEL   APLOG_TRACE1
 

Typedefs

typedef struct h2_push_diary_entry h2_push_diary_entry
 

Functions

static const charpolicy_str (h2_push_policy policy)
 
static int attr_char (char c)
 
static int ptoken_char (char c)
 
static int skip_ws (link_ctx *ctx)
 
static int find_chr (link_ctx *ctx, char c, size_t *pidx)
 
static int read_chr (link_ctx *ctx, char c)
 
static charmk_str (link_ctx *ctx, size_t end)
 
static int read_qstring (link_ctx *ctx, const char **ps)
 
static int read_ptoken (link_ctx *ctx, const char **ps)
 
static int read_link (link_ctx *ctx)
 
static int read_pname (link_ctx *ctx, const char **pname)
 
static int read_pvalue (link_ctx *ctx, const char **pvalue)
 
static int read_param (link_ctx *ctx)
 
static int read_sep (link_ctx *ctx)
 
static void init_params (link_ctx *ctx)
 
static int same_authority (const h2_request *req, const apr_uri_t *uri)
 
static int set_push_header (void *ctx, const char *key, const char *value)
 
static int has_param (link_ctx *ctx, const char *param)
 
static int has_relation (link_ctx *ctx, const char *rel)
 
static int add_push (link_ctx *ctx)
 
static void inspect_link (link_ctx *ctx, const char *s, size_t slen)
 
static int head_iter (void *ctx, const char *key, const char *value)
 
apr_array_header_th2_push_collect (apr_pool_t *p, const struct h2_request *req, apr_uint32_t push_policy, const struct h2_headers *res)
 
static unsigned int val_apr_hash (const char *str)
 
static void calc_apr_hash (h2_push_diary *diary, apr_uint64_t *phash, h2_push *push)
 
static apr_int32_t ceil_power_of_2 (apr_int32_t n)
 
static h2_push_diarydiary_create (apr_pool_t *p, h2_push_digest_type dtype, int N)
 
h2_push_diaryh2_push_diary_create (apr_pool_t *p, int N)
 
static int h2_push_diary_find (h2_push_diary *diary, apr_uint64_t hash)
 
static void move_to_last (h2_push_diary *diary, apr_size_t idx)
 
static void remove_first (h2_push_diary *diary)
 
static void h2_push_diary_append (h2_push_diary *diary, h2_push_diary_entry *e)
 
apr_array_header_th2_push_diary_update (h2_session *session, apr_array_header_t *pushes)
 
apr_array_header_th2_push_collect_update (struct h2_stream *stream, const struct h2_request *req, const struct h2_headers *res)
 
static int cmp_puint64 (const void *p1, const void *p2)
 
static apr_status_t gset_encode_bit (gset_encoder *encoder, int bit)
 
static apr_status_t gset_encode_next (gset_encoder *encoder, apr_uint64_t pval)
 
apr_status_t h2_push_diary_digest_get (h2_push_diary *diary, apr_pool_t *pool, int maxP, const char *authority, const char **pdata, apr_size_t *plen)
 

Variables

static unsigned char cbit_mask []
 

Macro Definition Documentation

◆ GCSLOG_LEVEL

#define GCSLOG_LEVEL   APLOG_TRACE1

Definition at line 475 of file h2_push.c.

Typedef Documentation

◆ h2_push_diary_entry

Function Documentation

◆ add_push()

static int add_push ( link_ctx ctx)
static

Definition at line 318 of file h2_push.c.

◆ attr_char()

static int attr_char ( char  c)
static

Definition at line 74 of file h2_push.c.

◆ calc_apr_hash()

static void calc_apr_hash ( h2_push_diary diary,
apr_uint64_t phash,
h2_push push 
)
static

Definition at line 521 of file h2_push.c.

◆ ceil_power_of_2()

static apr_int32_t ceil_power_of_2 ( apr_int32_t  n)
static

Definition at line 537 of file h2_push.c.

◆ cmp_puint64()

static int cmp_puint64 ( const void *  p1,
const void *  p2 
)
static

Definition at line 718 of file h2_push.c.

◆ diary_create()

static h2_push_diary * diary_create ( apr_pool_t p,
h2_push_digest_type  dtype,
int  N 
)
static

Definition at line 549 of file h2_push.c.

◆ find_chr()

static int find_chr ( link_ctx ctx,
char  c,
size_t pidx 
)
static

Definition at line 141 of file h2_push.c.

◆ gset_encode_bit()

static apr_status_t gset_encode_bit ( gset_encoder encoder,
int  bit 
)
static

Definition at line 739 of file h2_push.c.

◆ gset_encode_next()

static apr_status_t gset_encode_next ( gset_encoder encoder,
apr_uint64_t  pval 
)
static

Definition at line 761 of file h2_push.c.

◆ h2_push_collect()

apr_array_header_t * h2_push_collect ( apr_pool_t p,
const struct h2_request req,
apr_uint32_t  push_policy,
const struct h2_headers res 
)

Determine the list of h2_push'es to send to the client on behalf of the given request/response pair.

Parameters
pthe pool to use
reqthe requst from the client
resthe response from the server
Returns
array of h2_push addresses or NULL

Definition at line 441 of file h2_push.c.

◆ h2_push_collect_update()

apr_array_header_t * h2_push_collect_update ( struct h2_stream stream,
const struct h2_request req,
const struct h2_headers res 
)

Collect pushes for the given request/response pair, enter them into the diary and return those pushes newly entered.

Definition at line 692 of file h2_push.c.

◆ h2_push_diary_append()

static void h2_push_diary_append ( h2_push_diary diary,
h2_push_diary_entry e 
)
static

Definition at line 639 of file h2_push.c.

◆ h2_push_diary_create()

h2_push_diary * h2_push_diary_create ( apr_pool_t p,
int  N 
)

Create a new push diary for the given maximum number of entries.

Parameters
pthe pool to use
Nthe max number of entries, rounded up to 2^x
Returns
the created diary, might be NULL of max_entries is 0

Definition at line 585 of file h2_push.c.

◆ h2_push_diary_digest_get()

apr_status_t h2_push_diary_digest_get ( h2_push_diary diary,
apr_pool_t pool,
int  maxP,
const char authority,
const char **  pdata,
apr_size_t plen 
)

Get a cache digest as described in https://datatracker.ietf.org/doc/draft-kazuho-h2-cache-digest/ from the contents of the push diary.

Parameters
diarythe diary to calculdate the digest from
pthe pool to use
pdataon successful return, the binary cache digest
plenon successful return, the length of the binary data

Definition at line 806 of file h2_push.c.

◆ h2_push_diary_find()

static int h2_push_diary_find ( h2_push_diary diary,
apr_uint64_t  hash 
)
static

Definition at line 590 of file h2_push.c.

◆ h2_push_diary_update()

apr_array_header_t * h2_push_diary_update ( struct h2_session session,
apr_array_header_t pushes 
)

Filters the given pushes against the diary and returns only those pushes that were newly entered in the diary.

Definition at line 651 of file h2_push.c.

◆ has_param()

static int has_param ( link_ctx ctx,
const char param 
)
static

Definition at line 294 of file h2_push.c.

◆ has_relation()

static int has_relation ( link_ctx ctx,
const char rel 
)
static

Definition at line 300 of file h2_push.c.

◆ head_iter()

static int head_iter ( void *  ctx,
const char key,
const char value 
)
static

Definition at line 427 of file h2_push.c.

◆ init_params()

static void init_params ( link_ctx ctx)
static

Definition at line 260 of file h2_push.c.

◆ inspect_link()

static void inspect_link ( link_ctx ctx,
const char s,
size_t  slen 
)
static

Definition at line 371 of file h2_push.c.

◆ mk_str()

static char * mk_str ( link_ctx ctx,
size_t  end 
)
static

Definition at line 162 of file h2_push.c.

◆ move_to_last()

static void move_to_last ( h2_push_diary diary,
apr_size_t  idx 
)
static

Definition at line 607 of file h2_push.c.

◆ policy_str()

static const char * policy_str ( h2_push_policy  policy)
static

Definition at line 46 of file h2_push.c.

◆ ptoken_char()

static int ptoken_char ( char  c)
static

Definition at line 95 of file h2_push.c.

◆ read_chr()

static int read_chr ( link_ctx ctx,
char  c 
)
static

Definition at line 153 of file h2_push.c.

◆ read_link()

static int read_link ( link_ctx ctx)
static

Definition at line 200 of file h2_push.c.

◆ read_param()

static int read_param ( link_ctx ctx)
static

Definition at line 239 of file h2_push.c.

◆ read_pname()

static int read_pname ( link_ctx ctx,
const char **  pname 
)
static

Definition at line 213 of file h2_push.c.

◆ read_ptoken()

static int read_ptoken ( link_ctx ctx,
const char **  ps 
)
static

Definition at line 183 of file h2_push.c.

◆ read_pvalue()

static int read_pvalue ( link_ctx ctx,
const char **  pvalue 
)
static

Definition at line 229 of file h2_push.c.

◆ read_qstring()

static int read_qstring ( link_ctx ctx,
const char **  ps 
)
static

Definition at line 170 of file h2_push.c.

◆ read_sep()

static int read_sep ( link_ctx ctx)
static

Definition at line 252 of file h2_push.c.

◆ remove_first()

static void remove_first ( h2_push_diary diary)
static

Definition at line 626 of file h2_push.c.

◆ same_authority()

static int same_authority ( const h2_request req,
const apr_uri_t uri 
)
static

Definition at line 270 of file h2_push.c.

◆ set_push_header()

static int set_push_header ( void *  ctx,
const char key,
const char value 
)
static

Definition at line 281 of file h2_push.c.

◆ skip_ws()

static int skip_ws ( link_ctx ctx)
static

Definition at line 131 of file h2_push.c.

◆ val_apr_hash()

static unsigned int val_apr_hash ( const char str)
static

Definition at line 515 of file h2_push.c.

Variable Documentation

◆ cbit_mask

unsigned char cbit_mask[]
static
Initial value:
= {
0x80u,
0x40u,
0x20u,
0x10u,
0x08u,
0x04u,
0x02u,
0x01u,
}

Definition at line 728 of file h2_push.c.