00001
00002
00003
00004
00005 #ifdef __cplusplus
00006 extern "C" {
00007 #endif
00008
00009 #ifndef PACKETS_HEADER_FILE
00010 #define PACKETS_HEADER_FILE
00011
00012 #include <stdio.h>
00013 #include <string.h>
00014 #include <sys/socket.h>
00015 #include <netinet/in.h>
00016 #include <arpa/inet.h>
00017 #include <errno.h>
00018 #include <stdarg.h>
00019
00020 #include "packets_data.h"
00021 #include "conversion.h"
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #define DHCP_P_STR_HADDR_SIZE 48
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #define DHCP_P_STR_HADDR_SIZE_EXACT 33
00046
00047
00048
00049
00050
00051 #define DHCP_P_STR_SNAME_SIZE 65
00052
00053
00054
00055
00056
00057 #define DHCP_P_STR_FILE_SIZE 129
00058
00059
00060
00061 #define OPTIONS_OPTION_VALUE_SIZE 256
00062
00063
00064
00065
00066
00067 void packet_logging_service (int dbg,
00068 char *logfile,
00069 int (*logger) (const char *file, const char * fmt,...));
00070
00071 void packets_clear (struct dhcp_packet *p);
00072
00073 void packets_set_op (struct dhcp_packet *p, int op);
00074 void packets_set_htype (struct dhcp_packet *p, int htype);
00075 void packets_set_hlen (struct dhcp_packet *p, int hlen);
00076 void packets_set_hops (struct dhcp_packet *p, int hops);
00077 void packets_set_xid (struct dhcp_packet *p, unsigned long int xid);
00078 void packets_set_secs (struct dhcp_packet *p, unsigned short int secs);
00079 void packets_set_flags (struct dhcp_packet *p, unsigned short int flags);
00080 int packets_set_ciaddr (struct dhcp_packet *p, char *ciaddr);
00081 void packets_set_bin_ciaddr (struct dhcp_packet *p, unsigned long int ciaddr);
00082 int packets_set_yiaddr (struct dhcp_packet *p, char *yiaddr);
00083 int packets_set_siaddr (struct dhcp_packet *p, char *siaddr);
00084 int packets_set_giaddr (struct dhcp_packet *p, char *giaddr);
00085 void packets_set_bin_giaddr (struct dhcp_packet *p, unsigned long int giaddr);
00086 void packets_set_chaddr (struct dhcp_packet *p, char *chaddr);
00087 void packets_set_sname (struct dhcp_packet *p, char *sname);
00088 void packets_set_file (struct dhcp_packet *p, char *file);
00089
00090 unsigned char packets_get_op (struct dhcp_packet *p);
00091 unsigned char packets_get_htype (struct dhcp_packet *p);
00092 unsigned char packets_get_hlen (struct dhcp_packet *p);
00093 unsigned char packets_get_hops (struct dhcp_packet *p);
00094 unsigned long int packets_get_xid (struct dhcp_packet *p);
00095 unsigned short int packets_get_secs (struct dhcp_packet *p);
00096 unsigned short int packets_get_flags (struct dhcp_packet *p);
00097 char* packets_get_ciaddr (struct dhcp_packet *p);
00098 unsigned long int packets_get_bin_ciaddr (struct dhcp_packet *p);
00099 char* packets_get_yiaddr (struct dhcp_packet *p);
00100 char* packets_get_siaddr (struct dhcp_packet *p);
00101 char* packets_get_giaddr (struct dhcp_packet *p);
00102 unsigned long int packets_get_bin_giaddr (struct dhcp_packet *p);
00103 char* packets_get_chaddr (struct dhcp_packet *p);
00104 char* packets_get_chaddr_no_separator (struct dhcp_packet *p);
00105 char* packets_get_bin_chaddr (struct dhcp_packet *p);
00106 char* packets_get_sname (struct dhcp_packet *p);
00107 char* packets_get_file (struct dhcp_packet *p);
00108
00109 char* packets_get_node_id (struct dhcp_packet *p);
00110 unsigned char packets_get_shelf (struct dhcp_packet *p);
00111 unsigned char packets_get_numero_slot (struct dhcp_packet *p);
00112 unsigned char packets_get_numero_port (struct dhcp_packet *p);
00113 unsigned short int packets_get_vci (struct dhcp_packet *p);
00114 unsigned short int packets_get_vlan_id (struct dhcp_packet *p);
00115
00116 void packets_init_option_writer (struct dhcp_packet *p);
00117 void packets_options_clear (struct dhcp_packet *p);
00118 int packets_set_option (struct dhcp_packet *p, unsigned char option, char *value, int len);
00119 void packets_close_option (struct dhcp_packet *p);
00120
00121 void packets_init_option_reader (struct dhcp_packet *p);
00122 int packets_parse_options (struct dhcp_packet *p);
00123 int packets_get_option (struct dhcp_packet *p, int option, int *len, unsigned char **value);
00124 int packets_get_message_type (struct dhcp_packet *p);
00125 char* packets_get_subnet_mask (struct dhcp_packet *p);
00126
00127 void packet_init_dump_service();
00128 int packet_dump (struct dhcp_packet *p, char *file, char *csv, struct sockaddr_in *from, struct sockaddr_in *to);
00129 int check_packet_size (int size);
00130 void packet_set_taille (struct dhcp_packet *p, int taille);
00131
00132 char* packets_type_to_char (int type);
00133
00134 #endif
00135
00136
00137
00138
00139 #ifdef __cplusplus
00140 }
00141 #endif
00142
00143