Request.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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 
16 Snmp::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 
37 void
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 
snmp_session wrapper add pack/unpack feature
Definition: Session.h:22
void setType(int aType)
sets message type; use MessageType enum
Definition: TypedMsgHdr.cc:100
void checkType(int aType) const
Definition: TypedMsgHdr.cc:94
Request()=default
recipient's constructor
@ mtSnmpRequest
Definition: Messages.h:39
bool hasFd() const
whether the message has a descriptor stored
Definition: TypedMsgHdr.cc:187
Pointer clone() const override
returns a copy of this
Definition: Request.cc:53
void putPod(const Pod &pod)
store POD
Definition: TypedMsgHdr.h:126
SNMP request.
Definition: Request.h:24
void pack(Ipc::TypedMsgHdr &msg) const override
prepare for sendmsg()
Definition: Request.cc:38
int getFd() const
returns stored descriptor
Definition: TypedMsgHdr.cc:217
Definition: Pdu.h:23
struct msghdr with a known type, fixed-size I/O and control buffers
Definition: TypedMsgHdr.h:34
void putFd(int aFd)
stores descriptor
Definition: TypedMsgHdr.cc:196
void getPod(Pod &pod) const
load POD
Definition: TypedMsgHdr.h:118
Definition: IpcIoFile.h:23

 

Introduction

Documentation

Support

Miscellaneous