Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

packets_operations.h File Reference

#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include "tables.h"
#include "packets.h"
#include "logging.h"

Go to the source code of this file.

Defines

#define DYNAMIC_IP   0
 This value defines a dynamic IP address (that should be tacken from the dynamic pool).

#define STATIC_IP   1
 This value defines a static IP address (that should be tacken from the static pool).


Functions

int packets_send_offer (struct dhcp_packet *p, struct mysql_tables *mysql_tables, char *ip, unsigned long int broadcast, unsigned long int server_ip, int socket_desc, struct sockaddr_in *client_address, int tip)
 Send a DHCPOFFER and log the output packet. More...

int packets_send_ack (struct dhcp_packet *p, struct mysql_tables *mysql_tables, char *ip, unsigned long int broadcast, unsigned long int server_ip, int socket_desc, struct sockaddr_in *client_address, int tip)
 Send a DHCPACK in response to a REQUEST and log the output packet. More...

int packets_send_nack (struct dhcp_packet *p, struct mysql_tables *mysql_tables, char *ip, unsigned long int broadcast, unsigned long int server_ip, int socket_desc, struct sockaddr_in *client_address)
 Send a DHCPNAK in response to a REQUEST and log the output packet. More...

int packets_send_dummy_nak (struct dhcp_packet *p, struct mysql_tables *mysql_tables, char *ip, unsigned long int broadcast, unsigned long int server_ip, int socket_desc, struct sockaddr_in *client_address)
 Send a dummy DHCPNAK and log the output packet. More...

int reply_to_inform (struct dhcp_packet *p, struct mysql_tables *mysql_tables, unsigned long int broadcast, unsigned long int server_ip, int socket_desc, struct sockaddr_in *client_address)
 Send a DHCPACK as response to an INFORM. More...

int log_profile (const char *file, const char *mes, const struct opt *profile)
 Log a packet's profile (list of options) in a human readables format. More...


Detailed Description

Header file for the high level DHCP packet manipulation module (packets_operations.c).

Definition in file packets_operations.h.


Function Documentation

int log_profile const char *    file,
const char *    mes,
const struct opt   profile
 

Log a packet's profile (list of options) in a human readables format.

Author:
Denis BEURIVE
Parameters:
file  Pointer to a zero terminated string of characters that represents the path to the log file.
mes  Pointer to a zero terminated string of characters that represents a text that will be printed before the profile.
profile  pointer to a opt data structure that contains the profile to print.
Returns:
Upon successful completion, the function returns the value 0. Othrwise, the function returns the value 1.

Definition at line 719 of file packets_operations.c.

References dater().

int packets_send_ack struct dhcp_packet   p,
struct mysql_tables   mysql_tables,
char *    ip,
unsigned long int    broadcast,
unsigned long int    server_ip,
int    socket_desc,
struct sockaddr_in *    client_address,
int    tip
 

Send a DHCPACK in response to a REQUEST and log the output packet.

Author:
Denis BEURIVE
Parameters:
p  Pointer to the incoming packet (should be a DHCP REQUEST).
mysql_tables  pointer to a 'mysql_tables' data structure that contains the loaded client's context.
ip  Pointer to a zero terminated string of characters that represents the client's IP address.
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.
socket_desc  Socket descriptor of the DHCP server.
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 sends broadcasts).
tip  Flag that indicates wether the IP address should be taken from the STATIC pool or the dynamic pool. Values can be:
Returns:
Upon successful completion, the function returns the value 0. Otherwise, the function returns the value 1.

Definition at line 520 of file packets_operations.c.

References mysql_tables::abonne_ip, add_option_to_profile(), BOOTREPLY, global_config::broadcast_mode, context2profile(), global_config::csv_file, dhcp_packet::ctrl, global_config::debug, global_config::debug_file, DHCPACK_HEXA, global_config::dumper_mode, DYNAMIC_IP, table_ip_lease::gateway, table_abonne_ip::gateway, mysql_tables::ip_lease, global_config::log_file, my_syslog(), packet_dump(), packets_clear(), packets_close_option(), packets_get_bin_chaddr(), packets_get_bin_ciaddr(), packets_get_bin_giaddr(), packets_get_flags(), packets_get_hlen(), packets_get_htype(), packets_get_secs(), packets_get_xid(), packets_set_bin_ciaddr(), packets_set_bin_giaddr(), packets_set_chaddr(), packets_set_flags(), packets_set_hlen(), packets_set_hops(), packets_set_htype(), packets_set_op(), packets_set_option(), packets_set_secs(), packets_set_siaddr(), packets_set_xid(), packets_set_yiaddr(), global_config::server_ip_seen_by_client, STATIC_IP, table_ip_lease::subnet, table_abonne_ip::subnet, op_control::taille, and TARGET_PORT.

Referenced by find_ip_and_reply().

int packets_send_dummy_nak struct dhcp_packet   p,
struct mysql_tables   mysql_tables,
char *    ip,
unsigned long int    broadcast,
unsigned long int    server_ip,
int    socket_desc,
struct sockaddr_in *    client_address
 

Send a dummy DHCPNAK and log the output packet.

Author:
Denis BEURIVE
Parameters:
p  Pointer to the incoming packet (should be a DHCP REQUEST).
mysql_tables  pointer to a 'mysql_tables' data structure that contains the loaded client's context.
ip  Pointer to a zero terminated string of characters that represents the client's IP address.
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.
socket_desc  Socket descriptor of the DHCP server.
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 sends broadcasts).
Returns:
Upon successful completion, the function returns the value 0. Otherwise, the function returns the value 1.

Definition at line 1084 of file packets_operations.c.

References global_config::log_file, my_syslog(), and packets_send_nack().

Referenced by main().

int packets_send_nack struct dhcp_packet   p,
struct mysql_tables   mysql_tables,
char *    ip,
unsigned long int    broadcast,
unsigned long int    server_ip,
int    socket_desc,
struct sockaddr_in *    client_address
 

Send a DHCPNAK in response to a REQUEST and log the output packet.

Author:
Denis BEURIVE
Parameters:
p  Pointer to the incoming packet (should be a DHCP REQUEST).
mysql_tables  pointer to a 'mysql_tables' data structure that contains the loaded client's context.
ip  Pointer to a zero terminated string of characters that represents the client's IP address.
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.
socket_desc  Socket descriptor of the DHCP server.
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 sends broadcasts).
Returns:
Upon successful completion, the function returns the value 0. Otherwise, the function returns the value 1.

Definition at line 921 of file packets_operations.c.

References add_option_to_profile(), BOOTREPLY, global_config::broadcast_mode, clear_profile(), global_config::csv_file, dhcp_packet::ctrl, global_config::debug, global_config::debug_file, DHCPNAK_HEXA, global_config::dumper_mode, global_config::log_file, my_syslog(), packet_dump(), packets_clear(), packets_close_option(), packets_get_bin_chaddr(), packets_get_bin_ciaddr(), packets_get_bin_giaddr(), packets_get_flags(), packets_get_hlen(), packets_get_htype(), packets_get_secs(), packets_get_xid(), packets_set_bin_ciaddr(), packets_set_bin_giaddr(), packets_set_chaddr(), packets_set_flags(), packets_set_hlen(), packets_set_hops(), packets_set_htype(), packets_set_op(), packets_set_option(), packets_set_secs(), packets_set_siaddr(), packets_set_xid(), packets_set_yiaddr(), global_config::server_ip_seen_by_client, op_control::taille, and TARGET_PORT.

Referenced by find_ip_and_reply(), and packets_send_dummy_nak().

int packets_send_offer struct dhcp_packet   p,
struct mysql_tables   mysql_tables,
char *    ip,
unsigned long int    broadcast,
unsigned long int    server_ip,
int    socket_desc,
struct sockaddr_in *    client_address,
int    tip
 

Send a DHCPOFFER and log the output packet.

Author:
Denis BEURIVE
Parameters:
p  Pointer to the incoming packet (should be a DHCP DISCOVER).
mysql_tables  pointer to a 'mysql_tables' data structure that contains the loaded client's context.
ip  Pointer to a zero terminated string of characters that represents the IP address of the user.
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.
socket_desc  Socket descriptor of the DHCP server.
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).
tip  Flag that indicates wether the IP address should be taken from the STATIC pool or the dynamic pool. Values can be:
Returns:
Upon successful completion, the function returns the value 0. Otherwise, the function returns the value 1.

Definition at line 309 of file packets_operations.c.

References mysql_tables::abonne_ip, add_option_to_profile(), BOOTREPLY, global_config::broadcast_mode, context2profile(), global_config::csv_file, dhcp_packet::ctrl, global_config::debug, global_config::debug_file, DHCPOFFER_HEXA, global_config::dumper_mode, DYNAMIC_IP, table_ip_lease::gateway, table_abonne_ip::gateway, mysql_tables::ip_lease, global_config::log_file, my_syslog(), packet_dump(), packets_clear(), packets_close_option(), packets_get_bin_chaddr(), packets_get_bin_giaddr(), packets_get_flags(), packets_get_hlen(), packets_get_htype(), packets_get_secs(), packets_get_xid(), packets_set_bin_giaddr(), packets_set_chaddr(), packets_set_flags(), packets_set_hlen(), packets_set_hops(), packets_set_htype(), packets_set_op(), packets_set_option(), packets_set_secs(), packets_set_siaddr(), packets_set_xid(), packets_set_yiaddr(), global_config::server_ip_seen_by_client, STATIC_IP, table_ip_lease::subnet, table_abonne_ip::subnet, op_control::taille, and TARGET_PORT.

Referenced by find_ip_and_reply().

int reply_to_inform struct dhcp_packet   p,
struct mysql_tables   mysql_tables,
unsigned long int    broadcast,
unsigned long int    server_ip,
int    socket_desc,
struct sockaddr_in *    client_address
 

Send a DHCPACK as response to an INFORM.

Author:
Denis BEURIVE
Parameters:
p  Pointer to the incoming packet (should be a DHCP INFORM).
mysql_tables  pointer to a 'mysql_tables' data structure that contains the loaded client's context.
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.
socket_desc  Socket descriptor of the DHCP server.
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. Otherwise, the function returns the value 1.

Definition at line 769 of file packets_operations.c.

References add_option_to_profile(), BOOTREPLY, global_config::broadcast_mode, context2profile(), global_config::csv_file, dhcp_packet::ctrl, global_config::debug, global_config::debug_file, DHCPACK_HEXA, global_config::dumper_mode, global_config::log_file, my_syslog(), packet_dump(), packets_clear(), packets_close_option(), packets_get_bin_chaddr(), packets_get_bin_ciaddr(), packets_get_bin_giaddr(), packets_get_flags(), packets_get_hlen(), packets_get_htype(), packets_get_secs(), packets_get_xid(), packets_set_bin_ciaddr(), packets_set_bin_giaddr(), packets_set_chaddr(), packets_set_flags(), packets_set_hlen(), packets_set_hops(), packets_set_htype(), packets_set_op(), packets_set_option(), packets_set_secs(), packets_set_siaddr(), packets_set_xid(), remove_option_from_profile(), global_config::server_ip_seen_by_client, op_control::taille, and TARGET_PORT.

Referenced by find_ip_and_reply().


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