UserDataBase Header Format:
---------------------------

                           1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	     	  Magic ID            |        Num Of Items           |	
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	 		       Length of Items			      				  |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

      Magic ID :   0xABAB - IP_PROFILE		
		   0xACAC - APP_PROFILE		
		   0xAAAA - GROUP_PROFILE	
		   0xBBBB - USER_PROFILE		
		   0xCCCC - FILTER_PROFILE	
		   0xDDDD - DEFAULT_FILTER	
		   0xFFFF - INVALID_MAGIC_ID


UserDataBase Fields:
--------------------

                           1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	     Magic ID (0xABAB)        |        Num Of Items           |	
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	 		       Length of Items			      				  |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	    UserDataBase Enabled      |	    Default Filter Action     |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |								      							  |
      |	      List of IP Addresses That Needs No Authentication	      |
      |		   	(Variable Length Field)			      				  |
      |			     (Refer DS:1)			      					  |
      |								      							  |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	     Magic ID (0xACAC)        |        Num Of Items           |	
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	 		       Length of Items			      				  |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |								      							  |
      |	   List of App Port & Protocol That Needs No Authentication   |
      |		   	(Variable Length Field)			      				  |
      |			     (Refer DS:2)			      					  |
      |								      							  |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	     Magic ID (0xAAAA)        |        Num Of Items           |	
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	 		       Length of Items			      				  |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |								      							  |
      |	       		      Group Profile			      				  |
      |		       	 (Variable Length Field)		      			  |
      |			     (Refer DS:3)			      					  |
      |								      							  |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	     Magic ID (0xBBBB)        |        Num Of Items           |	
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	 		       Length of Items			      				  |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |								      							  |
      |	       		      User Profile			      				  |
      |		       	 (Variable Length Field)		      			  |
      |			     (Refer DS:4)			      					  |
      |								      							  |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	     Magic ID (0xCCCC)        |        Num Of Items           |	
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	 		       Length of Items			      				  |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	  Number of Domain Names      |				      			  |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+				      			  |
      |								      							  |
      |			 Filter Header Structure		      				  |
      |			      (Refer DS 5)			      					  |
      |								      							  |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |								      						      |
      |	     	  Filter Profile Depends on the Filter Type	          |
      |		       	 (Variable Length Field)		      			  |
      |			       (Refer DS 5)			      					  |
      |								      							  |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+



Fig 1 :Filter Header:
       --------------

                           1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	       Filter Type	      |	   	Group Mask....	      |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |	     ....Group Mask	      |		Filter Action	      |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |		Length		      |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


/***************************************************************************/

Data Structures:
----------------

DS:1 List of IP Address That Needs No Authentication:
     ------------------------------------------------

typedef struct TEMP_IP_DEFAULT
{
	char lower_address[16];
	char upper_address[16];
}TEMP_IP_DEFAULT;

DS:2 List of APP Address That Needs No Authentication:
     -------------------------------------------------

typedef struct TEMP_APP_DEFAULT
{
	USHORT lower_port;
	USHORT upper_port;
	USHORT protocol;
}TEMP_APP_DEFAULT;

DS:3 Group Profile:
     ______________
typedef struct TEMP_GROUP_PROFILE
{
	char	 group_name [MAX_LENGTH_GROUP_PROFILE_NAME];
	char	 group_description [MAX_LENGTH_GROUP_PROFILE_DESC];
	USHORT 	 defaulter_login_attempts;
	USHORT	 defaulter_number_of_login_attempts;
	USHORT	 defaulter_blacklisted_sites;
	USHORT	 defaulter_number_of_attempts_of_blacklisted_sites;
	USHORT	 audit_log_for_login_attempts;
	USHORT	 audit_log_for_blacklisted_sites;
	USHORT	 allow_sites;
	ULONG	 user_permission [7]; // Number of Days in a week
	USHORT	 group_no; 
}TEMP_GROUP_PROFILE;

DS:4 User Profile:
     _____________
typedef struct TEMP_USER_PROFILE
{
	char	user_name [MAX_LENGTH_USER_NAME];
	char	user_password [MAX_LENGTH_USER_PASSWORD];
	char	group_name [MAX_LENGTH_GROUP_PROFILE_NAME];
	USHORT	defaulter;
	USHORT	account_status;
}TEMP_USER_PROFILE;

DS:5 Filter Header & Profile:
     ________________________

typedef struct TEMP_FILTER_HEADER
{
   USHORT type;
   ULONG mask;
   USHORT action;		
   USHORT length;
}TEMP_FILTER_HEADER;

/***************************************************************************/


Effects On Group Mask on Deleting/Inserting Groups:
___________________________________________________


On Deleting a Group:
____________________

* Reinitialize all the Group Mask parameter for all the nodes.

Example:-
Consider the group mask to be - 

1 | 0 | 0 | 1 | 1 | 1 | 0 | 0
 	        |
	       	+--------> Remove This Bit

Now after deleting group4 the mask will be

0 | 1 | 0 | 0 | 1 | 1 | 0 | 0
            
Step1:
		10011100
(AND with)	11110000
		--------
		10010000   -  Result1	
		--------
Right Shift this Bit by one we get 1001100

Step2:
		10011100
(AND with)	00000111
		--------
		00000100   -  Result2
		--------
Step3:
	Result1 (OR) Result2

		01001000
		00000100
		--------
		01001100
		--------

Handling Domain Name Filters :
______________________________

* Domain Name Filters are maintained in Linked List.
* is_resolved gives the resolved status.
* Set this field TRUE on resolving Domain Name.
* Send a DNS Query after adding the DN filter to list.
* Check for any duplication in the IP Addresses tree for the resolved address.
* If exist
	* Make the ptr_to_domain_name_list to point to the DN List node.
  else
	* Add Resolved IP Addresses to the IP Add Tree along with the Group Mask.


