> > >Starting the SNMP Agent >
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"> REL="HOME"
TITLE="eCos Reference Manual"
HREF="ecos-ref.html"> REL="UP"
TITLE="SNMP for eCos"
HREF="net-snmp-ecos-port.html"> REL="PREVIOUS"
TITLE="Changes to eCos sources"
HREF="net-snmp-ecos-changes.html"> REL="NEXT"
TITLE="Configuring eCos"
HREF="net-snmp-configuring-ecos.html"> > CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
> CLASS="NAVHEADER"
> SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
> > COLSPAN="3"
ALIGN="center"
>eCos Reference Manual > > > WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
> HREF="net-snmp-ecos-changes.html"
ACCESSKEY="P"
>Prev > > WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 47. SNMP for CLASS="emphasis"
> CLASS="EMPHASIS"
>eCos > > > WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
> HREF="net-snmp-configuring-ecos.html"
ACCESSKEY="N"
>Next > > > > ALIGN="LEFT"
WIDTH="100%"> > CLASS="SECT1"
> CLASS="SECT1"
> NAME="NET-SNMP-STARTING-THE-SNMP-AGENT">Starting the SNMP Agent > >A routine to instantiate and start the SNMP agent thread in the default
configuration is provided in
CLASS="FILENAME"
>PACKAGES/net/snmp/agent/VERSION/src/snmptask.c > > >It starts the snmpd thread at priority
CLASS="LITERAL"
>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). > BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
> > > CLASS="PROGRAMLISTING"
>#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:
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
> > > CLASS="PROGRAMLISTING"
>externC void (* CLASS="emphasis"
> CLASS="EMPHASIS"
>snmpd_reinit_function > >)( void ); > > > >
with a suitable function pointer. > >The entry point to the SNMP agent is
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
> > > CLASS="PROGRAMLISTING"
>externC void CLASS="FUNCTION"
>snmpd >( void (* CLASS="emphasis"
> CLASS="EMPHASIS"
>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 CLASS="LITERAL"
>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 CLASS="LITERAL"
>snmpd(); > yourself and do
CLASS="emphasis"
> CLASS="EMPHASIS"
>not > > call CLASS="LITERAL"
>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 CLASS="LITERAL"
>snmpd > module are available,
specifically:
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
> > > CLASS="PROGRAMLISTING"
>void CLASS="FUNCTION"
>SnmpdShutDown >(int CLASS="emphasis"
> CLASS="EMPHASIS"
>a > >); > > > >
which causes the CLASS="LITERAL"
>snmpd > to restart itself —
including the callback to your init function — as soon as possible. > >The parameter CLASS="emphasis"
> CLASS="EMPHASIS"
>a > > is ignored. It is there because in
CLASS="LITERAL"
>snmpd >'s “natural environment” this routine
is a CLASS="LITERAL"
>UNIX > signal handler. > >The helper functions in the network stack for managing
CLASS="LITERAL"
>DHCP >
leases will call CLASS="FUNCTION"
>SnmpdShutDown() >
when necessary, for example if network interfaces go down and/or come up
again. > > CLASS="NAVFOOTER"
> ALIGN="LEFT"
WIDTH="100%"> SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
> > WIDTH="33%"
ALIGN="left"
VALIGN="top"
> HREF="net-snmp-ecos-changes.html"
ACCESSKEY="P"
>Prev > > WIDTH="34%"
ALIGN="center"
VALIGN="top"
> HREF="ecos-ref.html"
ACCESSKEY="H"
>Home > > WIDTH="33%"
ALIGN="right"
VALIGN="top"
> HREF="net-snmp-configuring-ecos.html"
ACCESSKEY="N"
>Next > > > > WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Changes to eCos sources > WIDTH="34%"
ALIGN="center"
VALIGN="top"
> HREF="net-snmp-ecos-port.html"
ACCESSKEY="U"
>Up > > WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Configuring eCos > > > > > >