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 #ifndef vacm_h_
00091 #define vacm_h_
00092
00093 #include <agent_pp/mib.h>
00094 #include <agent_pp/snmp_textual_conventions.h>
00095 #include <agent_pp/snmp_pp_ext.h>
00096
00097 #ifdef AGENTPP_NAMESPACE
00098 namespace Agentpp
00099 {
00100 #endif
00101
00102 #define oidSnmpModules "1.3.6.1.6.3"
00103 #define oidSnmpVacmMIB "1.3.6.1.6.3.16"
00104 #define oidVacmMIBObjects "1.3.6.1.6.3.16.1"
00105 #define oidVacmMIBConformance "1.3.6.1.6.3.16.2"
00106
00107 #define oidVacmContextTable "1.3.6.1.6.3.16.1.1"
00108 #define oidVacmContextEntry "1.3.6.1.6.3.16.1.1.1"
00109 #define oidVacmContextName "1.3.6.1.6.3.16.1.1.1.1"
00110
00111 #define oidVacmSecurityToGroupTable "1.3.6.1.6.3.16.1.2"
00112 #define oidVacmSecurityToGroupEntry "1.3.6.1.6.3.16.1.2.1"
00113 #define oidVacmSecurityModel "1.3.6.1.6.3.16.1.2.1.1" // 1.index
00114 #define oidVacmSecurityName "1.3.6.1.6.3.16.1.2.1.2" // 2.index
00115 #define oidVacmGroupName "1.3.6.1.6.3.16.1.2.1.3"
00116 #define oidVacmSecurityToGroupStorageType "1.3.6.1.6.3.16.1.2.1.4"
00117 #define oidVacmSecurityToGroupStatus "1.3.6.1.6.3.16.1.2.1.5"
00118
00119 #define oidVacmAccessTable "1.3.6.1.6.3.16.1.4"
00120 #define oidVacmAccessEntry "1.3.6.1.6.3.16.1.4.1" // groupName 1. index
00121 #define oidVacmAccessContextPrefix "1.3.6.1.6.3.16.1.4.1.1" // 2. index
00122 #define oidVacmAccessSecurityModel "1.3.6.1.6.3.16.1.4.1.2" // 3. index
00123 #define oidVacmAccessSecurityLevel "1.3.6.1.6.3.16.1.4.1.3" // 4. index
00124 #define oidVacmAccessContextMatch "1.3.6.1.6.3.16.1.4.1.4"
00125 #define oidVacmAccessReadViewName "1.3.6.1.6.3.16.1.4.1.5"
00126 #define oidVacmAccessWriteViewName "1.3.6.1.6.3.16.1.4.1.6"
00127 #define oidVacmAccessNotifyViewName "1.3.6.1.6.3.16.1.4.1.7"
00128 #define oidVacmAccessStorageType "1.3.6.1.6.3.16.1.4.1.8"
00129 #define oidVacmAccessStatus "1.3.6.1.6.3.16.1.4.1.9"
00130
00131 #define oidVacmMIBViews "1.3.6.1.6.3.16.1.5"
00132 #define oidVacmViewSpinLock "1.3.6.1.6.3.16.1.5.1"
00133 #define oidVacmViewTreeFamilyTable "1.3.6.1.6.3.16.1.5.2"
00134 #define oidVacmViewTreeFamilyEntry "1.3.6.1.6.3.16.1.5.2.1"
00135 #define oidVacmViewTreeFamilyViewName "1.3.6.1.6.3.16.1.5.2.1.1" // 1. index
00136 #define oidVacmViewTreeFamilySubtree "1.3.6.1.6.3.16.1.5.2.1.2" // 2. index
00137 #define oidVacmViewTreeFamilyMask "1.3.6.1.6.3.16.1.5.2.1.3"
00138 #define oidVacmViewTreeFamilyType "1.3.6.1.6.3.16.1.5.2.1.4"
00139 #define oidVacmViewTreeFamilyStorageType "1.3.6.1.6.3.16.1.5.2.1.5"
00140 #define oidVacmViewTreeFamilyStatus "1.3.6.1.6.3.16.1.5.2.1.6"
00141
00142 #define oidVacmMIBCompliances "1.3.6.1.6.3.16.2.1"
00143 #define oidVacmMIBGroups "1.3.6.1.6.3.16.2.2"
00144
00145
00146 #ifndef oidSnmpUnavailableContexts
00147 #define oidSnmpUnavailableContexts "1.3.6.1.6.3.12.1.4.0"
00148 #define oidSnmpUnknownContexts "1.3.6.1.6.3.12.1.5.0"
00149 #endif
00150
00151 #ifndef TRUE
00152 #define TRUE 1
00153 #endif
00154
00155 #ifndef FALSE
00156 #define FALSE 0
00157 #endif
00158
00159 #ifndef boolean
00160 #define boolean int
00161 #endif
00162
00163 #define VACM_accessAllowed 0
00164 #define VACM_notInView 1
00165 #define VACM_noSuchView 2
00166 #define VACM_noSuchContext 3
00167 #define VACM_noGroupName 4
00168 #define VACM_noAccessEntry 5
00169 #define VACM_otherError 6
00170
00171 #define VACM_viewFound 7
00172
00173 static const char * vacmErrs[] = {
00174 "accessAllowed",
00175 "notInView",
00176 "noSuchView ",
00177 "noSuchContext",
00178 "noGroupName",
00179 "noAccessEntry",
00180 "otherError",
00181 "viewFound"
00182 };
00183
00184 #define mibView_read 1
00185 #define mibView_write 2
00186 #define mibView_notify 3
00187
00188 #define storageType_other 1
00189 #define storageType_volatile 2
00190 #define storageType_nonVolatile 3
00191 #define storageType_permanent 4
00192 #define storageType_readOnly 5
00193
00194 #define match_exact 1
00195 #define match_prefix 2
00196
00197 #define view_included 1
00198 #define view_excluded 2
00199
00200
00201 class SnmpUnknownContexts;
00202 class SnmpUnavailableContexts;
00203 class VacmContextTable;
00204 class VacmSecurityToGroupTable;
00205 class VacmAccessTable;
00206 class VacmViewTreeFamilyTable;
00207 class Mib;
00208 class Oidx;
00209
00210
00211 class AGENTPP_DECL Vacm
00212 {
00213 public:
00214 typedef struct
00215 {
00216 VacmContextTable* contextTable;
00217 VacmSecurityToGroupTable* securityToGroupTable;
00218 VacmAccessTable* accessTable;
00219 VacmViewTreeFamilyTable* viewTreeFamilyTable;
00220 SnmpUnknownContexts* snmpUnknownContexts;
00221 SnmpUnavailableContexts* snmpUnavailableContexts;
00222 } ClassPointers;
00223
00224 Vacm();
00225 Vacm(Mib&);
00226 virtual ~Vacm();
00227
00242 virtual int isAccessAllowed(const int securityModel,
00243 const NS_SNMP OctetStr &securityName,
00244 const int securityLevel, const int viewType,
00245 const NS_SNMP OctetStr &context, const Oidx &o);
00246
00257 virtual int isAccessAllowed(const NS_SNMP OctetStr &viewName, const Oidx &o);
00258
00271 virtual int getViewName(const int securityModel, const NS_SNMP OctetStr &securityName,
00272 const int securityLevel, const int viewType,
00273 const NS_SNMP OctetStr &context, NS_SNMP OctetStr &viewName);
00274
00275 void incUnknownContexts();
00276 NS_SNMP SnmpInt32 getUnknownContexts();
00277 static const char* getErrorMsg(int nr) { return vacmErrs[nr];};
00278
00287 boolean addNewContext(const NS_SNMP OctetStr &newContext);
00288
00294 void deleteContext(const NS_SNMP OctetStr &context);
00295
00304 boolean addNewGroup(const int securityModel,
00305 const NS_SNMP OctetStr& securityName,
00306 const NS_SNMP OctetStr& groupName,
00307 const int storageType);
00308
00312 void deleteGroup(const int securityModel, const NS_SNMP OctetStr& securityName);
00313
00327 boolean addNewAccessEntry(const NS_SNMP OctetStr& groupName,
00328 const NS_SNMP OctetStr& prefix,
00329 const int securityModel, const int securityLevel,
00330 const int match,
00331 const NS_SNMP OctetStr& readView,
00332 const NS_SNMP OctetStr& writeView,
00333 const NS_SNMP OctetStr& notifyView,
00334 const int storageType);
00335
00345 void deleteAccessEntry(const NS_SNMP OctetStr& groupName,
00346 const NS_SNMP OctetStr& prefix,
00347 const int securityModel, const int securityLevel);
00348
00360 boolean addNewView(const NS_SNMP OctetStr& viewName,
00361 const Oidx& subtree,
00362 const NS_SNMP OctetStr& mask,
00363 const int type, const int storageType);
00364
00371 void deleteView(const NS_SNMP OctetStr& viewName, const Oidx& subtree);
00372
00380 ClassPointers get_vacm_tables() { return vcp; }
00381
00382 protected:
00383 ClassPointers vcp;
00384 };
00385
00386
00387 class AGENTPP_DECL SnmpUnavailableContexts: public MibLeaf
00388 {
00389 public:
00390 SnmpUnavailableContexts();
00391 void incValue();
00392 NS_SNMP SnmpInt32 getValue();
00393 };
00394
00395 class AGENTPP_DECL SnmpUnknownContexts: public MibLeaf
00396 {
00397 public:
00398 SnmpUnknownContexts();
00399 void incValue();
00400 NS_SNMP SnmpInt32 getValue();
00401 };
00402
00403
00404
00405
00406
00407
00408 class AGENTPP_DECL VacmContextTable: public MibTable
00409 {
00410
00411 public:
00412 VacmContextTable();
00413 ~VacmContextTable();
00414
00415 boolean isContextSupported(const NS_SNMP OctetStr& context);
00416 boolean addNewRow(const NS_SNMP OctetStr& context);
00417 void deleteRow(const NS_SNMP OctetStr& context);
00418 };
00419
00420
00421
00422
00423
00424
00425 class AGENTPP_DECL VacmSecurityToGroupTable: public StorageTable
00426 {
00427
00428 public:
00429 VacmSecurityToGroupTable();
00430 virtual ~VacmSecurityToGroupTable();
00431
00432 virtual boolean ready_for_service(Vbx*, int);
00433 virtual boolean could_ever_be_managed(const Oidx&, int&);
00434 virtual void row_added(MibTableRow*, const Oidx&, MibTable*);
00435 boolean getGroupName(const int& securiyModel,
00436 const NS_SNMP OctetStr& securityName,
00437 NS_SNMP OctetStr& groupName);
00438 boolean isGroupNameOK(const NS_SNMP OctetStr&);
00439 boolean addNewRow(const int securityModel,
00440 const NS_SNMP OctetStr& securityName,
00441 const NS_SNMP OctetStr& groupName, const int storageType);
00442 void deleteRow(const int securityModel,
00443 const NS_SNMP OctetStr& securityName);
00444 };
00445
00446
00447
00448
00449
00450
00451 class AGENTPP_DECL VacmAccessTable: public StorageTable
00452 {
00453
00454 public:
00455 VacmAccessTable(VacmSecurityToGroupTable*);
00456 virtual ~VacmAccessTable();
00457
00458 virtual boolean ready_for_service(Vbx*, int);
00459 virtual boolean could_ever_be_managed(const Oidx&, int&);
00460 virtual void row_added(MibTableRow*, const Oidx&, MibTable*);
00461 boolean getViewName(const NS_SNMP OctetStr& group,
00462 const NS_SNMP OctetStr& context,
00463 const int securityModel,
00464 const int securityLevel,
00465 const int viewType,
00466 NS_SNMP OctetStr& viewName);
00467
00468 boolean addNewRow(const NS_SNMP OctetStr& groupName,
00469 const NS_SNMP OctetStr& prefix,
00470 const int securityModel, const int securityLevel,
00471 const int match, const NS_SNMP OctetStr& readView,
00472 const NS_SNMP OctetStr& writeView,
00473 const NS_SNMP OctetStr& notifyView, const int storageType);
00474 void deleteRow(const NS_SNMP OctetStr& groupName, const NS_SNMP OctetStr& prefix,
00475 const int securityModel, const int securityLevel);
00476 protected:
00477 VacmSecurityToGroupTable* securityToGroupTable;
00478
00479 };
00480
00481 class AGENTPP_DECL VacmAccessTableStatus: public snmpRowStatus
00482 {
00483 public:
00484 VacmAccessTableStatus(const Oidx&, int);
00485 virtual ~VacmAccessTableStatus() {};
00486
00487 virtual MibEntryPtr clone();
00488
00489 protected:
00490 int base_len;
00491
00492 };
00493
00494 class AGENTPP_DECL ViewNameIndex
00495 {
00496
00497 public:
00498 ViewNameIndex(const NS_SNMP OctetStr& vname): name(vname) {}
00499 ~ViewNameIndex() { views.clear();}
00500
00501 void add(MibTableRow* row) { views.add(row);}
00502 void remove(MibTableRow* row) { views.remove(row);}
00503 boolean isEmpty() { return views.empty();}
00504
00505 NS_SNMP OctetStr name;
00506 List<MibTableRow> views;
00507 };
00508
00509
00510
00511
00512
00513
00514 #if !defined (AGENTPP_DECL_TEMPL_LIST_VIEWNAMEINDEX)
00515 #define AGENTPP_DECL_TEMPL_LIST_VIEWNAMEINDEX
00516 AGENTPP_DECL_TEMPL template class AGENTPP_DECL List<ViewNameIndex>;
00517 #endif
00518
00519 class AGENTPP_DECL VacmViewTreeFamilyTable: public StorageTable
00520 {
00521 friend class VacmViewTreeFamilyTableStatus;
00522 public:
00523 VacmViewTreeFamilyTable();
00524 virtual ~VacmViewTreeFamilyTable();
00525
00526 virtual boolean ready_for_service(Vbx*, int);
00527 virtual boolean could_ever_be_managed(const Oidx&, int&);
00528 virtual void row_added(MibTableRow*, const Oidx&, MibTable*);
00529 virtual void row_activated(MibTableRow*, const Oidx&, MibTable*);
00530 virtual void row_deactivated(MibTableRow*, const Oidx&, MibTable*);
00531 virtual void row_delete(MibTableRow*, const Oidx&, MibTable*);
00532 virtual void row_init(MibTableRow*, const Oidx&, MibTable* t=0);
00533 boolean isInMibView(const NS_SNMP OctetStr&, const Oidx&);
00534 boolean addNewRow(const NS_SNMP OctetStr& viewName, const Oidx& subtree,
00535 const NS_SNMP OctetStr& mask, const int type,
00536 const int storageType);
00537 void deleteRow(const NS_SNMP OctetStr& viewName, const Oidx& subtree);
00538 virtual void clear() { StorageTable::clear(); buildViewNameIndex();}
00539 virtual void reset() { StorageTable::reset(); buildViewNameIndex();}
00540
00541 protected:
00542 boolean bit(unsigned int, NS_SNMP OctetStr&);
00543 ViewNameIndex* viewsOf(const NS_SNMP OctetStr& viewName);
00544 void buildViewNameIndex();
00545
00546 List<ViewNameIndex> viewNameIndex;
00547 };
00548
00549 class AGENTPP_DECL VacmViewTreeFamilyTableStatus: public snmpRowStatus
00550 {
00551 public:
00552 VacmViewTreeFamilyTableStatus(const Oidx&, int);
00553 virtual ~VacmViewTreeFamilyTableStatus() {}
00554 virtual int set(const Vbx&);
00555 virtual MibEntryPtr clone();
00556
00557 protected:
00558 int base_len;
00559 };
00560
00561
00562
00563
00564
00565
00566 class AGENTPP_DECL VacmMIB: public MibGroup
00567 {
00568
00569 public:
00570 VacmMIB(Vacm::ClassPointers);
00571 };
00572
00573 #ifdef AGENTPP_NAMESPACE
00574 }
00575 #endif
00576 #endif