⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 net-snmp-starting-the-snmp-agent.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
字号:
<!-- Copyright (C) 2003 Red Hat, Inc.                                --><!-- This material may be distributed only subject to the terms      --><!-- and conditions set forth in the Open Publication License, v1.0  --><!-- or later (the latest version is presently available at          --><!-- http://www.opencontent.org/openpub/).                           --><!-- Distribution of the work or derivative of the work in any       --><!-- standard (paper) book form is prohibited unless prior           --><!-- permission is obtained from the copyright holder.               --><HTML><HEAD><TITLE>Starting the SNMP Agent</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="SNMP for eCos"HREF="net-snmp-ecos-port.html"><LINKREL="PREVIOUS"TITLE="Changes to eCos sources"HREF="net-snmp-ecos-changes.html"><LINKREL="NEXT"TITLE="Configuring eCos"HREF="net-snmp-configuring-ecos.html"></HEAD><BODYCLASS="SECT1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="net-snmp-ecos-changes.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 47. SNMP for <SPANCLASS="emphasis"><ICLASS="EMPHASIS">eCos</I></SPAN></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="net-snmp-configuring-ecos.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="NET-SNMP-STARTING-THE-SNMP-AGENT">Starting the SNMP Agent</H1><P>A routine to instantiate and start the SNMP agent thread in the defaultconfiguration is provided in<TTCLASS="FILENAME">PACKAGES/net/snmp/agent/VERSION/src/snmptask.c</TT></P><P>It starts the snmpd thread at priority<TTCLASS="LITERAL">CYGPKG_NET_THREAD_PRIORITY+1</TT>by default, ie. one step less important than the TCP/IP stack servicethread.It also statically creates and uses a very large stack of around 100KiloBytes.To use that convenience function, this code fragment may be copied (inplain C).</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">#ifdef CYGPKG_SNMPAGENT{                extern void cyg_net_snmp_init(void);                cyg_net_snmp_init();            }#endif</PRE></TD></TR></TABLE><P>In case you need to perform initialization, for example setting up SNMPv3security features, when the snmp agent starts and every time it restarts,you can register a callback function by simply writing the global variable:<TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">externC void (*<SPANCLASS="emphasis"><ICLASS="EMPHASIS">snmpd_reinit_function</I></SPAN>)( void );</PRE></TD></TR></TABLE>with a suitable function pointer.</P><P>The entry point to the SNMP agent is<TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">externC void <TTCLASS="FUNCTION">snmpd</TT>( void (*<SPANCLASS="emphasis"><ICLASS="EMPHASIS">initfunc</I></SPAN>)( void ) );</PRE></TD></TR></TABLE>so you can of course easily start it in a thread of your choice at anotherpriority instead if required, after performing whatever otherinitialization your SNMP MIBs need.  A larger than default stacksize isrequired.  The <TTCLASS="LITERAL">initfunc</TT> parameter is the callbackfunction mentioned above &#8212; a NULL parameter there is safe andobviously means no callback is registered.</P><P>Note that if you call <TTCLASS="LITERAL">snmpd();</TT> yourself and do<SPANCLASS="emphasis"><ICLASS="EMPHASIS">not</I></SPAN> call <TTCLASS="LITERAL">cyg_net_snmp_init();</TT> thenthat routine, global variable, and the default large stack will not beused.  This is the recommended way control such features from yourapplication; create and start the thread yourself at the appropriatemoment.</P><P>Other APIs from the <TTCLASS="LITERAL">snmpd</TT> module are available,specifically:<TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void <TTCLASS="FUNCTION">SnmpdShutDown</TT>(int <SPANCLASS="emphasis"><ICLASS="EMPHASIS">a</I></SPAN>);</PRE></TD></TR></TABLE>which causes the <TTCLASS="LITERAL">snmpd</TT> to restart itself &#8212;including the callback to your init function &#8212; as soon as possible.</P><P>The parameter <SPANCLASS="emphasis"><ICLASS="EMPHASIS">a</I></SPAN> is ignored.  It is there because in<TTCLASS="LITERAL">snmpd</TT>'s &#8220;natural environment&#8221; this routineis a <TTCLASS="LITERAL">UNIX</TT> signal handler.</P><P>The helper functions in the network stack for managing<TTCLASS="LITERAL">DHCP</TT>leases will call <TTCLASS="FUNCTION">SnmpdShutDown()</TT>when necessary, for example if network interfaces go down and/or come upagain.</P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="net-snmp-ecos-changes.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="net-snmp-configuring-ecos.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Changes to eCos sources</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="net-snmp-ecos-port.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Configuring eCos</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -