/**************************************/
/* Rule Set Based Access Control      */
/* Author and (c) 1999,2000: Amon Ott */
/* Data structures / AUTH             */
/* Last modified: 19/Feb/2000         */
/**************************************/

#ifndef __RSBAC_AUTH_DATA_STRUC_H
#define __RSBAC_AUTH_DATA_STRUC_H

#include <linux/types.h>
#include <rsbac/aci.h>
#include <rsbac/types.h>

/**********************************************/
/* Capability lists                           */
/**********************************************/

#define RSBAC_AUTH_F_CAP_SET_VERSION 2
#define RSBAC_AUTH_OLD_F_CAP_SET_VERSION 1
#define RSBAC_AUTH_F_CAP_FILENAME "auth_fc"

/* This list represents sets of capabilities, using a set-id and a sublist each */

struct rsbac_auth_cap_set_sublist_item_t
    {
             __u32                               first_id;
             __u32                               last_id;
      struct rsbac_auth_cap_set_sublist_item_t * prev;
      struct rsbac_auth_cap_set_sublist_item_t * next;
    };

struct rsbac_auth_old_cap_set_sublist_item_t
    {
             __u16                               id;
      struct rsbac_auth_cap_set_sublist_item_t * prev;
      struct rsbac_auth_cap_set_sublist_item_t * next;
    };

struct rsbac_auth_p_cap_set_list_item_t
    {
             rsbac_auth_p_cap_set_id_t             id;
             u_int                                 sublist_length;
      struct rsbac_auth_cap_set_sublist_item_t   * sublist_head;
      struct rsbac_auth_cap_set_sublist_item_t   * sublist_tail;
      struct rsbac_auth_p_cap_set_list_item_t    * prev;
      struct rsbac_auth_p_cap_set_list_item_t    * next;
    };

struct rsbac_auth_p_cap_set_list_head_t
    {
      struct rsbac_auth_p_cap_set_list_item_t * head;
      struct rsbac_auth_p_cap_set_list_item_t * tail;
      struct rsbac_auth_p_cap_set_list_item_t * curr;
             rwlock_t                           lock;
             u_int                              count;
    };

struct rsbac_auth_f_cap_set_list_item_t
    {
             rsbac_auth_f_cap_set_id_t           id;
             u_int                               sublist_length;
      struct rsbac_auth_cap_set_sublist_item_t * sublist_head;
      struct rsbac_auth_cap_set_sublist_item_t * sublist_tail;
      struct rsbac_auth_f_cap_set_list_item_t  * prev;
      struct rsbac_auth_f_cap_set_list_item_t  * next;
    };

struct rsbac_auth_f_cap_set_list_head_t
    {
      struct rsbac_auth_f_cap_set_list_item_t * head;
      struct rsbac_auth_f_cap_set_list_item_t * tail;
      struct rsbac_auth_f_cap_set_list_item_t * curr;
             rwlock_t                           lock;
             u_int                              count;
             boolean                            dirty;
    };

/* The list of devices is also a double linked list, so we define list    */
/* items and a list head.                                                 */

struct rsbac_auth_device_list_item_t
    {
      kdev_t                                   id;  /* set to 0 before deletion */
      struct rsbac_auth_f_cap_set_list_head_t  list_head;
      struct rsbac_auth_device_list_item_t   * prev;
      struct rsbac_auth_device_list_item_t   * next;
      boolean                                  no_write;
    };
    
/* To provide consistency we use spinlocks for all list accesses. The     */
/* 'curr' entry is used to avoid repeated lookups for the same item.       */    
    
struct rsbac_auth_device_list_head_t
    {
      struct rsbac_auth_device_list_item_t * head;
      struct rsbac_auth_device_list_item_t * tail;
      struct rsbac_auth_device_list_item_t * curr;
      rwlock_t                               lock;
      u_int                                  count;
    };

#endif
