The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
rlm_brotli.c File Reference

Add support for brotli compression. More...

#include <talloc.h>
#include <brotli/encode.h>
#include <brotli/decode.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/server/cf_parse.h>
#include <freeradius-devel/unlang/xlat.h>
#include <freeradius-devel/unlang/xlat_func.h>
+ Include dependency graph for rlm_brotli.c:

Go to the source code of this file.

Data Structures

struct  rlm_brotli_compress_t
 
struct  rlm_brotli_decompress_t
 
struct  rlm_brotli_t
 

Macros

#define LOG_PREFIX   mctx->inst->name
 

Functions

static int block_bits_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
static TALLOC_CTX * brotli_pool_get (void)
 
static void * brotli_talloc_alloc (void *uctx, size_t size)
 
static void brotli_talloc_free (UNUSED void *uctx, void *to_free)
 
static xlat_action_t brotli_xlat_compress (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *args)
 Produce a brotli compressed string. More...
 
static xlat_action_t brotli_xlat_decompress (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *args)
 Decompress a brotli string. More...
 
static int mod_bootstrap (module_inst_ctx_t const *mctx)
 
static int quality_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
static int window_bits_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 

Variables

fr_table_num_sorted_t const brotli_mode []
 
size_t brotli_mode_len = NUM_ELEMENTS(brotli_mode)
 
static _Thread_local TALLOC_CTX * brotli_pool
 Thread-local pool for brotli state. More...
 
static xlat_arg_parser_t const brotli_xlat_compress_args []
 
static xlat_arg_parser_t const brotli_xlat_decompress_args []
 
static const conf_parser_t module_compress_config []
 
static const conf_parser_t module_config []
 
static const conf_parser_t module_decompress_config []
 
module_rlm_t rlm_brotli
 

Detailed Description

Add support for brotli compression.

Id
d87f5b0f2364c7c760d53e0df3a00a3f373f9c99

Definition in file rlm_brotli.c.


Data Structure Documentation

◆ rlm_brotli_compress_t

struct rlm_brotli_compress_t

Definition at line 47 of file rlm_brotli.c.

Data Fields
int block_bits Default block bits to use when compressing data.
bool block_bits_is_set Whether block_bits has been set.
BrotliEncoderMode mode Default mode to use when compressing data.
int quality Default quality to use when compressing data.
int window_bits Default window bits to use when compressing data.

◆ rlm_brotli_decompress_t

struct rlm_brotli_decompress_t

Definition at line 55 of file rlm_brotli.c.

Data Fields
size_t max_size Maximum amount we attempt to decode.

◆ rlm_brotli_t

struct rlm_brotli_t

Definition at line 59 of file rlm_brotli.c.

+ Collaboration diagram for rlm_brotli_t:
Data Fields
rlm_brotli_compress_t compress Compression settings.
rlm_brotli_decompress_t decompress Decompression settings.
bool large_window non-standard "large", window size.

Macro Definition Documentation

◆ LOG_PREFIX

#define LOG_PREFIX   mctx->inst->name

Definition at line 27 of file rlm_brotli.c.

Function Documentation

◆ block_bits_parse()

static int block_bits_parse ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
conf_parser_t const *  rule 
)
static

Definition at line 154 of file rlm_brotli.c.

+ Here is the call graph for this function:

◆ brotli_pool_get()

static TALLOC_CTX* brotli_pool_get ( void  )
inlinestatic

Definition at line 97 of file rlm_brotli.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ brotli_talloc_alloc()

static void* brotli_talloc_alloc ( void *  uctx,
size_t  size 
)
static

Definition at line 109 of file rlm_brotli.c.

+ Here is the caller graph for this function:

◆ brotli_talloc_free()

static void brotli_talloc_free ( UNUSED void *  uctx,
void *  to_free 
)
static

Definition at line 115 of file rlm_brotli.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_bootstrap()

static int mod_bootstrap ( module_inst_ctx_t const *  mctx)
static

Definition at line 382 of file rlm_brotli.c.

+ Here is the call graph for this function:

◆ quality_parse()

static int quality_parse ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
conf_parser_t const *  rule 
)
static

Definition at line 120 of file rlm_brotli.c.

+ Here is the call graph for this function:

◆ window_bits_parse()

static int window_bits_parse ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
conf_parser_t const *  rule 
)
static

Definition at line 137 of file rlm_brotli.c.

+ Here is the call graph for this function:

Variable Documentation

◆ brotli_mode

fr_table_num_sorted_t const brotli_mode[]
Initial value:
= {
{ L("font"), BROTLI_MODE_FONT },
{ L("generic"), BROTLI_MODE_GENERIC },
{ L("text"), BROTLI_MODE_TEXT },
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition: build.h:207

Definition at line 65 of file rlm_brotli.c.

◆ brotli_mode_len

size_t brotli_mode_len = NUM_ELEMENTS(brotli_mode)

Definition at line 70 of file rlm_brotli.c.

◆ brotli_pool

_Thread_local TALLOC_CTX* brotli_pool
static

Thread-local pool for brotli state.

Definition at line 94 of file rlm_brotli.c.

◆ brotli_xlat_compress_args

xlat_arg_parser_t const brotli_xlat_compress_args[]
static
Initial value:
= {
{ .required = true, .type = FR_TYPE_OCTETS },
}
@ FR_TYPE_OCTETS
Raw octets.
Definition: merged_model.c:84
#define XLAT_ARG_PARSER_TERMINATOR
Definition: xlat.h:166

Definition at line 171 of file rlm_brotli.c.

◆ brotli_xlat_decompress_args

xlat_arg_parser_t const brotli_xlat_decompress_args[]
static
Initial value:
= {
{ .required = true, .single = true, .type = FR_TYPE_OCTETS },
}

Definition at line 280 of file rlm_brotli.c.

◆ module_compress_config

const conf_parser_t module_compress_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("mode", rlm_brotli_compress_t, mode), .dflt = "generic",
.func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = brotli_mode, .len = &brotli_mode_len } },
{ FR_CONF_OFFSET("quality", rlm_brotli_compress_t, quality), .dflt = STRINGIFY(BROTLI_DEFAULT_QUALITY), .func = quality_parse },
{ FR_CONF_OFFSET("window_bits", rlm_brotli_compress_t, window_bits), .dflt = STRINGIFY(BROTLI_DEFAULT_WINDOW), .func = window_bits_parse },
{ FR_CONF_OFFSET_IS_SET("block_bits", FR_TYPE_INT32, 0, rlm_brotli_compress_t, block_bits), .dflt = STRINGIFY(BROTLI_MAX_INPUT_BLOCK_BITS), .func = block_bits_parse },
}
#define STRINGIFY(x)
Definition: build.h:195
int cf_table_parse_int(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic function for parsing conf pair values as int.
Definition: cf_parse.c:1474
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:626
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:268
#define FR_CONF_OFFSET_IS_SET(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct,...
Definition: cf_parse.h:282
@ FR_TYPE_INT32
32 Bit signed integer.
Definition: merged_model.c:105
static int block_bits_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Definition: rlm_brotli.c:154
fr_table_num_sorted_t const brotli_mode[]
Definition: rlm_brotli.c:65
static int window_bits_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Definition: rlm_brotli.c:137
static int quality_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Definition: rlm_brotli.c:120
size_t brotli_mode_len
Definition: rlm_brotli.c:70

Definition at line 72 of file rlm_brotli.c.

◆ module_config

const conf_parser_t module_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("large_window", rlm_brotli_t, large_window), .dflt = "no" },
}
#define FR_CONF_OFFSET_SUBSECTION(_name, _flags, _struct, _field, _subcs)
conf_parser_t which populates a sub-struct using a CONF_SECTION
Definition: cf_parse.h:297
static const conf_parser_t module_decompress_config[]
Definition: rlm_brotli.c:81
static const conf_parser_t module_compress_config[]
Definition: rlm_brotli.c:72

Definition at line 86 of file rlm_brotli.c.

◆ module_decompress_config

const conf_parser_t module_decompress_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET_TYPE_FLAGS("max_size", FR_TYPE_SIZE, 0, rlm_brotli_decompress_t, max_size), .dflt = "10M" },
}
#define FR_CONF_OFFSET_TYPE_FLAGS(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:241
@ FR_TYPE_SIZE
Unsigned integer capable of representing any memory address on the local system.
Definition: merged_model.c:115

Definition at line 81 of file rlm_brotli.c.

◆ rlm_brotli

module_rlm_t rlm_brotli
Initial value:
= {
.common = {
.name = "brotli",
.inst_size = sizeof(rlm_brotli_t),
.bootstrap = mod_bootstrap,
}
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:65
static const conf_parser_t config[]
Definition: base.c:188
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Definition: rlm_brotli.c:382
static const conf_parser_t module_config[]
Definition: rlm_brotli.c:86

Definition at line 407 of file rlm_brotli.c.