OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [doc/] [html/] [ref/] [net-snmp-starting-the-snmp-agent.html] - Blame information for rev 598

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 28 unneback
<!-- Copyright (C) 2003 Red Hat, Inc.                                -->
2
<!-- This material may be distributed only subject to the terms      -->
3
<!-- and conditions set forth in the Open Publication License, v1.0  -->
4
<!-- or later (the latest version is presently available at          -->
5
<!-- http://www.opencontent.org/openpub/).                           -->
6
<!-- Distribution of the work or derivative of the work in any       -->
7
<!-- standard (paper) book form is prohibited unless prior           -->
8
<!-- permission is obtained from the copyright holder.               -->
9
<HTML
10
><HEAD
11
><TITLE
12
>Starting the SNMP Agent</TITLE
13
><meta name="MSSmartTagsPreventParsing" content="TRUE">
14
<META
15
NAME="GENERATOR"
16
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
17
"><LINK
18
REL="HOME"
19
TITLE="eCos Reference Manual"
20
HREF="ecos-ref.html"><LINK
21
REL="UP"
22
TITLE="SNMP for eCos"
23
HREF="net-snmp-ecos-port.html"><LINK
24
REL="PREVIOUS"
25
TITLE="Changes to eCos sources"
26
HREF="net-snmp-ecos-changes.html"><LINK
27
REL="NEXT"
28
TITLE="Configuring eCos"
29
HREF="net-snmp-configuring-ecos.html"></HEAD
30
><BODY
31
CLASS="SECT1"
32
BGCOLOR="#FFFFFF"
33
TEXT="#000000"
34
LINK="#0000FF"
35
VLINK="#840084"
36
ALINK="#0000FF"
37
><DIV
38
CLASS="NAVHEADER"
39
><TABLE
40
SUMMARY="Header navigation table"
41
WIDTH="100%"
42
BORDER="0"
43
CELLPADDING="0"
44
CELLSPACING="0"
45
><TR
46
><TH
47
COLSPAN="3"
48
ALIGN="center"
49
>eCos Reference Manual</TH
50
></TR
51
><TR
52
><TD
53
WIDTH="10%"
54
ALIGN="left"
55
VALIGN="bottom"
56
><A
57
HREF="net-snmp-ecos-changes.html"
58
ACCESSKEY="P"
59
>Prev</A
60
></TD
61
><TD
62
WIDTH="80%"
63
ALIGN="center"
64
VALIGN="bottom"
65
>Chapter 47. SNMP for <SPAN
66
CLASS="emphasis"
67
><I
68
CLASS="EMPHASIS"
69
>eCos</I
70
></SPAN
71
></TD
72
><TD
73
WIDTH="10%"
74
ALIGN="right"
75
VALIGN="bottom"
76
><A
77
HREF="net-snmp-configuring-ecos.html"
78
ACCESSKEY="N"
79
>Next</A
80
></TD
81
></TR
82
></TABLE
83
><HR
84
ALIGN="LEFT"
85
WIDTH="100%"></DIV
86
><DIV
87
CLASS="SECT1"
88
><H1
89
CLASS="SECT1"
90
><A
91
NAME="NET-SNMP-STARTING-THE-SNMP-AGENT">Starting the SNMP Agent</H1
92
><P
93
>A routine to instantiate and start the SNMP agent thread in the default
94
configuration is provided in
95
<TT
96
CLASS="FILENAME"
97
>PACKAGES/net/snmp/agent/VERSION/src/snmptask.c</TT
98
></P
99
><P
100
>It starts the snmpd thread at priority
101
<TT
102
CLASS="LITERAL"
103
>CYGPKG_NET_THREAD_PRIORITY+1</TT
104
>
105
by default, ie. one step less important than the TCP/IP stack service
106
thread.
107
It also statically creates and uses a very large stack of around 100
108
KiloBytes.
109
To use that convenience function, this code fragment may be copied (in
110
plain C).</P
111
><TABLE
112
BORDER="5"
113
BGCOLOR="#E0E0F0"
114
WIDTH="70%"
115
><TR
116
><TD
117
><PRE
118
CLASS="PROGRAMLISTING"
119
>#ifdef CYGPKG_SNMPAGENT
120
{
121
                extern void cyg_net_snmp_init(void);
122
                cyg_net_snmp_init();
123
 
124
}
125
#endif</PRE
126
></TD
127
></TR
128
></TABLE
129
><P
130
>In case you need to perform initialization, for example setting up SNMPv3
131
security features, when the snmp agent starts and every time it restarts,
132
you can register a callback function by simply writing the global variable:
133
<TABLE
134
BORDER="5"
135
BGCOLOR="#E0E0F0"
136
WIDTH="70%"
137
><TR
138
><TD
139
><PRE
140
CLASS="PROGRAMLISTING"
141
>externC void (*<SPAN
142
CLASS="emphasis"
143
><I
144
CLASS="EMPHASIS"
145
>snmpd_reinit_function</I
146
></SPAN
147
>)( void );</PRE
148
></TD
149
></TR
150
></TABLE
151
>
152
with a suitable function pointer.</P
153
><P
154
>The entry point to the SNMP agent is
155
<TABLE
156
BORDER="5"
157
BGCOLOR="#E0E0F0"
158
WIDTH="70%"
159
><TR
160
><TD
161
><PRE
162
CLASS="PROGRAMLISTING"
163
>externC void <TT
164
CLASS="FUNCTION"
165
>snmpd</TT
166
>( void (*<SPAN
167
CLASS="emphasis"
168
><I
169
CLASS="EMPHASIS"
170
>initfunc</I
171
></SPAN
172
>)( void ) );</PRE
173
></TD
174
></TR
175
></TABLE
176
>
177
so you can of course easily start it in a thread of your choice at another
178
priority instead if required, after performing whatever other
179
initialization your SNMP MIBs need.  A larger than default stacksize is
180
required.  The <TT
181
CLASS="LITERAL"
182
>initfunc</TT
183
> parameter is the callback
184
function mentioned above &#8212; a NULL parameter there is safe and
185
obviously means no callback is registered.</P
186
><P
187
>Note that if you call <TT
188
CLASS="LITERAL"
189
>snmpd();</TT
190
> yourself and do
191
<SPAN
192
CLASS="emphasis"
193
><I
194
CLASS="EMPHASIS"
195
>not</I
196
></SPAN
197
> call <TT
198
CLASS="LITERAL"
199
>cyg_net_snmp_init();</TT
200
> then
201
that routine, global variable, and the default large stack will not be
202
used.  This is the recommended way control such features from your
203
application; create and start the thread yourself at the appropriate
204
moment.</P
205
><P
206
>Other APIs from the <TT
207
CLASS="LITERAL"
208
>snmpd</TT
209
> module are available,
210
specifically:
211
<TABLE
212
BORDER="5"
213
BGCOLOR="#E0E0F0"
214
WIDTH="70%"
215
><TR
216
><TD
217
><PRE
218
CLASS="PROGRAMLISTING"
219
>void <TT
220
CLASS="FUNCTION"
221
>SnmpdShutDown</TT
222
>(int <SPAN
223
CLASS="emphasis"
224
><I
225
CLASS="EMPHASIS"
226
>a</I
227
></SPAN
228
>);</PRE
229
></TD
230
></TR
231
></TABLE
232
>
233
which causes the <TT
234
CLASS="LITERAL"
235
>snmpd</TT
236
> to restart itself &#8212;
237
including the callback to your init function &#8212; as soon as possible.</P
238
><P
239
>The parameter <SPAN
240
CLASS="emphasis"
241
><I
242
CLASS="EMPHASIS"
243
>a</I
244
></SPAN
245
> is ignored.  It is there because in
246
<TT
247
CLASS="LITERAL"
248
>snmpd</TT
249
>'s &#8220;natural environment&#8221; this routine
250
is a <TT
251
CLASS="LITERAL"
252
>UNIX</TT
253
> signal handler.</P
254
><P
255
>The helper functions in the network stack for managing
256
<TT
257
CLASS="LITERAL"
258
>DHCP</TT
259
>
260
leases will call <TT
261
CLASS="FUNCTION"
262
>SnmpdShutDown()</TT
263
>
264
when necessary, for example if network interfaces go down and/or come up
265
again.</P
266
></DIV
267
><DIV
268
CLASS="NAVFOOTER"
269
><HR
270
ALIGN="LEFT"
271
WIDTH="100%"><TABLE
272
SUMMARY="Footer navigation table"
273
WIDTH="100%"
274
BORDER="0"
275
CELLPADDING="0"
276
CELLSPACING="0"
277
><TR
278
><TD
279
WIDTH="33%"
280
ALIGN="left"
281
VALIGN="top"
282
><A
283
HREF="net-snmp-ecos-changes.html"
284
ACCESSKEY="P"
285
>Prev</A
286
></TD
287
><TD
288
WIDTH="34%"
289
ALIGN="center"
290
VALIGN="top"
291
><A
292
HREF="ecos-ref.html"
293
ACCESSKEY="H"
294
>Home</A
295
></TD
296
><TD
297
WIDTH="33%"
298
ALIGN="right"
299
VALIGN="top"
300
><A
301
HREF="net-snmp-configuring-ecos.html"
302
ACCESSKEY="N"
303
>Next</A
304
></TD
305
></TR
306
><TR
307
><TD
308
WIDTH="33%"
309
ALIGN="left"
310
VALIGN="top"
311
>Changes to eCos sources</TD
312
><TD
313
WIDTH="34%"
314
ALIGN="center"
315
VALIGN="top"
316
><A
317
HREF="net-snmp-ecos-port.html"
318
ACCESSKEY="U"
319
>Up</A
320
></TD
321
><TD
322
WIDTH="33%"
323
ALIGN="right"
324
VALIGN="top"
325
>Configuring eCos</TD
326
></TR
327
></TABLE
328
></DIV
329
></BODY
330
></HTML
331
>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.