11#ifndef SQUID_IPC_TYPED_MSG_HDR_H
12#define SQUID_IPC_TYPED_MSG_HDR_H
17#include <sys/socket.h>
54 template <
class Pod>
void getPod(Pod &pod)
const;
55 template <
class Pod>
void putPod(
const Pod &pod);
75 char *
raw() {
return reinterpret_cast<char*
>(
this); }
76 const char *
raw()
const {
return reinterpret_cast<const char*
>(
this); }
77 size_t size()
const {
return sizeof(*this); }
120 static_assert(std::is_trivially_copyable<Pod>::value,
"getPod() used for a POD");
128 static_assert(std::is_trivially_copyable<Pod>::value,
"putPod() used for a POD");
129 putFixed(&pod,
sizeof(pod));
struct msghdr with a known type, fixed-size I/O and control buffers
struct Ipc::TypedMsgHdr::CtrlBuffer ctrl
same as .msg_control
void getRaw(void *raw, size_t size) const
low-level loading of exactly size bytes of raw data
int getFd() const
returns stored descriptor
unsigned int offset
data offset for the next get/put*() to start with
void putRaw(const void *raw, size_t size)
low-level storage of exactly size bytes of raw data
void putString(const String &s)
store variable-length string
TypedMsgHdr & operator=(const TypedMsgHdr &tmh)
void putFd(int aFd)
stores descriptor
bool hasMoreData() const
returns true if there is data to extract; handy for optional parts
void getFixed(void *raw, size_t size) const
always load size bytes
struct Ipc::TypedMsgHdr::DataBuffer data
same as .msg_iov[0].iov_base
void putInt(int n)
store an integer
size_t size() const
not true message size
void getPod(Pod &pod) const
load POD
void getString(String &s) const
load variable-length string
bool hasFd() const
whether the message has a descriptor stored
struct iovec ios[1]
same as .msg_iov[]
struct sockaddr_un name
same as .msg_name
void allocData()
initialize io vector with one io record
void checkType(int aType) const
void putFixed(const void *raw, size_t size)
always store size bytes
void prepForReading()
reset and provide all buffers
void putPod(const Pod &pod)
store POD
void setType(int aType)
sets message type; use MessageType enum
int getInt() const
load an integer
void address(const struct sockaddr_un &addr)
sets [dest.] address
char raw[SQUID_CMSG_SPACE(sizeof(int))]
control buffer space for one fd
int type_
Message kind, uses MessageType values.
size_t size
actual raw data size (for sanity checks)
char raw[maxSize]
buffer with type-specific data