Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

mysql_interface.c File Reference

#include <string.h>
#include <stdio.h>
#include "mysql_interface.h"
#include "strings_utils.h"
#include "conversion.h"
#include "modem.h"
#include "logging.h"

Go to the source code of this file.

Defines

#define SQL_REQUEST_SIZE   2048
 Maximum number of bytes for a SQL request.

#define NASPORT_SIZE   512
 Maximum number of bytes for the "NASPORT" identifier. The "NASPORT" identifier is the following string : "node= shelf= port= slot= vlan=<>", (that describes the exact location on the DSLAM).


Functions

int load_abonnes (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config)
 Load the content of table 'abonnes'. This function is called wether the DHCP request went through the relay agent or not (directly from client to server). More...

int load_vlan (struct smysql *mysql_info, struct smysql *mysql_info_pool, struct mysql_tables *mysql_tables, struct global_config *config)
 Load the content of table 'vlan'. More...

int load_ip_lease (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config)
 Load the content of table 'ip_lease'. More...

int load_pool (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config)
 Load the content of table 'pool'. More...

int try_reserve_ip_from_pool (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config, unsigned long int timeout)
 Update an element in the table 'pool'. Try to reserve an IP in the pool. More...

int try_find_and_reserve_ip_from_pool (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config, unsigned long int timeout)
 Update an element in the table 'pool'. Try to find and reserve an IP in the pool. More...

void clear_tables (struct mysql_tables *mysql_tables)
 Initialize the table structure. More...

int my_fake_syslog (const char *file, const char *fmt,...)
 Fake logging service (used if logging is not activated). More...

int load_abonne_ip (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config)
 Load the content of table 'abonne_ip'. More...

int load_options (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config)
 Load the content of table 'options'. More...

int release_ip_from_pool (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config)
 Release IP from pool. More...

int load_context (struct smysql *mysql_info, struct smysql *mysql_info_write, struct mysql_tables *mysql_tables, struct global_config *config)
 Load the entire context associated with a user. More...

int find_ip_in_vlan_pool (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config)
 Lookup the IP pool in order to find out if a guven user has an IP address. More...

int get_ip_from_pool (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config, unsigned int timeout, int reserve_ip)
 Try to reserve an IP address in the IP pool. More...

int send_to_radonline (struct smysql *mysql_info, struct mysql_tables *mysql_tables, char *ip, int action, struct global_config *config)
 Send a ticket (START or STOP) into the Radonline database. More...

int mydns_init (struct smysql *mysql_info)
 Initialize the MyDns service. More...

int send_to_mydns (struct smysql *mysql_info, struct mysql_tables *mysql_tables, char *ip, int action, struct global_config *config)
 Send a ticket (START or STOP) into the MyDns database. More...

int load_logistic (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config)
 Load the content of table 'LOGIDTIC'. More...

int blackhole_abonne (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config)
 Set a client's profile to "autoconfblackhole". More...

int remove_autoconf_bh (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config)
 Set a client's profile to "STANDARD". More...

int set_flag_check_radius (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config)
 Set the flag FLAG_CHECK_RADIUS to the value 1. More...

int signal_unknown_mac_address (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config)
 Insert a couple (login_modem,mac_address) into the LOGISTIC_RADIUS table. More...

int nack_flag_abonne (struct smysql *mysql_info, struct mysql_tables *mysql_tables, struct global_config *config, unsigned long int new_value)
 Update the value of the field 'nack_flag' of the table 'abonnes'. More...


Variables

unsigned int mydns_id
 This value is used for all transactions with MyDns. It comes from the following SQL request: SELECT id FROM soa WHERE origin='user.'.


Detailed Description

This file implements high level MySql functionnalities.

Definition in file mysql_interface.c.


Function Documentation

int blackhole_abonne struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config
 

Set a client's profile to "autoconfblackhole".

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. The following information must be set :
  • abonnes.abonnes_id
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
  • MYSQL_INTERFACE_NOT_FOUND
  • MYSQL_INTERFACE_MORE_THAN_ONE

Definition at line 3360 of file mysql_interface.c.

References mysql_tables::abonnes, table_abonnes::abonnes_id, smysql::debug, smysql::log_file, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_MORE_THAN_ONE, MYSQL_INTERFACE_NOT_FOUND, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, SQL_REQUEST_SIZE, and sql_update().

Referenced by look_up_logistic().

void clear_tables struct mysql_tables   mysql_tables
 

Initialize the table structure.

Author:
Denis BEURIVE
Parameters:
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model.

Definition at line 62 of file mysql_interface.c.

Referenced by main().

int find_ip_in_vlan_pool struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config
 

Lookup the IP pool in order to find out if a guven user has an IP address.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration. This structure points to the 'read/write' database.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. Make sure to load the context first (using load_context()). Tables 'vlan' and 'pool' will be use to initialize the following entries:
  • ip_lease->vlan_id = vlan->vlan_id
  • pool->abonnes_id = abonnes->abonnes_id
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
Returns:
Upon successful completion, the function returs the value 0. Otherwize, the function may return one of the following values:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_MORE_THAN_ONE
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
  • MYSQL_INTERFACE_NO_TIMESTAMP
  • MYSQL_INTERFACE_NO_LEASE_ID
  • MYSQL_INTERFACE_NO_IP_FOUND
Remarks:
  • The result is copied into the entry 'pool' of the structure pointed by 'mysql_tables'.
  • The entry 'ip_lease' is also initialized.
  • Make sure to load the context first (using load_context()). If you forget, some data won't be correctly initialized.

Definition at line 2090 of file mysql_interface.c.

References mysql_tables::abonnes, mysql_tables::ip_lease, load_ip_lease(), load_pool(), smysql::log_file, my_fake_syslog(), smysql::my_syslog, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_MORE_THAN_ONE, MYSQL_INTERFACE_NO_IP_FOUND, MYSQL_INTERFACE_NO_LEASE_ID, MYSQL_INTERFACE_NO_TIMESTAMP, MYSQL_INTERFACE_NOT_FOUND, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, mysql_tables::pool, and mysql_tables::vlan.

Referenced by find_ip_and_reply(), and get_ip_from_pool().

int get_ip_from_pool struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config,
unsigned int    timeout,
int    reserve_ip
 

Try to reserve an IP address in the IP pool.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration. This structure points to the 'read/write' database.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. The entry 'ip_lease' must have the following field:
  • vlan_id
The entry 'pool' must have the following entries:
  • abonnes_id
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
timeout  Timeout for the expiration date. The timeout's value depends on the event. It could be:
  • An OFFER (reply to DISCOVER).
  • An ACK (reply to OFFER).
reserve_ip  This flag tells the function whether it should try to reserve an IP address from the pool.
  • 0: Do not try to reserve IP address from pool.
  • Any other value: Try to reserve IP address from pool.
Returns:
  • If the function finds a free IP address in the pool, it returns the value 1.
  • If the function did not find a free IP address in the pool, it returns the value 0.
  • Otherwize, the function may return one of the following values:
    • MYSQL_INTERFACE_UNEXPECTED_ERROR
    • MYSQL_INTERFACE_SQL_PROBLEM
    • MYSQL_INTERFACE_RECONNECTION_FAILED
    • MYSQL_INTERFACE_CONNECTION_LOST
    • MYSQL_INTERFACE_REQUEST_SKIPED
    • MYSQL_INTERFACE_NO_TIMESTAMP
    • MYSQL_INTERFACE_NO_LEASE_ID
    • MYSQL_INTERFACE_MORE_THAN_ONE
Remarks:
  • The result is copied into the entry 'pool' of the structure pointed by 'mysql_tables'.
  • The entry 'ip_lease' is also initialized.

Definition at line 2272 of file mysql_interface.c.

References table_pool::abonnes_id, smysql::debug, find_ip_in_vlan_pool(), table_pool::ip, mysql_tables::ip_lease, table_pool::ip_lease_id, table_ip_lease::ip_lease_id, load_pool(), smysql::log_file, my_fake_syslog(), smysql::my_syslog, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_MORE_THAN_ONE, MYSQL_INTERFACE_NO_IP_FOUND, MYSQL_INTERFACE_NO_LEASE_ID, MYSQL_INTERFACE_NO_TIMESTAMP, MYSQL_INTERFACE_NOT_FOUND, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, mysql_tables::pool, table_pool::pool_id, try_find_and_reserve_ip_from_pool(), and try_reserve_ip_from_pool().

Referenced by find_ip_and_reply().

int load_abonne_ip struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config
 

Load the content of table 'abonne_ip'.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. Entry 'abonne_ip' must have the following definitions (that will be used for SQL query):
  • abonnes_id
  • vlan_id
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_NOT_FOUND
  • MYSQL_INTERFACE_MORE_THAN_ONE
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
Remarks:
The result is copied into the entry 'abonne_ip' of the structure pointed by 'mysql_tables'.

Definition at line 699 of file mysql_interface.c.

References mysql_tables::abonne_ip, table_abonne_ip::abonne_ip_id, table_abonne_ip::abonnes_id, smysql::debug, table_abonne_ip::gateway, table_abonne_ip::ip, IP_ADDRESS_STR_SIZE, smysql::log_file, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_MORE_THAN_ONE, MYSQL_INTERFACE_NOT_FOUND, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, smysql::result, SQL_REQUEST_SIZE, sql_select(), table_abonne_ip::subnet, and table_abonne_ip::vlan_id.

Referenced by find_ip_and_reply().

int load_abonnes struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config
[static]
 

Load the content of table 'abonnes'. This function is called wether the DHCP request went through the relay agent or not (directly from client to server).

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. The following information must be set :
  • abonnes.node_id
  • abonnes.shelf
  • abonnes.numero_port
  • abonnes.numero_slot
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_NOT_FOUND
  • MYSQL_INTERFACE_MORE_THAN_ONE
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
Remarks:
The result is copied into the entry 'abonnes' of the structure pointed by 'mysql_tables'.

Definition at line 111 of file mysql_interface.c.

References mysql_tables::abonnes, table_abonnes::abonnes_id, smysql::debug, table_abonnes::first_connection, smysql::log_file, table_abonnes::login_radius, LOGIN_RADIUS_SIZE, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_MORE_THAN_ONE, MYSQL_INTERFACE_NOT_FOUND, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, table_abonnes::nack_flag, table_abonnes::node_id, table_abonnes::numero_port, table_abonnes::numero_slot, OPTIONNAL_PROFILE_SIZE, table_abonnes::profile, smysql::result, table_abonnes::shelf, SQL_REQUEST_SIZE, and sql_select().

Referenced by load_context().

int load_context struct smysql   mysql_info,
struct smysql   mysql_info_write,
struct mysql_tables   mysql_tables,
struct global_config   config
 

Load the entire context associated with a user.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration. This structure points to the 'read only' database.
mysql_info_write  Pointer to a 'smysql' data structure that contains the MySql configuration. This structure points to the 'read / write' database.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. Entry 'abonnes' must have the following definitions (that will be used for SQL query):
  • node_id
  • shelf
  • numero_port
  • numero_slot
Entry 'vlan' must have the following definitions (that will be used for SQL query):
  • vlan_tag
  • vlan_gateway
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_NOT_FOUND
  • MYSQL_INTERFACE_MORE_THAN_ONE
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
  • MYSQL_INTERFACE_TOO_MANY_ITEMS
Remarks:
  • The result is copied into entries:
    • 'abonnes'
    • 'vlan'
    • 'options'
  • This function takes care of the black-hole flag. If necessary, the correct balckhole profile is loaded.

Definition at line 1818 of file mysql_interface.c.

References mysql_tables::abonnes, smysql::debug, load_abonnes(), load_options(), load_vlan(), smysql::log_file, my_fake_syslog(), smysql::my_syslog, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_MORE_THAN_ONE, MYSQL_INTERFACE_NOT_FOUND, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_TOO_MANY_ITEMS, MYSQL_INTERFACE_UNEXPECTED_ERROR, OPTIONNAL_PROFILE_SIZE, mysql_tables::options, and mysql_tables::vlan.

Referenced by main().

int load_ip_lease struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config
[static]
 

Load the content of table 'ip_lease'.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. Entry 'ip_lease' must have the following definitions (that will be used for SQL query):
  • vlan_id
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_NOT_FOUND
  • MYSQL_INTERFACE_MORE_THAN_ONE
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
Remarks:
The result is copied into the entry 'ip_lease' of the structure pointed by 'mysql_tables'.

Definition at line 1033 of file mysql_interface.c.

References table_ip_lease::cidr, CIDR_SIZE, smysql::debug, table_ip_lease::gateway, IP_ADDRESS_STR_SIZE, mysql_tables::ip_lease, table_ip_lease::ip_lease_id, smysql::log_file, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_MORE_THAN_ONE, MYSQL_INTERFACE_NOT_FOUND, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, smysql::result, SQL_REQUEST_SIZE, sql_select(), table_ip_lease::subnet, and table_ip_lease::vlan_id.

Referenced by find_ip_in_vlan_pool().

int load_logistic struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config
 

Load the content of table 'LOGIDTIC'.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. The following information must be set :
  • logistic.LOGIN_MODEM
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_NOT_FOUND
  • MYSQL_INTERFACE_MORE_THAN_ONE
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
Remarks:
The result is copied into the entry 'table_logistic_radius' of the structure pointed by 'mysql_tables'. Fields are:
  • RADIUS_LOGIN
  • FLAG_CHECK_RADIUS

Definition at line 3227 of file mysql_interface.c.

References smysql::debug, table_logistic_radius::FLAG_CHECK_RADIUS, smysql::log_file, table_logistic_radius::LOGIN_MODEM, mysql_tables::logistic, LOGISTIC_RADIUS_LOGIN_SIZE, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_MORE_THAN_ONE, MYSQL_INTERFACE_NOT_FOUND, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, table_logistic_radius::RADIUS_LOGIN, smysql::result, SQL_REQUEST_SIZE, and sql_select().

Referenced by look_up_logistic().

int load_options struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config
 

Load the content of table 'options'.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. The first element of the entry 'options' must have the following definitions (that will be used for SQL query):
  • profile_optionnel
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_NOT_FOUND
  • MYSQL_INTERFACE_TOO_MANY_ITEMS
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
Remarks:
The result is copied into the entry 'options' of the structure pointed by 'mysql_tables'.

Definition at line 856 of file mysql_interface.c.

References COMMENT_SIZE, smysql::debug, smysql::log_file, MAX_PROFILE_OPTIONS, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_NOT_FOUND, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_TOO_MANY_ITEMS, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, mysql_tables::option_number, OPTION_TYPE_SIZE, OPTION_VALUE_SIZE, OPTIONNAL_PROFILE_SIZE, mysql_tables::options, smysql::result, SQL_REQUEST_SIZE, and sql_select().

Referenced by load_context(), and main().

int load_pool struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config
[static]
 

Load the content of table 'pool'.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. Entry 'pool' must have the following definitions (that will be used for SQL query):
  • ip_lease_id
  • abonnes_id
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following values:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_NOT_FOUND
  • MYSQL_INTERFACE_MORE_THAN_ONE
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
  • MYSQL_INTERFACE_NO_TIMESTAMP
Remarks:
The result is copied into the entry 'pool' of the structure pointed by 'mysql_tables'.

Definition at line 1186 of file mysql_interface.c.

References table_pool::abonnes_id, smysql::debug, table_pool::expiration, get_unix_timestamp(), table_pool::ip, IP_ADDRESS_STR_SIZE, table_pool::ip_lease_id, smysql::log_file, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_MORE_THAN_ONE, MYSQL_INTERFACE_NO_TIMESTAMP, MYSQL_INTERFACE_NOT_FOUND, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_NO_TIMESTAMP, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, mysql_tables::pool, table_pool::pool_id, smysql::result, global_config::sql_expiration_security_delay, SQL_REQUEST_SIZE, and sql_select().

Referenced by find_ip_in_vlan_pool(), and get_ip_from_pool().

int load_vlan struct smysql   mysql_info,
struct smysql   mysql_info_pool,
struct mysql_tables   mysql_tables,
struct global_config   config
[static]
 

Load the content of table 'vlan'.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration. This handler should point to the "read only" database.
mysql_info_pool  Pointer to a 'smysql' data structure that contains the MySql configuration. This handler should point to the "read/write" database.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. Entry 'vlan' must have the following definitions (that will be used for SQL query):
  • vlan_tag
  • vlan_gateway
Note that the IP address "vlan_gateway" may be the IP address of the client (sometimes, the client sends the DHCP request directly to the server).
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_NOT_FOUND
  • MYSQL_INTERFACE_MORE_THAN_ONE
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
Remarks:
  • The result is copied into the entry 'vlan' of the structure pointed by 'mysql_tables'.
  • This function deals with UNICASTS or BROADCASTS from clients.
    • Broadcast: The IP address "vlan.vlan_gateway" is the IP address of the gateway that forwarded the packet from the client to the serveur.
    • Unicast: The IP address "vlan.vlan_gateway" is the IP address of the client. It could be a statically allocated IP (from the "read only" database). Or, it could be a dynamically allocated IP (from the "read/write" database).
  • The parameter "vlan_tag" has been removed because ALCATEL DSLAMs don't send the VLAN information. The happened the 7/6/2006.

Definition at line 297 of file mysql_interface.c.

References ACCT_IDENTIFIER_SIZE, table_vlan::comment, COMMENT_SIZE, smysql::debug, get_unix_timestamp(), LABEL_SIZE, table_vlan::libelle, smysql::log_file, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_MORE_THAN_ONE, MYSQL_INTERFACE_NO_TIMESTAMP, MYSQL_INTERFACE_NOT_FOUND, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_NO_TIMESTAMP, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, table_vlan::offer_timeout, OPTIONNAL_PROFILE_SIZE, table_vlan::profile_optionnel, table_vlan::radius_identifiant, smysql::result, global_config::sql_expiration_security_delay, SQL_REQUEST_SIZE, sql_select(), mysql_tables::vlan, table_vlan::vlan_gateway, table_vlan::vlan_id, and table_vlan::vlan_tag.

Referenced by load_context().

int my_fake_syslog const char *    file,
const char *    fmt,
...   
[static]
 

Fake logging service (used if logging is not activated).

Author:
Denis BEURIVE

Definition at line 69 of file mysql_interface.c.

Referenced by blackhole_abonne(), find_ip_in_vlan_pool(), get_ip_from_pool(), load_abonne_ip(), load_abonnes(), load_context(), load_ip_lease(), load_logistic(), load_options(), load_pool(), load_vlan(), mydns_init(), nack_flag_abonne(), release_ip_from_pool(), remove_autoconf_bh(), send_to_mydns(), send_to_radonline(), set_flag_check_radius(), signal_unknown_mac_address(), try_find_and_reserve_ip_from_pool(), and try_reserve_ip_from_pool().

int mydns_init struct smysql   mysql_info
 

Initialize the MyDns service.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration. This structure points to the 'mydns' database.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function returns the value 1.

Definition at line 2884 of file mysql_interface.c.

References smysql::debug, smysql::log_file, my_fake_syslog(), smysql::my_syslog, mydns_id, MYSQL_CONNECTION_LOST, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, smysql::result, SQL_REQUEST_SIZE, and sql_select().

Referenced by main().

int nack_flag_abonne struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config,
unsigned long int    new_value
 

Update the value of the field 'nack_flag' of the table 'abonnes'.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. The following information must be set :
  • abonnes.abonnes_id
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
new_value  New value for the field 'nack_flag'.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
  • MYSQL_INTERFACE_NOT_FOUND
  • MYSQL_INTERFACE_MORE_THAN_ONE

Definition at line 3763 of file mysql_interface.c.

References mysql_tables::abonnes, table_abonnes::abonnes_id, smysql::debug, smysql::log_file, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_MORE_THAN_ONE, MYSQL_INTERFACE_NOT_FOUND, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, SQL_REQUEST_SIZE, and sql_update().

Referenced by find_ip_and_reply().

int release_ip_from_pool struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config
 

Release IP from pool.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. Entry 'pool' must have the following definitions (that will be used for SQL query):
  • ip_lease_id
  • abonnes_id
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
  • MYSQL_INTERFACE_NO_TIMESTAMP

Definition at line 1666 of file mysql_interface.c.

References table_pool::abonnes_id, smysql::debug, get_unix_timestamp(), table_pool::ip_lease_id, smysql::log_file, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_NO_TIMESTAMP, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_NO_TIMESTAMP, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, mysql_tables::pool, SQL_REQUEST_SIZE, and sql_update().

Referenced by find_ip_and_reply().

int remove_autoconf_bh struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config
 

Set a client's profile to "STANDARD".

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. The following information must be set :
  • abonnes.abonnes_id
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
  • MYSQL_INTERFACE_MORE_THAN_ONE

Definition at line 3449 of file mysql_interface.c.

References mysql_tables::abonnes, table_abonnes::abonnes_id, smysql::debug, smysql::log_file, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_MORE_THAN_ONE, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, SQL_REQUEST_SIZE, and sql_update().

Referenced by main().

int send_to_mydns struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
char *    ip,
int    action,
struct global_config   config
 

Send a ticket (START or STOP) into the MyDns database.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration. This structure points to the 'mydns' database.
mysql_tables  Pointer to a 'mysql_tables' data structure that contains the loaded context.
ip  Pointer to a zero terminated string of characters that represents the IP address of the user.
action  This integer represents the action to execute. Its value could be:
  • MYDNS_START
  • MYDNS_STOP
config  Pointer to a 'global_config' data structure that represents the global server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following values:
  • MYSQL_REQUEST_SKIPED
  • MYSQL_CONNECTION_LOST
  • MYSQL_RECONNECTION_FAILED
  • MYSQL_SQL_PROBLEM
  • MYSQL_UNEXPECTED_ERROR
Remarks:
You must all the function mydns_init() first! This will set the variable mydns_id to the correct value.

Definition at line 2992 of file mysql_interface.c.

References mysql_tables::abonnes, smysql::debug, smysql::log_file, my_fake_syslog(), smysql::my_syslog, mydns_id, MYDNS_LOGIN_SIZE, MYDNS_START, MYDNS_STOP, MYSQL_CONNECTION_LOST, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, sql_delete(), sql_insert(), and SQL_REQUEST_SIZE.

Referenced by find_ip_and_reply().

int send_to_radonline struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
char *    ip,
int    action,
struct global_config   config
 

Send a ticket (START or STOP) into the Radonline database.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration. This structure points to the 'radonline' database.
mysql_tables  Pointer to a 'mysql_tables' data structure that contains the loaded context.
ip  Pointer to a zero terminated string of characters that represents the IP address of the user.
action  This integer represents the action to execute. Its value could be:
  • RADONLINE_START
  • RADONLINE_STOP
config  Pointer to a 'global_config' data structure that represents the global server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following values:
  • MYSQL_REQUEST_SKIPED
  • MYSQL_CONNECTION_LOST
  • MYSQL_RECONNECTION_FAILED
  • MYSQL_SQL_PROBLEM
  • MYSQL_UNEXPECTED_ERROR
Remarks:
This function checks the values of the following records:
  • ogistic.radonline_acct_identifier
  • ogistic.login_modem
If these records are defined, special values are assiged to ACCT_IDENTIFIER and LOGIN_MODEM.

Definition at line 2586 of file mysql_interface.c.

References mysql_tables::abonnes, smysql::debug, smysql::log_file, mysql_tables::logistic, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, NASPORT_SIZE, RADONLINE_START, RADONLINE_STOP, sql_delete(), sql_insert(), SQL_REQUEST_SIZE, and mysql_tables::vlan.

Referenced by find_ip_and_reply().

int set_flag_check_radius struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config
 

Set the flag FLAG_CHECK_RADIUS to the value 1.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. The following information must be set :
  • logistic.LOGIN_MODEM
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
  • MYSQL_INTERFACE_NOT_FOUND
  • MYSQL_INTERFACE_MORE_THAN_ONE

Definition at line 3538 of file mysql_interface.c.

References smysql::debug, smysql::log_file, table_logistic_radius::LOGIN_MODEM, mysql_tables::logistic, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_MORE_THAN_ONE, MYSQL_INTERFACE_NOT_FOUND, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, SQL_REQUEST_SIZE, and sql_update().

Referenced by look_up_logistic().

int signal_unknown_mac_address struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config
 

Insert a couple (login_modem,mac_address) into the LOGISTIC_RADIUS table.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. The following information must be set :
  • logistic.LOGIN_MODEM
  • logistic.MAC_ADDRESS
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_UNEXPECTED_ERROR

Definition at line 3629 of file mysql_interface.c.

References smysql::debug, smysql::log_file, table_logistic_radius::LOGIN_MODEM, mysql_tables::logistic, table_logistic_radius::MAC_ADDRESS, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, sql_insert(), and SQL_REQUEST_SIZE.

Referenced by look_up_logistic().

int try_find_and_reserve_ip_from_pool struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config,
unsigned long int    timeout
[static]
 

Update an element in the table 'pool'. Try to find and reserve an IP in the pool.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. Entry 'pool' must have the following definitions (that will be used for SQL query):
  • abonnes_id
  • ip_lease_id
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
timeout  This timeout is used to ensure that some operations gave time to terminate.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
  • MYSQL_INTERFACE_NO_TIMESTAMP

Definition at line 1521 of file mysql_interface.c.

References table_pool::abonnes_id, smysql::debug, get_unix_timestamp(), table_pool::ip_lease_id, smysql::log_file, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_NO_TIMESTAMP, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_NO_TIMESTAMP, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, mysql_tables::pool, SQL_REQUEST_SIZE, and sql_update().

Referenced by get_ip_from_pool().

int try_reserve_ip_from_pool struct smysql   mysql_info,
struct mysql_tables   mysql_tables,
struct global_config   config,
unsigned long int    timeout
[static]
 

Update an element in the table 'pool'. Try to reserve an IP in the pool.

Author:
Denis BEURIVE
Parameters:
mysql_info  Pointer to a 'smysql' data structure that contains the MySql configuration.
mysql_tables  Pointer to a 'mysql_tables' data structure that represents the databases model. Entry 'pool' must have the following definitions (that will be used for SQL query):
  • pool_id
  • abonnes_id
config  Pointer to a 'global_config' data structure that contains the main server's configuration.
timeout  Timeout for the expiration time. The timeout's value could be associated to:
  • An offer (reply to a DISCOVER).
  • An ACK (reply to a REQUEST).
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function may return one of the following value:
  • MYSQL_INTERFACE_REQUEST_SKIPED
  • MYSQL_INTERFACE_CONNECTION_LOST
  • MYSQL_INTERFACE_RECONNECTION_FAILED
  • MYSQL_INTERFACE_SQL_PROBLEM
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
  • MYSQL_INTERFACE_NO_TIMESTAMP

Definition at line 1386 of file mysql_interface.c.

References table_pool::abonnes_id, smysql::debug, get_unix_timestamp(), smysql::log_file, my_fake_syslog(), smysql::my_syslog, MYSQL_CONNECTION_LOST, MYSQL_INTERFACE_CONNECTION_LOST, MYSQL_INTERFACE_NO_TIMESTAMP, MYSQL_INTERFACE_RECONNECTION_FAILED, MYSQL_INTERFACE_REQUEST_SKIPED, MYSQL_INTERFACE_SQL_PROBLEM, MYSQL_INTERFACE_UNEXPECTED_ERROR, MYSQL_NO_TIMESTAMP, MYSQL_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, mysql_tables::pool, table_pool::pool_id, global_config::sql_expiration_security_delay, SQL_REQUEST_SIZE, and sql_update().

Referenced by get_ip_from_pool().


Generated on Mon Jun 19 12:31:06 2006 for MyDhcp_V2 by doxygen1.2.15