agent__read__config_8c.html from net-snmp at Krugle
Show agent__read__config_8c.html syntax highlighted
<!--#set var="section" value="development" -->
<!--#include virtual="/page-top.html" -->
<!-- CONTENT START -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>agent_read_config.c File Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body bgcolor="#ffffff">
<!-- Generated by Doxygen 1.2.11 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="annotated.html">Data Structures</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Data Fields</a> <a class="qindex" href="globals.html">Globals</a> </center>
<hr><h1>agent_read_config.c File Reference</h1><code>#include <<a class="el" href="config_8h-source.html">config.h</a>></code><br>
<code>#include <sys/types.h></code><br>
<code>#include <stdlib.h></code><br>
<code>#include <string.h></code><br>
<code>#include <stdio.h></code><br>
<code>#include <ctype.h></code><br>
<code>#include <errno.h></code><br>
<code>#include <sys/time.h></code><br>
<code>#include <time.h></code><br>
<code>#include <netinet/in.h></code><br>
<code>#include <netinet/in_systm.h></code><br>
<code>#include <netinet/ip.h></code><br>
<code>#include <sys/queue.h></code><br>
<code>#include <sys/socket.h></code><br>
<code>#include <net/route.h></code><br>
<code>#include <dmalloc.h></code><br>
<code>#include <unistd.h></code><br>
<code>#include <pwd.h></code><br>
<code>#include <grp.h></code><br>
<code>#include "mibincl.h"</code><br>
<code>#include "snmp_secmod.h"</code><br>
<code>#include "snmpusm.h"</code><br>
<code>#include "mibgroup/struct.h"</code><br>
<code>#include "read_config.h"</code><br>
<code>#include "<a class="el" href="agent__read__config_8h-source.html">agent_read_config.h</a>"</code><br>
<code>#include "callback.h"</code><br>
<code>#include "<a class="el" href="snmp__agent_8h-source.html">snmp_agent.h</a>"</code><br>
<code>#include "<a class="el" href="agent__trap_8h-source.html">agent_trap.h</a>"</code><br>
<code>#include "<a class="el" href="snmpd_8h-source.html">snmpd.h</a>"</code><br>
<code>#include "system.h"</code><br>
<code>#include "snmp_debug.h"</code><br>
<code>#include "snmp_alarm.h"</code><br>
<code>#include "default_store.h"</code><br>
<code>#include "<a class="el" href="ds__agent_8h-source.html">ds_agent.h</a>"</code><br>
<code>#include "<a class="el" href="table_8h-source.html">helpers/table.h</a>"</code><br>
<code>#include "<a class="el" href="table__iterator_8h-source.html">helpers/table_iterator.h</a>"</code><br>
<code>#include "<a class="el" href="table__data_8h-source.html">helpers/table_data.h</a>"</code><br>
<code>#include "<a class="el" href="table__dataset_8h-source.html">helpers/table_dataset.h</a>"</code><br>
<code>#include "mib_module_includes.h"</code><br>
<code>#include "mib_module_dot_conf.h"</code><br>
<p>
<a href="agent__read__config_8c-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td colspan=2><br><h2>Functions</h2></td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="agent__read__config_8c.html#a2">snmpd_set_agent_user</a> (const char *token, char *cptr)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="agent__read__config_8c.html#a3">snmpd_set_agent_group</a> (const char *token, char *cptr)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="agent__read__config_8c.html#a4">snmpd_set_agent_address</a> (const char *token, char *cptr)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="agent__read__config_8c.html#a5">init_agent_read_config</a> (const char *app)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="agent__read__config_8c.html#a6">update_config</a> (void)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="agent__read__config_8c.html#a7">snmpd_register_config_handler</a> (const char *token, void(*parser)(const char *, char *), void(*releaser)(void), const char *help)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="agent__read__config_8c.html#a8">snmpd_unregister_config_handler</a> (const char *token)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="agent__read__config_8c.html#a9">snmpd_store_config</a> (const char *line)</td></tr>
<tr><td colspan=2><br><h2>Variables</h2></td></tr>
<tr><td nowrap align=right valign=top>char </td><td valign=bottom><a class="el" href="agent__read__config_8c.html#a0">dontReadConfigFiles</a></td></tr>
<tr><td nowrap align=right valign=top>char * </td><td valign=bottom><a class="el" href="agent__read__config_8c.html#a1">optconfigfile</a></td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a name="a5" doxytag="agent_read_config.c::init_agent_read_config"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void init_agent_read_config </td>
<td class="md">( </td>
<td class="md" nowrap>const char * </td>
<td class="mdname1"> <em>app</em> </td>
<td class="md">) </td>
<td class="md"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="agent__read__config_8c-source.html#l00169">169</a> of file <a class="el" href="agent__read__config_8c-source.html">agent_read_config.c</a>.<div class="fragment"><pre>00170 {
00171 <font class="keywordflow">if</font> ( app != NULL )
00172 ds_set_string(DS_LIBRARY_ID, DS_LIB_APPTYPE, app);
00173
00174 register_app_config_handler(<font class="stringliteral">"authtrapenable"</font>,
00175 snmpd_parse_config_authtrap, NULL,
00176 <font class="stringliteral">"1 | 2\t\t(1 = enable, 2 = disable)"</font>);
00177
00178 <font class="keywordflow">if</font> ( ds_get_boolean(DS_APPLICATION_ID, <a class="code" href="ds__agent_8h.html#a1">DS_AGENT_ROLE</a>) == <a class="code" href="snmpd_8h.html#a0">MASTER_AGENT</a> )<font class="keyword"> </font>{
00179 register_app_config_handler(<font class="stringliteral">"trapsink"</font>,
00180 snmpd_parse_config_trapsink, snmpd_free_trapsinks,
00181 <font class="stringliteral">"host [community] [port]"</font>);
00182 register_app_config_handler(<font class="stringliteral">"trap2sink"</font>,
00183 snmpd_parse_config_trap2sink, NULL,
00184 <font class="stringliteral">"host [community] [port]"</font>);
00185 register_app_config_handler(<font class="stringliteral">"informsink"</font>,
00186 snmpd_parse_config_informsink, NULL,
00187 <font class="stringliteral">"host [community] [port]"</font>);
00188 register_app_config_handler(<font class="stringliteral">"trapsess"</font>,
00189 snmpd_parse_config_trapsess, NULL,
00190 <font class="stringliteral">"[snmpcmdargs] host"</font>);
00191 }
00192 register_app_config_handler(<font class="stringliteral">"trapcommunity"</font>,
00193 snmpd_parse_config_trapcommunity,
00194 snmpd_free_trapcommunity,
00195 <font class="stringliteral">"community-string"</font>);
00196 <font class="preprocessor">#ifdef HAVE_UNISTD_H</font>
00197 register_app_config_handler(<font class="stringliteral">"agentuser"</font>,
00198 <a class="code" href="agent__read__config_8c.html#a2">snmpd_set_agent_user</a>, NULL,
00199 <font class="stringliteral">"userid"</font>);
00200 register_app_config_handler(<font class="stringliteral">"agentgroup"</font>,
00201 <a class="code" href="agent__read__config_8c.html#a3">snmpd_set_agent_group</a>, NULL,
00202 <font class="stringliteral">"groupid"</font>);
00203 <font class="preprocessor">#endif</font>
00204 register_app_config_handler(<font class="stringliteral">"agentaddress"</font>,
00205 <a class="code" href="agent__read__config_8c.html#a4">snmpd_set_agent_address</a>, NULL,
00206 <font class="stringliteral">"SNMP bind address"</font>);
00207 register_app_config_handler(<font class="stringliteral">"table"</font>,
00208 config_parse_table_set, NULL, <font class="stringliteral">"tableoid"</font>);
00209 register_app_config_handler(<font class="stringliteral">"add_row"</font>,
00210 config_parse_add_row, NULL, <font class="stringliteral">"indexes... values..."</font>);
00211
00212 <font class="preprocessor">#include "mib_module_dot_conf.h"</font>
00213 <font class="preprocessor">#ifdef TESTING</font>
00214 print_config_handlers();
00215 <font class="preprocessor">#endif</font>
00216 }
</pre></div> </td>
</tr>
</table>
<a name="a7" doxytag="agent_read_config.c::snmpd_register_config_handler"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void snmpd_register_config_handler </td>
<td class="md">( </td>
<td class="md" nowrap>const char * </td>
<td class="mdname"> <em>token</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>void(* </td>
<td class="mdname"> <em>parser</em>)(const char *, char *), </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>void(* </td>
<td class="mdname"> <em>releaser</em>)(void), </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>const char * </td>
<td class="mdname"> <em>help</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="agent__read__config_8c-source.html#l00226">226</a> of file <a class="el" href="agent__read__config_8c-source.html">agent_read_config.c</a>.<div class="fragment"><pre>00230 {
00231 DEBUGMSGTL((<font class="stringliteral">"snmpd_register_app_config_handler"</font>,
00232 <font class="stringliteral">"registering .conf token for \"%s\"\n"</font>, token));
00233 register_app_config_handler(token, parser, releaser, help);
00234 }
</pre></div> </td>
</tr>
</table>
<a name="a4" doxytag="agent_read_config.c::snmpd_set_agent_address"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void snmpd_set_agent_address </td>
<td class="md">( </td>
<td class="md" nowrap>const char * </td>
<td class="mdname"> <em>token</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>char * </td>
<td class="mdname"> <em>cptr</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="agent__read__config_8c-source.html#l00150">150</a> of file <a class="el" href="agent__read__config_8c-source.html">agent_read_config.c</a>.<div class="fragment"><pre>00151 {
00152 <font class="keywordtype">char</font> buf[SPRINT_MAX_LEN];
00153 <font class="keywordtype">char</font> *ptr;
00154
00155 <font class="comment">/* has something been specified before? */</font>
00156 ptr = ds_get_string(DS_APPLICATION_ID, <a class="code" href="ds__agent_8h.html#a6">DS_AGENT_PORTS</a>);
00157
00158 <font class="keywordflow">if</font> (ptr)
00159 <font class="comment">/* append to the older specification string */</font>
00160 sprintf(buf,<font class="stringliteral">"%s,%s"</font>, ptr, cptr);
00161 <font class="keywordflow">else</font>
00162 strcpy(buf,cptr);
00163
00164 DEBUGMSGTL((<font class="stringliteral">"snmpd_ports"</font>,<font class="stringliteral">"port spec: %s\n"</font>, buf));
00165 ds_set_string(DS_APPLICATION_ID, <a class="code" href="ds__agent_8h.html#a6">DS_AGENT_PORTS</a>, strdup(buf));
00166
00167 }
</pre></div> </td>
</tr>
</table>
<a name="a3" doxytag="agent_read_config.c::snmpd_set_agent_group"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void snmpd_set_agent_group </td>
<td class="md">( </td>
<td class="md" nowrap>const char * </td>
<td class="mdname"> <em>token</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>char * </td>
<td class="mdname"> <em>cptr</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="agent__read__config_8c-source.html#l00133">133</a> of file <a class="el" href="agent__read__config_8c-source.html">agent_read_config.c</a>.<div class="fragment"><pre>00134 {
00135 <font class="preprocessor">#if defined(HAVE_GETGRNAM) && defined(HAVE_GRP_H)</font>
00136 <font class="keyword">struct </font>group *info;
00137 <font class="preprocessor">#endif</font>
00138
00139 <font class="keywordflow">if</font> (cptr[0] == <font class="charliteral">'#'</font>)
00140 ds_set_int(DS_APPLICATION_ID, <a class="code" href="ds__agent_8h.html#a10">DS_AGENT_GROUPID</a>, atoi(&cptr[1]));
00141
00142 <font class="preprocessor">#if defined(HAVE_GETGRNAM) && defined(HAVE_GRP_H)</font>
00143 <font class="keywordflow">if</font> ((info = getgrnam(cptr)) != NULL) {
00144 ds_set_int(DS_APPLICATION_ID, <a class="code" href="ds__agent_8h.html#a10">DS_AGENT_GROUPID</a>, info->gr_gid);
00145 }
00146 <font class="preprocessor">#endif</font>
00147 }
</pre></div> </td>
</tr>
</table>
<a name="a2" doxytag="agent_read_config.c::snmpd_set_agent_user"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void snmpd_set_agent_user </td>
<td class="md">( </td>
<td class="md" nowrap>const char * </td>
<td class="mdname"> <em>token</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>char * </td>
<td class="mdname"> <em>cptr</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="agent__read__config_8c-source.html#l00117">117</a> of file <a class="el" href="agent__read__config_8c-source.html">agent_read_config.c</a>.<div class="fragment"><pre>00118 {
00119 <font class="preprocessor">#if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H)</font>
00120 <font class="keyword">struct </font>passwd *info;
00121 <font class="preprocessor">#endif</font>
00122
00123 <font class="keywordflow">if</font> (cptr[0] == <font class="charliteral">'#'</font>)
00124 ds_set_int(DS_APPLICATION_ID, <a class="code" href="ds__agent_8h.html#a9">DS_AGENT_USERID</a>, atoi(&cptr[1]));
00125
00126 <font class="preprocessor">#if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H)</font>
00127 <font class="keywordflow">if</font> ((info = getpwnam(cptr)) != NULL) {
00128 ds_set_int(DS_APPLICATION_ID, <a class="code" href="ds__agent_8h.html#a9">DS_AGENT_USERID</a>, info->pw_uid);
00129 }
00130 <font class="preprocessor">#endif</font>
00131 }
</pre></div> </td>
</tr>
</table>
<a name="a9" doxytag="agent_read_config.c::snmpd_store_config"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void snmpd_store_config </td>
<td class="md">( </td>
<td class="md" nowrap>const char * </td>
<td class="mdname1"> <em>line</em> </td>
<td class="md">) </td>
<td class="md"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="agent__read__config_8c-source.html#l00245">245</a> of file <a class="el" href="agent__read__config_8c-source.html">agent_read_config.c</a>.<div class="fragment"><pre>00246 {
00247 read_app_config_store(line);
00248 }
</pre></div> </td>
</tr>
</table>
<a name="a8" doxytag="agent_read_config.c::snmpd_unregister_config_handler"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void snmpd_unregister_config_handler </td>
<td class="md">( </td>
<td class="md" nowrap>const char * </td>
<td class="mdname1"> <em>token</em> </td>
<td class="md">) </td>
<td class="md"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="agent__read__config_8c-source.html#l00237">237</a> of file <a class="el" href="agent__read__config_8c-source.html">agent_read_config.c</a>.<div class="fragment"><pre>00238 {
00239 unregister_app_config_handler(token);
00240 }
</pre></div> </td>
</tr>
</table>
<a name="a6" doxytag="agent_read_config.c::update_config"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void update_config </td>
<td class="md">( </td>
<td class="md" nowrap>void </td>
<td class="mdname1"> </td>
<td class="md">) </td>
<td class="md"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="agent__read__config_8c-source.html#l00218">218</a> of file <a class="el" href="agent__read__config_8c-source.html">agent_read_config.c</a>.
<p>
Referenced by <a class="el" href="snmpd_8c-source.html#l00291">main</a>().
<p>
<div class="fragment"><pre>00219 {
00220 free_config();
00221 read_configs();
00222 }
</pre></div> </td>
</tr>
</table>
<hr><h2>Variable Documentation</h2>
<a name="a0" doxytag="agent_read_config.c::dontReadConfigFiles"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> char dontReadConfigFiles
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="agent__read__config_8c-source.html#l00113">113</a> of file <a class="el" href="agent__read__config_8c-source.html">agent_read_config.c</a>. </td>
</tr>
</table>
<a name="a1" doxytag="agent_read_config.c::optconfigfile"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> char* optconfigfile
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="agent__read__config_8c-source.html#l00114">114</a> of file <a class="el" href="agent__read__config_8c-source.html">agent_read_config.c</a>. </td>
</tr>
</table>
<hr><address><small>Generated on Sat Nov 10 14:09:53 2001 for net-snmp by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.gif" alt="doxygen" align="middle" border=0
width=110 height=53></a>1.2.11 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>,
© 1997-2001</small></address>
</body>
</html>
<!--#include virtual="/sfbutton.html" -->
<!--#include virtual="/sfbutton.html" -->
<!-- CONTENT END -->
<!--#include virtual="/page-bottom.html" -->
See more files for this project here