The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
rlm_sql_oracle.c File Reference
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/util/debug.h>
#include <sys/stat.h>
#include <oci.h>
#include "rlm_sql.h"
+ Include dependency graph for rlm_sql_oracle.c:

Go to the source code of this file.

Data Structures

struct  rlm_sql_oracle_conn_t
 
struct  rlm_sql_oracle_t
 

Macros

#define LOG_PREFIX   "sql - oracle"
 
#define MAX_DATASTR_LEN   64
 

Functions

static int _sql_socket_destructor (rlm_sql_oracle_conn_t *conn)
 
static int max_dflt (CONF_PAIR **out, UNUSED void *parent, CONF_SECTION *cs, fr_token_t quote, conf_parser_t const *rule)
 
static int max_dflt (CONF_PAIR **out, void *parent, CONF_SECTION *cs, fr_token_t quote, conf_parser_t const *rule)
 
static int mod_bootstrap (module_inst_ctx_t const *mctx)
 
static int mod_detach (module_detach_ctx_t const *mctx)
 
static int sql_affected_rows (rlm_sql_handle_t *handle, rlm_sql_config_t const *config)
 
static int sql_check_reconnect (rlm_sql_handle_t *handle, rlm_sql_config_t const *config)
 
static size_t sql_error (TALLOC_CTX *ctx, sql_log_entry_t out[], NDEBUG_UNUSED size_t outlen, rlm_sql_handle_t *handle, rlm_sql_config_t const *config)
 Retrieves any errors associated with the connection handle. More...
 
static sql_rcode_t sql_fetch_row (rlm_sql_row_t *out, rlm_sql_handle_t *handle, rlm_sql_config_t const *config)
 
static sql_rcode_t sql_fields (char const **out[], rlm_sql_handle_t *handle, rlm_sql_config_t const *config)
 
static sql_rcode_t sql_finish_query (rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
 
static sql_rcode_t sql_finish_select_query (rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
 
static sql_rcode_t sql_free_result (rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
 
static int sql_num_fields (rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
 
static int sql_num_rows (rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
 
static sql_rcode_t sql_query (rlm_sql_handle_t *handle, rlm_sql_config_t const *config, char const *query)
 
static sql_rcode_t sql_select_query (rlm_sql_handle_t *handle, rlm_sql_config_t const *config, char const *query)
 
static int sql_snprint_error (char *out, size_t outlen, rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
 Write the last Oracle error out to a buffer. More...
 
static sql_rcode_t sql_socket_init (rlm_sql_handle_t *handle, rlm_sql_config_t const *config, UNUSED fr_time_delta_t timeout)
 

Variables

static const conf_parser_t driver_config []
 
rlm_sql_driver_t rlm_sql_oracle
 
static const conf_parser_t spool_config []
 

Data Structure Documentation

◆ rlm_sql_oracle_conn_t

struct rlm_sql_oracle_conn_t

Definition at line 67 of file rlm_sql_oracle.c.

Data Fields
int col_count Number of columns associated with the result set.
OCISvcCtx * ctx
OCIError * error
int id
sb2 * ind
OCIStmt * query
char ** row

◆ rlm_sql_oracle_t

struct rlm_sql_oracle_t

Definition at line 53 of file rlm_sql_oracle.c.

Data Fields
OCIEnv * env Number of columns associated with the result set.
OCIError * error Oracle error handle.
OCISPool * pool Oracle session pool handle.
char * pool_name The name of the session pool returned by OCISessionPoolCreate.
ub4 pool_name_len Length of pool_name in bytes.
uint32_t spool_inc Specifies the increment for sessions to be started if the current number of sessions are less than sessMax.
uint32_t spool_max Specifies the maximum number of sessions that can be opened in the session pool.
uint32_t spool_min Specifies the minimum number of sessions in the session pool.
uint32_t spool_timeout The sessions idle time (in seconds) (0 disable).
uint32_t stmt_cache_size Statement cache size for each of the sessions in a session pool.

Macro Definition Documentation

◆ LOG_PREFIX

#define LOG_PREFIX   "sql - oracle"

Definition at line 25 of file rlm_sql_oracle.c.

◆ MAX_DATASTR_LEN

#define MAX_DATASTR_LEN   64

Definition at line 102 of file rlm_sql_oracle.c.

Function Documentation

◆ _sql_socket_destructor()

static int _sql_socket_destructor ( rlm_sql_oracle_conn_t conn)
static

Definition at line 267 of file rlm_sql_oracle.c.

+ Here is the caller graph for this function:

◆ max_dflt() [1/2]

static int max_dflt ( CONF_PAIR **  out,
UNUSED void *  parent,
CONF_SECTION cs,
fr_token_t  quote,
conf_parser_t const *  rule 
)
static

Definition at line 91 of file rlm_sql_oracle.c.

+ Here is the call graph for this function:

◆ max_dflt() [2/2]

static int max_dflt ( CONF_PAIR **  out,
void *  parent,
CONF_SECTION cs,
fr_token_t  quote,
conf_parser_t const *  rule 
)
static

◆ mod_bootstrap()

static int mod_bootstrap ( module_inst_ctx_t const *  mctx)
static

Definition at line 169 of file rlm_sql_oracle.c.

+ Here is the call graph for this function:

◆ mod_detach()

static int mod_detach ( module_detach_ctx_t const *  mctx)
static

Definition at line 158 of file rlm_sql_oracle.c.

◆ sql_affected_rows()

static int sql_affected_rows ( rlm_sql_handle_t handle,
rlm_sql_config_t const *  config 
)
static

Definition at line 620 of file rlm_sql_oracle.c.

+ Here is the call graph for this function:

◆ sql_check_reconnect()

static int sql_check_reconnect ( rlm_sql_handle_t handle,
rlm_sql_config_t const *  config 
)
static

Definition at line 253 of file rlm_sql_oracle.c.

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

◆ sql_error()

static size_t sql_error ( TALLOC_CTX *  ctx,
sql_log_entry_t  out[],
NDEBUG_UNUSED size_t  outlen,
rlm_sql_handle_t handle,
rlm_sql_config_t const *  config 
)
static

Retrieves any errors associated with the connection handle.

Note
Caller will free any memory allocated in ctx.
Parameters
ctxto allocate temporary error buffers in.
outArray of sql_log_entrys to fill.
outlenLength of out array.
handlerlm_sql connection handle.
configrlm_sql config.
Returns
number of errors written to the sql_log_entry_t array.

Definition at line 141 of file rlm_sql_oracle.c.

+ Here is the call graph for this function:

◆ sql_fetch_row()

static sql_rcode_t sql_fetch_row ( rlm_sql_row_t out,
rlm_sql_handle_t handle,
rlm_sql_config_t const *  config 
)
static

Definition at line 537 of file rlm_sql_oracle.c.

+ Here is the call graph for this function:

◆ sql_fields()

static sql_rcode_t sql_fields ( char const **  out[],
rlm_sql_handle_t handle,
rlm_sql_config_t const *  config 
)
static

Definition at line 323 of file rlm_sql_oracle.c.

+ Here is the call graph for this function:

◆ sql_finish_query()

static sql_rcode_t sql_finish_query ( rlm_sql_handle_t handle,
UNUSED rlm_sql_config_t const *  config 
)
static

Definition at line 592 of file rlm_sql_oracle.c.

◆ sql_finish_select_query()

static sql_rcode_t sql_finish_select_query ( rlm_sql_handle_t handle,
UNUSED rlm_sql_config_t const *  config 
)
static

Definition at line 604 of file rlm_sql_oracle.c.

◆ sql_free_result()

static sql_rcode_t sql_free_result ( rlm_sql_handle_t handle,
UNUSED rlm_sql_config_t const *  config 
)
static

Definition at line 573 of file rlm_sql_oracle.c.

◆ sql_num_fields()

static int sql_num_fields ( rlm_sql_handle_t handle,
UNUSED rlm_sql_config_t const *  config 
)
static

Definition at line 311 of file rlm_sql_oracle.c.

+ Here is the caller graph for this function:

◆ sql_num_rows()

static int sql_num_rows ( rlm_sql_handle_t handle,
UNUSED rlm_sql_config_t const *  config 
)
static

Definition at line 526 of file rlm_sql_oracle.c.

+ Here is the caller graph for this function:

◆ sql_query()

static sql_rcode_t sql_query ( rlm_sql_handle_t handle,
rlm_sql_config_t const *  config,
char const *  query 
)
static

Definition at line 364 of file rlm_sql_oracle.c.

+ Here is the call graph for this function:

◆ sql_select_query()

static sql_rcode_t sql_select_query ( rlm_sql_handle_t handle,
rlm_sql_config_t const *  config,
char const *  query 
)
static

Definition at line 395 of file rlm_sql_oracle.c.

+ Here is the call graph for this function:

◆ sql_snprint_error()

static int sql_snprint_error ( char *  out,
size_t  outlen,
rlm_sql_handle_t handle,
UNUSED rlm_sql_config_t const *  config 
)
static

Write the last Oracle error out to a buffer.

Parameters
outWhere to write the error (should be at least 512 bytes).
outlenThe length of the error buffer.
handlesql handle.
configInstance config.
Returns
  • 0 on success.
  • -1 if there was no error.

Definition at line 114 of file rlm_sql_oracle.c.

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

◆ sql_socket_init()

static sql_rcode_t sql_socket_init ( rlm_sql_handle_t handle,
rlm_sql_config_t const *  config,
UNUSED fr_time_delta_t  timeout 
)
static

Definition at line 274 of file rlm_sql_oracle.c.

+ Here is the call graph for this function:

Variable Documentation

◆ driver_config

const conf_parser_t driver_config[]
static
Initial value:
= {
{ FR_CONF_POINTER("spool", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) spool_config },
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:626
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
Definition: cf_parse.h:310
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition: cf_parse.h:400
static const conf_parser_t spool_config[]

Definition at line 86 of file rlm_sql_oracle.c.

◆ rlm_sql_oracle

rlm_sql_driver_t rlm_sql_oracle
Initial value:
= {
.common = {
.name = "sql_oracle",
.inst_size = sizeof(rlm_sql_oracle_t),
.bootstrap = mod_bootstrap,
.detach = mod_detach
},
.number = 5,
.sql_socket_init = sql_socket_init,
.sql_query = sql_query,
.sql_select_query = sql_select_query,
.sql_num_fields = sql_num_fields,
.sql_num_rows = sql_num_rows,
.sql_affected_rows = sql_affected_rows,
.sql_fetch_row = sql_fetch_row,
.sql_fields = sql_fields,
.sql_free_result = sql_free_result,
.sql_error = sql_error,
.sql_finish_query = sql_finish_query,
.sql_finish_select_query = sql_finish_select_query
}
#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_detach(module_detach_ctx_t const *mctx)
static sql_rcode_t sql_fetch_row(rlm_sql_row_t *out, rlm_sql_handle_t *handle, rlm_sql_config_t const *config)
static int mod_bootstrap(module_inst_ctx_t const *mctx)
static sql_rcode_t sql_free_result(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
static sql_rcode_t sql_finish_query(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
static int sql_affected_rows(rlm_sql_handle_t *handle, rlm_sql_config_t const *config)
static int sql_num_rows(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
static sql_rcode_t sql_fields(char const **out[], rlm_sql_handle_t *handle, rlm_sql_config_t const *config)
static const conf_parser_t driver_config[]
static sql_rcode_t sql_finish_select_query(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
static sql_rcode_t sql_select_query(rlm_sql_handle_t *handle, rlm_sql_config_t const *config, char const *query)
static int sql_num_fields(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
static sql_rcode_t sql_query(rlm_sql_handle_t *handle, rlm_sql_config_t const *config, char const *query)
static size_t sql_error(TALLOC_CTX *ctx, sql_log_entry_t out[], NDEBUG_UNUSED size_t outlen, rlm_sql_handle_t *handle, rlm_sql_config_t const *config)
Retrieves any errors associated with the connection handle.
static sql_rcode_t sql_socket_init(rlm_sql_handle_t *handle, rlm_sql_config_t const *config, UNUSED fr_time_delta_t timeout)

Definition at line 627 of file rlm_sql_oracle.c.

◆ spool_config

const conf_parser_t spool_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("stmt_cache_size", rlm_sql_oracle_t, stmt_cache_size), .dflt = "32" },
{ FR_CONF_OFFSET("timeout", rlm_sql_oracle_t, spool_timeout), .dflt = "0" },
{ FR_CONF_OFFSET("min", rlm_sql_oracle_t, spool_min), .dflt = "1" },
{ FR_CONF_OFFSET("max", rlm_sql_oracle_t, spool_max), .dflt_func = max_dflt },
{ FR_CONF_OFFSET("inc", rlm_sql_oracle_t, spool_inc), .dflt = "1" },
}
#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
static int max_dflt(CONF_PAIR **out, void *parent, CONF_SECTION *cs, fr_token_t quote, conf_parser_t const *rule)

Definition at line 77 of file rlm_sql_oracle.c.