/************************************ */
/* Rule Set Based Access Control      */
/*                                    */
/* Author and (c) 1999,2000: Amon Ott */
/*                                    */
/* System Calls                       */
/*                                    */
/* Last modified: 22/Feb/2000         */
/************************************ */

#ifndef __RSBAC_SYSCALLS_H
#define __RSBAC_SYSCALLS_H

/* to keep include/asm-alpha/unistd.h happy */
#define __LIBRARY__

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

/* General */

inline _syscall0(int, rsbac_stats);

inline _syscall2(int, rsbac_check,
                 int, correct,
                 int, check_inode);

inline _syscall5(int, rsbac_get_attr,
                        enum rsbac_target_t, target,
                        union rsbac_target_id_t *, tid,
                        enum rsbac_attribute_t, attr,
                        union rsbac_attribute_value_t *, value,
                        int, inherit);

inline _syscall5(int, rsbac_get_attr_n,
                        enum rsbac_target_t, target,
                        char *, t_name,
                        enum rsbac_attribute_t, attr,
                        union rsbac_attribute_value_t *, value,
                        int, inherit);

inline _syscall4(int, rsbac_set_attr,
                        enum rsbac_target_t, target,
                        union rsbac_target_id_t *, tid,
                        enum rsbac_attribute_t, attr,
                        union rsbac_attribute_value_t *, value);

inline _syscall4(int, rsbac_set_attr_n,
                        enum rsbac_target_t, target,
                        char *, t_name,
                        enum rsbac_attribute_t, attr,
                        union rsbac_attribute_value_t *, value);

inline _syscall2(int, rsbac_remove_target,
                        enum rsbac_target_t, target,
                        union rsbac_target_id_t *, tid);

inline _syscall2(int, rsbac_remove_target_n,
                        enum rsbac_target_t, target,
                        char *, t_name);

inline _syscall2(int, rsbac_switch,
                        enum rsbac_switch_target_t, target,
                        int, value);

inline _syscall2(int, rsbac_adf_log_switch,
                        enum rsbac_adf_request_t, target,
                        int, value);

inline _syscall0(int,rsbac_write);

inline _syscall3(int, rsbac_log,
                        int, type,
                        char *, buf,
                        int, len);

/* MAC */

inline _syscall1(int, rsbac_mac_set_curr_seclevel,
                        rsbac_security_level_t, level);

inline _syscall0(rsbac_security_level_t,
                        rsbac_mac_get_curr_seclevel);

inline _syscall1(int, rsbac_mac_set_max_seclevel,
                        rsbac_security_level_t, level);

inline _syscall0(rsbac_security_level_t,
                        rsbac_mac_get_max_seclevel);

inline _syscall1(int, rsbac_mac_set_curr_categories,
                        rsbac_mac_category_vector_t *, categories);

inline _syscall1(int, rsbac_mac_get_curr_categories,
                        rsbac_mac_category_vector_t *, categories);

inline _syscall1(int, rsbac_mac_set_max_categories,
                        rsbac_mac_category_vector_t *, categories);

inline _syscall1(int, rsbac_mac_get_max_categories,
                        rsbac_mac_category_vector_t *, categories);

/* PM */

inline _syscall0(int, rsbac_stats_pm);

inline _syscall3(int, rsbac_pm,
                        enum  rsbac_pm_function_type_t, function,
                        union rsbac_pm_function_param_t *, param_p,
                              rsbac_pm_tkt_id_t, ticket);

inline _syscall1(int, rsbac_pm_change_current_task,
                        rsbac_pm_task_id_t, task);

inline _syscall3(int, rsbac_pm_create_file,
                        const char *, filename,
                        int, mode,
                        rsbac_pm_object_class_id_t, object_class);

/* MS */

inline _syscall1(int, rsbac_ms_get_copied,
                        int, fd);

/* RC */

inline _syscall2(int, rsbac_rc_copy_role,
                        rsbac_rc_role_id_t, from_role,
                        rsbac_rc_role_id_t, to_role);

inline _syscall4(int, rsbac_rc_get_item,
                        enum  rsbac_rc_target_t, target,
                        union rsbac_rc_target_id_t *, tid_p,
                        enum  rsbac_rc_item_t, item,
                        union rsbac_rc_item_value_t *, value_p);

inline _syscall4(int, rsbac_rc_set_item,
                        enum  rsbac_rc_target_t, target,
                        union rsbac_rc_target_id_t *, tid_p,
                        enum  rsbac_rc_item_t, item,
                        union rsbac_rc_item_value_t *, value_p);

inline _syscall1(int, rsbac_rc_change_role,
                        rsbac_rc_role_id_t, role);

inline _syscall3(int, rsbac_rc_get_eff_rights_n,
                      enum rsbac_target_t, target,
                           char *, t_name,
                      rsbac_rc_request_vector_t *, request_vector_p);

/* AUTH */

inline _syscall3(int, rsbac_auth_add_p_cap,
                        rsbac_pid_t, pid,
                        rsbac_uid_t, first_uid,
                        rsbac_uid_t, last_uid);

inline _syscall3(int, rsbac_auth_remove_p_cap,
                        rsbac_pid_t, pid,
                        rsbac_uid_t, first_uid,
                        rsbac_uid_t, last_uid);

inline _syscall3(int, rsbac_auth_add_f_cap,
                        char *, filename,
                        rsbac_uid_t, first_uid,
                        rsbac_uid_t, last_uid);

inline _syscall3(int, rsbac_auth_remove_f_cap,
                        char *, filename,
                        rsbac_uid_t, first_uid,
                        rsbac_uid_t, last_uid);

inline _syscall3(int, rsbac_auth_get_f_caplist,
                        char *, filename,
                        rsbac_uid_t *, caplist,
                        int, maxnum);

/* ACL */

inline _syscall2(int, rsbac_acl,
                 enum  rsbac_acl_syscall_type_t, call,
                 struct rsbac_acl_syscall_arg_t *, arg);

inline _syscall2(int, rsbac_acl_n,
                 enum  rsbac_acl_syscall_type_t, call,
                 struct rsbac_acl_syscall_n_arg_t *, arg);

inline _syscall3(int, rsbac_acl_get_mask,
                 enum   rsbac_target_t, target,
                 union  rsbac_target_id_t *, tid,
                        rsbac_acl_rights_vector_t *, mask_p);

inline _syscall3(int, rsbac_acl_get_mask_n,
                 enum   rsbac_target_t, target,
                        char *, t_name,
                        rsbac_acl_rights_vector_t *, mask_p);

inline _syscall3(int, rsbac_acl_get_rights,
                 struct rsbac_acl_syscall_arg_t *, arg,
                       rsbac_acl_rights_vector_t *, rights_p,
                       u_int, effective);

inline _syscall3(int, rsbac_acl_get_rights_n,
                 struct rsbac_acl_syscall_n_arg_t *, arg,
                       rsbac_acl_rights_vector_t *, rights_p,
                       u_int, effective);

inline _syscall4(int, rsbac_acl_get_tlist,
                 enum   rsbac_target_t, target,
                 union  rsbac_target_id_t *, tid,
                 struct rsbac_acl_entry_t *, entry_array,
                        u_int, maxnum);

inline _syscall4(int, rsbac_acl_get_tlist_n,
                 enum   rsbac_target_t, target,
                        char *, t_name,
                 struct rsbac_acl_entry_t *, entry_array,
                        u_int, maxnum);

inline _syscall2(int, rsbac_acl_group,
                 enum  rsbac_acl_group_syscall_type_t, call,
                 union rsbac_acl_group_syscall_arg_t *, arg_p);

/* constructor for individual ipc-socket-ids for each process */
inline u_long
    rsbac_create_ipc_sock_id(rsbac_pid_t pid, int fd)
  { /* (8 * sizeof(int)) = 16 */
    return(fd | ( ((u_long) pid) << 16 ) );
  };

#endif
