Mercurial > ecos
comparison packages/net/snmp/agent/current/src/agent_read_config.c @ 103:95f3e12a6327 ecos-sw-2000-06-23
Merge from eCos master repository on 2000-06-23-16:41:10-BST
| author | jlarmour |
|---|---|
| date | Fri, 23 Jun 2000 17:06:31 +0000 |
| parents | |
| children | e0c0827131d1 |
comparison
equal
deleted
inserted
replaced
| 102:6409b6d94dd7 | 103:95f3e12a6327 |
|---|---|
| 1 //========================================================================== | |
| 2 // | |
| 3 // ./agent/current/src/agent_read_config.c | |
| 4 // | |
| 5 // | |
| 6 //========================================================================== | |
| 7 //####COPYRIGHTBEGIN#### | |
| 8 // | |
| 9 // ------------------------------------------- | |
| 10 // The contents of this file are subject to the Red Hat eCos Public License | |
| 11 // Version 1.1 (the "License"); you may not use this file except in | |
| 12 // compliance with the License. You may obtain a copy of the License at | |
| 13 // http://www.redhat.com/ | |
| 14 // | |
| 15 // Software distributed under the License is distributed on an "AS IS" | |
| 16 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 17 // License for the specific language governing rights and limitations under | |
| 18 // the License. | |
| 19 // | |
| 20 // The Original Code is eCos - Embedded Configurable Operating System, | |
| 21 // released September 30, 1998. | |
| 22 // | |
| 23 // The Initial Developer of the Original Code is Red Hat. | |
| 24 // Portions created by Red Hat are | |
| 25 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. | |
| 26 // All Rights Reserved. | |
| 27 // ------------------------------------------- | |
| 28 // | |
| 29 //####COPYRIGHTEND#### | |
| 30 //####UCDSNMPCOPYRIGHTBEGIN#### | |
| 31 // | |
| 32 // ------------------------------------------- | |
| 33 // | |
| 34 // Portions of this software may have been derived from the UCD-SNMP | |
| 35 // project, <http://ucd-snmp.ucdavis.edu/> from the University of | |
| 36 // California at Davis, which was originally based on the Carnegie Mellon | |
| 37 // University SNMP implementation. Portions of this software are therefore | |
| 38 // covered by the appropriate copyright disclaimers included herein. | |
| 39 // | |
| 40 // The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2" | |
| 41 // ------------------------------------------- | |
| 42 // | |
| 43 //####UCDSNMPCOPYRIGHTEND#### | |
| 44 //========================================================================== | |
| 45 //#####DESCRIPTIONBEGIN#### | |
| 46 // | |
| 47 // Author(s): hmt | |
| 48 // Contributors: hmt | |
| 49 // Date: 2000-05-30 | |
| 50 // Purpose: Port of UCD-SNMP distribution to eCos. | |
| 51 // Description: | |
| 52 // | |
| 53 // | |
| 54 //####DESCRIPTIONEND#### | |
| 55 // | |
| 56 //========================================================================== | |
| 57 /******************************************************************** | |
| 58 Copyright 1989, 1991, 1992 by Carnegie Mellon University | |
| 59 | |
| 60 Derivative Work - | |
| 61 Copyright 1996, 1998, 1999, 2000 The Regents of the University of California | |
| 62 | |
| 63 All Rights Reserved | |
| 64 | |
| 65 Permission to use, copy, modify and distribute this software and its | |
| 66 documentation for any purpose and without fee is hereby granted, | |
| 67 provided that the above copyright notice appears in all copies and | |
| 68 that both that copyright notice and this permission notice appear in | |
| 69 supporting documentation, and that the name of CMU and The Regents of | |
| 70 the University of California not be used in advertising or publicity | |
| 71 pertaining to distribution of the software without specific written | |
| 72 permission. | |
| 73 | |
| 74 CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL | |
| 75 WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED | |
| 76 WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR | |
| 77 THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL, | |
| 78 INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING | |
| 79 FROM THE LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF | |
| 80 CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |
| 81 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
| 82 *********************************************************************/ | |
| 83 /* | |
| 84 * agent_read_config.c | |
| 85 */ | |
| 86 | |
| 87 #include <config.h> | |
| 88 | |
| 89 #include <sys/types.h> | |
| 90 #if HAVE_STDLIB_H | |
| 91 #include <stdlib.h> | |
| 92 #endif | |
| 93 #if HAVE_STRING_H | |
| 94 #include <string.h> | |
| 95 #else | |
| 96 #include <strings.h> | |
| 97 #endif | |
| 98 #include <stdio.h> | |
| 99 #include <ctype.h> | |
| 100 #include <errno.h> | |
| 101 | |
| 102 #if TIME_WITH_SYS_TIME | |
| 103 # ifdef WIN32 | |
| 104 # include <sys/timeb.h> | |
| 105 # else | |
| 106 # include <sys/time.h> | |
| 107 # endif | |
| 108 # include <time.h> | |
| 109 #else | |
| 110 # if HAVE_SYS_TIME_H | |
| 111 # include <sys/time.h> | |
| 112 # else | |
| 113 # include <time.h> | |
| 114 # endif | |
| 115 #endif | |
| 116 #if HAVE_NETINET_IN_H | |
| 117 #include <netinet/in.h> | |
| 118 #endif | |
| 119 #if HAVE_NETINET_IN_SYSTM_H | |
| 120 #include <netinet/in_systm.h> | |
| 121 #endif | |
| 122 #if HAVE_NETINET_IP_H | |
| 123 #include <netinet/ip.h> | |
| 124 #endif | |
| 125 #ifdef INET6 | |
| 126 #if HAVE_NETINET_IP6_H | |
| 127 #include <netinet/ip6.h> | |
| 128 #endif | |
| 129 #endif | |
| 130 #if HAVE_SYS_QUEUE_H | |
| 131 #include <sys/queue.h> | |
| 132 #endif | |
| 133 #if HAVE_SYS_SOCKET_H | |
| 134 #include <sys/socket.h> | |
| 135 #elif HAVE_WINSOCK_H | |
| 136 #include <winsock.h> | |
| 137 #endif | |
| 138 #if HAVE_SYS_STREAM_H | |
| 139 #include <sys/stream.h> | |
| 140 #endif | |
| 141 #if HAVE_NET_ROUTE_H | |
| 142 #include <net/route.h> | |
| 143 #endif | |
| 144 #if HAVE_NETINET_IP_VAR_H | |
| 145 #include <netinet/ip_var.h> | |
| 146 #endif | |
| 147 #ifdef INET6 | |
| 148 #if HAVE_NETINET6_IP6_VAR_H | |
| 149 #include <netinet6/ip6_var.h> | |
| 150 #endif | |
| 151 #endif | |
| 152 #if HAVE_NETINET_IN_PCB_H | |
| 153 #include <netinet/in_pcb.h> | |
| 154 #endif | |
| 155 #if HAVE_INET_MIB2_H | |
| 156 #include <inet/mib2.h> | |
| 157 #endif | |
| 158 | |
| 159 #if HAVE_DMALLOC_H | |
| 160 #include <dmalloc.h> | |
| 161 #endif | |
| 162 | |
| 163 #include "mibincl.h" | |
| 164 #include "snmpusm.h" | |
| 165 | |
| 166 #include "mibgroup/struct.h" | |
| 167 #include "read_config.h" | |
| 168 #include "agent_read_config.h" | |
| 169 #include "callback.h" | |
| 170 #include "snmp_agent.h" | |
| 171 #include "agent_trap.h" | |
| 172 #include "snmpd.h" | |
| 173 #include "system.h" | |
| 174 #include "snmp_debug.h" | |
| 175 #include "snmp_alarm.h" | |
| 176 #include "default_store.h" | |
| 177 #include "ds_agent.h" | |
| 178 #include "mib_module_includes.h" | |
| 179 | |
| 180 char dontReadConfigFiles; | |
| 181 char *optconfigfile; | |
| 182 | |
| 183 void init_agent_read_config (const char *app) | |
| 184 { | |
| 185 if ( app != NULL ) | |
| 186 ds_set_string(DS_LIBRARY_ID, DS_LIB_APPTYPE, app); | |
| 187 | |
| 188 register_app_config_handler("authtrapenable", | |
| 189 snmpd_parse_config_authtrap, NULL, | |
| 190 "1 | 2\t\t(1 = enable, 2 = disable)"); | |
| 191 | |
| 192 if ( ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_ROLE) == MASTER_AGENT ) { | |
| 193 register_app_config_handler("trapsink", | |
| 194 snmpd_parse_config_trapsink, snmpd_free_trapsinks, | |
| 195 "host [community]"); | |
| 196 register_app_config_handler("trap2sink", | |
| 197 snmpd_parse_config_trap2sink, NULL, | |
| 198 "host [community]"); | |
| 199 register_app_config_handler("informsink", | |
| 200 snmpd_parse_config_informsink, NULL, | |
| 201 "host [community]"); | |
| 202 } | |
| 203 register_app_config_handler("trapcommunity", | |
| 204 snmpd_parse_config_trapcommunity, | |
| 205 snmpd_free_trapcommunity, | |
| 206 "community-string"); | |
| 207 #include "mib_module_dot_conf.h" | |
| 208 #ifdef TESTING | |
| 209 print_config_handlers(); | |
| 210 #endif | |
| 211 } | |
| 212 | |
| 213 void update_config(void) | |
| 214 { | |
| 215 free_config(); | |
| 216 read_configs(); | |
| 217 } | |
| 218 | |
| 219 | |
| 220 void | |
| 221 snmpd_register_config_handler(const char *token, | |
| 222 void (*parser) (const char *, char *), | |
| 223 void (*releaser) (void), | |
| 224 const char *help) | |
| 225 { | |
| 226 DEBUGMSGTL(("snmpd_register_app_config_handler", | |
| 227 "registering .conf token for \"%s\"\n", token)); | |
| 228 register_app_config_handler(token, parser, releaser, help); | |
| 229 } | |
| 230 | |
| 231 void | |
| 232 snmpd_unregister_config_handler(const char *token) | |
| 233 { | |
| 234 unregister_app_config_handler(token); | |
| 235 } | |
| 236 | |
| 237 /* this function is intended for use by mib-modules to store permenant | |
| 238 configuration information generated by sets or persistent counters */ | |
| 239 void | |
| 240 snmpd_store_config(const char *line) | |
| 241 { | |
| 242 read_app_config_store(line); | |
| 243 } |
