1 /* 2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors 3 * 4 * Squid software is distributed under GPLv2+ license and includes 5 * contributions from numerous individuals and organizations. 6 * Please see the COPYING and CONTRIBUTORS files for details. 7 */ 8 9 /* DEBUG: section 49 SNMP Interface */ 10 11 #ifndef SQUID_SNMPX_FORWARDER_H 12 #define SQUID_SNMPX_FORWARDER_H 13 14 #include "ipc/Forwarder.h" 15 #include "snmp/Pdu.h" 16 #include "snmp/Session.h" 17 18 class CommCloseCbParams; 19 20 namespace Snmp 21 { 22 23 /** Forwards a single client SNMP request to Coordinator. 24 * Waits for an ACK from Coordinator 25 * Send the data unit with an error response if forwarding fails. 26 */ 27 class Forwarder: public Ipc::Forwarder 28 { 29 CBDATA_CLASS(Forwarder); 30 31 public: 32 Forwarder(const Pdu& aPdu, const Session& aSession, int aFd, 33 const Ip::Address& anAddress); 34 35 protected: 36 /* Ipc::Forwarder API */ 37 virtual void swanSong(); 38 virtual void handleTimeout(); 39 virtual void handleException(const std::exception& e); 40 41 private: 42 void noteCommClosed(const CommCloseCbParams& params); 43 void sendError(int error); 44 45 private: 46 int fd; ///< client connection descriptor 47 AsyncCall::Pointer closer; ///< comm_close handler for the connection 48 }; 49 50 void SendResponse(unsigned int requestId, const Pdu& pdu); 51 52 } // namespace Snmp 53 54 #endif /* SQUID_SNMPX_FORWARDER_H */ 55 56