Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

find_ip_and_reply.h File Reference

#include <netinet/in.h>
#include "packets_data.h"
#include "mysql_interface.h"

Go to the source code of this file.

Defines

#define DHCP_INVALID_MESSAGE_TYPE   -100
 Return value for the function find_ip_and_reply(). Invailid DHCP message type.

#define DHCP_NO_DYNAMIC_IP_FOUND   -101
 Return value for the function find_ip_and_reply(). Could not find any available IP address.

#define DHCP_LEASE_INCONSTANCY   -102
 Return value for the function find_ip_and_reply(). An unexpected error occured while trying to retrieve the lease value.

#define DHCP_NO_DYNAMIC_IP_FOUND_RELEASE   -103
 Return value for the function find_ip_and_reply(). The server received a DHCP RELEASE from a user that got a dynamic IP address. But the server could not find any busy IP address associated to this user within the pool. This is not a problem. We just ignore this event.

#define DHCP_RADONLINE_MYSQL_SQL_PROBLEM   -104
 Return value for the function find_ip_and_reply(). Could not send a (START or STOP) ticket to Radonline. Some SQL error occured.

#define DHCP_RADONLINE_MYSQL_UNEXPECTED_ERROR   -105
 Return value for the function find_ip_and_reply(). Could not send a (START or STOP) ticket to Radonline. An unexpected SQL error occured.

#define DHCP_MYDNS_MYSQL_SQL_PROBLEM   -106
 Return value for the function find_ip_and_reply(). Could not send a (START or STOP) ticket to MyDqs database. Some SQL error occured.

#define DHCP_MYDNS_MYSQL_UNEXPECTED_ERROR   -107
 Return value for the function find_ip_and_reply(). Could not send a (START or STOP) ticket to MyDqs database. An unexpected SQL error occured.


Functions

int find_ip_and_reply (struct smysql *mysql_info_read, struct smysql *mysql_info_read_write, struct smysql *mysql_radonline, struct smysql *mysql_mydns, struct mysql_tables *mysql_tables, struct dhcp_packet *packet, struct global_config *config, int sck, unsigned long int broadcast, unsigned long int server_ip, struct sockaddr_in *client_address)
 Try to find an IP address for the client and send a DHCP response. More...


Detailed Description

Header file for the big functionnality that finds the IP address and reply to the client. Return values start from -100.

Definition in file find_ip_and_reply.h.


Function Documentation

int find_ip_and_reply struct smysql   mysql_info_read,
struct smysql   mysql_info_read_write,
struct smysql   mysql_radonline,
struct smysql   mysql_mydns,
struct mysql_tables   mysql_tables,
struct dhcp_packet   packet,
struct global_config   config,
int    sck,
unsigned long int    broadcast,
unsigned long int    server_ip,
struct sockaddr_in *    client_address
 

Try to find an IP address for the client and send a DHCP response.

Author:
Denis BEURIVE
Parameters:
mysql_info_read  Pointer to a 'smysql' data structure that contains the MySql configuration for the 'read only' database.
mysql_info_read_write  Pointer to a 'smysql' data structure that contains the MySql configuration for the 'read/write' database.
mysql_radonline  Pointer to a 'smysql' data structure that contains the MySql configuration for the 'Radonline' database.
mysql_mydns  Pointer to a 'smysql' data structure that contains the MySql configuration for the 'MyDns' database.
mysql_tables  pointer to a structure that contains the client's context (all database tables).
packet  Pointer to a 'dhcp_packet' data structure that contains the DHCP packet.
config  Pointer to a 'global_config' data structure that contains the main configuration for the server.
sck  Descriptor og the socket used by the server to receive requests, and reply to these requests.
broadcast  4 bytes long integer that contains the binary representation (in network byte order) of the broadcast IP address.
server_ip  4 bytes long integer that contains the binary representation (in network byte order) of the server IP address.
client_address  client_address Pointer to a 'sockaddr_in' data structure that contains the internet address of the incoming packet's sender. If the configuration tag 'enable-broadcast-responses' is set to "yes", then the parameter 'client_address' is never used (since the server always send broadcasts).
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_MORE_THAN_ONE
  • MYSQL_INTERFACE_UNEXPECTED_ERROR
  • MYSQL_INTERFACE_NO_TIMESTAMP
  • MYSQL_INTERFACE_NO_LEASE_ID
  • MYSQL_INTERFACE_NOT_FOUND
  • DHCP_NO_DYNAMIC_IP_FOUND
  • DHCP_INVALID_MESSAGE_TYPE
  • DHCP_LEASE_INCONSTANCY
  • DHCP_NO_DYNAMIC_IP_FOUND_RELEASE
  • DHCP_RADONLINE_MYSQL_SQL_PROBLEM
  • DHCP_RADONLINE_MYSQL_UNEXPECTED_ERROR
  • DHCP_MYDNS_MYSQL_SQL_PROBLEM
  • DHCP_MYDNS_MYSQL_UNEXPECTED_ERROR
Remarks:
  • Make sure to call function packets_parse_options() before (see documentation for function packets_parse_options(), which needs some initialisations).
  • The context should have been loaded first using the function load_context().
  • A fix has been made in order to avoid MyDns manipulation for the VIDEO VCI. The VCI number is hard coded.

Definition at line 117 of file find_ip_and_reply.c.

References mysql_tables::abonne_ip, mysql_tables::abonnes, table_abonnes::abonnes_id, dhcp_packet::ctrl, global_config::debug, DHCP_INVALID_MESSAGE_TYPE, DHCP_LEASE_INCONSTANCY, DHCP_MYDNS_MYSQL_SQL_PROBLEM, DHCP_MYDNS_MYSQL_UNEXPECTED_ERROR, DHCP_NO_DYNAMIC_IP_FOUND, DHCP_NO_DYNAMIC_IP_FOUND_RELEASE, DHCP_RADONLINE_MYSQL_SQL_PROBLEM, DHCP_RADONLINE_MYSQL_UNEXPECTED_ERROR, DHCPDISCOVER, DHCPINFORM, DHCPRELEASE, DHCPREQUEST, DYNAMIC_IP, find_ip_in_vlan_pool(), get_ip_from_pool(), get_lease_from_context(), mysql_tables::ip_lease, load_abonne_ip(), global_config::log_file, table_abonnes::login_radius, my_syslog(), MYDNS_START, MYDNS_STOP, MYSQL_CONNECTION_LOST, 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_RECONNECTION_FAILED, MYSQL_REQUEST_SKIPED, MYSQL_SQL_PROBLEM, MYSQL_UNEXPECTED_ERROR, nack_flag_abonne(), packets_get_message_type(), packets_get_vlan_id(), packets_send_ack(), packets_send_nack(), packets_send_offer(), mysql_tables::pool, RADONLINE_START, RADONLINE_STOP, release_ip_from_pool(), reply_to_inform(), send_to_mydns(), send_to_radonline(), STATIC_IP, and mysql_tables::vlan.

Referenced by main().


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