From: wessels <> Date: Tue, 2 Dec 1997 10:30:21 +0000 (+0000) Subject: make SNMP code #ifdef-able, including config parsing X-Git-Tag: SQUID_3_0_PRE1~4429 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1df370e38a088aa3c12e0971d7324351325ff724;p=thirdparty%2Fsquid.git make SNMP code #ifdef-able, including config parsing --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 7a3ecf6626..186a52a535 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.236 1997/12/02 00:17:30 wessels Exp $ + * $Id: cache_cf.cc,v 1.237 1997/12/02 03:30:21 wessels Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -30,8 +30,11 @@ */ #include "squid.h" + +#if SQUID_SNMP #include "snmp.h" #include "snmp_config.h" +#endif static const char *const T_SECOND_STR = "second"; static const char *const T_MINUTE_STR = "minute"; @@ -55,7 +58,9 @@ 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); @@ -362,6 +367,7 @@ dump_acl(StoreEntry * entry, const char *name, acl * acl) storeAppendPrintf(entry, "%s -- UNIMPLEMENTED\n", name); } +#if SQUID_SNMP static void parse_snmp_conf(snmpconf ** s) { @@ -376,7 +382,6 @@ parse_snmp_conf(snmpconf ** s) p = strtok(NULL, null_string); strcpy(buff, p); tokenize(buff, tokens, 10); - if (!strcmp("view", tokens[0])) { if (create_view(tokens) < 0) debug(49, 5) ("snmp: parse_snmpconf(): error\n"); @@ -390,6 +395,24 @@ parse_snmp_conf(snmpconf ** s) 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) { @@ -913,12 +936,6 @@ parse_onoff(int *var) #define dump_eol dump_string #define free_eol free_string -static void -dump_snmp_conf(StoreEntry * entry, const char *name, snmpconf * head) -{ - storeAppendPrintf(entry, "%s -- UNIMPLEMENTED\n", name); -} - static void dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head) { @@ -980,17 +997,6 @@ parse_refreshpattern(refresh_t ** head) safe_free(pattern); } -static void -free_snmp_conf(snmpconf ** head) -{ - snmpconf *t; - while ((t = *head) != NULL) { - *head = t->next; - safe_free(t->line); - safe_free(t); - } -} - static void free_refreshpattern(refresh_t ** head) { diff --git a/src/cf.data.pre b/src/cf.data.pre index e8f3eb6489..226593bbb7 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -1929,6 +1929,7 @@ NAME: snmp_port TYPE: ushort LOC: Config.Port.snmp DEFAULT: 3401 +IFDEF: SQUID_SNMP DOC_START Port for snmp. <=0 to disable. DOC_END @@ -1937,6 +1938,7 @@ NAME: snmp_config_file TYPE: string LOC: Config.Snmp.configFile DEFAULT: @DEFAULT_SNMP_CONF@ +IFDEF: SQUID_SNMP DOC_START External snmp configuration file, CMU-snmpd style. DOC_END @@ -1945,6 +1947,7 @@ NAME: snmp_do_queueing TYPE: onoff LOC: Config.Snmp.do_queueing DEFAULT: on +IFDEF: SQUID_SNMP DOC_START If disabled, snmp packets will not be queued but delivered immediately. This could be performant when you want to monitor @@ -1955,6 +1958,7 @@ NAME: forward_snmpd_port TYPE: ushort LOC: Config.Snmp.localPort DEFAULT: 0 +IFDEF: SQUID_SNMP DOC_START This configures whether we should be forwarding SNMP requests to another snmpd. The reason for putting this piece of functionality @@ -1974,6 +1978,7 @@ NAME: snmp_mib_path TYPE: string LOC: Config.Snmp.mibPath DEFAULT: @DEFAULT_MIB_PATH@ +IFDEF: SQUID_SNMP DOC_START The location of squid's mib. DOC_END @@ -1982,6 +1987,7 @@ NAME: snmp_port TYPE: ushort LOC: Config.Port.snmp DEFAULT: 3401 +IFDEF: SQUID_SNMP DOC_START Port for snmp. <=0 to disable. DOC_END @@ -1990,6 +1996,7 @@ NAME: snmp_config_file TYPE: string LOC: Config.Snmp.configFile DEFAULT: @DEFAULT_SNMP_CONF@ +IFDEF: SQUID_SNMP DOC_START External snmp configuration file, CMU-snmpd style. DOC_END @@ -1998,15 +2005,18 @@ NAME: snmp_do_queueing TYPE: onoff LOC: Config.Snmp.do_queueing DEFAULT: on +IFDEF: SQUID_SNMP DOC_START If disabled, snmp packets will not be queued but delivered immediately. This could be performant when you want to monitor a cache in trouble, but this could also bring squid to block. DOC_END + NAME: forward_snmpd_port TYPE: ushort LOC: Config.Snmp.localPort DEFAULT: 0 +IFDEF: SQUID_SNMP DOC_START This configures whether we should be forwarding SNMP requests to another snmpd. The reason for putting this piece of @@ -2025,6 +2035,7 @@ NAME: trap_sink TYPE: string LOC: Config.Snmp.trap_sink DEFAULT: 127.0.0.1 +IFDEF: SQUID_SNMP DOC_START Hostname or ip address of trap sink for snmp DOC_END @@ -2033,6 +2044,7 @@ NAME: snmp_trap_community TYPE: string LOC: Config.Snmp.trap_community DEFAULT: public +IFDEF: SQUID_SNMP DOC_START Community name for traps DOC_END @@ -2041,6 +2053,7 @@ NAME: snmp_enable_authen_traps TYPE: onoff LOC: Config.Snmp.conf_authtraps DEFAULT: off +IFDEF: SQUID_SNMP DOC_START Enable SNMP authenticated traps DOC_END @@ -2049,6 +2062,7 @@ NAME: snmp_agent_conf TYPE: snmp_conf LOC: Config.Snmp.snmpconf DEFAULT: none +IFDEF: SQUID_SNMP DOC_START Define snmp views, users and communities Example: diff --git a/src/cf_gen.cc b/src/cf_gen.cc index 5549121ae7..1477bed0a5 100644 --- a/src/cf_gen.cc +++ b/src/cf_gen.cc @@ -1,5 +1,5 @@ /* - * $Id: cf_gen.cc,v 1.16 1997/12/01 22:45:50 wessels Exp $ + * $Id: cf_gen.cc,v 1.17 1997/12/02 03:30:22 wessels Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Max Okumoto @@ -74,6 +74,7 @@ typedef struct Entry { char *default_value; char *default_if_none; char *comment; + char *ifdef; Line *doc; struct Entry *next; } Entry; @@ -175,6 +176,12 @@ main(int argc, char *argv[]) exit(1); } curr->type = strdup(ptr); + } else if (!strncmp(buff, "IFDEF:", 6)) { + if ((ptr = strtok(buff + 6, WS)) == NULL) { + printf("Error on line %d\n", linenum); + exit(1); + } + curr->ifdef = strdup(ptr); } else if (!strcmp(buff, "DOC_START")) { state = sDOC; } else if (!strcmp(buff, "DOC_NONE")) { @@ -317,6 +324,8 @@ gen_default(Entry * head, FILE * fp) continue; } assert(entry->default_value); + if (entry->ifdef) + fprintf(fp, "#ifdef %s\n", entry->ifdef); if (strcmp(entry->default_value, "none") == 0) { fprintf(fp, "\t/* No default for %s */\n", entry->name); } else { @@ -324,6 +333,8 @@ gen_default(Entry * head, FILE * fp) entry->name, entry->default_value); } + if (entry->ifdef) + fprintf(fp, "#endif\n"); } fprintf(fp, "\tcfg_filename = NULL;\n"); fprintf(fp, "}\n\n"); @@ -344,6 +355,8 @@ gen_default_if_none(Entry * head, FILE * fp) assert(entry->loc); if (entry->default_if_none == NULL) continue; + if (entry->ifdef) + fprintf(fp, "#ifdef %s\n", entry->ifdef); fprintf(fp, "\tif (check_null_%s(%s))\n" "\t\tdefault_line(\"%s %s\");\n", @@ -351,6 +364,8 @@ gen_default_if_none(Entry * head, FILE * fp) entry->loc, entry->name, entry->default_if_none); + if (entry->ifdef) + fprintf(fp, "#endif\n"); } fprintf(fp, "}\n\n"); } @@ -380,6 +395,8 @@ gen_parse(Entry * head, FILE * fp) entry->name ); assert(entry->loc); + if (entry->ifdef) + fprintf(fp, "#ifdef %s\n", entry->ifdef); if (strcmp(entry->loc, "none") == 0) { fprintf(fp, "\t\tparse_%s();\n", @@ -391,6 +408,8 @@ gen_parse(Entry * head, FILE * fp) entry->type, entry->loc ); } + if (entry->ifdef) + fprintf(fp, "#endif\n"); } fprintf(fp, @@ -417,10 +436,14 @@ gen_dump(Entry * head, FILE * fp) continue; if (strcmp(entry->name, "comment") == 0) continue; + if (entry->ifdef) + fprintf(fp, "#ifdef %s\n", entry->ifdef); fprintf(fp, "\tdump_%s(entry, \"%s\", %s);\n", entry->type, entry->name, entry->loc); + if (entry->ifdef) + fprintf(fp, "#endif\n"); } fprintf(fp, "}\n\n"); } @@ -440,7 +463,11 @@ gen_free(Entry * head, FILE * fp) continue; if (strcmp(entry->name, "comment") == 0) continue; + if (entry->ifdef) + fprintf(fp, "#ifdef %s\n", entry->ifdef); fprintf(fp, "\tfree_%s(&%s);\n", entry->type, entry->loc); + if (entry->ifdef) + fprintf(fp, "#endif\n"); } fprintf(fp, "}\n\n"); } diff --git a/src/structs.h b/src/structs.h index 73d724541e..3e3164e051 100644 --- a/src/structs.h +++ b/src/structs.h @@ -34,11 +34,13 @@ struct _acl_deny_info_list { struct _acl_deny_info_list *next; }; +#if SQUID_SNMP struct _snmpconf { char *line; int type; struct _snmpconf *next; }; +#endif struct _acl { char name[ACL_NAME_SZ]; @@ -131,8 +133,11 @@ struct _SquidConfig { struct { ushortlist *http; u_short icp; +#if SQUID_SNMP u_short snmp; +#endif } Port; +#if SQUID_SNMP struct { char *configFile; char *agentInfo; @@ -147,6 +152,7 @@ struct _SquidConfig { usecEntry *users; communityEntry *communities; } Snmp; +#endif struct { char *log; char *access; @@ -362,20 +368,6 @@ struct _fileMap { unsigned long *file_map; }; -struct _fqdncache_entry { - /* first two items must be equivalent to hash_link in hash.h */ - char *name; - struct _fqdncache_entry *next; - time_t lastref; - time_t expires; - unsigned char name_count; - char *names[FQDN_MAX_NAMES + 1]; - struct _fqdn_pending *pending_head; - char *error_message; - unsigned char locks; - fqdncache_status_t status:3; -}; - struct _hash_link { char *key; struct _hash_link *next; @@ -557,6 +549,21 @@ struct _ipcache_entry { ipcache_status_t status:3; }; +struct _fqdncache_entry { + /* first two items must be equivalent to hash_link in hash.h */ + char *name; + struct _fqdncache_entry *next; + time_t lastref; + time_t expires; + unsigned char name_count; + char *names[FQDN_MAX_NAMES + 1]; + struct _fqdn_pending *pending_head; + char *error_message; + dlink_node lru; + unsigned char locks; + fqdncache_status_t status:3; +}; + struct _domain_ping { char *domain; int do_ping; /* boolean */