To use the SNMP agent, the SNMP library and agent packages must be
included in your configuration. To incorporate the stack into your
configuration select the SNMP library and SNMP agent packages in the
eCos Configuration Tool, or at the command line type:
$ ecosconfig add snmplib snmpagent
After adding the networking, common ethernet device drivers,
snmp library and snmp agent packages, there is no configuration
required. However there are a number of configuration options
that can be set such as some details for the System MIB, and
disabling SNMPv3 support (see below).
Starting the SNMP agent is not integrated into network
tests other than snmpping below, nor is it
started automatically in normal eCos startup -
it is up to the application to start the agent when it is ready,
at least after the network interfaces are both ‘up’.
The default build supports all three versions of the SNMP protocol, but without
any dispatcher functionality (rfc 2571, section 3.1.1.2). This has the
following implications :
1. There is no community authentication for v1 and v2c.
2. Security provided by v3 can be bypassed by using v1/v2c protocol.
To provide the dispatcher with rfc 2571 type functionality, it is required to
set up security models and access profiles. This can be provided in the normal
Unix style by writing the required configurations in snmpd.conf
file. Application code may setup profiles in snmpd.conf and
optionally set the environment variable SNMPCONFPATH to
point to the file if it is not in the usual location. The whole concept works
in the usual way as with the standard UCD-SNMP distribution.
The support of the trapsink command in the
snmpd.conf file is not tested
and there may be problems for it working as expected. Moreover, in systems that do not
have filesystem support, there is no way to configure a trap-session in the
conventional way.
For reasons mentioned above, applications need to initialize their own trap
sessions and pass it the details of trap-sink. The following is a small sample
for initializing a v1 trap session :
typedef struct trap {
unsigned char ip [4];
unsigned int port;
unsigned char community [256];
}
trap trapsink;
unsinged char sink [16];
...
...
if (trapsink.ip != 0) {
sprintf (sink, "%d.%d.%d.%d",
trapsink[0], trapsink[1], trapsink[2], trapsink[3]);
if (create_trap_session (sink,
trapsink.port,
(char *)trapsink.community,
SNMP_VERSION_1,
SNMP_MSG_TRAP) == 0) {
log_error ("Creation of trap session failed \n");
}
}
Using snmpd.conf requires the inclusion of one of the file-system packages
(eg. CYGPKG_RAMFS) and CYGPKG_FILEIO. With these two packages included, the
SNMP sub-system will read the snmpd.conf file from the location specified in
SNMPCONFPATH, or the standard builtin locations, and use
these profiles. Only the profiles specified in the ACCESS-CONTROL
section of snmpd.conf file have
been tested and shown to work. Other profiles which have been implemented in
UCD-SNMP-4.1.2's snmpd.conf may not work
because the sole purpose of adding support for the snmpd.conf file has been to
set up ACCESS-CONTROL models.
At startup, the SNMP module tries to look for file snmp.conf.
If this file is not available, the module successively looks for files
snmpd.conf, snmp.local.conf and
snmpd.local.conf at the locations pointed to by SNMPCONFPATH environment variable. In case SNMPCONFPATH is not defined, the search sequence is carried out in default directories.
The default directories are :/usr/share/snmp, /usr/local/share/snmp and $(HOME)/.snmp.
The configurations read from these files are used to control both, SNMP
applications and the SNMP agent; in the usual UNIX fashion.
The inclusion of snmpd.conf support is enabled by default when suitable
filesystems and FILEIO packages are active.