#include "squid.h"
#include "acl/FilledChecklist.h"
#include "base/AsyncCallbacks.h"
#include "base/CbcPointer.h"
#include "CachePeer.h"
#include "CachePeers.h"
#include "client_db.h"
#include "comm.h"
#include "comm/Connection.h"
#include "comm/Loops.h"
#include "fatal.h"
#include "ip/Address.h"
#include "ip/tools.h"
#include "ipc/StartListening.h"
#include "snmp/Forwarder.h"
#include "snmp_agent.h"
#include "snmp_core.h"
#include "SnmpRequest.h"
#include "SquidConfig.h"
#include "SquidMath.h"
#include "tools.h"
Go to the source code of this file.
Functions | |
static void | snmpPortOpened (Ipc::StartListeningAnswer &) |
static mib_tree_entry * | snmpAddNodeStr (const char *base_str, int o, oid_ParseFn *parsefunction, instance_Fn *instancefunction, AggrType aggrType=atNone) |
static mib_tree_entry * | snmpAddNode (oid *name, int len, oid_ParseFn *parsefunction, instance_Fn *instancefunction, AggrType aggrType, int children,...) |
static oid * | snmpCreateOid (int length,...) |
mib_tree_entry * | snmpLookupNodeStr (mib_tree_entry *entry, const char *str) |
bool | snmpCreateOidFromStr (const char *str, oid **name, int *nl) |
static oid * | static_Inst (oid *name, snint *len, mib_tree_entry *current, oid_ParseFn **Fn) |
static oid * | time_Inst (oid *name, snint *len, mib_tree_entry *current, oid_ParseFn **Fn) |
static oid * | peer_Inst (oid *name, snint *len, mib_tree_entry *current, oid_ParseFn **Fn) |
static oid * | client_Inst (oid *name, snint *len, mib_tree_entry *current, oid_ParseFn **Fn) |
static void | snmpDecodePacket (SnmpRequest *rq) |
static void | snmpConstructReponse (SnmpRequest *rq) |
static oid_ParseFn * | snmpTreeNext (oid *Current, snint CurrentLen, oid **Next, snint *NextLen) |
static oid_ParseFn * | snmpTreeGet (oid *Current, snint CurrentLen) |
static mib_tree_entry * | snmpTreeEntry (oid entry, snint len, mib_tree_entry *current) |
static mib_tree_entry * | snmpTreeSiblingEntry (oid entry, snint len, mib_tree_entry *current) |
void | snmpSnmplibDebug (int lvl, char *buf) |
void | snmpInit (void) |
void | snmpOpenPorts (void) |
void | snmpClosePorts (void) |
void | snmpHandleUdp (int sock, void *) |
struct snmp_pdu * | snmpAgentResponse (struct snmp_pdu *PDU) |
AggrType | snmpAggrType (oid *Current, snint CurrentLen) |
static void | snmpAddNodeChild (mib_tree_entry *entry, mib_tree_entry *child) |
const char * | snmpDebugOid (oid *Name, snint Len, MemBuf &outbuf) |
void | addr2oid (Ip::Address &addr, oid *Dest) |
void | oid2addr (oid *id, Ip::Address &addr, u_int size) |
Variables | |
mib_tree_entry * | mib_tree_head |
mib_tree_entry * | mib_tree_last |
Comm::ConnectionPointer | snmpIncomingConn |
Comm::ConnectionPointer | snmpOutgoingConn |
SQUIDCEXTERN void(* | snmplib_debug_hook )(int, char *) |
Function Documentation
◆ addr2oid()
void addr2oid | ( | Ip::Address & | addr, |
oid * | Dest | ||
) |
Definition at line 1083 of file snmp_core.cc.
References code, debugs, Ip::Address::getInAddr(), INETADDRESSTYPE_IPV4, INETADDRESSTYPE_IPV6, Ip::Address::isIPv6(), size, and snmpDebugOid().
Referenced by client_Inst().
◆ client_Inst()
|
static |
Definition at line 768 of file snmp_core.cc.
References addr2oid(), client_entry(), debugs, instance, Ip::Address::isAnyAddr(), Ip::Address::isIPv4(), _mib_tree_entry::len, oid2addr(), _mib_tree_entry::parsefunction, Ip::Address::setAnyAddr(), size, and xmalloc.
Referenced by peer_Inst(), and snmpInit().
◆ oid2addr()
void oid2addr | ( | oid * | id, |
Ip::Address & | addr, | ||
u_int | size | ||
) |
Definition at line 1115 of file snmp_core.cc.
References debugs, size, and snmpDebugOid().
Referenced by client_Inst(), and snmp_meshCtblFn().
◆ peer_Inst()
|
static |
Definition at line 726 of file snmp_core.cc.
References client_Inst(), CurrentCachePeers(), debugs, instance, _mib_tree_entry::leaves, _mib_tree_entry::len, Less(), _mib_tree_entry::name, _mib_tree_entry::parent, _mib_tree_entry::parsefunction, CachePeers::size(), and xmalloc.
Referenced by snmpInit().
◆ snmpAddNode()
|
static |
Definition at line 995 of file snmp_core.cc.
References _mib_tree_entry::aggrType, _mib_tree_entry::children, debugs, _mib_tree_entry::instancefunction, _mib_tree_entry::leaves, _mib_tree_entry::len, _mib_tree_entry::name, _mib_tree_entry::parent, _mib_tree_entry::parsefunction, snmpDebugOid(), and xmalloc.
Referenced by snmpAddNodeStr(), and snmpInit().
◆ snmpAddNodeChild()
|
static |
Definition at line 882 of file snmp_core.cc.
References _mib_tree_entry::children, debugs, _mib_tree_entry::leaves, _mib_tree_entry::parent, and xrealloc().
Referenced by snmpAddNodeStr().
◆ snmpAddNodeStr()
|
static |
Definition at line 963 of file snmp_core.cc.
References debugs, mib_tree_head, snmpAddNode(), snmpAddNodeChild(), snmpCreateOidFromStr(), and snmpLookupNodeStr().
Referenced by snmpInit().
◆ snmpAgentResponse()
Definition at line 460 of file snmp_core.cc.
References snmp_pdu::command, debugs, snmp_pdu::errindex, snmp_pdu::errstat, variable_list::name, variable_list::name_length, variable_list::next_variable, snmp_pdu::reqid, SNMP_ERR_NOERROR, SNMP_ERR_NOSUCHNAME, snmp_pdu_create(), SNMP_PDU_GET, SNMP_PDU_GETNEXT, SNMP_PDU_RESPONSE, snmp_var_free(), snmp_var_new(), snmpTreeGet(), snmpTreeNext(), snmp_pdu::variables, and xfree.
Referenced by Snmp::SendResponse(), and snmpConstructReponse().
◆ snmpAggrType()
Definition at line 573 of file snmp_core.cc.
References _mib_tree_entry::aggrType, atNone, debugs, mib_tree_head, MYNAME, _mib_tree_entry::name, and snmpTreeEntry().
Referenced by Snmp::Pdu::aggregate(), and Snmp::Pdu::fixAggregate().
◆ snmpClosePorts()
void snmpClosePorts | ( | void | ) |
Definition at line 323 of file snmp_core.cc.
References Comm::Connection::close(), DBG_IMPORTANT, debugs, Comm::IsConnOpen(), Comm::Connection::local, snmpIncomingConn, and snmpOutgoingConn.
Referenced by serverConnectionsClose(), and SquidShutdown().
◆ snmpConstructReponse()
|
static |
Definition at line 430 of file snmp_core.cc.
References comm_udp_sendto(), debugs, SnmpRequest::from, IamWorkerProcess(), SnmpRequest::outbuf, SnmpRequest::outlen, SnmpRequest::PDU, SnmpRequest::session, snmp_build(), snmp_free_pdu(), snmpAgentResponse(), SnmpRequest::sock, AsyncJob::Start(), and UsingSmp().
Referenced by snmpDecodePacket().
◆ snmpCreateOid()
◆ snmpCreateOidFromStr()
Definition at line 934 of file snmp_core.cc.
References safe_free, and xrealloc().
Referenced by snmpAddNodeStr(), and snmpLookupNodeStr().
◆ snmpDebugOid()
Definition at line 1056 of file snmp_core.cc.
References MemBuf::append(), MemBuf::content(), MemBuf::init(), MemBuf::isNull(), and MAX_IPSTRLEN.
Referenced by addr2oid(), oid2addr(), snmp_meshCtblFn(), snmp_netDnsFn(), snmp_netFqdnFn(), snmp_netIpFn(), snmp_sysFn(), snmpAddNode(), snmpTreeGet(), and snmpTreeNext().
◆ snmpDecodePacket()
|
static |
Definition at line 384 of file snmp_core.cc.
References SquidConfig::accessList, Acl::Answer::allowed(), SnmpRequest::buf, SnmpRequest::community, Config, DBG_IMPORTANT, debugs, ACLChecklist::fastCheck(), SnmpRequest::from, SnmpRequest::len, SnmpRequest::PDU, snmp_pdu::reqid, SnmpRequest::session, SquidConfig::snmp, snmp_coexist_V2toV1(), ACLFilledChecklist::snmp_community, snmp_free_pdu(), snmp_parse(), snmp_pdu_create(), SNMP_VERSION_1, snmpConstructReponse(), ACLFilledChecklist::src_addr, snmp_session::Version, and xfree.
Referenced by snmpHandleUdp().
◆ snmpHandleUdp()
void snmpHandleUdp | ( | int | sock, |
void * | |||
) |
Definition at line 347 of file snmp_core.cc.
References SnmpRequest::buf, COMM_SELECT_READ, comm_udp_recvfrom(), DBG_IMPORTANT, debugs, SnmpRequest::from, SnmpRequest::len, SnmpRequest::outbuf, SnmpRequest::outlen, Comm::SetSelect(), SNMP_REQUEST_SIZE, snmpDecodePacket(), snmpHandleUdp(), SnmpRequest::sock, xcalloc(), xfree, xmalloc, and xstrerr().
Referenced by snmpHandleUdp(), and snmpPortOpened().
◆ snmpInit()
void snmpInit | ( | void | ) |
Definition at line 71 of file snmp_core.cc.
References assert, atAverage, atMax, atMin, atNone, atSum, client_Inst(), CONF_ADMIN, CONF_LOG_FAC, CONF_ST_MMAXSZ, CONF_ST_SWHIWM, CONF_ST_SWLOWM, CONF_ST_SWMAXSZ, CONF_STORAGE, CONF_UNIQNAME, CONF_VERSION, CONF_VERSION_ID, debugs, DNS_REP, DNS_REQ, DNS_SERVERS, FQDN_ENT, FQDN_GHBN, FQDN_HITS, FQDN_MISS, FQDN_NEGHIT, FQDN_PENDHIT, FQDN_REQ, IP_ENT, IP_GHBN, IP_HITS, IP_LOC, IP_MISS, IP_NEGHIT, IP_PENDHIT, IP_REQ, MESH_CTBL, MESH_CTBL_ADDR, MESH_CTBL_ADDR_TYPE, MESH_CTBL_HTBYTES, MESH_CTBL_HTHITBYTES, MESH_CTBL_HTHITS, MESH_CTBL_HTREQ, MESH_CTBL_ICPBYTES, MESH_CTBL_ICPHITBYTES, MESH_CTBL_ICPHITS, MESH_CTBL_ICPREQ, MESH_PTBL, MESH_PTBL_ADDR, MESH_PTBL_ADDR_TYPE, MESH_PTBL_FETCHES, MESH_PTBL_HTTP, MESH_PTBL_ICP, MESH_PTBL_IGN, MESH_PTBL_INDEX, MESH_PTBL_KEEPAL_R, MESH_PTBL_KEEPAL_S, MESH_PTBL_NAME, MESH_PTBL_PACKED, MESH_PTBL_RTT, MESH_PTBL_SENT, MESH_PTBL_STATE, MESH_PTBL_TYPE, mib_tree_head, mib_tree_last, NET_DNS_CACHE, NET_FQDN_CACHE, NET_IP_CACHE, peer_Inst(), PERF_MEDIAN_BHR, PERF_MEDIAN_DNS, PERF_MEDIAN_HTTP_ALL, PERF_MEDIAN_HTTP_HIT, PERF_MEDIAN_HTTP_MISS, PERF_MEDIAN_HTTP_NH, PERF_MEDIAN_HTTP_NM, PERF_MEDIAN_ICP_QUERY, PERF_MEDIAN_ICP_REPLY, PERF_MEDIAN_RHR, PERF_MEDIAN_TIME, PERF_PROTO, PERF_PROTOSTAT_AGGR, PERF_PROTOSTAT_AGGR_CLIENTS, PERF_PROTOSTAT_AGGR_CURSWAP, PERF_PROTOSTAT_AGGR_ERRORS, PERF_PROTOSTAT_AGGR_HTTP_ERRORS, PERF_PROTOSTAT_AGGR_HTTP_HITS, PERF_PROTOSTAT_AGGR_HTTP_KBYTES_IN, PERF_PROTOSTAT_AGGR_HTTP_KBYTES_OUT, PERF_PROTOSTAT_AGGR_HTTP_REQ, PERF_PROTOSTAT_AGGR_ICP_R, PERF_PROTOSTAT_AGGR_ICP_RKB, PERF_PROTOSTAT_AGGR_ICP_S, PERF_PROTOSTAT_AGGR_ICP_SKB, PERF_PROTOSTAT_AGGR_KBYTES_IN, PERF_PROTOSTAT_AGGR_KBYTES_OUT, PERF_PROTOSTAT_AGGR_REQ, PERF_PROTOSTAT_MEDIAN, PERF_SYS, PERF_SYS_CPUTIME, PERF_SYS_CPUUSAGE, PERF_SYS_CURLRUEXP, PERF_SYS_CURMAX_FD, PERF_SYS_CURRESERVED_FD, PERF_SYS_CURUNLREQ, PERF_SYS_CURUNUSED_FD, PERF_SYS_CURUSED_FD, PERF_SYS_MAXRESSZ, PERF_SYS_MEMUSAGE, PERF_SYS_NUMOBJCNT, PERF_SYS_NUMR, PERF_SYS_PF, snmp_confFn(), snmp_meshCtblFn(), snmp_meshPtblFn(), snmp_netDnsFn(), snmp_netFqdnFn(), snmp_netIpFn(), snmp_prfProtoFn(), snmp_prfSysFn(), snmp_sysFn(), snmpAddNode(), snmpAddNodeStr(), snmpCreateOid(), snmplib_debug_hook, snmpLookupNodeStr(), snmpSnmplibDebug(), static_Inst(), SYS_UPTIME, SYSSTOR, SYSVMSIZ, and time_Inst().
Referenced by mainInitialize().
◆ snmpLookupNodeStr()
mib_tree_entry * snmpLookupNodeStr | ( | mib_tree_entry * | entry, |
const char * | str | ||
) |
Definition at line 892 of file snmp_core.cc.
References assert, _mib_tree_entry::children, _mib_tree_entry::leaves, mib_tree_head, _mib_tree_entry::name, snmpCreateOidFromStr(), and xfree.
Referenced by snmpAddNodeStr(), and snmpInit().
◆ snmpOpenPorts()
void snmpOpenPorts | ( | void | ) |
Definition at line 259 of file snmp_core.cc.
References SquidConfig::Addrs, asyncCallbackFun, Config, DBG_CRITICAL, DBG_IMPORTANT, debugs, Ip::EnableIpv6, fatal(), Ipc::fdnInSnmpSocket, Ipc::fdnOutSnmpSocket, IPV6_SPECIAL_SPLITSTACK, Ip::Address::isAnyAddr(), Ip::Address::isNoAddr(), Comm::Connection::local, Ip::Address::port(), SquidConfig::Port, Ip::Address::setIPv4(), SquidConfig::snmp, SquidConfig::snmp_incoming, SquidConfig::snmp_outgoing, snmpIncomingConn, snmpOutgoingConn, snmpPortOpened(), and Ipc::StartListening().
Referenced by serverConnectionsOpen().
◆ snmpPortOpened()
|
static |
Definition at line 305 of file snmp_core.cc.
References COMM_SELECT_READ, Ipc::StartListeningAnswer::conn, conn, DBG_IMPORTANT, debugs, fatalf(), Comm::Connection::fd, Comm::IsConnOpen(), Comm::Connection::local, Comm::SetSelect(), snmpHandleUdp(), snmpIncomingConn, and snmpOutgoingConn.
Referenced by snmpOpenPorts().
◆ snmpSnmplibDebug()
void snmpSnmplibDebug | ( | int | lvl, |
char * | buf | ||
) |
◆ snmpTreeEntry()
|
static |
Definition at line 865 of file snmp_core.cc.
References _mib_tree_entry::leaves, and _mib_tree_entry::name.
Referenced by snmpAggrType(), snmpTreeGet(), and snmpTreeNext().
◆ snmpTreeGet()
|
static |
Definition at line 542 of file snmp_core.cc.
References debugs, mib_tree_head, _mib_tree_entry::name, _mib_tree_entry::parsefunction, snmpDebugOid(), and snmpTreeEntry().
Referenced by snmpAgentResponse().
◆ snmpTreeNext()
|
static |
Definition at line 596 of file snmp_core.cc.
References debugs, _mib_tree_entry::instancefunction, _mib_tree_entry::leaves, _mib_tree_entry::len, mib_tree_head, mib_tree_last, _mib_tree_entry::name, _mib_tree_entry::parent, _mib_tree_entry::parsefunction, snmpDebugOid(), snmpTreeEntry(), and snmpTreeSiblingEntry().
Referenced by snmpAgentResponse().
◆ snmpTreeSiblingEntry()
|
static |
Definition at line 838 of file snmp_core.cc.
References _mib_tree_entry::leaves, and _mib_tree_entry::name.
Referenced by snmpTreeNext().
◆ static_Inst()
|
static |
Definition at line 683 of file snmp_core.cc.
References instance, _mib_tree_entry::parsefunction, and xmalloc.
Referenced by snmpInit().
◆ time_Inst()
|
static |
Definition at line 697 of file snmp_core.cc.
References identifier, instance, _mib_tree_entry::parsefunction, TIME_INDEX, TIME_INDEX_LEN, and xmalloc.
Referenced by snmpInit().
Variable Documentation
◆ mib_tree_head
mib_tree_entry* mib_tree_head |
Definition at line 35 of file snmp_core.cc.
Referenced by snmpAddNodeStr(), snmpAggrType(), snmpInit(), snmpLookupNodeStr(), snmpTreeGet(), and snmpTreeNext().
◆ mib_tree_last
mib_tree_entry* mib_tree_last |
Definition at line 36 of file snmp_core.cc.
Referenced by snmpInit(), and snmpTreeNext().
◆ snmpIncomingConn
Comm::ConnectionPointer snmpIncomingConn |
Definition at line 38 of file snmp_core.cc.
Referenced by snmpClosePorts(), snmpOpenPorts(), and snmpPortOpened().
◆ snmplib_debug_hook
SQUIDCEXTERN void(* snmplib_debug_hook) (int, char *) | ( | int | , |
char * | |||
) |
Definition at line 46 of file snmp_core.cc.
Referenced by snmpInit().
◆ snmpOutgoingConn
Comm::ConnectionPointer snmpOutgoingConn |
Definition at line 39 of file snmp_core.cc.
Referenced by snmpClosePorts(), snmpOpenPorts(), and snmpPortOpened().