From: wessels <> Date: Fri, 21 Nov 1997 07:29:31 +0000 (+0000) Subject: kostas initial snmp support X-Git-Tag: SQUID_3_0_PRE1~4506 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2bbd722b151bb681d0f238a461ac32eb18dc61d6;p=thirdparty%2Fsquid.git kostas initial snmp support --- diff --git a/configure b/configure index 385d489353..9f147ce5c9 100755 --- a/configure +++ b/configure @@ -50,6 +50,8 @@ mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= +SNMPLIB='libsnmp.a' + # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 @@ -3608,6 +3610,7 @@ s%@host_os@%$host_os%g s%@CACHE_HTTP_PORT@%$CACHE_HTTP_PORT%g s%@CACHE_ICP_PORT@%$CACHE_ICP_PORT%g s%@CC@%$CC%g +s%@SNMPLIB@%$SNMPLIB%g s%@CPP@%$CPP%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_DATA@%$INSTALL_DATA%g @@ -3677,6 +3680,7 @@ CONFIG_FILES=\${CONFIG_FILES-"\ ./lib/Makefile \ ./include/config.h \ ./scripts/Makefile \ + ./snmplib/Makefile \ ./scripts/RunCache \ ./scripts/RunAccel \ ./src/Makefile \ diff --git a/configure.in b/configure.in index 35b9e6d11a..2ad288be3f 100644 --- a/configure.in +++ b/configure.in @@ -3,13 +3,13 @@ dnl Configuration input file for Squid dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.82 1997/10/31 05:15:06 wessels Exp $ +dnl $Id: configure.in,v 1.83 1997/11/21 00:29:32 wessels Exp $ dnl dnl dnl AC_INIT(src/main.c) AC_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.82 $)dnl +AC_REVISION($Revision: 1.83 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AC_CONFIG_AUX_DIR(aux) @@ -584,6 +584,9 @@ if test "$ac_cv_lib_malloc_main" = "yes" ; then XTRA_OBJS="$XTRA_OBJS /usr/lib/debug/mallocmap.o" fi fi +SNMPLIB='libsnmp.a' +AC_SUBST(SNMPLIB) + AC_SUBST(XTRA_OBJS) if test -z "$XTRA_LIBS"; then @@ -604,6 +607,7 @@ AC_OUTPUT(\ ./scripts/RunAccel \ ./src/Makefile \ ./contrib/Makefile \ + ./snmplib/Makefile \ ./icons/Makefile \ ./errors/Makefile \ ) diff --git a/doc/Programming-Guide/prog-guide.sgml b/doc/Programming-Guide/prog-guide.sgml index 3fe9eb0de5..1aef7cb09b 100644 --- a/doc/Programming-Guide/prog-guide.sgml +++ b/doc/Programming-Guide/prog-guide.sgml @@ -64,7 +64,7 @@ Squid consists of the following major components Client Side

- These routines exist primarily in two source files: $@ install-mkdirs: @@ -264,6 +275,7 @@ install: all install-mkdirs $(RM) -f $(libexecdir)/-$$f; \ fi; \ done + $(INSTALL_FILE) mib.txt $(sysconfdir)/mib.txt $(INSTALL_FILE) squid.conf $(sysconfdir)/squid.conf.default @if test -f $(sysconfdir)/squid.conf ; then \ echo "$@ will not overwrite existing $(sysconfdir)/squid.conf" ; \ @@ -271,6 +283,14 @@ install: all install-mkdirs echo "$(INSTALL_FILE) squid.conf $(sysconfdir)"; \ $(INSTALL_FILE) squid.conf $(sysconfdir); \ fi + $(INSTALL_FILE) snmp.conf $(sysconfdir)/snmp.conf.default + @if test -f $(sysconfdir)/snmp.conf ; then \ + echo "$@ will not overwrite existing $(sysconfdir)/snmp.conf" ; \ + else \ + echo "$(INSTALL_FILE) snmp.conf $(sysconfdir)"; \ + $(INSTALL_FILE) snmp.conf $(sysconfdir); \ + fi + $(INSTALL_FILE) mime.conf $(sysconfdir)/mime.conf.default @if test -f $(sysconfdir)/mime.conf ; then \ echo "$@ will not overwrite existing $(sysconfdir)/mime.conf" ; \ diff --git a/src/client.cc b/src/client.cc index c4c7964e94..7272bd5ed9 100644 --- a/src/client.cc +++ b/src/client.cc @@ -1,6 +1,6 @@ /* - * $Id: client.cc,v 1.40 1997/11/03 22:43:08 wessels Exp $ + * $Id: client.cc,v 1.41 1997/11/21 00:29:34 wessels Exp $ * * DEBUG: section 0 WWW Client * AUTHOR: Harvest Derived @@ -270,7 +270,7 @@ main(int argc, char *argv[]) fprintf(stderr, "client: ERROR: Cannot connect to %s:%d: Host unknown.\n", hostname, port); } else { char tbuf[BUFSIZ]; - sprintf(tbuf, "client: ERROR: Cannot connect to %s:%d", + snprintf(tbuf, BUFSIZ, "client: ERROR: Cannot connect to %s:%d", hostname, port); perror(tbuf); } diff --git a/src/globals.h b/src/globals.h index 10143abc16..280400f5ea 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.19 1997/11/20 06:25:26 wessels Exp $ + * $Id: globals.h,v 1.20 1997/11/21 00:29:35 wessels Exp $ */ extern FILE *debug_log; /* NULL */ @@ -68,6 +68,11 @@ extern int opt_zap_disk_store; /* 0 */ extern int syslog_enable; /* 0 */ extern int theInIcpConnection; /* -1 */ extern int theOutIcpConnection; /* -1 */ +#ifdef SQUID_SNMP +extern int theInSnmpConnection; /* -1 */ +extern int theOutSnmpConnection; /* -1 */ +extern char *snmp_agentinfo; +#endif extern int vhost_mode; /* 0 */ extern int vizSock; /* -1 */ extern iostats IOStats; @@ -80,6 +85,7 @@ extern struct in_addr any_addr; extern struct in_addr local_addr; extern struct in_addr no_addr; extern struct in_addr theOutICPAddr; +extern struct in_addr theOutSNMPAddr; extern struct timeval current_time; extern struct timeval squid_start; extern time_t squid_curtime; /* 0 */ diff --git a/src/main.cc b/src/main.cc index e5a18eb695..8f535a33a7 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.192 1997/11/15 00:14:49 wessels Exp $ + * $Id: main.cc,v 1.193 1997/11/21 00:29:36 wessels Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -130,7 +130,10 @@ static void mainParseOptions(int, char **); static void sendSignal(void); static void serverConnectionsOpen(void); static void watch_child(char **); - +#ifdef SQUID_SNMP +extern void init_snmp(); +extern void initSquidSnmp(); +#endif static void usage(void) { @@ -401,24 +404,8 @@ serverConnectionsOpen(void) } } #ifdef SQUID_SNMP - if (Config.Port.snmp) { - enter_suid(); - fd = comm_open(SOCK_STREAM, - 0, - Config.Addrs.snmp_incoming, - SQUID_SNMP_PORT, - COMM_NONBLOCKING, - "SNMP Socket"); - leave_suid(); - if (fd < 0) - continue; - comm_listen(fd); - commSetSelect(fd, COMM_SELECT_READ, snmpAccept, NULL, 0); - debug(1, 1) ("Accepting SNMP connections on port %d, FD %d.\n", - (int) SQUID_SNMP_PORT, fd); - } -#endif /* SQUID_SNMP */ - + initSquidSnmp(); +#endif clientdbInit(); icmpOpen(); @@ -583,6 +570,10 @@ mainInitialize(void) statAvgInit(); } configured_once = 1; + +#ifdef SQUID_SNMP + init_snmp(); +#endif } int diff --git a/src/protos.h b/src/protos.h index 8997b51da2..88f65e12f2 100644 --- a/src/protos.h +++ b/src/protos.h @@ -239,8 +239,15 @@ extern PF icpHandleUdp; extern PF httpAccept; extern DEFER httpAcceptDefer; #ifdef SQUID_SNMP -extern PF snmpAccept; +/*extern PF snmpHandleUdp;*/ +/*extern void initSquidSnmp();*/ #endif /* SQUID_SNMP */ + +extern void icpSendERROR(int fd, + log_type errorCode, + const char *text, + clientHttpRequest *, + int httpCode); extern void AppendUdp(icpUdpData *); extern PF icpUdpReply; extern void icpHandleIcpV3(int, struct sockaddr_in, char *, int); diff --git a/src/structs.h b/src/structs.h index 38a85e7079..7e885e76d4 100644 --- a/src/structs.h +++ b/src/structs.h @@ -129,6 +129,13 @@ struct _SquidConfig { u_short snmp; #endif } Port; + struct { + char *configFile; + char *agentInfo; + char *mibPath; + u_short localPort; + int do_queueing; + } Snmp; struct { char *log; char *access; @@ -169,10 +176,11 @@ struct _SquidConfig { struct in_addr tcp_incoming; struct in_addr tcp_outgoing; struct in_addr udp_incoming; + struct in_addr udp_outgoing; #ifdef SQUID_SNMP struct in_addr snmp_incoming; + struct in_addr snmp_outgoing; #endif /* SQUID_SNMP */ - struct in_addr udp_outgoing; struct in_addr client_netmask; } Addrs; size_t tcpRcvBufsz;