#include <time.h>
#include "mysql.h"
Go to the source code of this file.
Data Structures | |
struct | smysql |
Data structure used to store the configuration for MySql connection. More... | |
Defines | |
#define | MYSQL_CONFIGURATION_TAG_NUMBER 12 |
Number of configuration tags for MySql in a configuration file. | |
#define | RADONLINE_START 0 |
This constant is used by the function send_to_radonline(). It tells the function that a START ticket should be inserted into the Radonline database. | |
#define | RADONLINE_STOP 1 |
This constant is used by the function send_to_radonline(). It tells the function that a STOP ticket should be inserted into the Radonline database. | |
#define | MYDNS_START 0 |
This constant is used by the function send_to_mydns(). It tells the function that a START ticket should be inserted into the MyDns database. | |
#define | MYDNS_STOP 1 |
This constant is used by the function send_to_mydns(). It tells the function that a STOP ticket should be inserted into the MyDns database. | |
#define | MYSQL_MAX_ERROR_SIZE 4096 |
Maximum number of characters for the buffer that hold the message associated with the last MySql error. | |
#define | MAX_SQL_REQUEST_SIZE 4096 |
Maximum number of characters for a SQL request. | |
#define | DB_HOST_MAX_SIZE 256 |
Maximum number of characters for the database host name. | |
#define | DB_USER_MAX_SIZE 256 |
Maximum number of characters for a database user login. | |
#define | DB_NAME_MAX_SIZE 256 |
Maximum number of characters for a database name. | |
#define | DB_PASSWD_MAX_SIZE 256 |
Maximum number of characters for a database password. | |
#define | MYSQL_SOCKET_FILE_MAX_SIZE 256 |
Maximum number of characters for the path to the MySql UNIX socket. | |
#define | MYSQL_DEBUG_FILE_MAX_SIZE 256 |
Maximum number of characters for the path to the MySql debug file. | |
#define | MYSQL_REQUEST_SKIPED -1 |
Return value for the functions:
| |
#define | MYSQL_CONNECTION_LOST -2 |
Return value for the functions:
| |
#define | MYSQL_RECONNECTION_FAILED -3 |
Return value for the functions:
| |
#define | MYSQL_SQL_PROBLEM -4 |
Return value for the functions:
| |
#define | MYSQL_UNEXPECTED_ERROR -5 |
Return value for the functions:
| |
#define | MYSQL_NO_TIMESTAMP -6 |
Return value for the functions:
| |
Functions | |
int | load_mysql_configuration_from_file (char *path, struct smysql *mysql_info, char *tags[MYSQL_CONFIGURATION_TAG_NUMBER], int(*logger)(const char *file, const char *fmt,...)) |
Load MySql configuration from a given configuration file. More... | |
void | mysql_set_logger (int(*logger)(const char *file, const char *fmt,...), struct smysql *mysql_info) |
Assign a logging service to a given MySql handler. More... | |
void | init_mysql_structure (struct smysql *mysql_info) |
Initialise the Mysql management structure. More... | |
int | connect_to_mysql (struct smysql *mysql_info) |
Connect to Mysql server. More... | |
void | disconnect_from_mysql (struct smysql *mysql_info) |
Close the connection with the Mysql server and free allocated memory. More... | |
int | sql_update (struct smysql *mysql_info, char *query) |
Execute an UPDATE SQL statement. More... | |
int | sql_insert (struct smysql *mysql_info, char *query) |
Execute an INSERT SQL statement. More... | |
int | sql_delete (struct smysql *mysql_info, char *query) |
Execute a DELETE SQL statement. More... | |
int | sql_replace (struct smysql *mysql_info, char *query) |
Execute a REPLACE SQL statement. More... | |
int | sql_select (struct smysql *mysql_info, char *query) |
Execute a SELECT SQL statement. More... | |
time_t | get_unix_timestamp (struct smysql *mysql_info, int *error) |
Return the UNIX timestamp of the MySql server. More... |
Definition in file mysql_header.h.
|
Connect to Mysql server.
Definition at line 149 of file mysql.c. References clear_error_reporting(), smysql::connect_retry, smysql::connect_sleep, smysql::connect_timeout, smysql::connected, smysql::db, smysql::handler, smysql::host, smysql::log_file, my_fake_syslog(), my_syslog(), smysql::my_syslog, smysql::passwd, smysql::port, set_last_error(), smysql::socket, and smysql::user. Referenced by main(), sql_select(), and standard_query(). |
|
Close the connection with the Mysql server and free allocated memory.
Definition at line 253 of file mysql.c. References smysql::handler. Referenced by sql_select(), and standard_query(). |
|
Return the UNIX timestamp of the MySql server.
Definition at line 1261 of file mysql.c. References smysql::debug, smysql::log_file, my_fake_syslog(), my_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_NO_TIMESTAMP, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, smysql::result, and sql_select(). Referenced by load_pool(), load_vlan(), release_ip_from_pool(), try_find_and_reserve_ip_from_pool(), and try_reserve_ip_from_pool(). |
|
Initialise the Mysql management structure.
Definition at line 114 of file mysql.c. References clear_error_reporting(), smysql::connected, smysql::handler, smysql::last_connection_timestamp, smysql::num_fields, smysql::num_rows, and smysql::result. Referenced by main(). |
|
Load MySql configuration from a given configuration file.
The size of the array is MYSQL_CONFIGURATION_TAG_NUMBER.
int (*logger) (const char *file, const char * fmt,...) If NULL, then logging is not activated (no matter if a log file is defined).
Definition at line 786 of file mysql.c. References clear_error_reporting(), smysql::connect_retry, smysql::connect_sleep, smysql::connect_timeout, smysql::db, DB_HOST_MAX_SIZE, DB_NAME_MAX_SIZE, DB_PASSWD_MAX_SIZE, DB_USER_MAX_SIZE, smysql::debug, get_value(), smysql::host, smysql::last_error_str, smysql::log_file, my_fake_syslog(), my_syslog(), smysql::my_syslog, MYSQL_CONFIGURATION_TAG_NUMBER, MYSQL_DEBUG_FILE_MAX_SIZE, MYSQL_MAX_ERROR_SIZE, mysql_set_logger(), MYSQL_SOCKET_FILE_MAX_SIZE, parse_configuration_file(), PARSE_CONFIGURATION_OK, smysql::passwd, smysql::port, smysql::reconnection_delay, smysql::socket, and smysql::user. Referenced by main(). |
|
Assign a logging service to a given MySql handler.
Definition at line 48 of file mysql.c. References smysql::my_syslog. Referenced by load_mysql_configuration_from_file(). |
|
Execute a DELETE SQL statement.
Definition at line 542 of file mysql.c. References standard_query(). Referenced by send_to_mydns(), and send_to_radonline(). |
|
Execute an INSERT SQL statement.
Definition at line 500 of file mysql.c. References standard_query(). Referenced by send_to_mydns(), send_to_radonline(), and signal_unknown_mac_address(). |
|
Execute a REPLACE SQL statement.
Definition at line 521 of file mysql.c. References standard_query(). |
|
Execute a SELECT SQL statement.
Definition at line 563 of file mysql.c. References clear_error_reporting(), connect_to_mysql(), smysql::connected, copy_error(), disconnect_from_mysql(), smysql::handler, smysql::last_connection_timestamp, smysql::last_error_int, smysql::last_error_str, smysql::log_file, my_fake_syslog(), my_syslog(), smysql::my_syslog, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, smysql::num_fields, smysql::num_rows, smysql::reconnection_delay, smysql::result, and set_last_error(). Referenced by get_unix_timestamp(), load_abonne_ip(), load_abonnes(), load_ip_lease(), load_logistic(), load_options(), load_pool(), load_vlan(), and mydns_init(). |
|
Execute an UPDATE SQL statement.
Definition at line 479 of file mysql.c. References standard_query(). Referenced by blackhole_abonne(), nack_flag_abonne(), release_ip_from_pool(), remove_autoconf_bh(), set_flag_check_radius(), try_find_and_reserve_ip_from_pool(), and try_reserve_ip_from_pool(). |