From: Christos Tsantilas Date: Fri, 28 Jan 2011 17:56:41 +0000 (+0200) Subject: Amos requests X-Git-Tag: take03^2~37^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f738d7837ae257736a58fc39962277cf192c3db1;p=thirdparty%2Fsquid.git Amos requests --- diff --git a/configure.ac b/configure.ac index ee58f1fa5c..1a1bcf1984 100644 --- a/configure.ac +++ b/configure.ac @@ -993,7 +993,7 @@ AC_ARG_ENABLE(snmp, ]) SQUID_DEFINE_BOOL(SQUID_SNMP,${enable_snmp:=yes}, [Define to enable SNMP monitoring of Squid]) -AM_CONDITIONAL(USE_SNMP, [test "x$enable_snmp" = "xyes"]) +AM_CONDITIONAL(ENABLE_SNMP, [test "x$enable_snmp" = "xyes"]) if test "x$enable_snmp" = "xyes"; then SNMPLIB='../snmplib/libsnmp.a' makesnmplib=snmplib diff --git a/src/Makefile.am b/src/Makefile.am index 068de32530..da42677421 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,7 @@ SNMP_ALL_SOURCE = \ snmp_core.h \ snmp_core.cc \ snmp_agent.cc -if USE_SNMP +if ENABLE_SNMP SNMP_SOURCE = $(SNMP_ALL_SOURCE) else SNMP_SOURCE = @@ -51,9 +51,9 @@ else SSL_LOCAL_LIBS = endif -if USE_SNMP +if ENABLE_SNMP SUBDIRS += snmpx -SNMPXLIB = snmpx/libsnmpx.la +SNMPX_LIBS = snmpx/libsnmpx.la endif if USE_ADAPTATION @@ -553,7 +553,7 @@ squid_LDADD = \ $(CRYPTLIB) \ $(REGEXLIB) \ $(SNMPLIB) \ - $(SNMPXLIB) \ + $(SNMPX_LIBS) \ ${ADAPTATION_LIBS} \ $(ESI_LIBS) \ $(SSL_LIBS) \ diff --git a/src/ipc/Coordinator.cc b/src/ipc/Coordinator.cc index 548d05146e..a79d4b8cc9 100644 --- a/src/ipc/Coordinator.cc +++ b/src/ipc/Coordinator.cc @@ -15,10 +15,11 @@ #include "mgr/Inquirer.h" #include "mgr/Request.h" #include "mgr/Response.h" +#if SQUID_SNMP #include "snmpx/Inquirer.h" #include "snmpx/Request.h" #include "snmpx/Response.h" - +#endif CBDATA_NAMESPACED_CLASS_INIT(Ipc, Coordinator); Ipc::Coordinator* Ipc::Coordinator::TheInstance = NULL; @@ -75,6 +76,7 @@ void Ipc::Coordinator::receive(const TypedMsgHdr& message) handleCacheMgrResponse(Mgr::Response(message)); break; +#if SQUID_SNMP case mtSnmpRequest: debugs(54, 6, HERE << "SNMP request"); handleSnmpRequest(Snmp::Request(message)); @@ -84,6 +86,7 @@ void Ipc::Coordinator::receive(const TypedMsgHdr& message) debugs(54, 6, HERE << "SNMP response"); handleSnmpResponse(Snmp::Response(message)); break; +#endif default: debugs(54, 1, HERE << "Unhandled message type: " << message.type()); @@ -143,6 +146,7 @@ Ipc::Coordinator::handleCacheMgrResponse(const Mgr::Response& response) Mgr::Inquirer::HandleRemoteAck(response); } +#if SQUID_SNMP void Ipc::Coordinator::handleSnmpRequest(const Snmp::Request& request) { @@ -162,6 +166,7 @@ Ipc::Coordinator::handleSnmpResponse(const Snmp::Response& response) debugs(54, 4, HERE); Snmp::Inquirer::HandleRemoteAck(response); } +#endif int Ipc::Coordinator::openListenSocket(const SharedListenRequest& request, diff --git a/src/ipc/Coordinator.h b/src/ipc/Coordinator.h index 6ef25cebf9..bafa3f7a09 100644 --- a/src/ipc/Coordinator.h +++ b/src/ipc/Coordinator.h @@ -15,8 +15,9 @@ #include "ipc/SharedListen.h" #include "ipc/StrandCoords.h" #include "mgr/forward.h" +#if SQUID_SNMP #include "snmpx/forward.h" - +#endif #include namespace Ipc @@ -47,9 +48,10 @@ protected: void handleSharedListenRequest(const SharedListenRequest& request); void handleCacheMgrRequest(const Mgr::Request& request); void handleCacheMgrResponse(const Mgr::Response& response); +#if SQUID_SNMP void handleSnmpRequest(const Snmp::Request& request); void handleSnmpResponse(const Snmp::Response& response); - +#endif /// calls comm_open_listener() int openListenSocket(const SharedListenRequest& request, int &errNo); diff --git a/src/ipc/FdNotes.cc b/src/ipc/FdNotes.cc index 9eb3328f33..f7ea3cf73f 100644 --- a/src/ipc/FdNotes.cc +++ b/src/ipc/FdNotes.cc @@ -17,8 +17,10 @@ Ipc::FdNote(int fdNoteId) "None", // fdnNone "HTTP Socket", // fdnHttpSocket "HTTPS Socket", // fdnHttpsSocket +#if SQUID_SNMP "Incoming SNMP Socket", // fdnInSnmpSocket "Outgoing SNMP Socket", // fdnOutSnmpSocket +#endif "Incoming ICP Socket", // fdnInIcpSocket "Incoming HTCP Socket" // fdnInHtcpSocket }; diff --git a/src/ipc/FdNotes.h b/src/ipc/FdNotes.h index 91409d0e72..20978ea2c8 100644 --- a/src/ipc/FdNotes.h +++ b/src/ipc/FdNotes.h @@ -15,7 +15,9 @@ namespace Ipc /// fd_note() label ID typedef enum { fdnNone, fdnHttpSocket, fdnHttpsSocket, +#if SQUID_SNMP fdnInSnmpSocket, fdnOutSnmpSocket, +#endif fdnInIcpSocket, fdnInHtcpSocket, fdnEnd } FdNoteId; diff --git a/src/ipc/Makefile.am b/src/ipc/Makefile.am index 0864394f39..4cda3bba0a 100644 --- a/src/ipc/Makefile.am +++ b/src/ipc/Makefile.am @@ -34,7 +34,6 @@ libipc_la_SOURCES = \ Inquirer.cc \ Inquirer.h \ Request.h \ - Response.cc \ Response.h DEFS += -DDEFAULT_PREFIX=\"$(prefix)\" diff --git a/src/ipc/Messages.h b/src/ipc/Messages.h index 59b2eb5db1..b358f1b981 100644 --- a/src/ipc/Messages.h +++ b/src/ipc/Messages.h @@ -8,10 +8,7 @@ #ifndef SQUID_IPC_MESSAGES_H #define SQUID_IPC_MESSAGES_H -#include "ipc/forward.h" -#include - -/** Declarations used by varios IPC messages */ +/** Declarations used by various IPC messages */ namespace Ipc { @@ -20,7 +17,9 @@ namespace Ipc typedef enum { mtNone = 0, mtRegistration, mtSharedListenRequest, mtSharedListenResponse, mtCacheMgrRequest, mtCacheMgrResponse, +#if SQUID_SNMP mtSnmpRequest, mtSnmpResponse +#endif } MessageType; } // namespace Ipc; diff --git a/src/ipc/Request.cc b/src/ipc/Request.cc deleted file mode 100644 index 2d8156ef0d..0000000000 --- a/src/ipc/Request.cc +++ /dev/null @@ -1,10 +0,0 @@ -/* - * $Id$ - * - * DEBUG: section 54 Interprocess Communication - * - */ - -#include "config.h" -#include "ipc/Request.h" -#include "ipc/TypedMsgHdr.h" diff --git a/src/ipc/Response.cc b/src/ipc/Response.cc deleted file mode 100644 index 5d1f39a9a0..0000000000 --- a/src/ipc/Response.cc +++ /dev/null @@ -1,17 +0,0 @@ -/* - * $Id$ - * - * DEBUG: section 54 Interprocess Communication - * - */ - -#include "config.h" -#include "ipc/Response.h" -#include "ipc/TypedMsgHdr.h" - - -std::ostream& Ipc::operator << (std::ostream &os, const Response& response) -{ - os << "[response.requestId %u]" << response.requestId << '}'; - return os; -} diff --git a/src/ipc/Response.h b/src/ipc/Response.h index bd3fa9afff..edbf2a971e 100644 --- a/src/ipc/Response.h +++ b/src/ipc/Response.h @@ -36,7 +36,13 @@ public: unsigned int requestId; ///< ID of request we are responding to }; -extern std::ostream& operator <<(std::ostream &os, const Response &response); +inline +std::ostream& operator << (std::ostream &os, const Response& response) +{ + os << "[response.requestId %u]" << response.requestId << '}'; + return os; +} + } // namespace Ipc diff --git a/src/ipc/Strand.cc b/src/ipc/Strand.cc index 6a4fd004f2..392fa13712 100644 --- a/src/ipc/Strand.cc +++ b/src/ipc/Strand.cc @@ -16,10 +16,11 @@ #include "mgr/Response.h" #include "mgr/Forwarder.h" #include "CacheManager.h" +#if SQUID_SNMP #include "snmpx/Forwarder.h" #include "snmpx/Request.h" #include "snmpx/Response.h" - +#endif CBDATA_NAMESPACED_CLASS_INIT(Ipc, Strand); @@ -67,6 +68,7 @@ void Ipc::Strand::receive(const TypedMsgHdr &message) handleCacheMgrResponse(Mgr::Response(message)); break; +#if SQUID_SNMP case mtSnmpRequest: handleSnmpRequest(Snmp::Request(message)); break; @@ -74,6 +76,7 @@ void Ipc::Strand::receive(const TypedMsgHdr &message) case mtSnmpResponse: handleSnmpResponse(Snmp::Response(message)); break; +#endif default: debugs(54, 1, HERE << "Unhandled message type: " << message.type()); @@ -106,6 +109,7 @@ void Ipc::Strand::handleCacheMgrResponse(const Mgr::Response& response) Mgr::Forwarder::HandleRemoteAck(response.requestId); } +#if SQUID_SNMP void Ipc::Strand::handleSnmpRequest(const Snmp::Request& request) { debugs(54, 6, HERE); @@ -117,6 +121,7 @@ void Ipc::Strand::handleSnmpResponse(const Snmp::Response& response) debugs(54, 6, HERE); Snmp::Forwarder::HandleRemoteAck(response.requestId); } +#endif void Ipc::Strand::timedout() { diff --git a/src/ipc/Strand.h b/src/ipc/Strand.h index 1394c0992e..5d2a0b28de 100644 --- a/src/ipc/Strand.h +++ b/src/ipc/Strand.h @@ -10,8 +10,9 @@ #include "ipc/Port.h" #include "mgr/forward.h" +#if SQUID_SNMP #include "snmpx/forward.h" - +#endif namespace Ipc { @@ -35,8 +36,10 @@ private: void handleRegistrationResponse(const StrandCoord &strand); void handleCacheMgrRequest(const Mgr::Request& request); void handleCacheMgrResponse(const Mgr::Response& response); +#if SQUID_SNMP void handleSnmpRequest(const Snmp::Request& request); void handleSnmpResponse(const Snmp::Response& response); +#endif private: bool isRegistered; ///< whether Coordinator ACKed registration (unused) diff --git a/src/snmp_core.cc b/src/snmp_core.cc index b9d65f5701..ecb7f91d59 100644 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@ -143,8 +143,8 @@ snmpInit(void) snmpAddNodeStr("1.3.6.1.4.1.3495.1.2", CONF_STORAGE, NULL, NULL); snmpAddNodeStr("1.3.6.1.4.1.3495.1.2.5", CONF_ST_MMAXSZ, snmp_confFn, static_Inst, atSum); snmpAddNodeStr("1.3.6.1.4.1.3495.1.2.5", CONF_ST_SWMAXSZ, snmp_confFn, static_Inst, atSum); - snmpAddNodeStr("1.3.6.1.4.1.3495.1.2.5", CONF_ST_SWHIWM, snmp_confFn, static_Inst, atSum); - snmpAddNodeStr("1.3.6.1.4.1.3495.1.2.5", CONF_ST_SWLOWM, snmp_confFn, static_Inst, atSum); + snmpAddNodeStr("1.3.6.1.4.1.3495.1.2.5", CONF_ST_SWHIWM, snmp_confFn, static_Inst, atMin); + snmpAddNodeStr("1.3.6.1.4.1.3495.1.2.5", CONF_ST_SWLOWM, snmp_confFn, static_Inst, atMax); snmpAddNodeStr("1.3.6.1.4.1.3495.1.2", CONF_UNIQNAME, snmp_confFn, static_Inst); diff --git a/src/snmpx/Pdu.cc b/src/snmpx/Pdu.cc index 91a70b0b23..6efcaf6038 100644 --- a/src/snmpx/Pdu.cc +++ b/src/snmpx/Pdu.cc @@ -65,6 +65,8 @@ Snmp::Pdu::aggregate(const Pdu& pdu) { case atSum: case atAverage: + // The mean-average division is done later + // when the Snmp::Pdu::fixAggregate() called aggr += var; break; case atMax: @@ -225,7 +227,7 @@ Snmp::Pdu::varCount() const void Snmp::Pdu::fixAggregate() { - if (!aggrCount) + if (aggrCount < 2) return; for (variable_list* p_aggr = variables; p_aggr != NULL; p_aggr = p_aggr->next_variable) { Var& aggr = static_cast(*p_aggr); diff --git a/src/snmpx/Pdu.h b/src/snmpx/Pdu.h index f1a4cd46c1..aad0e00b93 100644 --- a/src/snmpx/Pdu.h +++ b/src/snmpx/Pdu.h @@ -42,7 +42,7 @@ public: private: void init(); ///< initialize members void assign(const Pdu& pdu); ///< perform full assignment - int aggrCount; ///< The number of other Pdus merged into + unsigned int aggrCount; ///< The number of other Pdus merged into }; } // namespace Snmp diff --git a/src/snmpx/Var.cc b/src/snmpx/Var.cc index 32f972a1f7..ce1bf0ee04 100644 --- a/src/snmpx/Var.cc +++ b/src/snmpx/Var.cc @@ -254,14 +254,6 @@ Snmp::Var::asString() const return Range(val.string, val.string + val_len); } -ipaddr -Snmp::Var::asIpAddress() const -{ - Must(type == SMI_IPADDRESS); - Must(val.string != NULL && val_len == sizeof(ipaddr)); - return *reinterpret_cast(val.string); -} - void Snmp::Var::setInt(int value) { @@ -304,12 +296,6 @@ Snmp::Var::setTimeTicks(unsigned int ticks) setValue(&ticks, sizeof(ticks), SMI_TIMETICKS); } -void -Snmp::Var::setIpAddress(ipaddr addr) -{ - setValue(&addr, sizeof(addr), SMI_IPADDRESS); -} - void Snmp::Var::copyValue(const Var& var) { diff --git a/src/snmpx/Var.h b/src/snmpx/Var.h index c38cec4594..7d50e89788 100644 --- a/src/snmpx/Var.h +++ b/src/snmpx/Var.h @@ -48,7 +48,6 @@ public: unsigned int asTimeTicks() const; ///< returns variable value as time ticks Range asObject() const; ///< returns variable value as object oid Range asString() const; ///< returns variable value as chars string - ipaddr asIpAddress() const; ///< returns variable value as ip address void setInt(int value); ///< assign int value to variable void setCounter(int value); ///< assign Counter32 value to variable @@ -56,7 +55,6 @@ public: void setString(const Range& string); ///< assign string to variable void setObject(const Range& object); ///< assign object oid to variable void setTimeTicks(unsigned int ticks); ///