SNMP++  3.6.3
mp_v3.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## mp_v3.h
4  _##
5  _## SNMP++ v3.4
6  _## -----------------------------------------------
7  _## Copyright (c) 2001-2021 Jochen Katz, Frank Fock
8  _##
9  _## This software is based on SNMP++2.6 from Hewlett Packard:
10  _##
11  _## Copyright (c) 1996
12  _## Hewlett-Packard Company
13  _##
14  _## ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
15  _## Permission to use, copy, modify, distribute and/or sell this software
16  _## and/or its documentation is hereby granted without fee. User agrees
17  _## to display the above copyright notice and this license notice in all
18  _## copies of the software and any documentation of the software. User
19  _## agrees to assume all liability for the use of the software;
20  _## Hewlett-Packard, Frank Fock, and Jochen Katz make no representations
21  _## about the suitability of this software for any purpose. It is provided
22  _## "AS-IS" without warranty of any kind, either express or implied. User
23  _## hereby grants a royalty-free license to any and all derivatives based
24  _## upon this software code base.
25  _##
26  _##########################################################################*/
27 
28 // $Id$
29 
30 #ifndef _SNMP_MP_V3_H_
31 #define _SNMP_MP_V3_H_
32 
33 #include <libsnmp.h>
34 #include "snmp_pp/config_snmp_pp.h"
35 
36 #ifdef _SNMPv3
37 
38 #include "snmp_pp/reentrant.h"
39 #include "snmp_pp/target.h"
40 
41 #ifdef SNMP_PP_NAMESPACE
42 namespace Snmp_pp {
43 #endif
44 
45 class Pdu;
46 class OctetStr;
47 
48 #define MAX_HOST_NAME_LENGTH 128
49 #ifndef MAX_ENGINE_ID_CACHE_SIZE
50 #define MAX_ENGINE_ID_CACHE_SIZE 50000
51 #endif
52 
53 #define oidMPDGroup "1.3.6.1.6.3.11.2.1"
54 #define oidSnmpUnknownSecurityModels "1.3.6.1.6.3.11.2.1.1.0"
55 #define oidSnmpInvalidMsgs "1.3.6.1.6.3.11.2.1.2.0"
56 #define oidSnmpUnknownPDUHandlers "1.3.6.1.6.3.11.2.1.3.0"
57 
58 /** @name Error codes of the v3MP */
59 //@{
60 #define SNMPv3_MP_ERROR -1400
61 #define SNMPv3_MP_OK -1401
62 #define SNMPv3_MP_UNSUPPORTED_SECURITY_MODEL -1402
63 #define SNMPv3_MP_NOT_IN_TIME_WINDOW -1403
64 #define SNMPv3_MP_DOUBLED_MESSAGE -1404
65 #define SNMPv3_MP_INVALID_MESSAGE -1405
66 #define SNMPv3_MP_INVALID_ENGINEID -1406
67 #define SNMPv3_MP_NOT_INITIALIZED -1407
68 #define SNMPv3_MP_PARSE_ERROR -1408
69 #define SNMPv3_MP_UNKNOWN_MSGID -1409
70 #define SNMPv3_MP_MATCH_ERROR -1410
71 #define SNMPv3_MP_COMMUNITY_ERROR -1411
72 #define SNMPv3_MP_WRONG_USER_NAME -1412
73 #define SNMPv3_MP_BUILD_ERROR -1413
74 #define SNMPv3_MP_USM_ERROR -1414
75 #define SNMPv3_MP_UNKNOWN_PDU_HANDLERS -1415
76 #define SNMPv3_MP_UNAVAILABLE_CONTEXT -1416
77 #define SNMPv3_MP_UNKNOWN_CONTEXT -1417
78 #define SNMPv3_MP_REPORT_SENT -1418
79 //@}
80 
81 /** @name Statistics on error codes. */
82 //@{
83 #define SNMPv3_MP_MAX_ERROR SNMPv3_MP_ERROR
84 #define SNMPv3_MP_MIN_ERROR SNMPv3_MP_REPORT_SENT
85 #define SNMPv3_MP_ERRORCOUNT SNMPv3_MP_MAX_ERROR - SNMPv3_MP_MIN_ERROR
86 //@}
87 
88 class Snmp;
89 class USM;
90 
91 /**
92  * The SNMPv3 Message Processing Model (v3MP).
93  *
94  * If SNMPv3 is used, the application needs to create _one_ object of
95  * this class. This object will automatically create an object of the
96  * USM class. A pointer to this object is returned from the get_usm()
97  * method. See the USM documentation for a description on how to create
98  * and delete users.
99  *
100  * The only thing that may be configured after creation of the v3MP is
101  * the engine id table of the v3MP. Entries for other SNMP entities
102  * can be added through add_to_engine_id_table(). It is only required
103  * to add entries to this table if you want to disable engine id
104  * discovery and/or you don't want the delay caused by the automatic
105  * engine id discovery of SNMPv3.
106  */
108 {
109  friend class SnmpMessage;
110  friend class CSNMPMessageQueue;
111  friend class CSNMPMessage;
112  public:
113  /**
114  * Initialize the v3MP.
115  *
116  * Set the engineID of this SNMP entity and the Snmp object used to
117  * send reports. This function creates a new USM object that can
118  * be configured after getting a pointer to it through get_usm().
119  *
120  * The user is responsible to save and restore and increment the
121  * snmpEngineBoots counter (The functions getBootCounter() and
122  * saveBootCounter() can be used to do this.).
123  *
124  * @param engine_id - The locale engine id
125  * @param engine_boots - The new value for the snmpEngineBoots counter
126  * @param construct_status - OUT: SNMPv3_MP_OK or SNMPv3_MP_ERROR
127  *
128  */
129  v3MP(const OctetStr& engine_id,
130  unsigned int engine_boots, int &construct_status);
131 
132  /**
133  * Get the engine id of this SNMP entity.
134  *
135  * @param id - OUT: The engineID of this SNMP entity
136  *
137  * @return - SNMPv3_MP_OK or SNMPv3_MP_ERROR
138  */
139  void get_local_engine_id(OctetStr &id) { id = own_engine_id_oct; };
140 
141  /**
142  * Get the engine id of this SNMP entity as a OctetStr reference.
143  *
144  * @return Local engine id.
145  */
147  { return own_engine_id_oct; };
148 
149  /**
150  * Get a pointer to the USM object that is used by the v3MP.
151  */
152  USM *get_usm() { return usm; };
153 
154  /**
155  * Free all allocated ressources of the v3MP and leave it in an
156  * uninitialized state. After a call to this function, you can use
157  * mpInit() to reinitialize the v3MP.
158  *
159  */
160  ~v3MP();
161 
162  /**
163  * Add an entry to the engine id table.
164  *
165  * In this table all known engine ids are stored. If the discovery
166  * mode of the USM is enabled, snmp++ will add entries to this table
167  * whenever a new engine id is dicovered.
168  *
169  * @param engine_id - The engine id
170  * @param host - The numerical IP address
171  * @param port - The port
172  *
173  * @return - SNMPv3_MP_ERROR, SNMPv3_MP_OK
174  */
175  int add_to_engine_id_table(const OctetStr &engine_id,
176  const OctetStr &host, int port)
177  { return engine_id_table.add_entry(engine_id, host, port); };
178 
179  /**
180  * Remove an entry from the engine id table.
181  *
182  * @param host - The numerical IP address
183  * @param port - The port
184  *
185  * @return - SNMPv3_MP_ERROR, SNMPv3_MP_OK
186  */
187  int remove_from_engine_id_table(const OctetStr &host, int port)
188  { return engine_id_table.delete_entry(host, port); };
189 
190  /**
191  * Remove an entry from the engine id table.
192  *
193  * @param engine_id - The engine id
194  *
195  * @return - SNMPv3_MP_ERROR, SNMPv3_MP_OK
196  */
197  int remove_from_engine_id_table(const OctetStr &engine_id)
198  { return engine_id_table.delete_entry(engine_id); };
199 
200  /**
201  * Get the engine id of the SNMP entity at the given host/port.
202  *
203  * @param engine_id - OUT: The engine id
204  * @param hostport - The numerical IP address and port
205  * (syntax: a.b.c.d/port)
206  *
207  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
208  * SNMPv3_MP_OK
209  */
211  const OctetStr &hostport) const
212  { return engine_id_table.get_entry(engine_id, hostport); };
213 
214  /**
215  * Get the engineID of the SNMP entity at the given host/port.
216  *
217  * @param engineID - OUT: The engineID
218  * @param host - The numerical IP address
219  * @param port - The port
220  *
221  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
222  * SNMPv3_MP_OK
223  */
225  const OctetStr &host, int port) const
226  { return engine_id_table.get_entry(engineID, host, port); };
227 
228  /**
229  * Remove all entries from the engine id table.
230  *
231  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
232  * SNMPv3_MP_OK
233  */
235  { return engine_id_table.reset(); };
236 
237  /**
238  * Remove all occurences of this engine id from v3MP and USM.
239  *
240  * @param engine_id - The engine id to remove
241  *
242  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
243  * SNMPv3_MP_OK
244  */
245  int remove_engine_id(const OctetStr &engine_id);
246 
247  // ----------[ Access to status counters for agent++ ]--------------
248 
249  /**
250  * Get the value of the status counter snmpUnknownSecurityModels.
251  *
252  * @return - The status counter
253  */
254  unsigned long get_stats_unknown_security_models() const
255  { return snmpUnknownSecurityModels; };
256 
257  /**
258  * Get the value of the status counter snmpInvalidMsgs.
259  *
260  * @return - The status counter
261  */
262  unsigned long get_stats_invalid_msgs() const
263  { return snmpInvalidMsgs; };
264 
265  /**
266  * Get the value of the status counter snmpUnknownPDUHandlers.
267  *
268  * @return - The status counter
269  */
270  unsigned long get_stats_unknown_pdu_handlers() const
271  { return snmpUnknownPDUHandlers; };
272 
273  /**
274  * Increment the value of the status counter snmpUnknownSecurityModels.
275  */
277  { snmpUnknownSecurityModels++; };
278 
279  /**
280  * Increment the value of the status counter snmpInvalidMsgs.
281  */
282  void inc_stats_invalid_msgs() { snmpInvalidMsgs++; };
283 
284  /**
285  * Increment the value of the status counter snmpUnknownPDUHandlers.
286  */
287  void inc_stats_unknown_pdu_handlers() { snmpUnknownPDUHandlers++; };
288 
289  // temporary pointer will be removed...
290  static v3MP *I;
291 
292  protected:
293 
294  /**
295  * Parse the given buffer as a SNMPv3-Message.
296  *
297  * @param snmp_session - IN: The session used to receive the msg
298  * @param pdu - OUT: Parsed values are put into this struct
299  * @param inBuf - The buffer to parse
300  * @param inBufLength - The length of the buffer
301  * @param securityEngineID - OUT: The parsed securityEngineID
302  * @param securityName - OUT: The parsed securityName
303  * @param contextEngineID - OUT: The parsed contextEngineID
304  * @param contextName - OUT: The parsed contextName
305  * @param securityLevel - OUT: The parsed security level
306  * @param msgSecurityModel - OUT: The security model used
307  * @param spp_version - OUT: SNMP version (SNMPv3)
308  * @param from_address - Where the message came from (used to send
309  * a report if neccessary)
310  *
311  * @return - SNMPv3_MP_OK or any error listed in snmperr.h
312  */
313  int snmp_parse(Snmp *snmp_session,
314  struct snmp_pdu *pdu,
315  unsigned char *inBuf,
316  int inBufLength,
317  OctetStr &securityEngineID,
318  OctetStr &securityName,
319  OctetStr &contextEngineID,
320  OctetStr &contextName,
321  long &securityLevel,
322  long &msgSecurityModel,
323  snmp_version &spp_version,
324  UdpAddress from_address);
325 
326  /**
327  * Tests if the given buffer contains a SNMPv3-Message. The buffer is
328  * only parsed to extract the version of the message, no other checks
329  * are made.
330  *
331  * @param buffer - The message
332  * @param length - The length of the message
333  *
334  * @return - TRUE if the version could be extracted and it
335  * is a SNMPv3 message. On any error: FALSE.
336  *
337  */
338  static bool is_v3_msg( unsigned char *buffer, int length);
339 
340  /**
341  * Do the complete process of encoding the given values into the buffer
342  * ready to send to the target.
343  *
344  * @param pdu - The pdu structure
345  * @param packet - The buffer to store the serialized message
346  * @param out_length - IN: Length of the buffer,
347  * OUT: Length of the message
348  * @param securityEngineID - The securityEngineID
349  * @param securityNameIn - The securityName
350  * @param securityModel - Use this security model
351  * @param securityLevel - Use this security level
352  * @param contextEngineID - The contextEngineID
353  * @param contextName - The contextName
354  *
355  * @return - SNMPv3_MP_OK or any error listed in snmperr.h
356  */
357  int snmp_build(struct snmp_pdu *pdu,
358  unsigned char *packet,
359  int *out_length, // maximum Bytes in packet
360  const OctetStr &securityEngineID,
361  const OctetStr &securityNameIn,
362  int securityModel, int securityLevel,
363  const OctetStr &contextEngineID,
364  const OctetStr &contextName);
365 
366  /**
367  * Delete the entry with the given request id from the cache.
368  * This function is used in eventlist.cpp when a request
369  * has timed out.
370  *
371  * @param requestID - The request id.
372  * @param local_request - Does the request id belong to a local or to
373  * a remote request?
374  */
375  void delete_from_cache(unsigned long requestID,
376  const bool local_request = true)
377  { cache.delete_entry(requestID, local_request); };
378 
379  public:
380 
381  /**
382  * Delete the entry with the given request id from the cache.
383  * This function is used in agent++ RequestList.
384  *
385  * @param requestID - The request id.
386  * @param messageID - The message id.
387  * @param local_request - Does the request id belong to a local or to
388  * a remote request?
389  */
390  void delete_from_cache(unsigned long requestID,
391  unsigned long messageID,
392  const bool local_request)
393  { cache.delete_entry(requestID, messageID, local_request); };
394 
395  private:
396 
397  /**
398  * Send a report message.
399  *
400  * @param scopedPDU - The scopedPDU as received. If the pdu is not
401  * encrypted, the request id is extracted
402  * @param scopedPDULength - The lkength of the scopedPDU
403  * @param pdu - The pdu structure.
404  * @param errorCode - The code of the error that occured.
405  * @param sLevel - Send the report with this security level.
406  * @param sModel - Use this security model.
407  * @param sName - Use this security name
408  * @param destination - Send the report to this address.
409  * @param snmp_session - Snmp session to use for sending a report
410  *
411  * @return - SNMPv3_MP_ERROR, SNMPv3_MP_OK
412  */
413  int send_report(unsigned char* scopedPDU, int scopedPDULength,
414  struct snmp_pdu *pdu, int errorCode, int sLevel,
415  int sModel, OctetStr &sName,
416  UdpAddress &destination, Snmp *snmp_session);
417 
418 
419 
420  // =====================[ member classes ]==============================
421 
422  /**
423  * The engine id table is used to store known engine ids with
424  * corresponding hostadress and port.
425  */
427  {
428  public:
429 
430  EngineIdTable(int initial_size = 10);
431  ~EngineIdTable();
432 
433  /**
434  * Add an entry to the table.
435  *
436  * @param engine_id - The engineID
437  * @param host - The numerical IP address
438  * @param port - The port
439  *
440  * @return - SNMPv3_MP_ERROR, SNMPv3_MP_OK
441  */
442  int add_entry(const OctetStr &engine_id,
443  const OctetStr &host, int port);
444 
445  /**
446  * Get the engine_id of the SNMP entity at the given host/port.
447  *
448  * @param engine_id - OUT: The engineID
449  * @param hostport - The numerical IP address and port
450  * (syntax: a.b.c.d/port)
451  *
452  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
453  * SNMPv3_MP_OK
454  */
455  int get_entry(OctetStr &engine_id, const OctetStr &hostport) const;
456 
457  /**
458  * Get the engineID of the SNMP entity at the given host/port.
459  *
460  * @param engine_id - OUT: The engineID
461  * @param host - The numerical IP address
462  * @param port - The port
463  *
464  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
465  * SNMPv3_MP_OK
466  */
467  int get_entry(OctetStr &engine_id, const OctetStr &host, int port) const;
468 
469  /**
470  * Remove all entries from the engine id table.
471  *
472  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
473  * SNMPv3_MP_OK
474  */
475  int reset();
476 
477  /**
478  * Remove the given engine id from the table.
479  *
480  * @param engine_id - The engine id to remove
481  *
482  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
483  * SNMPv3_MP_OK
484  */
485  int delete_entry(const OctetStr &engine_id);
486 
487  /**
488  * Remove the entry for the given address/port from the table.
489  *
490  * @param host - Numeric IP address
491  * @param port - listen port of the snmp entity
492  *
493  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
494  * SNMPv3_MP_OK
495  */
496  int delete_entry(const OctetStr &host, int port);
497 
498  /**
499  * Get the upper limit of the number of entries in this engine ID cache.
500  * @return - the cache size upper limit (50.000 by default).
501  */
502  int get_cache_size_limit() { return upper_limit_entries; }
503 
504  /**
505  * Set the upper limit of the number of entries in this engine ID cache.
506  * Calls of this method with a cache size of 0 or less are ignored.
507  * @param size_upper_limit
508  * the upper limit of the engine ID cache size (50.000 by default).
509  */
510  void set_cache_size_limit(int size_upper_limit)
511  { if (size_upper_limit > 0) upper_limit_entries = size_upper_limit; }
512 
513  private:
514  bool initialize_table(const int size);
515 
516  struct Entry_T
517  {
520  int port;
521  };
522 
523  struct Entry_T *table;
524  int max_entries; ///< the maximum number of entries
525  int upper_limit_entries; ///< the upper most number of entries to keep
526  int entries; ///< the current amount of entries
528  };
529 
530 
531  /**
532  * Holds cache entries for currently processed requests.
533  */
534  class DLLOPT Cache
535  {
536  public:
537  Cache();
538  ~Cache();
539 
540  struct Entry_T
541  {
542  int msg_id;
543  unsigned long req_id;
550  struct SecurityStateReference *sec_state_ref;
553  };
554 
555  /**
556  * Add an entry to the cache.
557  *
558  * @param msg_id - The message id of the message
559  * @param req_id - The request id of the message
560  * @param sec_engine_id - The authoritative engineID
561  * @param sec_model - The security model used for this message
562  * @param sec_name - The name of the user
563  * @param sec_level - The security level used for this message
564  * @param context_engine_id - The context_engine_id
565  * @param context_name - The context_name
566  * @param sec_state_ref - The reference of the USM
567  * @param error_code - The code of the error that occured while
568  * parsing the received message
569  *
570  * @return - SNMPv3_MP_OK, SNMPv3_MP_ERROR or SNMPv3_DOUBLED_MESSAGE
571  * (an entry with the given values is already in the cache)
572  */
573  int add_entry(int msg_id, unsigned long req_id,
574  const OctetStr &sec_engine_id,
575  int sec_model,
576  const OctetStr &sec_name,
577  int sec_level,
578  const OctetStr &context_engine_id,
579  const OctetStr &context_name,
580  struct SecurityStateReference *sec_state_ref,
581  int error_code, bool local_request);
582  /**
583  * Search the cache for a message id, return the error code and
584  * the sec_state_ref and delete the entry from the cache.
585  *
586  * @param msg_id - Search for this message id
587  * @param error_code - OUT: The error code of the received message
588  * @param sec_state_ref - IN: Pointer to a pointer of the structure
589  * OUT: The structure as received by the USM when
590  * the message was parsed.
591  *
592  * @return - SNMPv3_MP_ERROR, SNMPv3_MP_OK
593  */
594  int get_entry(int msg_id, bool local_request, int *error_code,
595  struct SecurityStateReference **sec_state_ref);
596 
597  /**
598  * Delete the entry with the given request id from the cache.
599  * This function is used in eventlist.cpp when a request
600  * has timed out.
601  *
602  * @param req_id - The request id.
603  */
604  void delete_entry(unsigned long req_id, bool local_request);
605 
606  /**
607  * Delete the entry with the given request and message id from the cache.
608  *
609  * @param req_id - The request id.
610  * @param msg_id - The message id.
611  */
612  void delete_entry(unsigned long req_id, int msg_id,
613  bool local_request);
614 
615  /**
616  * Search the cache for a message id, return the whole entry and
617  * delete the entry from the cache.
618  *
619  * @param searchedID - Search for this message id
620  * @param res - IN: Pointer to an empy structure
621  * OUT: The filled structure
622  *
623  * @return - SNMPv3_MP_ERROR, SNMPv3_MP_OK
624  */
625  int get_entry(int searchedID, bool local_request,
626  struct Cache::Entry_T *res);
627 
628  void delete_content(struct Cache::Entry_T &ce);
629 
630  void set_usm(USM *usm_to_use) { usm = usm_to_use; };
631 
632  private:
633 #ifdef _THREADS
635 #endif
636  struct Entry_T *table; ///< whole table
637  int max_entries; ///< the maximum number of entries
638  int entries; ///< the current amount of entries
640  };
641 
642 
643  // =====================[ member variables ]==============================
646 
647  // the engineID of this SNMP entity
648  unsigned char *own_engine_id;
651 
652  unsigned int cur_msg_id; ///< msgID to use for next message
654 
655  USM *usm; ///< the USM object used
656 
657  // MIB Counters
659  unsigned int snmpInvalidMsgs;
661 };
662 
663 #ifdef SNMP_PP_NAMESPACE
664 } // end of namespace Snmp_pp
665 #endif
666 
667 #endif // _SNMPv3
668 
669 #endif // _SNMP_MP_V3_H_
int upper_limit_entries
the upper most number of entries to keep
Definition: mp_v3.h:525
int get_from_engine_id_table(OctetStr &engine_id, const OctetStr &hostport) const
Get the engine id of the SNMP entity at the given host/port.
Definition: mp_v3.h:210
void set_cache_size_limit(int size_upper_limit)
Set the upper limit of the number of entries in this engine ID cache.
Definition: mp_v3.h:510
#define SNMP_PP_MUTABLE
Cache cache
Definition: mp_v3.h:645
int get_cache_size_limit()
Get the upper limit of the number of entries in this engine ID cache.
Definition: mp_v3.h:502
SNMP_PP_MUTABLE SnmpSynchronized lock
Definition: mp_v3.h:527
int entries
the current amount of entries
Definition: mp_v3.h:638
int get_from_engine_id_table(OctetStr &engineID, const OctetStr &host, int port) const
Get the engineID of the SNMP entity at the given host/port.
Definition: mp_v3.h:224
void delete_from_cache(unsigned long requestID, unsigned long messageID, const bool local_request)
Delete the entry with the given request id from the cache.
Definition: mp_v3.h:390
unsigned long get_stats_invalid_msgs() const
Get the value of the status counter snmpInvalidMsgs.
Definition: mp_v3.h:262
void inc_stats_invalid_msgs()
Increment the value of the status counter snmpInvalidMsgs.
Definition: mp_v3.h:282
Holds cache entries for currently processed requests.
Definition: mp_v3.h:534
void inc_stats_unknown_pdu_handlers()
Increment the value of the status counter snmpUnknownPDUHandlers.
Definition: mp_v3.h:287
OctetStr context_engine_id
Definition: mp_v3.h:548
unsigned int snmpUnknownPDUHandlers
Definition: mp_v3.h:660
unsigned long get_stats_unknown_security_models() const
Get the value of the status counter snmpUnknownSecurityModels.
Definition: mp_v3.h:254
USM * get_usm()
Get a pointer to the USM object that is used by the v3MP.
Definition: mp_v3.h:152
unsigned int cur_msg_id
msgID to use for next message
Definition: mp_v3.h:652
int own_engine_id_len
Definition: mp_v3.h:649
void set_usm(USM *usm_to_use)
Definition: mp_v3.h:630
const OctetStr & get_local_engine_id() const
Get the engine id of this SNMP entity as a OctetStr reference.
Definition: mp_v3.h:146
SNMP class definition.
Definition: uxsnmp.h:107
USM * usm
Definition: mp_v3.h:639
OctetStr own_engine_id_oct
Definition: mp_v3.h:650
int add_to_engine_id_table(const OctetStr &engine_id, const OctetStr &host, int port)
Add an entry to the engine id table.
Definition: mp_v3.h:175
USM * usm
the USM object used
Definition: mp_v3.h:655
struct Entry_T * table
whole table
Definition: mp_v3.h:636
int reset_engine_id_table()
Remove all entries from the engine id table.
Definition: mp_v3.h:234
#define DLLOPT
struct Entry_T * table
Definition: mp_v3.h:523
The SNMPv3 Message Processing Model (v3MP).
Definition: mp_v3.h:107
int remove_from_engine_id_table(const OctetStr &engine_id)
Remove an entry from the engine id table.
Definition: mp_v3.h:197
unsigned char * own_engine_id
Definition: mp_v3.h:648
snmp_version
The SNMP version to use is passed with this enum.
Definition: target.h:76
EngineIdTable engine_id_table
Definition: mp_v3.h:644
The engine id table is used to store known engine ids with corresponding hostadress and port...
Definition: mp_v3.h:426
OctetStr sec_engine_id
Definition: mp_v3.h:544
unsigned int snmpInvalidMsgs
Definition: mp_v3.h:659
Definition: octet.h:67
OctetStr sec_name
Definition: mp_v3.h:546
int max_entries
the maximum number of entries
Definition: mp_v3.h:524
void delete_from_cache(unsigned long requestID, const bool local_request=true)
Delete the entry with the given request id from the cache.
Definition: mp_v3.h:375
void get_local_engine_id(OctetStr &id)
Get the engine id of this SNMP entity.
Definition: mp_v3.h:139
int remove_from_engine_id_table(const OctetStr &host, int port)
Remove an entry from the engine id table.
Definition: mp_v3.h:187
unsigned long get_stats_unknown_pdu_handlers() const
Get the value of the status counter snmpUnknownPDUHandlers.
Definition: mp_v3.h:270
This is the class for the User Based Security Model.
Definition: usm_v3.h:241
int max_entries
the maximum number of entries
Definition: mp_v3.h:637
struct SecurityStateReference * sec_state_ref
Definition: mp_v3.h:550
Definition: asn1.h:135
void inc_stats_unknown_security_models()
Increment the value of the status counter snmpUnknownSecurityModels.
Definition: mp_v3.h:276
DLLOPT int snmp_parse(struct snmp_pdu *pdu, unsigned char *data, int data_length, unsigned char *community_name, int &community_len, snmp_version &version)
unsigned long req_id
Definition: mp_v3.h:543
OctetStr context_name
Definition: mp_v3.h:549
Pdu class...
Definition: pdu.h:82
SNMP_PP_MUTABLE SnmpSynchronized cur_msg_id_lock
Definition: mp_v3.h:653
DLLOPT int snmp_build(struct snmp_pdu *pdu, unsigned char *packet, int *out_length, const long version, const unsigned char *community, const int community_len)
unsigned int snmpUnknownSecurityModels
Definition: mp_v3.h:658
int entries
the current amount of entries
Definition: mp_v3.h:526