A routine to instantiate and start the SNMP agent thread in the default configuration is provided in PACKAGES/net/snmp/agent/VERSION/src/snmptask.c
It starts the snmpd thread at priority CYGPKG_NET_THREAD_PRIORITY+1 by default, ie. one step less important than the TCP/IP stack service thread. It also statically creates and uses a very large stack of around 100 KiloBytes. To use that convenience function, this code fragment may be copied (in plain C).
#ifdef CYGPKG_SNMPAGENT { extern void cyg_net_snmp_init(void); 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 ); |
The entry point to the SNMP agent is
externC void |
Note that if you call snmpd(); yourself and do not call cyg_net_snmp_init(); then that routine, global variable, 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 |
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.