Logo
Home page Net-SNMP

Archive Search:

Require all words?

Site Search:
Google
agent_read_config.c File Reference
Main Page   Data Structures   File List   Data Fields   Globals  

agent_read_config.c File Reference

#include <config.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include <sys/time.h>
#include <time.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <net/route.h>
#include <dmalloc.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>
#include "mibincl.h"
#include "snmp_secmod.h"
#include "snmpusm.h"
#include "mibgroup/struct.h"
#include "read_config.h"
#include "agent_read_config.h"
#include "callback.h"
#include "snmp_agent.h"
#include "agent_trap.h"
#include "snmpd.h"
#include "system.h"
#include "snmp_debug.h"
#include "snmp_alarm.h"
#include "default_store.h"
#include "ds_agent.h"
#include "helpers/table.h"
#include "helpers/table_iterator.h"
#include "helpers/table_data.h"
#include "helpers/table_dataset.h"
#include "mib_module_includes.h"
#include "mib_module_dot_conf.h"

Go to the source code of this file.


Functions

void snmpd_set_agent_user (const char *token, char *cptr)
void snmpd_set_agent_group (const char *token, char *cptr)
void snmpd_set_agent_address (const char *token, char *cptr)
void init_agent_read_config (const char *app)
void update_config (void)
void snmpd_register_config_handler (const char *token, void(*parser)(const char *, char *), void(*releaser)(void), const char *help)
void snmpd_unregister_config_handler (const char *token)
void snmpd_store_config (const char *line)

Variables

char dontReadConfigFiles
char * optconfigfile

Function Documentation

void init_agent_read_config const char *    app
 

Definition at line 169 of file agent_read_config.c.

00170 {
00171   if ( app != NULL )
00172       ds_set_string(DS_LIBRARY_ID, DS_LIB_APPTYPE, app);
00173 
00174   register_app_config_handler("authtrapenable",
00175                           snmpd_parse_config_authtrap, NULL,
00176                           "1 | 2\t\t(1 = enable, 2 = disable)");
00177 
00178   if ( ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_ROLE) == MASTER_AGENT ) {
00179       register_app_config_handler("trapsink",
00180                           snmpd_parse_config_trapsink, snmpd_free_trapsinks,
00181                           "host [community] [port]");
00182       register_app_config_handler("trap2sink",
00183                           snmpd_parse_config_trap2sink, NULL,
00184                           "host [community] [port]");
00185       register_app_config_handler("informsink",
00186                           snmpd_parse_config_informsink, NULL,
00187                           "host [community] [port]");
00188       register_app_config_handler("trapsess",
00189                           snmpd_parse_config_trapsess, NULL,
00190                           "[snmpcmdargs] host");
00191   }
00192   register_app_config_handler("trapcommunity",
00193                           snmpd_parse_config_trapcommunity,
00194                           snmpd_free_trapcommunity,
00195                           "community-string");
00196 #ifdef HAVE_UNISTD_H
00197   register_app_config_handler("agentuser",
00198                           snmpd_set_agent_user, NULL,
00199                           "userid");
00200   register_app_config_handler("agentgroup",
00201                           snmpd_set_agent_group, NULL,
00202                           "groupid");
00203 #endif
00204   register_app_config_handler("agentaddress",
00205                           snmpd_set_agent_address, NULL,
00206                           "SNMP bind address");
00207   register_app_config_handler("table",
00208                               config_parse_table_set, NULL, "tableoid");
00209   register_app_config_handler("add_row",
00210                               config_parse_add_row, NULL, "indexes... values...");
00211   
00212 #include "mib_module_dot_conf.h"
00213 #ifdef TESTING
00214   print_config_handlers();
00215 #endif
00216 }

void snmpd_register_config_handler const char *    token,
void(*    parser)(const char *, char *),
void(*    releaser)(void),
const char *    help
 

Definition at line 226 of file agent_read_config.c.

00230 {
00231   DEBUGMSGTL(("snmpd_register_app_config_handler",
00232               "registering .conf token for \"%s\"\n", token));
00233   register_app_config_handler(token, parser, releaser, help);
00234 }

void snmpd_set_agent_address const char *    token,
char *    cptr
 

Definition at line 150 of file agent_read_config.c.

00151 {
00152     char buf[SPRINT_MAX_LEN];
00153     char *ptr;
00154 
00155     /* has something been specified before? */
00156     ptr = ds_get_string(DS_APPLICATION_ID, DS_AGENT_PORTS);
00157 
00158     if (ptr)
00159         /* append to the older specification string */
00160         sprintf(buf,"%s,%s", ptr, cptr);
00161     else
00162         strcpy(buf,cptr);
00163 
00164     DEBUGMSGTL(("snmpd_ports","port spec: %s\n", buf));
00165     ds_set_string(DS_APPLICATION_ID, DS_AGENT_PORTS, strdup(buf));
00166 
00167 }

void snmpd_set_agent_group const char *    token,
char *    cptr
 

Definition at line 133 of file agent_read_config.c.

00134 {
00135 #if defined(HAVE_GETGRNAM) && defined(HAVE_GRP_H)
00136 struct group *info;
00137 #endif
00138  
00139     if (cptr[0] == '#')
00140         ds_set_int(DS_APPLICATION_ID, DS_AGENT_GROUPID, atoi(&cptr[1]));
00141 
00142 #if defined(HAVE_GETGRNAM) && defined(HAVE_GRP_H)
00143     if ((info = getgrnam(cptr)) != NULL) {
00144         ds_set_int(DS_APPLICATION_ID, DS_AGENT_GROUPID, info->gr_gid);
00145     }
00146 #endif
00147 }

void snmpd_set_agent_user const char *    token,
char *    cptr
 

Definition at line 117 of file agent_read_config.c.

00118 {
00119 #if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H)
00120 struct passwd *info;
00121 #endif
00122  
00123     if (cptr[0] == '#')
00124         ds_set_int(DS_APPLICATION_ID, DS_AGENT_USERID, atoi(&cptr[1]));
00125 
00126 #if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H)
00127     if ((info = getpwnam(cptr)) != NULL) {
00128         ds_set_int(DS_APPLICATION_ID, DS_AGENT_USERID, info->pw_uid);
00129     }
00130 #endif
00131 }

void snmpd_store_config const char *    line
 

Definition at line 245 of file agent_read_config.c.

00246 {
00247   read_app_config_store(line);
00248 }

void snmpd_unregister_config_handler const char *    token
 

Definition at line 237 of file agent_read_config.c.

00238 {
00239   unregister_app_config_handler(token);
00240 }

void update_config void   
 

Definition at line 218 of file agent_read_config.c.

Referenced by main().

00219 {
00220   free_config();
00221   read_configs();
00222 }

Variable Documentation

char dontReadConfigFiles
 

Definition at line 113 of file agent_read_config.c.

char* optconfigfile
 

Definition at line 114 of file agent_read_config.c.


Generated on Sat Nov 10 14:09:53 2001 for net-snmp by doxygen1.2.11 written by Dimitri van Heesch, © 1997-2001
[an error occurred while processing this directive] [an error occurred while processing this directive]

Valid CSS!


Last modified: Wednesday, 01-Aug-2018 04:41:28 UTC
For questions regarding web content and site functionality, please write to the net-snmp-users mail list.