Name | Date | Size | |
---|---|---|---|
.. | 2016-11-07 20:19:16 | 14 | |
demo_module_3.c | 2016-11-07 20:19:16 | 9.9 KiB | |
demo_module_3.h | 2016-11-07 20:19:16 | 1.4 KiB | |
Makefile | 2016-11-07 20:19:16 | 1.2 KiB | |
README_demo_module_3 | 2016-11-07 20:19:16 | 8.1 KiB | |
SDK-DEMO1-MIB.txt | 2016-11-07 20:19:16 | 6.1 KiB |
README_demo_module_3
/*
*
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements.
*
*
* This distribution may include materials developed by third parties. Sun,
* Sun Microsystems, the Sun logo and Solaris are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
*/
README for demo_module_3
********************************************************************
------------
ways:
for more information about general tables data retrieval.
This example uses some dummy data to perform data retrieval for a
two-index table. It was generated by using "mib2c -c mib2c.iterate.conf"
against the me1ContactInfoTable group in the SDK-DEMO1-MIB.
Some functions have been added to the generated code to implement a
link list to provide the test data.
mib2c created templates called me1ContactInfoTable.c and me1ContactInfoTable.h.
These were renamed demo_module_3.c and demo_module_3.h for this demo.
Within me1ContactInfoTable.c, mib2c generated init_me1ContactInfoTable, and
this was renamed to init_demo_module_3.
Note that even though the SDK-DEMO1-MIB file contains the specification of
tables and scalar, running mib2c with mib2c.iterate.conf
generates template code only for the general table in the MIB.
How to Use the demo_module_3 Code Example
==========================================
The demo_module_3 code example includes the following files, by default
located in the directory /usr/demo/sma_snmp/demo_module_3.
Files:
o Makefile - Compiles the module source code
o demo_module_3.c - Source code for the module
o demo_module_3.h - Header file for the module
o SDK-DEMO1-MIB.txt - MIB file used in the module
To set up your environment for the demo:
1. Copy the demo code to a directory for which you have write permission.
For example:
2. Create a lib directory that you can use to store shared object libraries
that you generate from demo code examples, if you have not already done so.
For example:
3. Create a mibs directory that you can use to store MIB files for the demo
code examples, if you have not already done so.
For example:
4. Set the CC environment variable to the location of the C compiler to
be used.
For example, if you are using Sun ONE Studio:
5. Set your PATH environment variable to include the appropriate paths, so that
needed binaries can be found during the compilation process.
For example, in the csh:
To generate code templates from the sample MIB:
1. Change to the directory where you copied the demo module files.
For example:
% cd /home/username/demo/demo_module_3
2. Copy the SDK-DEMO1-MIB.txt file to the mibs directory you created for the
demos, if you have not already done so.
For example:
% cp SDK-DEMO1-MIB.txt /home/username/demo/mibs
3. Set your MIBS and MIBDIRS environment variables to
include the appropriate paths.
For example, in the csh:
% setenv MIBS +SDK-DEMO1-MIB
4. Run mib2c on the me1ContactInfoTable group in the SDK-DEMO1-MIB.
For example:
% mib2c -c mib2c.iterate.conf me1ContactInfoTable
The mib2c utility generates the following template files:
me1ContactInfoTable.c
me1ContactInfoTable.h
5. Compare the template files with the demo_module_3.c and the
demo_module_3.h files.
The demo_module_3 files were created by modifying the templates.
The following code is to set up the table with two indexes:
netsnmp_table_helper_add_indexes(table_info,
ASN_INTEGER, /* index: me1FloorNumber */
ASN_INTEGER, /* index: me1RoomNumber */
0);
Care must be taken in returning the "NEXT" data when function
me1ContactInfoTable_get_next_data_point() is called.
For instance, in the example code:
me1ContactEntry* nextNode = (me1ContactEntry*) *my_loop_context;
nextNode = nextNode->pNext;
The table data is pre-sorted so the next data is conveniently pointed by
the pNext pointer. If your implementation is more complicated you should
make sure the OIDs increase with the immediate next OID. (xxx.1.1, xxx.1.2,
etc).
To build the example:
1. Change to the directory where you copied the demo module files.
For example:
% cd /home/username/demo/demo_module_3
2. Use the make command to generate object files.
If you are running the 64-bit SPARC Solaris kernel, type:
If you are running the 32-bit SPARC Solaris kernel, type:
If you are running the Solaris x86 kernel, type:
3. Copy the module shared library object to the lib directory you created.
For example:
Setting Up Agent to Run demo_module_3
=====================================
==================