]>
Commit | Line | Data |
---|---|---|
51ea0904 | 1 | /* |
51ea0904 CT |
2 | * DEBUG: section 49 SNMP Interface |
3 | * | |
4 | */ | |
5 | ||
f7f3304a | 6 | #include "squid.h" |
51ea0904 CT |
7 | #include "ipc/Messages.h" |
8 | #include "ipc/TypedMsgHdr.h" | |
d6e3ad20 | 9 | #include "snmp/Request.h" |
51ea0904 | 10 | |
51ea0904 CT |
11 | Snmp::Request::Request(int aRequestorId, unsigned int aRequestId, |
12 | const Pdu& aPdu, const Session& aSession, | |
13 | int aFd, const Ip::Address& anAddress): | |
8fb5a96c CT |
14 | Ipc::Request(aRequestorId, aRequestId), |
15 | pdu(aPdu), session(aSession), fd(aFd), address(anAddress) | |
51ea0904 CT |
16 | { |
17 | } | |
18 | ||
19 | Snmp::Request::Request(const Request& request): | |
8fb5a96c CT |
20 | Ipc::Request(request.requestorId, request.requestId), |
21 | pdu(request.pdu), session(request.session), | |
22 | fd(request.fd), address(request.address) | |
51ea0904 CT |
23 | { |
24 | } | |
25 | ||
26 | Snmp::Request::Request(const Ipc::TypedMsgHdr& msg): | |
8fb5a96c | 27 | Ipc::Request(0, 0) |
51ea0904 CT |
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 | ||
9b440559 CT |
36 | // Requests from strands have FDs. Requests from Coordinator do not. |
37 | fd = msg.hasFd() ? msg.getFd() : -1; | |
51ea0904 CT |
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 | ||
9b440559 CT |
50 | // Requests sent to Coordinator have FDs. Requests sent to strands do not. |
51 | if (fd >= 0) | |
52 | msg.putFd(fd); | |
51ea0904 CT |
53 | } |
54 | ||
55 | Ipc::Request::Pointer | |
56 | Snmp::Request::clone() const | |
57 | { | |
58 | return new Request(*this); | |
59 | } |