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