Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

find_ip_and_reply.c File Reference

#include <stdio.h>
#include "find_ip_and_reply.h"
#include "packets_operations.h"
#include "logging.h"
#include "packets.h"
#include "strings_utils.h"

Go to the source code of this file.

Functions

unsigned int get_lease_from_context (struct mysql_tables *mysql_tables)
 Extract the ACK lease from a loaded context. More...

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

This file implements the most important part of the algorithm. It uses all the other modules. It is reponsible for searching client's IP and sending DHCP requests.

Definition in file find_ip_and_reply.c.


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().

unsigned int get_lease_from_context struct mysql_tables   mysql_tables [static]
 

Extract the ACK lease from a loaded context.

Author:
Denis BEURIVE
Parameters:
mysql_tables  Pointer to a 'mysql_tables' dtat structure that contains the loaded context.
Returns:
Upon successfull completion, the function returns the lease value. Otherwize, the function returns the value (unsigned int)(-1).
Remarks:
Make sure that the context has been loaded! Otherwize you will have unpredictable consequences.

Definition at line 24 of file find_ip_and_reply.c.

References MAX_PROFILE_OPTIONS, mysql_tables::option_number, and mysql_tables::options.

Referenced by find_ip_and_reply().


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