Request.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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(int aRequestorId, unsigned int 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  Ipc::Request(request.requestorId, request.requestId),
26  pdu(request.pdu), session(request.session),
27  fd(request.fd), address(request.address)
28 {
29 }
30 
32  Ipc::Request(0, 0)
33 {
35  msg.getPod(requestorId);
36  msg.getPod(requestId);
37  pdu.unpack(msg);
38  session.unpack(msg);
39  msg.getPod(address);
40 
41  // Requests from strands have FDs. Requests from Coordinator do not.
42  fd = msg.hasFd() ? msg.getFd() : -1;
43 }
44 
45 void
47 {
49  msg.putPod(requestorId);
50  msg.putPod(requestId);
51  pdu.pack(msg);
52  session.pack(msg);
53  msg.putPod(address);
54 
55  // Requests sent to Coordinator have FDs. Requests sent to strands do not.
56  if (fd >= 0)
57  msg.putFd(fd);
58 }
59 
62 {
63  return new Request(*this);
64 }
65 
snmp_session wrapper add pack/unpack feature
Definition: Session.h:22
void getPod(Pod &pod) const
load POD
Definition: TypedMsgHdr.h:50
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
void putPod(const Pod &pod)
store POD
Definition: TypedMsgHdr.h:52
Pdu pdu
SNMP protocol data unit.
Definition: Request.h:39
bool hasFd() const
whether the message has a descriptor stored
Definition: TypedMsgHdr.cc:177
void unpack(const Ipc::TypedMsgHdr &msg)
restore struct from the message
Definition: Session.cc:92
void unpack(const Ipc::TypedMsgHdr &msg)
restore struct from the message
Definition: Pdu.cc:190
int fd
client connection descriptor
Definition: Request.h:41
Definition: Pdu.h:23
Request(int aRequestorId, unsigned int aRequestId, const Pdu &aPdu, const Session &aSession, int aFd, const Ip::Address &anAddress)
Definition: Request.cc:16
unsigned int requestId
unique for sender; matches request w/ response
Definition: Request.h:39
Ip::Address address
client address
Definition: Request.h:42
virtual Pointer clone() const
returns a copy of this
Definition: Request.cc:61
int requestorId
kidId of the requestor; used for response destination
Definition: Request.h:38
SNMP request.
Definition: Request.h:24
virtual void pack(Ipc::TypedMsgHdr &msg) const
prepare for sendmsg()
Definition: Request.cc:46
void putFd(int aFd)
stores descriptor
Definition: TypedMsgHdr.cc:186
struct msghdr with a known type, fixed-size I/O and control buffers
Definition: TypedMsgHdr.h:31
void checkType(int aType) const
throws if stored type is not aType
Definition: TypedMsgHdr.cc:84
int getFd() const
returns stored descriptor
Definition: TypedMsgHdr.cc:207
void setType(int aType)
sets message type; use MessageType enum
Definition: TypedMsgHdr.cc:90
Session session
SNMP session.
Definition: Request.h:40

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors