30 #ifndef _SNMP_MP_V3_H_ 31 #define _SNMP_MP_V3_H_ 41 #ifdef SNMP_PP_NAMESPACE 48 #define MAX_HOST_NAME_LENGTH 128 49 #ifndef MAX_ENGINE_ID_CACHE_SIZE 50 #define MAX_ENGINE_ID_CACHE_SIZE 50000 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" 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 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 129 unsigned int engine_boots,
int &construct_status);
146 {
return own_engine_id_oct; };
176 {
return engine_id_table.add_entry(engine_id, host, port); };
187 {
return engine_id_table.delete_entry(host, port); };
197 {
return engine_id_table.delete_entry(engine_id); };
211 {
return engine_id_table.get_entry(engine_id, hostport); };
224 const OctetStr &host,
int port)
const 225 {
return engine_id_table.get_entry(engineID, host, port); };
234 {
return engine_id_table.reset(); };
244 int remove_engine_id(
const OctetStr &engine_id);
254 {
return snmpUnknownSecurityModels; };
262 {
return snmpInvalidMsgs; };
270 {
return snmpUnknownPDUHandlers; };
276 { snmpUnknownSecurityModels++; };
314 unsigned char *inBuf,
321 long &msgSecurityModel,
337 static bool is_v3_msg(
unsigned char *buffer,
int length);
357 unsigned char *packet,
361 int securityModel,
int securityLevel,
375 const bool local_request =
true)
376 { cache.delete_entry(requestID, local_request); };
390 unsigned long messageID,
391 const bool local_request)
392 { cache.delete_entry(requestID, messageID, local_request); };
412 int send_report(
unsigned char* scopedPDU,
int scopedPDULength,
413 struct snmp_pdu *pdu,
int errorCode,
int sLevel,
441 int add_entry(
const OctetStr &engine_id,
484 int delete_entry(
const OctetStr &engine_id);
495 int delete_entry(
const OctetStr &host,
int port);
510 {
if (size_upper_limit > 0) upper_limit_entries = size_upper_limit; }
513 bool initialize_table(
const int size);
572 int add_entry(
int msg_id,
unsigned long req_id,
579 struct SecurityStateReference *sec_state_ref,
580 int error_code,
bool local_request);
593 int get_entry(
int msg_id,
bool local_request,
int *error_code,
594 struct SecurityStateReference **sec_state_ref);
603 void delete_entry(
unsigned long req_id,
bool local_request);
611 void delete_entry(
unsigned long req_id,
int msg_id,
624 int get_entry(
int searchedID,
bool local_request,
662 #ifdef SNMP_PP_NAMESPACE 668 #endif // _SNMP_MP_V3_H_
int upper_limit_entries
the upper most number of entries to keep
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.
void set_cache_size_limit(int size_upper_limit)
Set the upper limit of the number of entries in this engine ID cache.
int get_cache_size_limit()
Get the upper limit of the number of entries in this engine ID cache.
SNMP_PP_MUTABLE SnmpSynchronized lock
int entries
the current amount of entries
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.
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.
unsigned long get_stats_invalid_msgs() const
Get the value of the status counter snmpInvalidMsgs.
void inc_stats_invalid_msgs()
Increment the value of the status counter snmpInvalidMsgs.
Holds cache entries for currently processed requests.
void inc_stats_unknown_pdu_handlers()
Increment the value of the status counter snmpUnknownPDUHandlers.
OctetStr context_engine_id
unsigned int snmpUnknownPDUHandlers
unsigned long get_stats_unknown_security_models() const
Get the value of the status counter snmpUnknownSecurityModels.
USM * get_usm()
Get a pointer to the USM object that is used by the v3MP.
unsigned int cur_msg_id
msgID to use for next message
void set_usm(USM *usm_to_use)
const OctetStr & get_local_engine_id() const
Get the engine id of this SNMP entity as a OctetStr reference.
OctetStr own_engine_id_oct
int add_to_engine_id_table(const OctetStr &engine_id, const OctetStr &host, int port)
Add an entry to the engine id table.
USM * usm
the USM object used
struct Entry_T * table
whole table
int reset_engine_id_table()
Remove all entries from the engine id table.
The SNMPv3 Message Processing Model (v3MP).
int remove_from_engine_id_table(const OctetStr &engine_id)
Remove an entry from the engine id table.
unsigned char * own_engine_id
snmp_version
The SNMP version to use is passed with this enum.
EngineIdTable engine_id_table
The engine id table is used to store known engine ids with corresponding hostadress and port...
unsigned int snmpInvalidMsgs
int max_entries
the maximum number of entries
void delete_from_cache(unsigned long requestID, const bool local_request=true)
Delete the entry with the given request id from the cache.
void get_local_engine_id(OctetStr &id)
Get the engine id of this SNMP entity.
int remove_from_engine_id_table(const OctetStr &host, int port)
Remove an entry from the engine id table.
unsigned long get_stats_unknown_pdu_handlers() const
Get the value of the status counter snmpUnknownPDUHandlers.
This is the class for the User Based Security Model.
int max_entries
the maximum number of entries
struct SecurityStateReference * sec_state_ref
void inc_stats_unknown_security_models()
Increment the value of the status counter snmpUnknownSecurityModels.
DLLOPT int snmp_parse(struct snmp_pdu *pdu, unsigned char *data, int data_length, unsigned char *community_name, int &community_len, snmp_version &version)
SNMP_PP_MUTABLE SnmpSynchronized cur_msg_id_lock
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
int entries
the current amount of entries