The Code Generator
For AGENT++
Version 1.8.3
Frank Fock
2
1 SYSTEM REQUIREMENTS ........................................................................... 3
2 INSTALLATION.............................................................................................. 3
3 WHAT IS AGENTGEN? ................................................................................. 3
4 AGENTGEN STANDARD............................................................................... 4
4.1 The Code Generation Steps....................................................................... 4
4.1.1 Initialize Your MIB Repository...................................................................... 4
4.1.2 Load MIB Files into The Repository .............................................................. 4
4.1.3 Check Repository Contents.......................................................................... 5
4.1.4 Code Generation......................................................................................... 5
4.1.5 Dump a MIB Module ................................................................................... 5
5 AGENTGEN PROFESSIONAL ...................................................................... 6
5.1 Start .......................................................................................................... 6
5.2 MIB Repository ......................................................................................... 7
5.2.1 Initialization ............................................................................................... 7
5.2.2 Adding MIBs............................................................................................... 7
5.2.3 Removing MIBs .......................................................................................... 8
5.2.4 Exporting the MIB Repository ...................................................................... 8
5.3 Code Generation........................................................................................ 9
5.3.1 Code Generation Wizard Step 1 ................................................................... 9
5.3.2 Code Generation Wizard Step 2 ................................................................. 11
5.3.3 Code Generation Wizard Step 3 ................................................................. 12
5.3.4 When to Use Which Generated Method...................................................... 13
5.4 Search Functions..................................................................................... 15
5.4.1 Find MIB Objects ...................................................................................... 15
5.4.2 Ambiguous Names.................................................................................... 16
6 PLUG-IN INTERFACE.................................................................................. 16
7 ERROR MESSAGES.................................................................................... 20
8 EXAMPLE MIB LIST .................................................................................... 22
3
1 System Requirements
To use AgentGen v1.8 on your computer, you need Java Runtime Environment v1.2.2 or
later installed.
1
2 Installation
Use a decompression tool of your choice (e.g., unzip), that is capable of the ZIP format,
to unpack the agenpro.zip file you downloaded from the AGENT++ web site in an arbitrary
folder. On UNIX system use the –a option to unzip, e.g. “unzip –a agenpro.zip”.
3 What Is AgentGen?
AgentGen is a tool to generate C++ source code from Simple Network Management
Protocol (SNMP) MIB
2
files. The generated code makes use of the AGENT++ API and thus
cannot be compiled without it.
Since the AGENT++ API changes from version to version, AgentGen can be
parameterized to generate code for a specific AGENT++ version.
AgentGen is available as two editions, AgentGen Standard and AgentGen
Professional. The following table compares their features:
Feature Standard Professional
Round-trip Engineering X
User Defined Plug-Ins X
Command Line Interface X X
Graphical User Interface X
Code Generation for v3.4, v3.3, v2.13 X X
Code Generation for Simulation Agents X X
Selective Object Generation X X
Selective Method Generation X
Generation of Ready2Compile Agent X
Uses AGENT-CAPABILITIES X
Search MIBs by Regular Expression X
Search MIBs for Ambiguous Names X
1
The bin directory of JDK 1.2.2/1.3/1.4 must be included in the PATH environment variable.
2
MIB = Management Information Base.
4
4 AgentGen Standard
4.1 The Code Generation Steps
4.1.1 Initialize Your MIB Repository
The first step after having installed AgentGen is initializing the MIB repository. The MIB
repository is an empty directory in your file system where the MIB information of AgentGen
will be stored. For example you can create a new directory by:
mkdir ~/mibrepository
As a prerequisite to start the scripts agentgen.sh (UNIX) and agentgen.bat (Windows)
respectively, you must change the current working directory to the directory where you
unzipped agenpro.zip. Then you initialize the repository by starting AgentGen as follows:
agentgen.sh ~/mibrepository initialize
Whenever you want to empty (reinitialize) your MIB repository you can run this command
again.
Note All files in the directory ~/mibreposi ory are deleted by this command!
: t
4.1.2 Load MIB Files into The Repository
There are two ways you can load MIB files into a MIB repository of AgentGen. First, you
can add a single MIB file to the repository. Second, you can add a list of files to the
repository. In both cases, an already loaded MIB module will be replaced by the new one.
To add a single file to the repository, run:
agentgen.sh ~/mibrepository add myMIB.txt
AgentGen will report any error, if the MIB cannot be loaded into the repository. Please see
section 6 for a list of error messages.
To load a list of MIB files, first create a text file that contains a MIB file path
3
per line.
Comments have to start with the character #. The files in the list have to be ordered by
their import dependencies. The first MIB files in the list must be those MIB files containing
MIB modules that do not import from any other MIB module. Next you should add those MIB
files with modules that import only from the first group of MIB modules and so on. After
having finished the MIB list, the files are loaded by:
agentgen.sh ~/mibrepository load miblist.txt
3
The path of each MIB file may be relative to the path of the list file.
5
4.1.3 Check Repository Contents
When you have successfully added your MIB modules to the repository, you can check its
contents by:
agentgen.sh ~/mibrepository contents
This command will list all the MIB modules available from the repository.
4.1.4 Code Generation
You can generate two types of AGENT++ code: normal code and simulation code. If
simulation code is generated every leaf MIB object is generated as a class being derived
from the SimMibLeaf class instead being derived from the MibLeaf class. This enables a
agent to serve as a simulation agent when the AGENTPP-SIMULATION-MIB objects are
added to its Mib. Using the AGENTPP-SIMULATION-MIB objects arbitrary objects of the
simulation agent can be created, written, and removed during runtime even if they have
maximum access rights of read-only.
AgentGen distinguishes between header (.h) and implementation files (.cpp). Because
AgentGen pipes its output to stdout, only one file type can be generated per run. For
example, if you like to generate header code for AGENT++v3.4 from the MIB module myMIB
you loaded into the repository before, you run:
agentgen.sh ~/mibrepository generate myMIB h 3.4 > /tmp/mymib.h
To generate the implementation file:
agentgen.sh ~/mibrepository generate myMIB c 3.4 > /tmp/mymib.cpp
If you want to generate code from the same MIB for a simulation agent:
agentgen.sh ~/mibrepository generate myMIB h 3.4,SIM > /tmp/mymib.h
and
agentgen.sh ~/mibrepository generate myMIB c 3.4,SIM > /tmp/mymib.cpp
respectively.
4.1.5 Dump a MIB Module
An additional feature of AgentGen is the capability of dumping the SMI definition of a
loaded MIB module. You can use this feature to verify that the parsing process of AgentGen
worked correctly. To dump the SMI definition of MIB module myMIB, run:
agentgen.sh ~/mibrepository module myMIB
- 1
- 2
- 3
前往页