Squid Web Cache master
Loading...
Searching...
No Matches
Request.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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#include "squid.h"
12#include "ipc/Messages.h"
13#include "ipc/TypedMsgHdr.h"
14#include "snmp/Request.h"
15
16Snmp::Request::Request(const int aRequestorId, const Ipc::RequestId aRequestId,
17 const Pdu& aPdu, const Session& aSession,
18 int aFd, const Ip::Address& anAddress):
19 Ipc::Request(aRequestorId, aRequestId),
20 pdu(aPdu), session(aSession), fd(aFd), address(anAddress)
21{
22}
23
25{
27 msg.getPod(requestorId);
28 msg.getPod(requestId);
29 pdu.unpack(msg);
30 session.unpack(msg);
31 msg.getPod(address);
32
33 // Requests from strands have FDs. Requests from Coordinator do not.
34 fd = msg.hasFd() ? msg.getFd() : -1;
35}
36
37void
39{
41 msg.putPod(requestorId);
42 msg.putPod(requestId);
43 pdu.pack(msg);
44 session.pack(msg);
45 msg.putPod(address);
46
47 // Requests sent to Coordinator have FDs. Requests sent to strands do not.
48 if (fd >= 0)
49 msg.putFd(fd);
50}
51
54{
55 return new Request(*this);
56}
57
Request()=default
recipient's constructor
struct msghdr with a known type, fixed-size I/O and control buffers
Definition TypedMsgHdr.h:35
int getFd() const
returns stored descriptor
void putFd(int aFd)
stores descriptor
void getPod(Pod &pod) const
load POD
bool hasFd() const
whether the message has a descriptor stored
void checkType(int aType) const
void putPod(const Pod &pod)
store POD
void setType(int aType)
sets message type; use MessageType enum
SNMP request.
Definition Request.h:25
Pointer clone() const override
returns a copy of this
Definition Request.cc:53
void pack(Ipc::TypedMsgHdr &msg) const override
prepare for sendmsg()
Definition Request.cc:38
snmp_session wrapper add pack/unpack feature
Definition Session.h:23
@ mtSnmpRequest
Definition Messages.h:39