Request.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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
Definition: TypedMsgHdr.cc:217
void putFd(int aFd)
stores descriptor
Definition: TypedMsgHdr.cc:196
void getPod(Pod &pod) const
load POD
Definition: TypedMsgHdr.h:118
bool hasFd() const
whether the message has a descriptor stored
Definition: TypedMsgHdr.cc:187
void checkType(int aType) const
Definition: TypedMsgHdr.cc:94
void putPod(const Pod &pod)
store POD
Definition: TypedMsgHdr.h:128
void setType(int aType)
sets message type; use MessageType enum
Definition: TypedMsgHdr.cc:100
Definition: Pdu.h:24
SNMP request.
Definition: Request.h:25
virtual void pack(Ipc::TypedMsgHdr &msg) const
prepare for sendmsg()
Definition: Request.cc:38
virtual Pointer clone() const
returns a copy of this
Definition: Request.cc:53
snmp_session wrapper add pack/unpack feature
Definition: Session.h:23
Definition: IpcIoFile.h:24
@ mtSnmpRequest
Definition: Messages.h:39

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors