AGENT++  4.0.3
v3_mib.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## AGENT++ 4.0 - v3_mib.h
4  _##
5  _## Copyright (C) 2000-2013 Frank Fock and Jochen Katz (agentpp.com)
6  _##
7  _## Licensed under the Apache License, Version 2.0 (the "License");
8  _## you may not use this file except in compliance with the License.
9  _## You may obtain a copy of the License at
10  _##
11  _## http://www.apache.org/licenses/LICENSE-2.0
12  _##
13  _## Unless required by applicable law or agreed to in writing, software
14  _## distributed under the License is distributed on an "AS IS" BASIS,
15  _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  _## See the License for the specific language governing permissions and
17  _## limitations under the License.
18  _##
19  _##########################################################################*/
20 #ifndef v3_mib_h_
21 #define v3_mib_h_
22 
23 #include <agent_pp/agent++.h>
24 
25 #ifdef _SNMPv3
26 
27 #include <agent_pp/mib.h>
28 #include <snmp_pp/usm_v3.h>
29 #include <snmp_pp/v3.h>
31 
32 #ifdef AGENTPP_NAMESPACE
33 namespace Agentpp {
34 #endif
35 
36 /**********************************************************************
37  *
38  * class V3SnmpEngine
39  *
40  **********************************************************************/
41 
42 class AGENTPP_DECL V3SnmpEngine: public MibGroup {
43 
44 public:
45 
46  V3SnmpEngine(void);
47 };
48 
49 class AGENTPP_DECL V3SnmpEngineID: public MibLeaf {
50 
51 public:
52  V3SnmpEngineID(const NS_SNMP v3MP *mp);
53  void get_request(Request*, int);
54 private:
55  const NS_SNMP v3MP *v3mp;
56 };
57 
58 class AGENTPP_DECL V3SnmpEngineBoots: public MibLeaf {
59 
60 public:
61  V3SnmpEngineBoots(const NS_SNMP USM *u);
62  void get_request(Request*, int);
63 private:
64  const NS_SNMP USM *usm;
65 };
66 
67 class AGENTPP_DECL V3SnmpEngineTime: public MibLeaf {
68 
69 public:
70  V3SnmpEngineTime(const NS_SNMP USM *u);
71  void get_request(Request*, int);
72 private:
73  const NS_SNMP USM *usm;
74 };
75 
76 class AGENTPP_DECL V3SnmpEngineMaxMessageSize: public MibLeaf {
77 
78 public:
79  V3SnmpEngineMaxMessageSize();
80 };
81 
82 
83 class AGENTPP_DECL UsmUserTableStatus: public snmpRowStatus
84 {
85  public:
86  UsmUserTableStatus(const Oidx&, int _base_len, NS_SNMP USM *usm);
87  virtual ~UsmUserTableStatus();
88 
89  virtual MibEntryPtr clone();
90  virtual int set(const Vbx& vb);
91  virtual int unset();
92 
93  void deleteUsmUser();
94  void addUsmUser();
95 
96  private:
97  int base_len;
98  NS_SNMP USM *usm;
99 };
100 
124 class AGENTPP_DECL UsmUserTable: public StorageTable
125 {
126  public:
127  UsmUserTable();
128  virtual ~UsmUserTable();
129 
130  virtual bool ready_for_service(Vbx* pvbs, int sz);
131  virtual void row_added(MibTableRow* new_row, const Oidx& ind, MibTable*);
132  virtual void row_init(MibTableRow* new_row, const Oidx& ind, MibTable*);
133 
142  MibTableRow *addNewRow(const NS_SNMP OctetStr& engineID,
143  const NS_SNMP OctetStr& userName,
144  const NS_SNMP OctetStr& securityName,
145  int authProtocol, const NS_SNMP OctetStr& authKey,
146  int privProtocol, const NS_SNMP OctetStr& privKey,
147  const bool add_to_usm = TRUE);
148 
158  MibTableRow *addNewRow(const NS_SNMP OctetStr& engineID,
159  const NS_SNMP OctetStr& userName,
160  int authProtocol, const NS_SNMP OctetStr& authKey,
161  int privProtocol, const NS_SNMP OctetStr& privKey,
162  const bool add_to_usm = TRUE)
163  { return addNewRow(engineID, userName, userName, authProtocol, authKey,
164  privProtocol, privKey, add_to_usm); };
165 
179  MibTableRow *addNewRow(const NS_SNMP OctetStr& userName,
180  const NS_SNMP OctetStr& securityName,
181  int authProtocol,
182  int privProtocol,
183  const NS_SNMP OctetStr& authPassword,
184  const NS_SNMP OctetStr& privPassword,
185  const bool addPasswordsToUSM = true);
186 
197  MibTableRow *addNewRow(const NS_SNMP OctetStr& userName,
198  const NS_SNMP OctetStr& securityName,
199  int authProtocol,
200  int privProtocol,
201  const NS_SNMP OctetStr& authPassword,
202  const NS_SNMP OctetStr& privPassword,
203  const NS_SNMP OctetStr& engineID,
204  const bool addPassWordsToUSM = false);
205 
214  MibTableRow *addNewRow(const NS_SNMP OctetStr& userName,
215  int authProtocol,
216  int privProtocol,
217  const NS_SNMP OctetStr& authPassword,
218  const NS_SNMP OctetStr& privPassword)
219  { return addNewRow(userName, userName, authProtocol, privProtocol,
220  authPassword, privPassword, true); };
221 
230  MibTableRow *addNewRow(const NS_SNMP OctetStr& userName,
231  int authProtocol,
232  int privProtocol,
233  const NS_SNMP OctetStr& authPassword,
234  const NS_SNMP OctetStr& privPassword,
235  const NS_SNMP OctetStr& engineID,
236  const bool addPassWordsToUSM = false)
237  { return addNewRow(userName, userName, authProtocol, privProtocol,
238  authPassword, privPassword, engineID, addPassWordsToUSM); };
239 
246  bool deleteRow(const NS_SNMP OctetStr& engineID,
247  const NS_SNMP OctetStr& userName);
248 
261  void deleteRows(const NS_SNMP OctetStr& userName);
262 
268  void removeAllUsers();
269 
270  MibTableRow* get_row(Oidx o) { return find_index(o); };
271 
272  static const Oidx auth_base;
273  static const Oidx priv_base;
274 
275  protected:
276  void initialize_key_change(MibTableRow*);
277 
278  private:
279  NS_SNMP USM *usm;
280 };
281 
282 
283 class AGENTPP_DECL UsmCloneFrom: public MibLeaf
284 {
285  public:
286  UsmCloneFrom(Oidx o);
287  virtual ~UsmCloneFrom() {};
288  virtual int prepare_set_request(Request* req, int& ind);
289  virtual void get_request(Request* req, int ind);
290  virtual int set(const Vbx& vb);
291  virtual bool value_ok(const Vbx& vb);
292  virtual MibEntryPtr clone();
293  private:
294  NS_SNMP USM *usm;
295 };
296 
297 class AGENTPP_DECL UsmKeyChange: public MibLeaf
298 {
299  public:
300  UsmKeyChange(Oidx o, int keylen, int hashfunction, int typeOfKey,
301  UsmKeyChange* ukc, NS_SNMP USM *u);
302  UsmKeyChange(Oidx o, NS_SNMP USM *u);
303  virtual ~UsmKeyChange();
304 
305  virtual int unset();
306  void initialize(int keylen, int hashfunction, int typeOfKey, UsmKeyChange* ukc);
307  virtual void get_request(Request* req, int ind);
308  virtual int prepare_set_request(Request* req, int& ind);
309  virtual int set(const Vbx& vb);
310  virtual bool value_ok(const Vbx& vb);
311  virtual MibEntryPtr clone();
312 
313  protected:
314  bool process_key_change(NS_SNMP OctetStr& os);
315 
316  int type_of_key;
317  int key_len;
318  int hash_function;
319  UsmKeyChange* otherKeyChangeObject;
320  NS_SNMP USM *usm;
321 };
322 
323 class AGENTPP_DECL UsmOwnKeyChange: public UsmKeyChange
324 {
325  public:
326  UsmOwnKeyChange(Oidx o, NS_SNMP USM *u) : UsmKeyChange(o, u) {};
327  UsmOwnKeyChange(Oidx o, int keylen, int hashfunction, int typeOfKey,
328  UsmKeyChange* ukc, NS_SNMP USM *u)
329  : UsmKeyChange(o, keylen, hashfunction, typeOfKey, ukc, u){};
330  virtual ~UsmOwnKeyChange();
331 
332  virtual int prepare_set_request(Request* req, int& ind);
333  virtual MibEntryPtr clone();
334 
335  private:
336 
337 };
338 
339 
340 /**********************************************************************
341  *
342  * class UsmStatsUnsupportedSecLevels
343  *
344  **********************************************************************/
345 
346 class AGENTPP_DECL UsmStatsUnsupportedSecLevels: public MibLeaf {
347 
348 public:
349  UsmStatsUnsupportedSecLevels(const NS_SNMP USM *u);
350  void get_request(Request*, int);
351 private:
352  const NS_SNMP USM *usm;
353 };
354 
355 /**********************************************************************
356  *
357  * class UsmStatsNotInTimeWindows
358  *
359  **********************************************************************/
360 
361 class AGENTPP_DECL UsmStatsNotInTimeWindows: public MibLeaf {
362 
363 public:
364  UsmStatsNotInTimeWindows(const NS_SNMP USM *u);
365  void get_request(Request*, int);
366 private:
367  const NS_SNMP USM *usm;
368 };
369 
370 /**********************************************************************
371  *
372  * class UsmStatsUnknownUserNames
373  *
374  **********************************************************************/
375 
376 class AGENTPP_DECL UsmStatsUnknownUserNames: public MibLeaf {
377 
378 public:
379  UsmStatsUnknownUserNames(const NS_SNMP USM *u);
380  void get_request(Request*, int);
381 private:
382  const NS_SNMP USM *usm;
383 };
384 
385 /**********************************************************************
386  *
387  * class UsmStatsUnknownEngineIDs
388  *
389  **********************************************************************/
390 
391 class AGENTPP_DECL UsmStatsUnknownEngineIDs: public MibLeaf {
392 
393 public:
394  UsmStatsUnknownEngineIDs(const NS_SNMP USM *u);
395  void get_request(Request*, int);
396 private:
397  const NS_SNMP USM *usm;
398 };
399 
400 /**********************************************************************
401  *
402  * class UsmStatsWrongDigests
403  *
404  **********************************************************************/
405 
406 class AGENTPP_DECL UsmStatsWrongDigests: public MibLeaf {
407 
408 public:
409  UsmStatsWrongDigests(const NS_SNMP USM *u);
410  void get_request(Request*, int);
411 private:
412  const NS_SNMP USM *usm;
413 };
414 
415 /**********************************************************************
416  *
417  * class UsmStatsDecryptionErrors
418  *
419  **********************************************************************/
420 
421 class AGENTPP_DECL UsmStatsDecryptionErrors: public MibLeaf {
422 
423 public:
424  UsmStatsDecryptionErrors(const NS_SNMP USM *u);
425  void get_request(Request*, int);
426 private:
427  const NS_SNMP USM *usm;
428 };
429 
430 
431 /**********************************************************************
432  *
433  * class UsmStats
434  *
435  **********************************************************************/
436 
437 class AGENTPP_DECL UsmStats: public MibGroup {
438 
439 public:
440 
441  UsmStats(void);
442 };
443 
444 class AGENTPP_DECL usm_mib: public MibGroup {
445 
446 public:
447 
448  usm_mib(UsmUserTable*);
449 };
450 
451 
452 class AGENTPP_DECL MPDGroup: public MibGroup {
453 
454 public:
455 
456  MPDGroup(void);
457 };
458 
459 class AGENTPP_DECL MPDGroupSnmpUnknownSecurityModels: public MibLeaf {
460 
461 public:
462  MPDGroupSnmpUnknownSecurityModels(const NS_SNMP v3MP *mp);
463  void get_request(Request*, int);
464 private:
465  const NS_SNMP v3MP *v3mp;
466 };
467 
468 class AGENTPP_DECL MPDGroupSnmpInvalidMsgs: public MibLeaf {
469 
470 public:
471  MPDGroupSnmpInvalidMsgs(const NS_SNMP v3MP *mp);
472  void get_request(Request*, int);
473 private:
474  const NS_SNMP v3MP *v3mp;
475 };
476 
477 class AGENTPP_DECL MPDGroupSnmpUnknownPDUHandlers: public MibLeaf {
478 
479 public:
480  MPDGroupSnmpUnknownPDUHandlers(const NS_SNMP v3MP *mp);
481  void get_request(Request*, int);
482 private:
483  const NS_SNMP v3MP *v3mp;
484 };
485 
486 
487 class AGENTPP_DECL usmUserAuthProtocol: public MibLeaf {
488 
489  public:
490  usmUserAuthProtocol(const Oidx&, NS_SNMP USM *u);
491  virtual bool value_ok(const Vbx&);
492  virtual MibEntryPtr clone();
493  private:
494  NS_SNMP USM *usm;
495 };
496 
497 class AGENTPP_DECL usmUserPrivProtocol: public MibLeaf {
498 
499  public:
500  usmUserPrivProtocol(const Oidx&, NS_SNMP USM *u);
501  virtual bool value_ok(const Vbx&);
502  virtual int prepare_set_request(Request*, int&);
503  virtual MibEntryPtr clone();
504  private:
505  NS_SNMP USM *usm;
506 };
507 #ifdef AGENTPP_NAMESPACE
508 }
509 #endif
510 #endif
511 
512 #endif
513