//******************************************** // Hash_PCSA.h // ------------------------------------------- // Data types and function declarations related // to PCSA records, which are stored in a hash // table // // Author: Leiwen Deng // Date: 12/10/2005 //******************************************** #ifndef HASH_PCSA_H #define HASH_PCSA_H #include "PCSA.h" #include using namespace std; #define MD5_DIGEST_CHARS 16 // length in bytes of an MD5 key //******************************************** // MD5_KEY structure // ------------------------------------------- // It stores a MD5 key and defines several // methods used by the hash table template //******************************************** struct MD5_KEY { char key[MD5_DIGEST_CHARS]; // the key data // The default constructor MD5_KEY( void ); // A copy constructor that allows the "const char *" type to be converted to MD5_KEY type automatically MD5_KEY( const char key_in[MD5_DIGEST_CHARS] ); // The evaluation method that pass value from "const char *" to MD5_KEY MD5_KEY& operator=( const char rkey[MD5_DIGEST_CHARS] ); }; // The equal comparison method for MD5_KEY type bool operator==( const MD5_KEY &key1, const MD5_KEY &key2 ); // Print the content of a MD5 key to a static string, input type is "MD5_KEY" const char * Print( const MD5_KEY &key ); // Print the content of a MD5 key to a static string, input type is "const char *" const char * MD5_Hex( const char md5key[MD5_DIGEST_CHARS] ); // the set used to record the first 'MAX_AC_SET_SIZE' unique IPs typedef set AC_SET; //******************************************** // PCSA_RECORD structure // ------------------------------------------- // Definition of the PCSA record. // Every PCSA record is associated with an // object cached by SQUID //******************************************** struct PCSA_RECORD{ u_short squid_refcount; // the reference count maintained by SQUID int refcount; // the reference count observed by AE PCSA * pcsa; // pointer to the PCSA counting unit AC_SET * ac_set; // pointer to a set used for accurate counting // The constructor PCSA_RECORD( void ); // The destructor ~PCSA_RECORD( void ); // Retrieve the number of unique client IPs that refer to this entry int Cardinality( void ) const; }; // Print the content of a PCSA record to a static string const char * Print( const PCSA_RECORD &pcsa_record ); // A hash function for MD5_KEY type int HashMD5( const MD5_KEY &key ); #endif