About NuDesign
Eval Download
SNMP Links

Tutorial for Visual xAgentBuilder for C++

Lesson 6: Non-volatile parameters

Every agent has a certain set of parameters that have to be stored in the non-volatile RAM. If we want our agents to use NVRAM we have to pass a pointer to the object that implements INonVolatile in the constructor. Implementation of the INonVolatile interface is provided in class BFileNVBFileNV, as you can guess, uses file as NVRAM. Here is the example of usage:


   BFileNV nv(“Lesson6.xnv”);

   BSNMPAgent snmpAgent(tm, &mh, &nv, NULL);


In the above example, the third parameter in the BSNMPAgent’s constructor is address of the nv object. Constructor expects a pointer to the object of INonVolatile derived class in that place, which is in this case BFileNV.

BFileNV has constructor that accepts the name of the file. If file does not exist, it will be created. File is expected to be in ASCII format. The general format of the text in the file is similar to the format of the windows INI files.


; header comment

; header comment

; . . .



; comment for section

<itemKey11> = <itemValue11>

<itemKey12> = <itemValue12>

. . .



; comment for section

<itemKey21> = <itemValue21>

<itemKey22> = <itemValue22>

. . .




; = comment line, ignored by BFileNV

<sectionName> = string

<itemKey> = string

<itemValue> = <primitiveValue> | <compositeValue>

<compositeValue> = <primitiveValue> [ <primitiveValue> [ . . . ] ]

<primitiveValue> = string | integer | string“(“integer“)”


Note that you can have as many comment lines in the file header as you wish. Section comments are restricted to one line only. While you can specify multiline comments in the section, only the first one will be saved.

Here is the example of the configuration file


; +--------------------------------------------+

; | this is nv ram for the agent in tutorial 6 |

; +--------------------------------------------+



; read-write objects in mib-2 system group


sysContact="Mr. SNMP"

sysName="Tutorial 6"



; communityName maxAccess(1=notify;2=readOnly;3=readWrite;4=readCreate)

1=public readOnly(2)

2=private readCreate(4)


. . .


mib-2.system and v1v2cCommunityTbl are section names. For the list of defined sections please take a look at the reference.

Items in the mib-2.system section are primitive values. When the string value has embedded space character(s), quotation mark must be applied (for example “Mr. SNMP”). Putting quotation marks around string without space characters is optional (for example both Toronto and “Toronto” are valid).

Items in the v1v2cCommunityTbl section are composite values. Composite values are usually used as rows of the table. Community table has two columns: communityName (string) and maxAccess (integer). Comment line is this section reminds us of that fact. Item keys for table rows are usually just ordinary numbers.  Values for all columns in one row must be specified. Otherwise, agent will ignore such entry.  Also, agent ignores the row if it contains wrong value (for example, if readOnly is specified for maxAccess instead of readOnly(2)).

Composite value has multiple elements. For example above, composite value “1” has string element 1 (public) and integer element 2 (integer with label readOnly(2)). Important fact is that for “integer with label” construct, only number is important. Even if you misspell label part agent will accept value.  Note that there is no prevention for wrong constructs. For example




will be interpreted as readWrite, as number 4 corresponds to read-write max access, even though the label part specifies valid name for max-access.

If two (or more) sections with the same name are found in the file, items will be merged.

If two (or more) items with the same name exist in the same section, the first will be used.

This agent accepts read requests (get/getNext/GetBulk) with community “public”, and any request with “private” community string.


Please proceed to Lesson 7: VACM

Previous    Next