All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Typedefs | Functions | Variables
rlm_json.c File Reference

Parses JSON responses. More...

#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/modules.h>
#include <freeradius-devel/map_proc.h>
#include <freeradius-devel/rad_assert.h>
#include <ctype.h>
#include "json.h"
+ Include dependency graph for rlm_json.c:

Go to the source code of this file.

Data Structures

struct  rlm_json_jpath_cache
 
struct  rlm_json_jpath_to_eval
 

Typedefs

typedef struct rlm_json_jpath_cache rlm_json_jpath_cache_t
 Forms a linked list of jpath head node pointers (a list of jpaths) More...
 
typedef struct
rlm_json_jpath_to_eval 
rlm_json_jpath_to_eval_t
 

Functions

static int _json_map_proc_get_value (TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t const *map, void *uctx)
 Converts a string value into a VALUE_PAIR. More...
 
static ssize_t jpath_validate_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt)
 Determine if a jpath expression is valid. More...
 
static int mod_bootstrap (UNUSED CONF_SECTION *conf, void *instance)
 
static rlm_rcode_t mod_map_proc (UNUSED void *mod_inst, void *proc_inst, REQUEST *request, char const *src, vp_map_t const *maps)
 Parses a JSON string, and executes jpath queries against it to map values to attributes. More...
 
static int mod_map_proc_instantiate (void *proc_inst, UNUSED void *mod_inst, UNUSED vp_tmpl_t const *src, vp_map_t const *maps)
 Pre-parse and validate literal jpath expressions for maps. More...
 

Variables

module_t rlm_json
 

Detailed Description

Parses JSON responses.

Id:
4610c92d83fcf2d3fe6b0287bf7292cb8dc59675
Author
Arran Cudbard-Bell

Definition in file rlm_json.c.


Data Structure Documentation

struct rlm_json_jpath_cache

Definition at line 45 of file rlm_json.c.

+ Collaboration diagram for rlm_json_jpath_cache:
Data Fields
fr_jpath_node_t * jpath First node in jpath expression.
rlm_json_jpath_cache_t * next Next jpath cache entry.
struct rlm_json_jpath_to_eval

Definition at line 50 of file rlm_json.c.

+ Collaboration diagram for rlm_json_jpath_to_eval:
Data Fields
fr_jpath_node_t const * jpath
json_object * root

Typedef Documentation

Forms a linked list of jpath head node pointers (a list of jpaths)

Definition at line 44 of file rlm_json.c.

Function Documentation

static int _json_map_proc_get_value ( TALLOC_CTX *  ctx,
VALUE_PAIR **  out,
REQUEST request,
vp_map_t const *  map,
void *  uctx 
)
static

Converts a string value into a VALUE_PAIR.

Parameters
[in,out]ctxto allocate VALUE_PAIR (s).
[out]outwhere to write the resulting VALUE_PAIR.
[in]requestThe current request.
[in]mapto process.
[in]uctxThe json tree/jpath expression to evaluate.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 177 of file rlm_json.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ssize_t jpath_validate_xlat ( char **  out,
size_t  outlen,
UNUSED void const *  mod_inst,
UNUSED void const *  xlat_inst,
REQUEST request,
char const *  fmt 
)
static

Determine if a jpath expression is valid.

Parameters
mod_instdata.
xlat_instdata.
outWhere to write the output (in the format
<bytes parsed>[:error]
).
outlenHow big out is.
requestThe current request.
fmtjpath expression to parse.
Returns
number of bytes written to out.

Definition at line 65 of file rlm_json.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int mod_bootstrap ( UNUSED CONF_SECTION conf,
void *  instance 
)
static

Definition at line 306 of file rlm_json.c.

+ Here is the call graph for this function:

static rlm_rcode_t mod_map_proc ( UNUSED void *  mod_inst,
void *  proc_inst,
REQUEST request,
char const *  src,
vp_map_t const *  maps 
)
static

Parses a JSON string, and executes jpath queries against it to map values to attributes.

Parameters
mod_instunused.
proc_instcached jpath sequences.
requestThe current request.
srcstring to parse.
mapsHead of the map list.
Returns

Definition at line 229 of file rlm_json.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int mod_map_proc_instantiate ( void *  proc_inst,
UNUSED void *  mod_inst,
UNUSED vp_tmpl_t const *  src,
vp_map_t const *  maps 
)
static

Pre-parse and validate literal jpath expressions for maps.

Parameters
[out]proc_instthe cache structure to fill.
[in]mod_instmodule instance (unused).
[in]srcWhere to get the JSON data from (unused).
[in]mapsset of maps to translate to jpaths.
Returns
  • 0 on success.
    • -1 on failure.

Definition at line 98 of file rlm_json.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

module_t rlm_json
Initial value:
= {
.magic = RLM_MODULE_INIT,
.name = "json",
.bootstrap = mod_bootstrap,
}
#define RLM_TYPE_THREAD_SAFE
Module is threadsafe.
Definition: modules.h:75
#define RLM_MODULE_INIT
Definition: modules.h:86
static int mod_bootstrap(UNUSED CONF_SECTION *conf, void *instance)
Definition: rlm_json.c:306

Definition at line 327 of file rlm_json.c.