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

Go to the source code of this file.

Data Structures

struct  rlm_sql_freetds_conn
 

Macros

#define MAX_DATASTR_LEN   256
 

Typedefs

typedef struct rlm_sql_freetds_conn rlm_sql_freetds_conn_t
 

Functions

static int _sql_socket_destructor (rlm_sql_freetds_conn_t *conn)
 
static CS_RETCODE CS_PUBLIC clientmsg_callback (CS_CONTEXT *context, UNUSED CS_CONNECTION *conn, CS_CLIENTMSG *emsgp)
 Client-Library error handler. More...
 
static CS_RETCODE CS_PUBLIC csmsg_callback (CS_CONTEXT *context, CS_CLIENTMSG *emsgp)
 Client error handler. More...
 
static CS_RETCODE CS_PUBLIC servermsg_callback (CS_CONTEXT *context, UNUSED CS_CONNECTION *conn, CS_SERVERMSG *msgp)
 Server error handler. More...
 
static int sql_affected_rows (rlm_sql_handle_t *handle, rlm_sql_config_t *config)
 
static size_t sql_error (UNUSED 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 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_finish_query (rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
 
static sql_rcode_t sql_finish_select_query (rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
 
static sql_rcode_t sql_free_result (UNUSED 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 int sql_num_rows (rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
 
static sql_rcode_t sql_query (rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config, char const *query)
 
static sql_rcode_t sql_select_query (rlm_sql_handle_t *handle, rlm_sql_config_t *config, char const *query)
 Execute a query when we expected a result set. More...
 
static sql_rcode_t sql_socket_init (rlm_sql_handle_t *handle, rlm_sql_config_t *config, struct timeval const *timeout)
 

Variables

rlm_sql_module_t rlm_sql_freetds
 

Data Structure Documentation

struct rlm_sql_freetds_conn

Definition at line 38 of file rlm_sql_freetds.c.

Data Fields
CS_COMMAND * command A prepared statement.
CS_CONTEXT * context Structure FreeTDS uses to avoid creating globals.
CS_CONNECTION * db Handle specifying a single connection to the database.
char * error The last error string created by one of the call backs.
bool established Set to false once the connection has been properly established.
char ** results Result strings from statement execution.

Macro Definition Documentation

#define MAX_DATASTR_LEN   256

Definition at line 47 of file rlm_sql_freetds.c.

Typedef Documentation

Function Documentation

static int _sql_socket_destructor ( rlm_sql_freetds_conn_t conn)
static

Definition at line 640 of file rlm_sql_freetds.c.

+ Here is the caller graph for this function:

static CS_RETCODE CS_PUBLIC clientmsg_callback ( CS_CONTEXT *  context,
UNUSED CS_CONNECTION *  conn,
CS_CLIENTMSG *  emsgp 
)
static

Client-Library error handler.

Callback for any errors raised by the Client-Library. Will overwrite any previous errors associated with a connection.

Parameters
contextThe FreeTDS library context.
connDB connection handle.
emsgpPointer to the error structure.
Returns
CS_SUCCEED

Definition at line 59 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static CS_RETCODE CS_PUBLIC csmsg_callback ( CS_CONTEXT *  context,
CS_CLIENTMSG *  emsgp 
)
static

Client error handler.

Callback for any errors raised by the client. Will overwrite any previous errors associated with a connection.

Parameters
contextThe FreeTDS library context.
emsgpPointer to the error structure.
Returns
CS_SUCCEED

Definition at line 103 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static CS_RETCODE CS_PUBLIC servermsg_callback ( CS_CONTEXT *  context,
UNUSED CS_CONNECTION *  conn,
CS_SERVERMSG *  msgp 
)
static

Server error handler.

Callback for any messages sent back from the server.

There's no standard categorisation of messages sent back from the server, so we don't know they're errors, the only thing we can do is write them to the long as informational messages.

Parameters
contextThe FreeTDS library context.
connDB connection handle.
msgpPointer to the error structure.
Returns
CS_SUCCEED

Definition at line 150 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int sql_affected_rows ( rlm_sql_handle_t handle,
rlm_sql_config_t config 
)
static

Definition at line 634 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

static size_t sql_error ( UNUSED 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 389 of file rlm_sql_freetds.c.

+ Here is the caller graph for this function:

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 565 of file rlm_sql_freetds.c.

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

Definition at line 334 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

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

Definition at line 619 of file rlm_sql_freetds.c.

+ Here is the caller graph for this function:

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

Definition at line 405 of file rlm_sql_freetds.c.

+ Here is the caller graph for this function:

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

Definition at line 608 of file rlm_sql_freetds.c.

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

Definition at line 313 of file rlm_sql_freetds.c.

+ Here is the caller graph for this function:

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

Definition at line 551 of file rlm_sql_freetds.c.

+ Here is the caller graph for this function:

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

Definition at line 192 of file rlm_sql_freetds.c.

+ Here is the caller graph for this function:

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

Execute a query when we expected a result set.

Note
Only the first row from queries returning several rows will be returned by this function, consecutive rows will be discarded.

Definition at line 429 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

static sql_rcode_t sql_socket_init ( rlm_sql_handle_t handle,
rlm_sql_config_t config,
struct timeval const *  timeout 
)
static

Definition at line 677 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

Variable Documentation

rlm_sql_module_t rlm_sql_freetds
Initial value:
= {
.name = "rlm_sql_freetds",
.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_fields = sql_fields,
.sql_affected_rows = sql_affected_rows,
.sql_fetch_row = sql_fetch_row,
.sql_free_result = sql_free_result,
.sql_error = sql_error,
.sql_finish_query = sql_finish_query,
.sql_finish_select_query = sql_finish_select_query
}
static sql_rcode_t sql_select_query(rlm_sql_handle_t *handle, rlm_sql_config_t *config, char const *query)
Execute a query when we expected a result set.
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(UNUSED rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
static int sql_num_rows(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
static sql_rcode_t sql_query(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config, char const *query)
static sql_rcode_t sql_fetch_row(rlm_sql_row_t *out, rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
static size_t sql_error(UNUSED 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_finish_query(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_finish_select_query(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
static int sql_affected_rows(rlm_sql_handle_t *handle, 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)

Definition at line 807 of file rlm_sql_freetds.c.