SNMP++  3.3.11
mp_v3.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## mp_v3.h
4  _##
5  _## SNMP++ v3.3
6  _## -----------------------------------------------
7  _## Copyright (c) 2001-2013 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 and Jochen Katz make no representations about the
21  _## 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  public:
112  /**
113  * Initialize the v3MP.
114  *
115  * Set the engineID of this SNMP entity and the Snmp object used to
116  * send reports. This function creates a new USM object that can
117  * be configured after getting a pointer to it through get_usm().
118  *
119  * The user is responsible to save and restore and increment the
120  * snmpEngineBoots counter (The functions getBootCounter() and
121  * saveBootCounter() can be used to do this.).
122  *
123  * @param engine_id - The locale engine id
124  * @param engine_boots - The new value for the snmpEngineBoots counter
125  * @param construct_status - OUT: SNMPv3_MP_OK or SNMPv3_MP_ERROR
126  *
127  */
128  v3MP(const OctetStr& engine_id,
129  unsigned int engine_boots, int &construct_status);
130 
131  /**
132  * Get the engine id of this SNMP entity.
133  *
134  * @param id - OUT: The engineID of this SNMP entity
135  *
136  * @return - SNMPv3_MP_OK or SNMPv3_MP_ERROR
137  */
138  void get_local_engine_id(OctetStr &id) { id = own_engine_id_oct; };
139 
140  /**
141  * Get the engine id of this SNMP entity as a OctetStr reference.
142  *
143  * @return Local engine id.
144  */
146  { return own_engine_id_oct; };
147 
148  /**
149  * Get a pointer to the USM object that is used by the v3MP.
150  */
151  USM *get_usm() { return usm; };
152 
153  /**
154  * Free all allocated ressources of the v3MP and leave it in an
155  * uninitialized state. After a call to this function, you can use
156  * mpInit() to reinitialize the v3MP.
157  *
158  */
159  ~v3MP();
160 
161  /**
162  * Add an entry to the engine id table.
163  *
164  * In this table all known engine ids are stored. If the discovery
165  * mode of the USM is enabled, snmp++ will add entries to this table
166  * whenever a new engine id is dicovered.
167  *
168  * @param engine_id - The engine id
169  * @param host - The numerical IP address
170  * @param port - The port
171  *
172  * @return - SNMPv3_MP_ERROR, SNMPv3_MP_OK
173  */
174  int add_to_engine_id_table(const OctetStr &engine_id,
175  const OctetStr &host, int port)
176  { return engine_id_table.add_entry(engine_id, host, port); };
177 
178  /**
179  * Remove an entry from the engine id table.
180  *
181  * @param host - The numerical IP address
182  * @param port - The port
183  *
184  * @return - SNMPv3_MP_ERROR, SNMPv3_MP_OK
185  */
186  int remove_from_engine_id_table(const OctetStr &host, int port)
187  { return engine_id_table.delete_entry(host, port); };
188 
189  /**
190  * Remove an entry from the engine id table.
191  *
192  * @param engine_id - The engine id
193  *
194  * @return - SNMPv3_MP_ERROR, SNMPv3_MP_OK
195  */
196  int remove_from_engine_id_table(const OctetStr &engine_id)
197  { return engine_id_table.delete_entry(engine_id); };
198 
199  /**
200  * Get the engine id of the SNMP entity at the given host/port.
201  *
202  * @param engine_id - OUT: The engine id
203  * @param hostport - The numerical IP address and port
204  * (syntax: a.b.c.d/port)
205  *
206  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
207  * SNMPv3_MP_OK
208  */
210  const OctetStr &hostport) const
211  { return engine_id_table.get_entry(engine_id, hostport); };
212 
213  /**
214  * Get the engineID of the SNMP entity at the given host/port.
215  *
216  * @param engineID - OUT: The engineID
217  * @param host - The numerical IP address
218  * @param port - The port
219  *
220  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
221  * SNMPv3_MP_OK
222  */
224  const OctetStr &host, int port) const
225  { return engine_id_table.get_entry(engineID, host, port); };
226 
227  /**
228  * Remove all entries from the engine id table.
229  *
230  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
231  * SNMPv3_MP_OK
232  */
234  { return engine_id_table.reset(); };
235 
236  /**
237  * Remove all occurences of this engine id from v3MP and USM.
238  *
239  * @param engine_id - The engine id to remove
240  *
241  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
242  * SNMPv3_MP_OK
243  */
244  int remove_engine_id(const OctetStr &engine_id);
245 
246  // ----------[ Access to status counters for agent++ ]--------------
247 
248  /**
249  * Get the value of the status counter snmpUnknownSecurityModels.
250  *
251  * @return - The status counter
252  */
253  unsigned long get_stats_unknown_security_models() const
254  { return snmpUnknownSecurityModels; };
255 
256  /**
257  * Get the value of the status counter snmpInvalidMsgs.
258  *
259  * @return - The status counter
260  */
261  unsigned long get_stats_invalid_msgs() const
262  { return snmpInvalidMsgs; };
263 
264  /**
265  * Get the value of the status counter snmpUnknownPDUHandlers.
266  *
267  * @return - The status counter
268  */
269  unsigned long get_stats_unknown_pdu_handlers() const
270  { return snmpUnknownPDUHandlers; };
271 
272  /**
273  * Increment the value of the status counter snmpUnknownSecurityModels.
274  */
276  { snmpUnknownSecurityModels++; };
277 
278  /**
279  * Increment the value of the status counter snmpInvalidMsgs.
280  */
281  void inc_stats_invalid_msgs() { snmpInvalidMsgs++; };
282 
283  /**
284  * Increment the value of the status counter snmpUnknownPDUHandlers.
285  */
286  void inc_stats_unknown_pdu_handlers() { snmpUnknownPDUHandlers++; };
287 
288  // temporary pointer will be removed...
289  static v3MP *I;
290 
291  protected:
292 
293  /**
294  * Parse the given buffer as a SNMPv3-Message.
295  *
296  * @param snmp_session - IN: The session used to receive the msg
297  * @param pdu - OUT: Parsed values are put into this struct
298  * @param inBuf - The buffer to parse
299  * @param inBufLength - The length of the buffer
300  * @param securityEngineID - OUT: The parsed securityEngineID
301  * @param securityName - OUT: The parsed securityName
302  * @param contextEngineID - OUT: The parsed contextEngineID
303  * @param contextName - OUT: The parsed contextName
304  * @param securityLevel - OUT: The parsed security level
305  * @param msgSecurityModel - OUT: The security model used
306  * @param spp_version - OUT: SNMP version (SNMPv3)
307  * @param from_address - Where the message came from (used to send
308  * a report if neccessary)
309  *
310  * @return - SNMPv3_MP_OK or any error listed in snmperr.h
311  */
312  int snmp_parse(Snmp *snmp_session,
313  struct snmp_pdu *pdu,
314  unsigned char *inBuf,
315  int inBufLength,
316  OctetStr &securityEngineID,
317  OctetStr &securityName,
318  OctetStr &contextEngineID,
319  OctetStr &contextName,
320  long &securityLevel,
321  long &msgSecurityModel,
322  snmp_version &spp_version,
323  UdpAddress from_address);
324 
325  /**
326  * Tests if the given buffer contains a SNMPv3-Message. The buffer is
327  * only parsed to extract the version of the message, no other checks
328  * are made.
329  *
330  * @param buffer - The message
331  * @param length - The length of the message
332  *
333  * @return - TRUE if the version could be extracted and it
334  * is a SNMPv3 message. On any error: FALSE.
335  *
336  */
337  static bool is_v3_msg( unsigned char *buffer, int length);
338 
339  /**
340  * Do the complete process of encoding the given values into the buffer
341  * ready to send to the target.
342  *
343  * @param pdu - The pdu structure
344  * @param packet - The buffer to store the serialized message
345  * @param out_length - IN: Length of the buffer,
346  * OUT: Length of the message
347  * @param securityEngineID - The securityEngineID
348  * @param securityNameIn - The securityName
349  * @param securityModel - Use this security model
350  * @param securityLevel - Use this security level
351  * @param contextEngineID - The contextEngineID
352  * @param contextName - The contextName
353  *
354  * @return - SNMPv3_MP_OK or any error listed in snmperr.h
355  */
356  int snmp_build(struct snmp_pdu *pdu,
357  unsigned char *packet,
358  int *out_length, // maximum Bytes in packet
359  const OctetStr &securityEngineID,
360  const OctetStr &securityNameIn,
361  int securityModel, int securityLevel,
362  const OctetStr &contextEngineID,
363  const OctetStr &contextName);
364 
365  /**
366  * Delete the entry with the given request id from the cache.
367  * This function is used in eventlist.cpp when a request
368  * has timed out.
369  *
370  * @param requestID - The request id.
371  * @param local_request - Does the request id belong to a local or to
372  * a remote request?
373  */
374  void delete_from_cache(unsigned long requestID,
375  const bool local_request = true)
376  { cache.delete_entry(requestID, local_request); };
377 
378  public:
379 
380  /**
381  * Delete the entry with the given request id from the cache.
382  * This function is used in agent++ RequestList.
383  *
384  * @param requestID - The request id.
385  * @param messageID - The message id.
386  * @param local_request - Does the request id belong to a local or to
387  * a remote request?
388  */
389  void delete_from_cache(unsigned long requestID,
390  unsigned long messageID,
391  const bool local_request)
392  { cache.delete_entry(requestID, messageID, local_request); };
393 
394  private:
395 
396  /**
397  * Send a report message.
398  *
399  * @param scopedPDU - The scopedPDU as received. If the pdu is not
400  * encrypted, the request id is extracted
401  * @param scopedPDULength - The lkength of the scopedPDU
402  * @param pdu - The pdu structure.
403  * @param errorCode - The code of the error that occured.
404  * @param sLevel - Send the report with this security level.
405  * @param sModel - Use this security model.
406  * @param sName - Use this security name
407  * @param destination - Send the report to this address.
408  * @param snmp_session - Snmp session to use for sending a report
409  *
410  * @return - SNMPv3_MP_ERROR, SNMPv3_MP_OK
411  */
412  int send_report(unsigned char* scopedPDU, int scopedPDULength,
413  struct snmp_pdu *pdu, int errorCode, int sLevel,
414  int sModel, OctetStr &sName,
415  UdpAddress &destination, Snmp *snmp_session);
416 
417 
418 
419  // =====================[ member classes ]==============================
420 
421  /**
422  * The engine id table is used to store known engine ids with
423  * corresponding hostadress and port.
424  */
426  {
427  public:
428 
429  EngineIdTable(int initial_size = 10);
430  ~EngineIdTable();
431 
432  /**
433  * Add an entry to the table.
434  *
435  * @param engine_id - The engineID
436  * @param host - The numerical IP address
437  * @param port - The port
438  *
439  * @return - SNMPv3_MP_ERROR, SNMPv3_MP_OK
440  */
441  int add_entry(const OctetStr &engine_id,
442  const OctetStr &host, int port);
443 
444  /**
445  * Get the engine_id of the SNMP entity at the given host/port.
446  *
447  * @param engine_id - OUT: The engineID
448  * @param hostport - The numerical IP address and port
449  * (syntax: a.b.c.d/port)
450  *
451  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
452  * SNMPv3_MP_OK
453  */
454  int get_entry(OctetStr &engine_id, const OctetStr &hostport) const;
455 
456  /**
457  * Get the engineID of the SNMP entity at the given host/port.
458  *
459  * @param engine_id - OUT: The engineID
460  * @param host - The numerical IP address
461  * @param port - The port
462  *
463  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
464  * SNMPv3_MP_OK
465  */
466  int get_entry(OctetStr &engine_id, const OctetStr &host, int port) const;
467 
468  /**
469  * Remove all entries from the engine id table.
470  *
471  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
472  * SNMPv3_MP_OK
473  */
474  int reset();
475 
476  /**
477  * Remove the given engine id from the table.
478  *
479  * @param engine_id - The engine id to remove
480  *
481  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
482  * SNMPv3_MP_OK
483  */
484  int delete_entry(const OctetStr &engine_id);
485 
486  /**
487  * Remove the entry for the given address/port from the table.
488  *
489  * @param host - Numeric IP address
490  * @param port - listen port of the snmp entity
491  *
492  * @return - SNMPv3_MP_NOT_INITIALIZED, SNMPv3_MP_ERROR,
493  * SNMPv3_MP_OK
494  */
495  int delete_entry(const OctetStr &host, int port);
496 
497  /**
498  * Get the upper limit of the number of entries in this engine ID cache.
499  * @return - the cache size upper limit (50.000 by default).
500  */
501  int get_cache_size_limit() { return upper_limit_entries; }
502 
503  /**
504  * Set the upper limit of the number of entries in this engine ID cache.
505  * Calls of this method with a cache size of 0 or less are ignored.
506  * @param size_upper_limit
507  * the upper limit of the engine ID cache size (50.000 by default).
508  */
509  void set_cache_size_limit(int size_upper_limit)
510  { if (size_upper_limit > 0) upper_limit_entries = size_upper_limit; }
511 
512  private:
513  bool initialize_table(const int size);
514 
515  struct Entry_T
516  {
519  int port;
520  };
521 
522  struct Entry_T *table;
523  int max_entries; ///< the maximum number of entries
524  int upper_limit_entries; ///< the upper most number of entries to keep
525  int entries; ///< the current amount of entries
527  };
528 
529 
530  /**
531  * Holds cache entries for currently processed requests.
532  */
533  class DLLOPT Cache
534  {
535  public:
536  Cache();
537  ~Cache();
538 
539  struct Entry_T
540  {
541  int msg_id;
542  unsigned long req_id;
549  struct SecurityStateReference *sec_state_ref;
552  };
553 
554  /**
555  * Add an entry to the cache.
556  *
557  * @param msg_id - The message id of the message
558  * @param req_id - The request id of the message
559  * @param sec_engine_id - The authoritative engineID
560  * @param sec_model - The security model used for this message
561  * @param sec_name - The name of the user
562  * @param sec_level - The security level used for this message
563  * @param context_engine_id - The context_engine_id
564  * @param context_name - The context_name
565  * @param sec_state_ref - The reference of the USM
566  * @param error_code - The code of the error that occured while
567  * parsing the received message
568  *
569  * @return - SNMPv3_MP_OK, SNMPv3_MP_ERROR or SNMPv3_DOUBLED_MESSAGE
570  * (an entry with the given values is already in the cache)
571  */
572  int add_entry(int msg_id, unsigned long req_id,
573  const OctetStr &sec_engine_id,
574  int sec_model,
575  const OctetStr &sec_name,
576  int sec_level,
577  const OctetStr &context_engine_id,
578  const OctetStr &context_name,
579  struct SecurityStateReference *sec_state_ref,
580  int error_code, bool local_request);
581  /**
582  * Search the cache for a message id, return the error code and
583  * the sec_state_ref and delete the entry from the cache.
584  *
585  * @param msg_id - Search for this message id
586  * @param error_code - OUT: The error code of the received message
587  * @param sec_state_ref - IN: Pointer to a pointer of the structure
588  * OUT: The structure as received by the USM when
589  * the message was parsed.
590  *
591  * @return - SNMPv3_MP_ERROR, SNMPv3_MP_OK
592  */
593  int get_entry(int msg_id, bool local_request, int *error_code,
594  struct SecurityStateReference **sec_state_ref);
595 
596  /**
597  * Delete the entry with the given request id from the cache.
598  * This function is used in eventlist.cpp when a request
599  * has timed out.
600  *
601  * @param req_id - The request id.
602  */
603  void delete_entry(unsigned long req_id, bool local_request);
604 
605  /**
606  * Delete the entry with the given request and message id from the cache.
607  *
608  * @param req_id - The request id.
609  * @param msg_id - The message id.
610  */
611  void delete_entry(unsigned long req_id, int msg_id,
612  bool local_request);
613 
614  /**
615  * Search the cache for a message id, return the whole entry and
616  * delete the entry from the cache.
617  *
618  * @param searchedID - Search for this message id
619  * @param res - IN: Pointer to an empy structure
620  * OUT: The filled structure
621  *
622  * @return - SNMPv3_MP_ERROR, SNMPv3_MP_OK
623  */
624  int get_entry(int searchedID, bool local_request,
625  struct Cache::Entry_T *res);
626 
627  void delete_content(struct Cache::Entry_T &ce);
628 
629  void set_usm(USM *usm_to_use) { usm = usm_to_use; };
630 
631  private:
632 #ifdef _THREADS
634 #endif
635  struct Entry_T *table; ///< whole table
636  int max_entries; ///< the maximum number of entries
637  int entries; ///< the current amount of entries
639  };
640 
641 
642  // =====================[ member variables ]==============================
645 
646  // the engineID of this SNMP entity
647  unsigned char *own_engine_id;
650 
651  unsigned int cur_msg_id; ///< msgID to use for next message
653 
654  USM *usm; ///< the USM object used
655 
656  // MIB Counters
658  unsigned int snmpInvalidMsgs;
660 };
661 
662 #ifdef SNMP_PP_NAMESPACE
663 } // end of namespace Snmp_pp
664 #endif
665 
666 #endif // _SNMPv3
667 
668 #endif // _SNMP_MP_V3_H_
int upper_limit_entries
the upper most number of entries to keep
Definition: mp_v3.h:524
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:209
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:509
#define SNMP_PP_MUTABLE
Cache cache
Definition: mp_v3.h:644
int get_cache_size_limit()
Get the upper limit of the number of entries in this engine ID cache.
Definition: mp_v3.h:501
SNMP_PP_MUTABLE SnmpSynchronized lock
Definition: mp_v3.h:526
int entries
the current amount of entries
Definition: mp_v3.h:637
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:223
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:389
unsigned long get_stats_invalid_msgs() const
Get the value of the status counter snmpInvalidMsgs.
Definition: mp_v3.h:261
void inc_stats_invalid_msgs()
Increment the value of the status counter snmpInvalidMsgs.
Definition: mp_v3.h:281
Holds cache entries for currently processed requests.
Definition: mp_v3.h:533
void inc_stats_unknown_pdu_handlers()
Increment the value of the status counter snmpUnknownPDUHandlers.
Definition: mp_v3.h:286
OctetStr context_engine_id
Definition: mp_v3.h:547
unsigned int snmpUnknownPDUHandlers
Definition: mp_v3.h:659
unsigned long get_stats_unknown_security_models() const
Get the value of the status counter snmpUnknownSecurityModels.
Definition: mp_v3.h:253
USM * get_usm()
Get a pointer to the USM object that is used by the v3MP.
Definition: mp_v3.h:151
unsigned int cur_msg_id
msgID to use for next message
Definition: mp_v3.h:651
int own_engine_id_len
Definition: mp_v3.h:648
void set_usm(USM *usm_to_use)
Definition: mp_v3.h:629
const OctetStr & get_local_engine_id() const
Get the engine id of this SNMP entity as a OctetStr reference.
Definition: mp_v3.h:145
SNMP class definition.
Definition: uxsnmp.h:107
USM * usm
Definition: mp_v3.h:638
OctetStr own_engine_id_oct
Definition: mp_v3.h:649
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:174
USM * usm
the USM object used
Definition: mp_v3.h:654
struct Entry_T * table
whole table
Definition: mp_v3.h:635
int reset_engine_id_table()
Remove all entries from the engine id table.
Definition: mp_v3.h:233
#define DLLOPT
struct Entry_T * table
Definition: mp_v3.h:522
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:196
unsigned char * own_engine_id
Definition: mp_v3.h:647
snmp_version
The SNMP version to use is passed with this enum.
Definition: target.h:76
EngineIdTable engine_id_table
Definition: mp_v3.h:643
The engine id table is used to store known engine ids with corresponding hostadress and port...
Definition: mp_v3.h:425
OctetStr sec_engine_id
Definition: mp_v3.h:543
unsigned int snmpInvalidMsgs
Definition: mp_v3.h:658
Definition: octet.h:67
OctetStr sec_name
Definition: mp_v3.h:545
int max_entries
the maximum number of entries
Definition: mp_v3.h:523
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:374
void get_local_engine_id(OctetStr &id)
Get the engine id of this SNMP entity.
Definition: mp_v3.h:138
int remove_from_engine_id_table(const OctetStr &host, int port)
Remove an entry from the engine id table.
Definition: mp_v3.h:186
unsigned long get_stats_unknown_pdu_handlers() const
Get the value of the status counter snmpUnknownPDUHandlers.
Definition: mp_v3.h:269
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:636
struct SecurityStateReference * sec_state_ref
Definition: mp_v3.h:549
Definition: asn1.h:135
void inc_stats_unknown_security_models()
Increment the value of the status counter snmpUnknownSecurityModels.
Definition: mp_v3.h:275
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:542
OctetStr context_name
Definition: mp_v3.h:548
Pdu class...
Definition: pdu.h:82
SNMP_PP_MUTABLE SnmpSynchronized cur_msg_id_lock
Definition: mp_v3.h:652
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:657
int entries
the current amount of entries
Definition: mp_v3.h:525