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

DNS services via libunbound. More...

#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/server/log.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include <fcntl.h>
#include "io.h"
#include "log.h"
+ Include dependency graph for rlm_unbound.c:

Go to the source code of this file.

Data Structures

struct  rlm_unbound_t
 
struct  rlm_unbound_thread_t
 
struct  unbound_request_t
 

Macros

#define LOG_PREFIX   mctx->mi->name
 
#define RCODEERROR(_code, _message)
 
#define UB_QUERY(_record, _rrvalue, _return, _hasprio)
 

Functions

static int _unbound_request_free (unbound_request_t *ur)
 
static int mod_bootstrap (module_inst_ctx_t const *mctx)
 
static int mod_thread_detach (module_thread_inst_ctx_t const *mctx)
 
static int mod_thread_instantiate (module_thread_inst_ctx_t const *mctx)
 
static xlat_action_t xlat_unbound (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
 Perform a DNS lookup using libunbound. More...
 
static void xlat_unbound_callback (void *mydata, int rcode, void *packet, int packet_len, int sec, char *why_bogus)
 Callback called by unbound when resolution started with ub_resolve_event() completes. More...
 
static xlat_action_t xlat_unbound_resume (UNUSED TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *in)
 
static void xlat_unbound_signal (xlat_ctx_t const *xctx, request_t *request, UNUSED fr_signal_t action)
 
static void xlat_unbound_timeout (UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx)
 Callback from our timeout event to cancel a request. More...
 

Variables

static const conf_parser_t module_config []
 
module_rlm_t rlm_unbound
 
static xlat_arg_parser_t const xlat_unbound_args []
 

Detailed Description

DNS services via libunbound.

Id
14a4371bf4a4ef91a23980d43956188a8af52813

Definition in file rlm_unbound.c.


Data Structure Documentation

◆ rlm_unbound_t

struct rlm_unbound_t

Definition at line 38 of file rlm_unbound.c.

Data Fields
char const * filename Unbound configuration file.
char const * hosts hosts file to load
char const * resolvconf resolv.conf file to use
uint32_t timeout

◆ rlm_unbound_thread_t

struct rlm_unbound_thread_t

Definition at line 46 of file rlm_unbound.c.

+ Collaboration diagram for rlm_unbound_thread_t:
Data Fields
unbound_io_event_base_t * ev_b Unbound event base.
rlm_unbound_t * inst Instance data.
unbound_log_t * u_log Unbound log structure.

◆ unbound_request_t

struct unbound_request_t

Definition at line 52 of file rlm_unbound.c.

+ Collaboration diagram for unbound_request_t:
Data Fields
int async_id Id of async query.
uint16_t count Number of results to return.
int done Indicator that the callback has been called Negative values indicate errors.
fr_event_timer_t const * ev Event for timeout.
bool has_priority Does the returned data start with a priority field.
fr_value_box_list_t list Where to put the parsed results.
TALLOC_CTX * out_ctx CTX to allocate parsed results in.
request_t * request Current request being processed.
fr_type_t return_type Data type to parse results into.
rlm_unbound_thread_t * t Thread running this request.
bool timedout Request timedout.

Macro Definition Documentation

◆ LOG_PREFIX

#define LOG_PREFIX   mctx->mi->name

Definition at line 27 of file rlm_unbound.c.

◆ RCODEERROR

#define RCODEERROR (   _code,
  _message 
)
Value:
case _code: \
REDEBUG(_message, xctx->mctx->mi->name); \
goto error

◆ UB_QUERY

#define UB_QUERY (   _record,
  _rrvalue,
  _return,
  _hasprio 
)
Value:
if (strcmp(query_vb->vb_strvalue, _record) == 0) { \
ur->return_type = _return; \
ur->has_priority = _hasprio; \
ub_resolve_event(t->ev_b->ub, host_vb->vb_strvalue, _rrvalue, 1, ur, \
xlat_unbound_callback, &ur->async_id); \
}
static void xlat_unbound_callback(void *mydata, int rcode, void *packet, int packet_len, int sec, char *why_bogus)
Callback called by unbound when resolution started with ub_resolve_event() completes.
Definition: rlm_unbound.c:98

Function Documentation

◆ _unbound_request_free()

static int _unbound_request_free ( unbound_request_t ur)
static

Definition at line 78 of file rlm_unbound.c.

+ Here is the caller graph for this function:

◆ mod_bootstrap()

static int mod_bootstrap ( module_inst_ctx_t const *  mctx)
static

Definition at line 486 of file rlm_unbound.c.

+ Here is the call graph for this function:

◆ mod_thread_detach()

static int mod_thread_detach ( module_thread_inst_ctx_t const *  mctx)
static

Definition at line 476 of file rlm_unbound.c.

+ Here is the call graph for this function:

◆ mod_thread_instantiate()

static int mod_thread_instantiate ( module_thread_inst_ctx_t const *  mctx)
static

Definition at line 421 of file rlm_unbound.c.

+ Here is the call graph for this function:

◆ xlat_unbound_callback()

static void xlat_unbound_callback ( void *  mydata,
int  rcode,
void *  packet,
int  packet_len,
int  sec,
char *  why_bogus 
)
static

Callback called by unbound when resolution started with ub_resolve_event() completes.

Parameters
mydatathe request tracking structure set up before ub_resolve_event() was called
rcodeshould be the rcode from the reply packet, but appears not to be
packetwire format reply packet
packet_lenlength of wire format packet
secDNSSEC status code
why_bogusString describing DNSSEC issue if sec = 1
rate_limitedWas the request rate limited due to unbound workload

Definition at line 98 of file rlm_unbound.c.

+ Here is the call graph for this function:

◆ xlat_unbound_resume()

static xlat_action_t xlat_unbound_resume ( UNUSED TALLOC_CTX *  ctx,
fr_dcursor_t out,
xlat_ctx_t const *  xctx,
request_t request,
UNUSED fr_value_box_list_t *  in 
)
static

Definition at line 286 of file rlm_unbound.c.

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

◆ xlat_unbound_signal()

static void xlat_unbound_signal ( xlat_ctx_t const *  xctx,
request_t request,
UNUSED fr_signal_t  action 
)
static

Definition at line 273 of file rlm_unbound.c.

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

◆ xlat_unbound_timeout()

static void xlat_unbound_timeout ( UNUSED fr_event_list_t el,
UNUSED fr_time_t  now,
void *  uctx 
)
static

Callback from our timeout event to cancel a request.

Definition at line 259 of file rlm_unbound.c.

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

Variable Documentation

◆ module_config

const conf_parser_t module_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET_FLAGS("filename", CONF_FLAG_FILE_INPUT, rlm_unbound_t, filename), .dflt = "${modconfdir}/unbound/default.conf" },
{ FR_CONF_OFFSET("timeout", rlm_unbound_t, timeout), .dflt = "3000" },
{ FR_CONF_OFFSET_FLAGS("resolvconf", CONF_FLAG_FILE_INPUT, rlm_unbound_t, resolvconf) },
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:627
#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_FLAGS(_name, _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:256
@ CONF_FLAG_FILE_INPUT
File matching value must exist, and must be readable.
Definition: cf_parse.h:411
static fr_time_delta_t timeout
Definition: dhcpclient.c:54

Definition at line 70 of file rlm_unbound.c.

◆ rlm_unbound

module_rlm_t rlm_unbound
Initial value:
= {
.common = {
.name = "unbound",
.inst_size = sizeof(rlm_unbound_t),
.bootstrap = mod_bootstrap,
.thread_inst_size = sizeof(rlm_unbound_thread_t),
.thread_inst_type = "rlm_unbound_thread_t",
.thread_instantiate = mod_thread_instantiate,
.thread_detach = mod_thread_detach
}
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:63
static const conf_parser_t config[]
Definition: base.c:183
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Definition: rlm_unbound.c:486
static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx)
Definition: rlm_unbound.c:421
static const conf_parser_t module_config[]
Definition: rlm_unbound.c:70
static int mod_thread_detach(module_thread_inst_ctx_t const *mctx)
Definition: rlm_unbound.c:476

Definition at line 503 of file rlm_unbound.c.

◆ xlat_unbound_args

xlat_arg_parser_t const xlat_unbound_args[]
static
Initial value:
= {
{ .required = true, .concat = true, .type = FR_TYPE_STRING },
{ .required = true, .concat = true, .type = FR_TYPE_STRING },
{ .single = true, .type = FR_TYPE_UINT16 },
}
@ FR_TYPE_STRING
String of printable characters.
Definition: merged_model.c:83
@ FR_TYPE_UINT16
16 Bit unsigned integer.
Definition: merged_model.c:98
#define XLAT_ARG_PARSER_TERMINATOR
Definition: xlat.h:166

Definition at line 335 of file rlm_unbound.c.