From: wessels <> Date: Tue, 17 Mar 1998 12:12:30 +0000 (+0000) Subject: SNMP changes/fixes X-Git-Tag: SQUID_3_0_PRE1~3810 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e14bf6d450a13f8ec961da2f76eb53337548bee;p=thirdparty%2Fsquid.git SNMP changes/fixes - changed some snmplib debugging messages - simplifed and fixed snmplib_debug_hook interface. It wasn't properly passing all the 'varargs' args. Now it just vsnprintf's to a buf and passes that. - struct _snmpconf was never used. - made 'snmp_agent_conf' a stringlist type - moved 'snmp_agent_conf' processing to snmpInit(). - moved snmpInit() call to before 'ready to serve requests' message. --- diff --git a/ChangeLog b/ChangeLog index 5d74273697..96bf6df17e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,10 @@ - Extended String object to use memory pools. Most fixed size char array fields will be replaced using string pools. Same for most malloc()-ed buffers. + - Changed icon handling to use the hostname and port of the squid + server, instead of the special hostname "internal.squid". + - All icons are now configured in mime.conf. No hardcoded icons, + including gohper icons. - Fixed ICP bug when we send queries, but expect zero replies. - Fixed alignment/casting bugs for ICP messages. @@ -12,6 +16,20 @@ Code is still beta and interoperability with browsers etc has not been tested. - Put #ifdefs around 'source_ping' code. + - Added missing typedef for _arp_ip_data (Wesha). + - Added regular-expression-based ACLs for client and server + domain names (Henrik Nordstrom). + - Fixed ident-related coredumps from incorrect callback data. + - Fixed parse_rfc1123() "space" bug. + - Fixed xrealloc() XMALLOC_DEBUG bug (not calling check_free()).. + - Fixed some src/asn.c end-of-reply bugs and memory leaks. + - Fixed some peer->options flag-setting bugs. + - Fixed single-parent feature to work again + - Removed 'single_parent_bypass' configuration option; instead + just use 'no-query'. + - Surrounded 'source_ping' code with #ifdefs. + - Changed 'deny_info URL' to use a custom Error page. + - Modified src/client.c for testing POST requests. Changes to squid-1.2.beta16 (Mar 4, 1998): diff --git a/snmplib/mib.c b/snmplib/mib.c index 31ee53b6c1..f686d3b1ff 100644 --- a/snmplib/mib.c +++ b/snmplib/mib.c @@ -697,7 +697,7 @@ int read_objid(input, output, out_len) } if (root == NULL){ - snmplib_debug(0, "Mib not initialized. Exiting.\n"); + snmplib_debug(0, "Mib not initialized.\n"); return 0; } if ((*out_len = parse_subtree(root, input, output, out_len)) == 0) diff --git a/snmplib/parse.c b/snmplib/parse.c index c4a6659764..a4e2620dea 100644 --- a/snmplib/parse.c +++ b/snmplib/parse.c @@ -1083,8 +1083,7 @@ parse(fp) } struct snmp_mib_tree * -read_mib(filename) - char *filename; +read_mib(char *filename) { FILE *fp; struct node *nodes; @@ -1094,7 +1093,7 @@ read_mib(filename) fp = fopen(filename, "r"); if (fp == NULL) { - snmplib_debug(0, "failed to open MIB file: '%s'\n", filename); + snmplib_debug(1, "init_mib: %s: %s\n", filename, xstrerror()); return(NULL); } diff --git a/snmplib/snmplib_debug.c b/snmplib/snmplib_debug.c index a300070022..52e629db10 100644 --- a/snmplib/snmplib_debug.c +++ b/snmplib/snmplib_debug.c @@ -8,6 +8,10 @@ #include #endif +#if !HAVE_SNPRINTF +#include "snprintf.h" +#endif + #ifdef __STDC__ void (*snmplib_debug_hook) (int,char *,...) = NULL; #else @@ -16,25 +20,29 @@ void (*snmplib_debug_hook) (va_alist) = NULL; extern void #ifdef __STDC__ -snmplib_debug(int lvl,char *fmt,...) +snmplib_debug(int lvl, char *fmt,...) { - va_list args; - va_start(args, fmt); + char buf[BUFSIZ]; + va_list args; + va_start(args, fmt); #else snmplib_debug(va_alist) - va_dcl + va_dcl { - va_list args; - int lvl; - char char *fmt; - va_start(args); - lvl = va_arg(args, int); - fmt = va_arg(args, char *); + va_list args; + int lvl; + char char *fmt; + char buf[BUFSIZ]; + va_start(args); + lvl = va_arg(args, int); + fmt = va_arg(args, char *); #endif - if (snmplib_debug_hook != NULL) - snmplib_debug_hook(lvl, fmt, args); - else - vfprintf(stderr, fmt, args); - va_end(args); + if (snmplib_debug_hook != NULL) { + vsnprintf(buf, BUFSIZ, fmt, args); + snmplib_debug_hook(lvl, buf); + } else { + vfprintf(stderr, fmt, args); + } + va_end(args); } diff --git a/src/cache_cf.cc b/src/cache_cf.cc index f7b4f98e47..4f6431544d 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.258 1998/03/16 21:45:00 wessels Exp $ + * $Id: cache_cf.cc,v 1.259 1998/03/17 05:12:34 wessels Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -57,14 +57,12 @@ static void self_destruct(void); static void wordlistAdd(wordlist **, const char *); static void configDoConfigure(void); -#if SQUID_SNMP -static void parse_snmp_conf(snmpconf **); -#endif static void parse_refreshpattern(refresh_t **); static int parseTimeUnits(const char *unit); static void parseTimeLine(time_t * tptr, const char *units); static void parse_string(char **); static void parse_wordlist(wordlist **); +static void parse_stringlist(wordlist **); static void default_all(void); static void defaults_if_none(void); static int parse_line(char *); @@ -380,53 +378,6 @@ dump_acl(StoreEntry * entry, const char *name, acl * acl) } } -#if SQUID_SNMP -static void -parse_snmp_conf(snmpconf ** s) -{ - static char buff[256]; - static char *tokens[10], *p; - - if (Mib == NULL) { - if (Config.Snmp.mibPath) - init_mib(Config.Snmp.mibPath); - else - fatal("snmp_mib_path should be defined before any snmp_agent_conf\n"); - } - p = strtok(NULL, null_string); - xstrncpy(buff, p, 256); - tokenize(buff, tokens, 10); - if (!strcmp("view", tokens[0])) { - if (create_view(tokens) < 0) - debug(49, 5) ("snmp: parse_snmpconf(): error\n"); - } else if (!strcmp("user", tokens[0])) { - if (create_user(tokens) < 0) - debug(49, 5) ("snmp: parse_snmpconf(): error\n"); - } else if (!strcmp("community", tokens[0])) { - if (create_community(tokens) < 0) - debug(49, 5) ("snmp: parse_snmpconf(): error\n"); - } else - debug(49, 5) ("snmp: unknown directive %s\n", tokens[0]); -} - -static void -dump_snmp_conf(StoreEntry * entry, const char *name, snmpconf * head) -{ - storeAppendPrintf(entry, "%s -- UNIMPLEMENTED\n", name); -} - -static void -free_snmp_conf(snmpconf ** head) -{ - snmpconf *t; - while ((t = *head) != NULL) { - *head = t->next; - safe_free(t->line); - safe_free(t); - } -} -#endif - static void parse_acl(acl ** acl) { @@ -1296,11 +1247,20 @@ static void parse_wordlist(wordlist ** list) { char *token; - while ((token = strtok(NULL, w_space))) wordlistAdd(list, token); } +static void +parse_stringlist(wordlist ** list) +{ + char *token; + while ((token = strtok(NULL, null_string))) + wordlistAdd(list, token); +} +#define free_stringlist free_wordlist +#define dump_stringlist dump_wordlist + #define free_wordlist wordlistDestroy #include "cf_parser.c" diff --git a/src/cf.data.pre b/src/cf.data.pre index 4b94cb5ed5..0672b6e16a 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -2075,7 +2075,7 @@ snmp_enable_authen_traps off DOC_END NAME: snmp_agent_conf -TYPE: snmp_conf +TYPE: stringlist LOC: Config.Snmp.snmpconf DEFAULT: none IFDEF: SQUID_SNMP diff --git a/src/main.cc b/src/main.cc index a35225a0d3..2d92e090d8 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.236 1998/03/13 05:41:37 wessels Exp $ + * $Id: main.cc,v 1.237 1998/03/17 05:12:36 wessels Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -453,6 +453,9 @@ mainInitialize(void) httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */ errorInitialize(); accessLogInit(); +#ifdef SQUID_SNMP + snmpInit(); +#endif #if MALLOC_DBG malloc_debug(0, malloc_debug_level); @@ -507,9 +510,6 @@ mainInitialize(void) eventAdd("fqdncache_purgelru", fqdncache_purgelru, NULL, 15); } configured_once = 1; -#ifdef SQUID_SNMP - snmpInit(); -#endif } int diff --git a/src/structs.h b/src/structs.h index bded2f3796..1c074d2dc1 100644 --- a/src/structs.h +++ b/src/structs.h @@ -43,7 +43,6 @@ struct _acl_arp_data { acl_arp_data *next; #endif }; - #endif struct _String { @@ -54,12 +53,6 @@ struct _String { }; #if SQUID_SNMP -struct _snmpconf { - char *line; - int type; - snmpconf *next; -}; - struct _snmp_request_t { u_char *buf; u_char *outbuf; @@ -102,7 +95,6 @@ typedef struct _usecEntry { int authWriteView; struct _usecEntry *next; } usecEntry; - #endif struct _acl { @@ -216,7 +208,7 @@ struct _SquidConfig { u_short localPort; int do_queueing; int conf_authtraps; - struct _snmpconf *snmpconf; + wordlist *snmpconf; viewEntry *views; usecEntry *users; communityEntry *communities; diff --git a/src/typedefs.h b/src/typedefs.h index d66953c4b4..15271990e8 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -27,7 +27,6 @@ typedef struct _acl_deny_info_list acl_deny_info_list; typedef struct _acl_proxy_auth acl_proxy_auth; typedef struct _acl_arp_data acl_arp_data; typedef struct _acl acl; -typedef struct _snmpconf snmpconf; typedef struct _snmp_request_t snmp_request_t; typedef struct _acl_list acl_list; typedef struct _acl_access acl_access;