]> git.ipfire.org Git - thirdparty/squid.git/blob - src/snmp/Request.cc
Sync with trunk rev.13542
[thirdparty/squid.git] / src / snmp / Request.cc
1 /*
2 * DEBUG: section 49 SNMP Interface
3 *
4 */
5
6 #include "squid.h"
7 #include "ipc/Messages.h"
8 #include "ipc/TypedMsgHdr.h"
9 #include "snmp/Request.h"
10
11 Snmp::Request::Request(int aRequestorId, unsigned int aRequestId,
12 const Pdu& aPdu, const Session& aSession,
13 int aFd, const Ip::Address& anAddress):
14 Ipc::Request(aRequestorId, aRequestId),
15 pdu(aPdu), session(aSession), fd(aFd), address(anAddress)
16 {
17 }
18
19 Snmp::Request::Request(const Request& request):
20 Ipc::Request(request.requestorId, request.requestId),
21 pdu(request.pdu), session(request.session),
22 fd(request.fd), address(request.address)
23 {
24 }
25
26 Snmp::Request::Request(const Ipc::TypedMsgHdr& msg):
27 Ipc::Request(0, 0)
28 {
29 msg.checkType(Ipc::mtSnmpRequest);
30 msg.getPod(requestorId);
31 msg.getPod(requestId);
32 pdu.unpack(msg);
33 session.unpack(msg);
34 msg.getPod(address);
35
36 // Requests from strands have FDs. Requests from Coordinator do not.
37 fd = msg.hasFd() ? msg.getFd() : -1;
38 }
39
40 void
41 Snmp::Request::pack(Ipc::TypedMsgHdr& msg) const
42 {
43 msg.setType(Ipc::mtSnmpRequest);
44 msg.putPod(requestorId);
45 msg.putPod(requestId);
46 pdu.pack(msg);
47 session.pack(msg);
48 msg.putPod(address);
49
50 // Requests sent to Coordinator have FDs. Requests sent to strands do not.
51 if (fd >= 0)
52 msg.putFd(fd);
53 }
54
55 Ipc::Request::Pointer
56 Snmp::Request::clone() const
57 {
58 return new Request(*this);
59 }