avtab.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * An access vector table (avtab) is a hash table
  3. * of access vectors and transition types indexed
  4. * by a type pair and a class. An access vector
  5. * table is used to represent the type enforcement
  6. * tables.
  7. *
  8. * Author : Stephen Smalley, <sds@epoch.ncsc.mil>
  9. */
  10. /* Updated: Frank Mayer <mayerf@tresys.com> and Karl MacMillan <kmacmillan@tresys.com>
  11. *
  12. * Added conditional policy language extensions
  13. *
  14. * Copyright (C) 2003 Tresys Technology, LLC
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation, version 2.
  18. */
  19. #ifndef _SS_AVTAB_H_
  20. #define _SS_AVTAB_H_
  21. struct avtab_key {
  22. u16 source_type; /* source type */
  23. u16 target_type; /* target type */
  24. u16 target_class; /* target object class */
  25. #define AVTAB_ALLOWED 1
  26. #define AVTAB_AUDITALLOW 2
  27. #define AVTAB_AUDITDENY 4
  28. #define AVTAB_AV (AVTAB_ALLOWED | AVTAB_AUDITALLOW | AVTAB_AUDITDENY)
  29. #define AVTAB_TRANSITION 16
  30. #define AVTAB_MEMBER 32
  31. #define AVTAB_CHANGE 64
  32. #define AVTAB_TYPE (AVTAB_TRANSITION | AVTAB_MEMBER | AVTAB_CHANGE)
  33. #define AVTAB_ENABLED_OLD 0x80000000 /* reserved for used in cond_avtab */
  34. #define AVTAB_ENABLED 0x8000 /* reserved for used in cond_avtab */
  35. u16 specified; /* what field is specified */
  36. };
  37. struct avtab_datum {
  38. u32 data; /* access vector or type value */
  39. };
  40. struct avtab_node {
  41. struct avtab_key key;
  42. struct avtab_datum datum;
  43. struct avtab_node *next;
  44. };
  45. struct avtab {
  46. struct avtab_node **htable;
  47. u32 nel; /* number of elements */
  48. };
  49. int avtab_init(struct avtab *);
  50. struct avtab_datum *avtab_search(struct avtab *h, struct avtab_key *k);
  51. void avtab_destroy(struct avtab *h);
  52. void avtab_hash_eval(struct avtab *h, char *tag);
  53. int avtab_read_item(void *fp, uint32_t vers, struct avtab *a,
  54. int (*insert)(struct avtab *a, struct avtab_key *k,
  55. struct avtab_datum *d, void *p),
  56. void *p);
  57. int avtab_read(struct avtab *a, void *fp, u32 vers);
  58. struct avtab_node *avtab_insert_nonunique(struct avtab *h, struct avtab_key *key,
  59. struct avtab_datum *datum);
  60. struct avtab_node *avtab_search_node(struct avtab *h, struct avtab_key *key);
  61. struct avtab_node *avtab_search_node_next(struct avtab_node *node, int specified);
  62. void avtab_cache_init(void);
  63. void avtab_cache_destroy(void);
  64. #define AVTAB_HASH_BITS 15
  65. #define AVTAB_HASH_BUCKETS (1 << AVTAB_HASH_BITS)
  66. #define AVTAB_HASH_MASK (AVTAB_HASH_BUCKETS-1)
  67. #define AVTAB_SIZE AVTAB_HASH_BUCKETS
  68. #endif /* _SS_AVTAB_H_ */