Configuring ecos, Version usage (v1, v2 or v3) – Comtrol eCos User Manual
Page 617
Chapter 47. SNMP for eCos
cyg_net_snmp_init();
}
#endif
In case you need to perform initialization, for example setting up SNMPv3 security features, when the snmp agent
starts and every time it restarts, you can register a callback function by simply writing the global variable:
externC void (*snmpd_reinit_function)( void );
with a suitable function pointer.
The entry point to the SNMP agent is
externC void
snmpd
( void (*initfunc)( void ) );
so you can of course easily start it in a thread of your choice at another priority instead if required, after performing
whatever other initialization your SNMP MIBs need. A larger than default stacksize is required. The
initfunc
parameter is the callback function mentioned above — a NULL parameter there is safe and obviously means no
callback is registered.
Note that if you call
snmpd();
yourself and do not call
cyg_net_snmp_init();
then that routine, global vari-
able, and the default large stack will not be used. This is the recommended way control such features from your
application; create and start the thread yourself at the appropriate moment.
Other APIs from the
snmpd
module are available, specifically:
void
SnmpdShutDown
(int a);
which causes the
snmpd
to restart itself — including the callback to your init function — as soon as possible.
The parameter a is ignored. It is there because in
snmpd
’s “natural environment” this routine is a
UNIX
signal
handler.
The helper functions in the network stack for managing
DHCP
leases will call
SnmpdShutDown()
when necessary,
for example if network interfaces go down and/or come up again.
Configuring eCos
To use the SNMP agent, the SNMP library and agent packages must be included in your configuration. To incorpo-
rate 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 automati-
cally 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’.
513