vacm.h
上传用户:wxp200602
上传日期:2007-10-30
资源大小:4028k
文件大小:7k
源码类别:

SNMP编程

开发平台:

Unix_Linux

  1. /*
  2.  * vacm.h
  3.  *
  4.  * SNMPv3 View-based Access Control Model
  5.  */
  6. #ifndef VACM_H
  7. #define VACM_H
  8. #ifdef __cplusplus
  9. extern          "C" {
  10. #endif
  11. #define VACM_SUCCESS       0
  12. #define VACM_NOSECNAME     1
  13. #define VACM_NOGROUP       2
  14. #define VACM_NOACCESS      3
  15. #define VACM_NOVIEW        4
  16. #define VACM_NOTINVIEW     5
  17. #define VACM_NOSUCHCONTEXT 6
  18. #define VACM_SUBTREE_UNKNOWN 7
  19. #define SECURITYMODEL 1
  20. #define SECURITYNAME 2
  21. #define SECURITYGROUP 3
  22. #define SECURITYSTORAGE 4
  23. #define SECURITYSTATUS 5
  24. #define ACCESSPREFIX 1
  25. #define ACCESSMODEL 2
  26. #define ACCESSLEVEL 3
  27. #define ACCESSMATCH 4
  28. #define ACCESSREAD 5
  29. #define ACCESSWRITE 6
  30. #define ACCESSNOTIFY 7
  31. #define ACCESSSTORAGE 8
  32. #define ACCESSSTATUS 9
  33. #define VACMVIEWSPINLOCK 1
  34. #define VIEWNAME 2
  35. #define VIEWSUBTREE 3
  36. #define VIEWMASK 4
  37. #define VIEWTYPE 5
  38. #define VIEWSTORAGE 6
  39. #define VIEWSTATUS 7
  40. #define VACM_MAX_STRING 32
  41. #define VACMSTRINGLEN   34      /* VACM_MAX_STRING + 2 */
  42.     struct vacm_groupEntry {
  43.         int             securityModel;
  44.         char            securityName[VACMSTRINGLEN];
  45.         char            groupName[VACMSTRINGLEN];
  46.         int             storageType;
  47.         int             status;
  48.         u_long          bitMask;
  49.         struct vacm_groupEntry *reserved;
  50.         struct vacm_groupEntry *next;
  51.     };
  52. #define CONTEXT_MATCH_EXACT  1
  53. #define CONTEXT_MATCH_PREFIX 2
  54.     struct vacm_accessEntry {
  55.         char            groupName[VACMSTRINGLEN];
  56.         char            contextPrefix[VACMSTRINGLEN];
  57.         int             securityModel;
  58.         int             securityLevel;
  59.         int             contextMatch;
  60.         char            readView[VACMSTRINGLEN];
  61.         char            writeView[VACMSTRINGLEN];
  62.         char            notifyView[VACMSTRINGLEN];
  63.         int             storageType;
  64.         int             status;
  65.         u_long          bitMask;
  66.         struct vacm_accessEntry *reserved;
  67.         struct vacm_accessEntry *next;
  68.     };
  69.     struct vacm_viewEntry {
  70.         char            viewName[VACMSTRINGLEN];
  71.         oid             viewSubtree[MAX_OID_LEN];
  72.         size_t          viewSubtreeLen;
  73.         u_char          viewMask[VACMSTRINGLEN];
  74.         size_t          viewMaskLen;
  75.         int             viewType;
  76.         int             viewStorageType;
  77.         int             viewStatus;
  78.         u_long          bitMask;
  79.         struct vacm_viewEntry *reserved;
  80.         struct vacm_viewEntry *next;
  81.     };
  82.     void            vacm_destroyViewEntry(const char *, oid *, size_t);
  83.     void            vacm_destroyAllViewEntries(void);
  84. #define VACM_MODE_FIND                0
  85. #define VACM_MODE_IGNORE_MASK         1
  86. #define VACM_MODE_CHECK_SUBTREE       2
  87.     struct vacm_viewEntry *vacm_getViewEntry(const char *, oid *, size_t,
  88.                                              int);
  89.     /*
  90.      * Returns a pointer to the viewEntry with the
  91.      * same viewName and viewSubtree
  92.      * Returns NULL if that entry does not exist.
  93.      */
  94.     int vacm_checkSubtree(const char *, oid *, size_t);
  95.     /*
  96.      * Check to see if everything within a subtree is in view, not in view,
  97.      * or possibly both.
  98.      *
  99.      * Returns:
  100.      *   VACM_SUCCESS          The OID is included in the view.
  101.      *   VACM_NOTINVIEW        If no entry in the view list includes the
  102.      *                         provided OID, or the OID is explicitly excluded
  103.      *                         from the view. 
  104.      *   VACM_SUBTREE_UNKNOWN  The entire subtree has both allowed and
  105.      *                         disallowed portions.
  106.      */
  107.     void
  108.                     vacm_scanViewInit(void);
  109.     /*
  110.      * Initialized the scan routines so that they will begin at the
  111.      * beginning of the list of viewEntries.
  112.      *
  113.      */
  114.     struct vacm_viewEntry *vacm_scanViewNext(void);
  115.     /*
  116.      * Returns a pointer to the next viewEntry.
  117.      * These entries are returned in no particular order,
  118.      * but if N entries exist, N calls to view_scanNext() will
  119.      * return all N entries once.
  120.      * Returns NULL if all entries have been returned.
  121.      * view_scanInit() starts the scan over.
  122.      */
  123.     struct vacm_viewEntry *vacm_createViewEntry(const char *, oid *,
  124.                                                 size_t);
  125.     /*
  126.      * Creates a viewEntry with the given index
  127.      * and returns a pointer to it.
  128.      * The status of this entry is created as invalid.
  129.      */
  130.     void            vacm_destroyGroupEntry(int, const char *);
  131.     void            vacm_destroyAllGroupEntries(void);
  132.     struct vacm_groupEntry *vacm_createGroupEntry(int, const char *);
  133.     struct vacm_groupEntry *vacm_getGroupEntry(int, const char *);
  134.     void            vacm_scanGroupInit(void);
  135.     struct vacm_groupEntry *vacm_scanGroupNext(void);
  136.     void            vacm_destroyAccessEntry(const char *, const char *,
  137.                                             int, int);
  138.     void            vacm_destroyAllAccessEntries(void);
  139.     struct vacm_accessEntry *vacm_createAccessEntry(const char *,
  140.                                                     const char *, int,
  141.                                                     int);
  142.     struct vacm_accessEntry *vacm_getAccessEntry(const char *,
  143.                                                  const char *, int, int);
  144.     void            vacm_scanAccessInit(void);
  145.     struct vacm_accessEntry *vacm_scanAccessNext(void);
  146.     void            vacm_destroySecurityEntry(const char *);
  147.     struct vacm_securityEntry *vacm_createSecurityEntry(const char *);
  148.     struct vacm_securityEntry *vacm_getSecurityEntry(const char *);
  149.     void            vacm_scanSecurityInit(void);
  150.     struct vacm_securityEntry *vacm_scanSecurityEntry(void);
  151.     int             vacm_is_configured(void);
  152.     void            vacm_save(const char *token, const char *type);
  153.     void            vacm_save_view(struct vacm_viewEntry *view,
  154.                                    const char *token, const char *type);
  155.     void            vacm_save_access(struct vacm_accessEntry *access_entry,
  156.                                      const char *token, const char *type);
  157.     void            vacm_save_group(struct vacm_groupEntry *group_entry,
  158.                                     const char *token, const char *type);
  159.     void            vacm_parse_config_view(const char *token, char *line);
  160.     void            vacm_parse_config_group(const char *token, char *line);
  161.     void            vacm_parse_config_access(const char *token,
  162.                                              char *line);
  163.     int             store_vacm(int majorID, int minorID, void *serverarg,
  164.                                void *clientarg);
  165. #ifdef __cplusplus
  166. }
  167. #endif
  168. #endif                          /* VACM_H */