00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 #ifndef vacm_class_h_
00093 #define vacm_class_h_
00094
00095 #include <agent_pp/snmp_pp_ext.h>
00096
00097 #ifdef AGENTPP_NAMESPACE
00098 namespace Agentpp {
00099 #endif
00100
00101 class SnmpUnknownContexts;
00102 class SnmpUnavailableContexts;
00103 class VacmContextTable;
00104 class VacmSecurityToGroupTable;
00105 class VacmAccessTable;
00106 class VacmViewTreeFamilyTable;
00107 class Mib;
00108 class Oidx;
00109
00110 #ifndef TRUE
00111 #define TRUE 1
00112 #endif
00113
00114 #ifndef FALSE
00115 #define FALSE 0
00116 #endif
00117
00118 #ifndef boolean
00119 #define boolean int
00120 #endif
00121
00122 #define VACM_accessAllowed 0
00123 #define VACM_notInView 1
00124 #define VACM_noSuchView 2
00125 #define VACM_noSuchContext 3
00126 #define VACM_noGroupName 4
00127 #define VACM_noAccessEntry 5
00128 #define VACM_otherError 6
00129
00130 #define VACM_viewFound 7
00131
00132 static const char * vacmErrs[] = {
00133 "accessAllowed",
00134 "notInView",
00135 "noSuchView ",
00136 "noSuchContext",
00137 "noGroupName",
00138 "noAccessEntry",
00139 "otherError"
00140 };
00141
00142
00143 #define mibView_read 1
00144 #define mibView_write 2
00145 #define mibView_notify 3
00146
00147 #define storageType_other 1
00148 #define storageType_volatile 2
00149 #define storageType_nonVolatile 3
00150 #define storageType_permanent 4
00151 #define storageType_readOnly 5
00152
00153 #define match_exact 1
00154 #define match_prefix 2
00155
00156 #define view_included 1
00157 #define view_excluded 2
00158
00159
00160 class AGENTPP_DECL Vacm
00161 {
00162 public:
00163
00164 typedef struct {
00165 VacmContextTable* contextTable;
00166 VacmSecurityToGroupTable* securityToGroupTable;
00167 VacmAccessTable* accessTable;
00168 VacmViewTreeFamilyTable* viewTreeFamilyTable;
00169 SnmpUnknownContexts* snmpUnknownContexts;
00170 SnmpUnavailableContexts* snmpUnavailableContexts;
00171 } ClassPointers;
00172
00173 Vacm();
00174 Vacm(Mib& );
00175 virtual ~Vacm();
00176 virtual int isAccessAllowed(int model, NS_SNMP OctetStr name, int level,
00177 int viewType,
00178 NS_SNMP OctetStr context, Oidx o);
00179 virtual int isAccessAllowed(NS_SNMP OctetStr viewName, Oidx o);
00180 int getViewName(int model, NS_SNMP OctetStr name, int level,
00181 int viewType, NS_SNMP OctetStr context,
00182 NS_SNMP OctetStr &viewName);
00183 void incUnknownContexts();
00184 NS_SNMP SnmpInt32 getUnknownContexts();
00185 static const char* getErrorMsg(int nr) { return vacmErrs[nr];};
00186
00190 boolean addNewContext(const NS_SNMP OctetStr &newContext);
00191
00195 void deleteContext(const NS_SNMP OctetStr &context);
00196
00200 boolean addNewGroup(int securityModel,
00201 const NS_SNMP OctetStr& securityName,
00202 const NS_SNMP OctetStr& groupName,
00203 int storageType);
00204
00208 void deleteGroup(int securityModel, const NS_SNMP OctetStr& securityName);
00209
00213 boolean addNewAccessEntry(const NS_SNMP OctetStr& groupName,
00214 const NS_SNMP OctetStr& prefix,
00215 int securityModel, int securityLevel,
00216 int match,
00217 const NS_SNMP OctetStr& readView,
00218 const NS_SNMP OctetStr& writeView,
00219 const NS_SNMP OctetStr& notifyView,
00220 int storageType);
00221
00225 void deleteAccessEntry(const NS_SNMP OctetStr& groupName,
00226 const NS_SNMP OctetStr& prefix,
00227 int securityModel, int securityLevel);
00228
00232 boolean addNewView(const NS_SNMP OctetStr& viewName,
00233 const Oidx& subtree,
00234 const NS_SNMP OctetStr& mask,
00235 int type, int storageType);
00236
00240 void deleteView(const NS_SNMP OctetStr& viewName, const Oidx& subtree);
00241
00249 ClassPointers get_vacm_tables() { return vcp; }
00250
00251 protected:
00252 ClassPointers vcp;
00253 };
00254
00255 #ifdef AGENTPP_NAMESPACE
00256 }
00257 #endif
00258 #endif