All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions | Variables
rlm_sql_postgresql.c File Reference
#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/rad_assert.h>
#include <sys/stat.h>
#include <libpq-fe.h>
#include <postgres_ext.h>
#include "config.h"
#include "rlm_sql.h"
#include "sql_postgresql.h"
+ Include dependency graph for rlm_sql_postgresql.c:

Go to the source code of this file.

Data Structures

struct  rlm_sql_postgres_config
 
struct  rlm_sql_postgres_conn
 

Macros

#define NAMEDATALEN   64
 

Typedefs

typedef struct
rlm_sql_postgres_config 
rlm_sql_postgres_config_t
 
typedef struct
rlm_sql_postgres_conn 
rlm_sql_postgres_conn_t
 

Functions

static int _sql_socket_destructor (rlm_sql_postgres_conn_t *conn)
 
static int affected_rows (PGresult *result)
 Return the number of affected rows of the result as an int instead of the string that postgresql provides. More...
 
static int CC_HINT (nonnull)
 
static void free_result_row (rlm_sql_postgres_conn_t *conn)
 Free the row of the current result that's stored in the conn struct. More...
 
static int mod_instantiate (CONF_SECTION *conf, rlm_sql_config_t *config)
 
static int sql_affected_rows (rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
 
static sql_rcode_t sql_classify_error (UNUSED PGresult const *result)
 
static size_t sql_error (TALLOC_CTX *ctx, sql_log_entry_t out[], size_t outlen, rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
 Retrieves any errors associated with the connection handle. More...
 
static size_t sql_escape_func (REQUEST *request, char *out, size_t outlen, char const *in, void *arg)
 
static sql_rcode_t sql_fetch_row (rlm_sql_row_t *out, rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
 
static sql_rcode_t sql_fields (char const **out[], rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
 
static sql_rcode_t sql_free_result (rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
 
static int sql_num_fields (rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
 
static sql_rcode_t sql_select_query (rlm_sql_handle_t *handle, rlm_sql_config_t *config, char const *query)
 

Variables

static CONF_PARSER driver_config []
 
rlm_sql_module_t rlm_sql_postgresql
 

Data Structure Documentation

struct rlm_sql_postgres_config

Definition at line 58 of file rlm_sql_postgresql.c.

Data Fields
char const * db_string
bool send_application_name
struct rlm_sql_postgres_conn

Definition at line 63 of file rlm_sql_postgresql.c.

Data Fields
int affected_rows
int cur_row
PGconn * db
int num_fields
PGresult * result
char ** row

Macro Definition Documentation

#define NAMEDATALEN   64

Definition at line 55 of file rlm_sql_postgresql.c.

Typedef Documentation

Function Documentation

static int _sql_socket_destructor ( rlm_sql_postgres_conn_t conn)
static

Definition at line 255 of file rlm_sql_postgresql.c.

+ Here is the caller graph for this function:

static int affected_rows ( PGresult *  result)
static

Return the number of affected rows of the result as an int instead of the string that postgresql provides.

Definition at line 183 of file rlm_sql_postgresql.c.

+ Here is the caller graph for this function:

static int CC_HINT ( nonnull  )
static

Definition at line 267 of file rlm_sql_postgresql.c.

+ Here is the call graph for this function:

static void free_result_row ( rlm_sql_postgres_conn_t conn)
static

Free the row of the current result that's stored in the conn struct.

Definition at line 191 of file rlm_sql_postgresql.c.

+ Here is the caller graph for this function:

static int mod_instantiate ( CONF_SECTION conf,
rlm_sql_config_t config 
)
static

Definition at line 77 of file rlm_sql_postgresql.c.

+ Here is the call graph for this function:

static int sql_affected_rows ( rlm_sql_handle_t handle,
UNUSED rlm_sql_config_t config 
)
static

Definition at line 501 of file rlm_sql_postgresql.c.

static sql_rcode_t sql_classify_error ( UNUSED PGresult const *  result)
static

Definition at line 248 of file rlm_sql_postgresql.c.

static size_t sql_error ( TALLOC_CTX *  ctx,
sql_log_entry_t  out[],
size_t  outlen,
rlm_sql_handle_t handle,
UNUSED rlm_sql_config_t 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 476 of file rlm_sql_postgresql.c.

static size_t sql_escape_func ( REQUEST request,
char *  out,
size_t  outlen,
char const *  in,
void *  arg 
)
static

Definition at line 508 of file rlm_sql_postgresql.c.

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

Definition at line 410 of file rlm_sql_postgresql.c.

+ Here is the call graph for this function:

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

Definition at line 392 of file rlm_sql_postgresql.c.

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

Definition at line 451 of file rlm_sql_postgresql.c.

+ Here is the call graph for this function:

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

Definition at line 440 of file rlm_sql_postgresql.c.

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

Definition at line 387 of file rlm_sql_postgresql.c.

+ Here is the call graph for this function:

Variable Documentation

CONF_PARSER driver_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("send_application_name", PW_TYPE_BOOLEAN, rlm_sql_postgres_config_t, send_application_name), .dflt = "no" },
}
#define CONF_PARSER_TERMINATOR
Definition: conffile.h:289
A truth value.
Definition: radius.h:56
#define FR_CONF_OFFSET(_n, _t, _s, _f)
Definition: conffile.h:168

Definition at line 72 of file rlm_sql_postgresql.c.

rlm_sql_module_t rlm_sql_postgresql
Initial value:
= {
.name = "rlm_sql_postgresql",
.mod_instantiate = mod_instantiate,
.sql_socket_init = sql_socket_init,
.sql_query = sql_query,
.sql_select_query = sql_select_query,
.sql_num_fields = sql_num_fields,
.sql_fields = sql_fields,
.sql_fetch_row = sql_fetch_row,
.sql_error = sql_error,
.sql_finish_query = sql_free_result,
.sql_finish_select_query = sql_free_result,
.sql_affected_rows = sql_affected_rows,
.sql_escape_func = sql_escape_func
}
static size_t sql_error(TALLOC_CTX *ctx, sql_log_entry_t out[], size_t outlen, rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
Retrieves any errors associated with the connection handle.
static sql_rcode_t sql_select_query(rlm_sql_handle_t *handle, rlm_sql_config_t *config, char const *query)
static sql_rcode_t sql_query(rlm_sql_handle_t *handle, rlm_sql_config_t *config, char const *query)
static int sql_affected_rows(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
static int mod_instantiate(CONF_SECTION *conf, rlm_sql_config_t *config)
static sql_rcode_t sql_socket_init(rlm_sql_handle_t *handle, rlm_sql_config_t *config, struct timeval const *timeout)
static sql_rcode_t sql_fetch_row(rlm_sql_row_t *out, rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
static sql_rcode_t sql_fields(char const **out[], rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
static int sql_num_fields(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
static size_t sql_escape_func(REQUEST *request, char *out, size_t outlen, char const *in, void *arg)
static sql_rcode_t sql_free_result(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)

Definition at line 532 of file rlm_sql_postgresql.c.