//******************************************** // AEI.h // ------------------------------------------- // Data types and function declarations of the // AEI (AE Interface) module // // Author: Leiwen Deng // Date: 12/10/2005 //******************************************** #ifndef AEI_H #define AEI_H #include "IPC.h" // File names #define AE_PROGRAM "/usr/local/squid/sbin/AE" // The executable file name of the Anti-pollution Engine(AE) #define LOG_FILE_NAME "/usr/local/squid/var/logs/IPC_AE.log" #define BLOCKED_ENTRY_FILE_NAME "/usr/local/squid/var/logs/blocked_entry" #define BLOCKED_CLIENT_FILE_NAME "/usr/local/squid/var/logs/blocked_client" // Interval in times of printing block-entry events to log file #define BLOCK_ENTRY_PRINT_INTERVAL 10 // Interval in times of printing block-client events to log file #define BLOCK_CLIENT_PRINT_INTERVAL 100 typedef unsigned int uint32; // Record of a blocked entry typedef struct _BlockedEntry BlockedEntry; // Record of a blocked client typedef struct _BlockedClient BlockedClient; struct _BlockedEntry{ hash_link hash; int block_count; }; struct _BlockedClient{ hash_link hash; int block_count; }; // The structure of system parameters typedef struct{ FILE * ipc_read; FILE * ipc_write; FILE * log_file; char log_updated; pid_t AE_pid; hash_table * blocked_entry_table; hash_table * blocked_client_table; }SYS_PARAMETER; extern SYS_PARAMETER sys_parameter; // system parameters // ************* Begin ************* // Functions implemented in "main.c" // Spawn a program and open a pair of pipe file to communicate with it pid_t IPC_Open2( const char * filename, int * fd_read, int * fd_write ); // Initialize the AEI char Initialize_AE_Interface( void ); // Close the AEI char Close_AE_Interface( void ); // Send access information to the AE through the pipe char SendAccessInfo( const ACCESS_INFO * access_info ); // Send a storage release notification to the AE through the pipe char SendReleaseNotification( StoreEntry * entry ); // ************* End *************** // ************* Begin ************* // Functions implemented in "client_side.c" // Process the feedback from the AE module void Process_AE_Feedback( void ); // Initialized the hash tables of blocked entries and blocked clients void AEI_DB_Init( void ); // De-initialize the hash tables of blocked entries and blocked clients void AEI_DB_FreeMemory( void ); // Create a new entry in the table of the blocked entries BlockedEntry * BlockedEntryCreate( const cache_key * key ); // Delete an entry from the table of the blocked entries void BlockedEntryDelete( BlockedEntry * e ); // Look up an entry in the table of the blocked entries BlockedEntry * BlockedEntryFind( const cache_key * key ); // Dump all blocked entries to a file void DumpBlockedEntry( void ); // Create a new entry in the table of the blocked clients BlockedClient * BlockedClientCreate( uint32 client_ip ); // Delete an entry from the table of the blocked clients void BlockedClientDelete( BlockedClient * e ); // Look up an entry in the table of the blocked clients BlockedClient * BlockedClientFind( uint32 client_ip ); // Dump all blocked clients to a file void DumpBlockedClient( void ); // An enhanced version of "hash_join", which allows the size of the hash table to be doubled when necessary void hash_insert_link( hash_table * hid, hash_link * lnk ); // ************* End *************** #endif