The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions | Variables
mruby.c File Reference
#include "rlm_mruby.h"
+ Include dependency graph for mruby.c:

Go to the source code of this file.

Data Structures

struct  mruby_pair_s
 

Macros

#define RUBYSETFLOAT(_size)
 
#define RUBYSETINT(_size)
 
#define RUBYSETUINT(_size)
 

Typedefs

typedef struct mruby_pair_s mruby_pair_t
 

Functions

mrb_value mruby_dict_attr_object (mrb_state *mrb, struct RClass *klass, fr_dict_attr_t const *da)
 
mrb_value mruby_inst_object (mrb_state *mrb, struct RClass *klass, rlm_mruby_t const *inst)
 
struct RClass * mruby_pair_class (mrb_state *mrb, struct RClass *parent)
 
static mrb_value mruby_pair_init (mrb_state *mrb, mrb_value self)
 Associate C structure with Ruby object representing a pair.
 
struct RClass * mruby_pair_list_class (mrb_state *mrb, struct RClass *parent)
 
static mrb_value mruby_pair_list_keys (mrb_state *mrb, mrb_value self)
 Fetch the list of children of a list.
 
static mrb_value mruby_pair_list_missing (mrb_state *mrb, mrb_value self)
 Implement mruby method_missing functionality to find child pairs.
 
static void mruby_pair_parent_build (mrb_state *mrb, mruby_pair_t *pair)
 Build parent structural pairs needed when a leaf node is set.
 
static mrb_value mruby_pair_value_to_ruby (mrb_state *mrb, request_t *request, fr_pair_t *vp)
 Convert a pair value to a suitable mruby value type.
 
struct RClass * mruby_request_class (mrb_state *mrb, struct RClass *parent)
 
static mrb_value mruby_request_control (mrb_state *mrb, mrb_value self)
 
static mrb_value mruby_request_frconfig (mrb_state *mrb, mrb_value self)
 
mrb_value mruby_request_object (mrb_state *mrb, struct RClass *klass, request_t *request)
 
static mrb_value mruby_request_reply (mrb_state *mrb, mrb_value self)
 
static mrb_value mruby_request_request (mrb_state *mrb, mrb_value self)
 
static mrb_value mruby_request_session_state (mrb_state *mrb, mrb_value self)
 
static void mruby_roby_to_pair_value (mrb_state *mrb, mrb_value *value, fr_pair_t *vp)
 Convert a ruby value to a fr_pair_t value.
 
static mrb_value mruby_ruby_pair_object (mrb_state *mrb, struct RClass *klass, mruby_pair_t *pair)
 
static mrb_value mruby_value_pair_append (mrb_state *mrb, mrb_value self)
 Append an instance of a value pair from mruby.
 
static mrb_value mruby_value_pair_del (mrb_state *mrb, mrb_value self)
 Delete a value pair from mruby.
 
static mrb_value mruby_value_pair_get (mrb_state *mrb, mrb_value self)
 Get a pair value from mruby.
 
mrb_value mruby_value_pair_object (mrb_state *mrb, struct RClass *klass, fr_pair_t *vp)
 
static mrb_value mruby_value_pair_set (mrb_state *mrb, mrb_value self)
 Set a value pair from mruby.
 

Variables

static const struct mrb_data_type mruby_dict_attr_type
 
static const struct mrb_data_type mruby_inst_type
 
static const struct mrb_data_type mruby_request_type
 
static const struct mrb_data_type mruby_ruby_pair_type
 
static const struct mrb_data_type mruby_value_pair_type
 

Data Structure Documentation

◆ mruby_pair_s

struct mruby_pair_s

Definition at line 29 of file mruby.c.

+ Collaboration diagram for mruby_pair_s:
Data Fields
fr_dict_attr_t const * da Dictionary attribute for this pair.
unsigned int idx Instance index.
rlm_mruby_t const * inst Module instance. Needed for access to classes.
mruby_pair_t * parent Parent pair.
request_t * request Current request.
fr_pair_t * vp Real pair if it exists.

Macro Definition Documentation

◆ RUBYSETFLOAT

#define RUBYSETFLOAT (   _size)
Value:
case FR_TYPE_FLOAT ## _size: \
switch (mrb_type(*value)) { \
case MRB_TT_FLOAT: \
vp->vp_float ## _size = mrb_float(*value); \
break; \
case MRB_TT_INTEGER: \
vp->vp_float ## _size = mrb_integer(*value); \
break; \
default: \
mrb_raise(mrb, E_ARGUMENT_ERROR, "Float or integer value required"); \
} \
break;
Test enumeration values.
Definition dict_test.h:92
fr_pair_t * vp

◆ RUBYSETINT

#define RUBYSETINT (   _size)
Value:
case FR_TYPE_INT ## _size: \
if (mrb_type(*value) != MRB_TT_INTEGER) mrb_raise(mrb, E_ARGUMENT_ERROR, "Integer value required"); \
vp->vp_int ## _size = mrb_integer(*value); \
break;

◆ RUBYSETUINT

#define RUBYSETUINT (   _size)
Value:
case FR_TYPE_UINT ## _size: \
if (mrb_type(*value) != MRB_TT_INTEGER) mrb_raise(mrb, E_ARGUMENT_ERROR, "Integer value required"); \
vp->vp_uint ## _size = mrb_integer(*value); \
break;

Typedef Documentation

◆ mruby_pair_t

typedef struct mruby_pair_s mruby_pair_t

Definition at line 28 of file mruby.c.

Function Documentation

◆ mruby_dict_attr_object()

mrb_value mruby_dict_attr_object ( mrb_state *  mrb,
struct RClass *  klass,
fr_dict_attr_t const *  da 
)

Definition at line 119 of file mruby.c.

+ Here is the caller graph for this function:

◆ mruby_inst_object()

mrb_value mruby_inst_object ( mrb_state *  mrb,
struct RClass *  klass,
rlm_mruby_t const *  inst 
)

Definition at line 109 of file mruby.c.

+ Here is the caller graph for this function:

◆ mruby_pair_class()

struct RClass * mruby_pair_class ( mrb_state *  mrb,
struct RClass *  parent 
)

Definition at line 625 of file mruby.c.

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

◆ mruby_pair_init()

static mrb_value mruby_pair_init ( mrb_state *  mrb,
mrb_value  self 
)
static

Associate C structure with Ruby object representing a pair.

Will be called with 5 or 6 arguments

  • a pointer to the module instance
  • a pointer to the request
  • a pointer to the dictionary attribute for the pair
  • the instance number of the pair
  • a pointer to the real pair (if it exists)
  • (optional) the parent pair C structure

Definition at line 144 of file mruby.c.

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

◆ mruby_pair_list_class()

struct RClass * mruby_pair_list_class ( mrb_state *  mrb,
struct RClass *  parent 
)

Definition at line 611 of file mruby.c.

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

◆ mruby_pair_list_keys()

static mrb_value mruby_pair_list_keys ( mrb_state *  mrb,
mrb_value  self 
)
static

Fetch the list of children of a list.

Definition at line 189 of file mruby.c.

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

◆ mruby_pair_list_missing()

static mrb_value mruby_pair_list_missing ( mrb_state *  mrb,
mrb_value  self 
)
static

Implement mruby method_missing functionality to find child pairs.

Definition at line 495 of file mruby.c.

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

◆ mruby_pair_parent_build()

static void mruby_pair_parent_build ( mrb_state *  mrb,
mruby_pair_t pair 
)
static

Build parent structural pairs needed when a leaf node is set.

Definition at line 301 of file mruby.c.

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

◆ mruby_pair_value_to_ruby()

static mrb_value mruby_pair_value_to_ruby ( mrb_state *  mrb,
request_t request,
fr_pair_t vp 
)
static

Convert a pair value to a suitable mruby value type.

Definition at line 209 of file mruby.c.

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

◆ mruby_request_class()

struct RClass * mruby_request_class ( mrb_state *  mrb,
struct RClass *  parent 
)

Definition at line 63 of file mruby.c.

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

◆ mruby_request_control()

static mrb_value mruby_request_control ( mrb_state *  mrb,
mrb_value  self 
)
static

Definition at line 53 of file mruby.c.

+ Here is the caller graph for this function:

◆ mruby_request_frconfig()

static mrb_value mruby_request_frconfig ( mrb_state *  mrb,
mrb_value  self 
)
static

Definition at line 38 of file mruby.c.

+ Here is the caller graph for this function:

◆ mruby_request_object()

mrb_value mruby_request_object ( mrb_state *  mrb,
struct RClass *  klass,
request_t request 
)

Definition at line 114 of file mruby.c.

+ Here is the caller graph for this function:

◆ mruby_request_reply()

static mrb_value mruby_request_reply ( mrb_state *  mrb,
mrb_value  self 
)
static

Definition at line 48 of file mruby.c.

+ Here is the caller graph for this function:

◆ mruby_request_request()

static mrb_value mruby_request_request ( mrb_state *  mrb,
mrb_value  self 
)
static

Definition at line 43 of file mruby.c.

+ Here is the caller graph for this function:

◆ mruby_request_session_state()

static mrb_value mruby_request_session_state ( mrb_state *  mrb,
mrb_value  self 
)
static

Definition at line 58 of file mruby.c.

+ Here is the caller graph for this function:

◆ mruby_roby_to_pair_value()

static void mruby_roby_to_pair_value ( mrb_state *  mrb,
mrb_value *  value,
fr_pair_t vp 
)
static

Convert a ruby value to a fr_pair_t value.

Definition at line 320 of file mruby.c.

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

◆ mruby_ruby_pair_object()

static mrb_value mruby_ruby_pair_object ( mrb_state *  mrb,
struct RClass *  klass,
mruby_pair_t pair 
)
static

Definition at line 129 of file mruby.c.

+ Here is the caller graph for this function:

◆ mruby_value_pair_append()

static mrb_value mruby_value_pair_append ( mrb_state *  mrb,
mrb_value  self 
)
static

Append an instance of a value pair from mruby.

The ruby method expects one argument - the value to assign to the pair

Definition at line 440 of file mruby.c.

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

◆ mruby_value_pair_del()

static mrb_value mruby_value_pair_del ( mrb_state *  mrb,
mrb_value  self 
)
static

Delete a value pair from mruby.

The ruby method expects an optional argument - the instance number

Definition at line 470 of file mruby.c.

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

◆ mruby_value_pair_get()

static mrb_value mruby_value_pair_get ( mrb_state *  mrb,
mrb_value  self 
)
static

Get a pair value from mruby.

The mruby method can take an optional argument to specify the instance number

Definition at line 275 of file mruby.c.

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

◆ mruby_value_pair_object()

mrb_value mruby_value_pair_object ( mrb_state *  mrb,
struct RClass *  klass,
fr_pair_t vp 
)

Definition at line 124 of file mruby.c.

+ Here is the caller graph for this function:

◆ mruby_value_pair_set()

static mrb_value mruby_value_pair_set ( mrb_state *  mrb,
mrb_value  self 
)
static

Set a value pair from mruby.

The ruby method expects one or two arguments

  • the value to assign to the pair
  • (optional) instance number

Definition at line 396 of file mruby.c.

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

Variable Documentation

◆ mruby_dict_attr_type

const struct mrb_data_type mruby_dict_attr_type
static
Initial value:
= {
.struct_name = "DictAttr",
.dfree = NULL
}

Definition at line 91 of file mruby.c.

◆ mruby_inst_type

const struct mrb_data_type mruby_inst_type
static
Initial value:
= {
.struct_name = "Inst",
.dfree = NULL
}

Definition at line 81 of file mruby.c.

◆ mruby_request_type

const struct mrb_data_type mruby_request_type
static
Initial value:
= {
.struct_name = "Request",
.dfree = NULL
}

Definition at line 86 of file mruby.c.

◆ mruby_ruby_pair_type

const struct mrb_data_type mruby_ruby_pair_type
static
Initial value:
= {
.struct_name = "RubyPair",
.dfree = NULL
}

Definition at line 101 of file mruby.c.

◆ mruby_value_pair_type

const struct mrb_data_type mruby_value_pair_type
static
Initial value:
= {
.struct_name = "ValuePair",
.dfree = NULL
}

Definition at line 96 of file mruby.c.