SNMP++  3.3.4
v3.h File Reference
#include <stdio.h>
#include <stdarg.h>
#include "snmp_pp/config_snmp_pp.h"

Go to the source code of this file.

Classes

class  Buffer< T >
 Tool class for easy allocation of buffer space. More...
 

Macros

#define debughexprintf(db_level, data, len)   debughexcprintf(db_level, NULL, data, len);
 Wrapper for debughexcprintf() without comment. More...
 
#define MAXLENGTH_ENGINEID   32
 
#define MAXLENGTH_CONTEXT_NAME   32
 
#define MAXLENGTH_FILENAME   255
 
#define MAXLENGTH_GLOBALDATA   42
 
#define oidV3SnmpEngine   "1.3.6.1.6.3.10.2.1"
 
#define oidV3SnmpEngineID   "1.3.6.1.6.3.10.2.1.1.0"
 
#define oidV3SnmpEngineBoots   "1.3.6.1.6.3.10.2.1.2.0"
 
#define oidV3SnmpEngineTime   "1.3.6.1.6.3.10.2.1.3.0"
 
#define oidV3SnmpEngineMaxMessageSize   "1.3.6.1.6.3.10.2.1.4.0"
 
#define oidSnmpUnavailableContexts   "1.3.6.1.6.3.12.1.4.0"
 
#define oidSnmpUnknownContexts   "1.3.6.1.6.3.12.1.5.0"
 
#define SecurityModel_any   SNMP_SECURITY_MODEL_ANY
 
#define SecurityModel_v1   SNMP_SECURITY_MODEL_V1
 
#define SecurityModel_v2   SNMP_SECURITY_MODEL_V2
 
#define SecurityModel_USM   SNMP_SECURITY_MODEL_USM
 
SNMPv3 Security Model values
#define SNMP_SECURITY_MODEL_ANY   0
 Not used in SNMP++. More...
 
#define SNMP_SECURITY_MODEL_V1   1
 Can be used for SNMPv1 only. More...
 
#define SNMP_SECURITY_MODEL_V2   2
 Can be used for SNMPv2 only. More...
 
#define SNMP_SECURITY_MODEL_USM   3
 Can be used for SNMPv3 only. More...
 
Error codes (storing engineBoots)

These values are returned by getBootCounter() and saveBootCounter().

#define SNMPv3_OK   0
 No error. More...
 
#define SNMPv3_NO_ENTRY_ERROR   -1
 No line for the engine id found. More...
 
#define SNMPv3_FILEOPEN_ERROR   -2
 Unable to open file. More...
 
#define SNMPv3_TOO_LONG_ERROR   -3
 The given engineID is too long. More...
 
#define SNMPv3_FILE_ERROR   -4
 The given file contains a wrong line. More...
 
#define SNMPv3_FILECREATE_ERROR   -5
 The File could not be created. More...
 
#define SNMPv3_FILERENAME_ERROR   -6
 Error renaming the temporary file. More...
 

Functions

DLLOPT void debug_set_level (const int db_level)
 Set the amount of log messages you want to get. More...
 
DLLOPT void debugprintf (int db_level, const char *format,...)
 SNMP++ logging function. More...
 
DLLOPT void debughexcprintf (int db_level, const char *comment, const unsigned char *data, const unsigned int len)
 SNMP++ logging function for hex strings. More...
 
DLLOPT int unsignedCharCompare (const unsigned char *str1, const long int ptr1len, const unsigned char *str2, const long int ptr2len)
 Compare two strings. More...
 
DLLOPT unsigned char * v3strcpy (const unsigned char *src, const int srclen)
 String copy function. More...
 
DLLOPT void encodeString (const unsigned char *in, const int in_length, char *out)
 Encode the given string into the output buffer. More...
 
DLLOPT void decodeString (const unsigned char *in, const int in_length, char *out)
 Decode the given encoded string into the output buffer. More...
 
DLLOPT int getBootCounter (const char *fileName, const OctetStr &engineId, unsigned int &boot)
 Read the bootCounter of the given engineID stored in the given file. More...
 
DLLOPT int saveBootCounter (const char *fileName, const OctetStr &engineId, const unsigned int boot)
 Store the bootCounter of the given engineID in the given file. More...
 

Macro Definition Documentation

#define debughexprintf (   db_level,
  data,
  len 
)    debughexcprintf(db_level, NULL, data, len);

Wrapper for debughexcprintf() without comment.

Definition at line 86 of file v3.h.

#define MAXLENGTH_CONTEXT_NAME   32

Definition at line 111 of file v3.h.

#define MAXLENGTH_ENGINEID   32

Definition at line 110 of file v3.h.

#define MAXLENGTH_FILENAME   255

Definition at line 112 of file v3.h.

#define MAXLENGTH_GLOBALDATA   42

Definition at line 113 of file v3.h.

#define oidSnmpUnavailableContexts   "1.3.6.1.6.3.12.1.4.0"

Definition at line 123 of file v3.h.

#define oidSnmpUnknownContexts   "1.3.6.1.6.3.12.1.5.0"

Definition at line 124 of file v3.h.

#define oidV3SnmpEngine   "1.3.6.1.6.3.10.2.1"

Definition at line 115 of file v3.h.

#define oidV3SnmpEngineBoots   "1.3.6.1.6.3.10.2.1.2.0"

Definition at line 117 of file v3.h.

#define oidV3SnmpEngineID   "1.3.6.1.6.3.10.2.1.1.0"

Definition at line 116 of file v3.h.

#define oidV3SnmpEngineMaxMessageSize   "1.3.6.1.6.3.10.2.1.4.0"

Definition at line 119 of file v3.h.

#define oidV3SnmpEngineTime   "1.3.6.1.6.3.10.2.1.3.0"

Definition at line 118 of file v3.h.

#define SecurityModel_any   SNMP_SECURITY_MODEL_ANY

Definition at line 264 of file v3.h.

#define SecurityModel_USM   SNMP_SECURITY_MODEL_USM

Definition at line 267 of file v3.h.

#define SecurityModel_v1   SNMP_SECURITY_MODEL_V1

Definition at line 265 of file v3.h.

#define SecurityModel_v2   SNMP_SECURITY_MODEL_V2

Definition at line 266 of file v3.h.

#define SNMP_SECURITY_MODEL_ANY   0

Not used in SNMP++.

Definition at line 46 of file v3.h.

#define SNMP_SECURITY_MODEL_USM   3

Can be used for SNMPv3 only.

Definition at line 49 of file v3.h.

#define SNMP_SECURITY_MODEL_V1   1

Can be used for SNMPv1 only.

Definition at line 47 of file v3.h.

#define SNMP_SECURITY_MODEL_V2   2

Can be used for SNMPv2 only.

Definition at line 48 of file v3.h.

#define SNMPv3_FILE_ERROR   -4

The given file contains a wrong line.

Definition at line 136 of file v3.h.

#define SNMPv3_FILECREATE_ERROR   -5

The File could not be created.

Definition at line 137 of file v3.h.

#define SNMPv3_FILEOPEN_ERROR   -2

Unable to open file.

Definition at line 134 of file v3.h.

#define SNMPv3_FILERENAME_ERROR   -6

Error renaming the temporary file.

Definition at line 138 of file v3.h.

#define SNMPv3_NO_ENTRY_ERROR   -1

No line for the engine id found.

Definition at line 133 of file v3.h.

#define SNMPv3_OK   0

No error.

Definition at line 132 of file v3.h.

#define SNMPv3_TOO_LONG_ERROR   -3

The given engineID is too long.

Definition at line 135 of file v3.h.

Function Documentation

DLLOPT void debug_set_level ( const int  db_level)

Set the amount of log messages you want to get.

To disable all messages, set the level to -1

Parameters
db_level- New level
DLLOPT void debughexcprintf ( int  db_level,
const char *  comment,
const unsigned char *  data,
const unsigned int  len 
)

SNMP++ logging function for hex strings.

Parameters
db_level- Priority of the message (0 = high)
comment- Comment printed before the hex dump (may be 0)
data- pointer to the hex data
len- length of the hex data
DLLOPT void debugprintf ( int  db_level,
const char *  format,
  ... 
)

SNMP++ logging function.

The default is to log all messages with a level < 19. To change that either edit v3.cpp or use a "extern unsigned int debug_level" to change the level.

Parameters
db_level- Priority of the message (0 = high)
format- Just like printf
DLLOPT void decodeString ( const unsigned char *  in,
const int  in_length,
char *  out 
)

Decode the given encoded string into the output buffer.

Parameters
in- The encoded string
in_length- The length of the encoded string
out- Buffer for the decoded string (half size of input string). The String will be null terminated.
DLLOPT void encodeString ( const unsigned char *  in,
const int  in_length,
char *  out 
)

Encode the given string into the output buffer.

For each byte of the string two bytes in the output buffer are used. The output buffer will contain chars from 0x64 to 0x79.

Parameters
in- The string (for example engine id) to encode
in_length- The length of the engineID
out- The output buffer for the encoded string, must have lenth 2 * in_length
DLLOPT int getBootCounter ( const char *  fileName,
const OctetStr engineId,
unsigned int &  boot 
)

Read the bootCounter of the given engineID stored in the given file.

Parameters
fileName- The name of the file
engineId- Read the bootCounter for this enigneID
boot- OUT: the bootCounter that was read
Returns
One of SNMPv3_OK, SNMPv3_TOO_LONG_ERROR, SNMPv3_FILE_ERROR, SNMPv3_NO_ENTRY_ERROR, SNMPv3_FILEOPEN_ERROR
DLLOPT int saveBootCounter ( const char *  fileName,
const OctetStr engineId,
const unsigned int  boot 
)

Store the bootCounter of the given engineID in the given file.

Parameters
fileName- The name of the file
engineId- Store the bootCounter for this enigneID
boot- The bootCounter
Returns
One of SNMPv3_OK, SNMPv3_FILEOPEN_ERROR, SNMPv3_FILECREATE_ERROR, SNMPv3_FILERENAME_ERROR.
DLLOPT int unsignedCharCompare ( const unsigned char *  str1,
const long int  ptr1len,
const unsigned char *  str2,
const long int  ptr2len 
)

Compare two strings.

Parameters
str1- The first byte array
ptr1len- Length of first array
str2- The second byte array
ptr2len- Length of second array
Returns
1 if the strings are identical, 0 if not.
DLLOPT unsigned char* v3strcpy ( const unsigned char *  src,
const int  srclen 
)

String copy function.

Note
The returned string has to be deleted with "delete []".
Parameters
src- Source string
srclen- Length of source string
Returns
Pointer to a null terminated copy of src (or 0 on error).