]> git.ipfire.org Git - thirdparty/squid.git/blame - src/snmp/Request.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / snmp / Request.cc
CommitLineData
51ea0904 1/*
4ac4a490 2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
51ea0904 3 *
bbc27441
AJ
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.
51ea0904
CT
7 */
8
bbc27441
AJ
9/* DEBUG: section 49 SNMP Interface */
10
f7f3304a 11#include "squid.h"
51ea0904
CT
12#include "ipc/Messages.h"
13#include "ipc/TypedMsgHdr.h"
d6e3ad20 14#include "snmp/Request.h"
51ea0904 15
51ea0904
CT
16Snmp::Request::Request(int aRequestorId, unsigned int aRequestId,
17 const Pdu& aPdu, const Session& aSession,
18 int aFd, const Ip::Address& anAddress):
f53969cc
SM
19 Ipc::Request(aRequestorId, aRequestId),
20 pdu(aPdu), session(aSession), fd(aFd), address(anAddress)
51ea0904
CT
21{
22}
23
24Snmp::Request::Request(const Request& request):
f53969cc
SM
25 Ipc::Request(request.requestorId, request.requestId),
26 pdu(request.pdu), session(request.session),
27 fd(request.fd), address(request.address)
51ea0904
CT
28{
29}
30
31Snmp::Request::Request(const Ipc::TypedMsgHdr& msg):
f53969cc 32 Ipc::Request(0, 0)
51ea0904
CT
33{
34 msg.checkType(Ipc::mtSnmpRequest);
35 msg.getPod(requestorId);
36 msg.getPod(requestId);
37 pdu.unpack(msg);
38 session.unpack(msg);
39 msg.getPod(address);
40
9b440559
CT
41 // Requests from strands have FDs. Requests from Coordinator do not.
42 fd = msg.hasFd() ? msg.getFd() : -1;
51ea0904
CT
43}
44
45void
46Snmp::Request::pack(Ipc::TypedMsgHdr& msg) const
47{
48 msg.setType(Ipc::mtSnmpRequest);
49 msg.putPod(requestorId);
50 msg.putPod(requestId);
51 pdu.pack(msg);
52 session.pack(msg);
53 msg.putPod(address);
54
9b440559
CT
55 // Requests sent to Coordinator have FDs. Requests sent to strands do not.
56 if (fd >= 0)
57 msg.putFd(fd);
51ea0904
CT
58}
59
60Ipc::Request::Pointer
61Snmp::Request::clone() const
62{
63 return new Request(*this);
64}
f53969cc 65