//******************************************** // AE.h // ------------------------------------------- // The header file of the AE (Anti-pollution // Engine) // // Author: Leiwen Deng // Date: 12/10/2005 //******************************************** #ifndef AE_H #define AE_H #include "IPC.h" #include "AE_PCSA.h" // File names #define LOG_FILE_NAME "/usr/local/squid/var/logs/AE.log" #define STATISTIC_FILE_NAME "/usr/local/squid/var/logs/stat" #define CONFIG_FILE_NAME "/usr/local/squid/etc/AE.conf" #define SKETCH_PROGRAM "/usr/local/squid/sbin/IDS_Srev32" #define SKETCH_TEMP_FILE_NAME "/usr/local/squid/var/AE_data/Sketch.temp" #define SKETCH_INPUT_FILE_NAME "/usr/local/squid/var/AE_data/Sketch.input" #define SKETCH_OUTPUT_FILE_NAME "/usr/local/squid/var/AE_data/Sketch.output" #define SKETCH_LOG_FILE_NAME "/usr/local/squid/var/logs/Sketch.log" #define MAX_CONFIG_LINE_WIDTH 200 // maximum width of line in the configuration file #define SHM_AEM_KEY 4258 // key of the shared memory // AEM operation codes #define AEM_NO_OPERATION 0 #define AEM_SHOW_TABLE 1 #define AEM_SHOW_TABLE_STRUCTURE 2 // Global flag codes #define FLAG_RUN_SKETCH 0x1 #define FLAG_AE_BUSY 0x2 #define FLAG_PROCESS_AEM 0x4 #define FLAG_QUIT 0x8 #define FLAG_SKETCH_FEEDBACK 0x10 // The shared memory structure used for passing parameters from AEM tool struct SHM_AEM { int operation; // the operation code }; // The structure of system parameters struct SYS_AE_PARAMETER { FILE * log_file; // pointer to the log file FILE * sketch_input; // pointer to the SKETCH input file FILE * statistic_file; // pointer to the statistic file bool log_updated; // a flag indicates whether the log file is updated or not PCSA_MAIN pcsa_main; // PCSA parameters SHM_AEM * shm_aem; // pointer to the shared memory space to receive parameters from AEM int flag; // the global flags, each bit indicates a different flag pid_t sketch_pid; // the pid of the SKETCH module bool PCSA_enable; // a flag indicates whether the PCSA module is enabled bool SKETCH_enable; // a flag indicates whether the SKETCH module is enabled double SKETCH_delta; // a parameter for running the SKETCH program double SKETCH_gamma; // a parameter for running the SKETCH program int SKETCH_interval; // the time in seconds that indicates the period of triggering the SKETCH module bool statistic_enable; // whether to enable statistic module or not SYS_AE_PARAMETER( void ); // the constructor }; // Parse the configuration file of the AE void ParseConfiguration( void ); // The signal handler for SIGTERM void Sig_Term( int sig_num ); // The signal handler for SIGALRM void Sig_Alarm( int sig_num ); // The signal handler for SIGUSR1 void Sig_User1( int sig_num ); // The signal handler for SIGUSR2 void Sig_User2( int sig_num ); // Quit the AE module void Quit( void ); // Install the handler for the SKETCH module void Install_SKETCH_Handler( void ); // Append a record to the SKETCH input file based on the input access information void Append_SKETCH_Record( const ACCESS_INFO &access_info ); // Trigger the data processing of the SKETCH module void Run_SKETCH( void ); // Process the feedback from the SKETCH module void Process_SKETCH_Feedback( void ); // Install the handler for the AEM tool void Install_AEM_Handler( void ); // Process the operation specified by the AEM tool. void Process_AEM_operation( void ); // Update PCSA records according to the input access information void PCSA_Process( const ACCESS_INFO &access_info ); // Send a block-entry request to the AEI char SendBlockEntryRequest( const MD5_KEY &md5key ); // Send a block-client request to the AEI char SendBlockClientRequest( uint32 client_ip ); // Check the pending processes triggered by signals void CheckPendingProcess( void ); // Perform statistics based on void Statistic( const ACCESS_INFO &access_info ); #endif