struct msghdr with a known type, fixed-size I/O and control buffers More...

#include <TypedMsgHdr.h>

Inheritance diagram for Ipc::TypedMsgHdr:
Collaboration diagram for Ipc::TypedMsgHdr:

Classes

struct  CtrlBuffer
 
struct  DataBuffer
 

Public Types

enum  { maxSize = 4096 }
 

Public Member Functions

 TypedMsgHdr ()
 
 TypedMsgHdr (const TypedMsgHdr &tmh)
 
TypedMsgHdroperator= (const TypedMsgHdr &tmh)
 
void address (const struct sockaddr_un &addr)
 sets [dest.] address More...
 
void setType (int aType)
 sets message type; use MessageType enum More...
 
void checkType (int aType) const
 
int rawType () const
 
template<class Pod >
void getPod (Pod &pod) const
 load POD More...
 
template<class Pod >
void putPod (const Pod &pod)
 store POD More...
 
void getString (String &s) const
 load variable-length string More...
 
void putString (const String &s)
 store variable-length string More...
 
int getInt () const
 load an integer More...
 
void putInt (int n)
 store an integer More...
 
void getFixed (void *raw, size_t size) const
 always load size bytes More...
 
void putFixed (const void *raw, size_t size)
 always store size bytes More...
 
bool hasMoreData () const
 returns true if there is data to extract; handy for optional parts More...
 
void putFd (int aFd)
 stores descriptor More...
 
int getFd () const
 returns stored descriptor More...
 
bool hasFd () const
 whether the message has a descriptor stored More...
 
void prepForReading ()
 reset and provide all buffers More...
 
char * raw ()
 
const char * raw () const
 
size_t size () const
 not true message size More...
 

Public Attributes

void * msg_name
 
socklen_t msg_namelen
 
struct iovecmsg_iov
 
size_t msg_iovlen
 
void * msg_control
 
size_t msg_controllen
 
int msg_flags
 

Private Member Functions

void clear ()
 
void sync ()
 
void allocData ()
 initialize io vector with one io record More...
 
void allocName ()
 
void allocControl ()
 
void getRaw (void *raw, size_t size) const
 low-level loading of exactly size bytes of raw data More...
 
void putRaw (const void *raw, size_t size)
 low-level storage of exactly size bytes of raw data More...
 

Private Attributes

struct sockaddr_un name
 same as .msg_name More...
 
struct iovec ios [1]
 same as .msg_iov[] More...
 
struct Ipc::TypedMsgHdr::DataBuffer data
 same as .msg_iov[0].iov_base More...
 
struct Ipc::TypedMsgHdr::CtrlBuffer ctrl
 same as .msg_control More...
 
unsigned int offset = 0
 data offset for the next get/put*() to start with More...
 

Detailed Description

Definition at line 32 of file TypedMsgHdr.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
maxSize 

Definition at line 35 of file TypedMsgHdr.h.

Constructor & Destructor Documentation

◆ TypedMsgHdr() [1/2]

Ipc::TypedMsgHdr::TypedMsgHdr ( )

Definition at line 19 of file TypedMsgHdr.cc.

References clear(), and sync().

◆ TypedMsgHdr() [2/2]

Ipc::TypedMsgHdr::TypedMsgHdr ( const TypedMsgHdr tmh)

Definition at line 25 of file TypedMsgHdr.cc.

Member Function Documentation

◆ address()

void Ipc::TypedMsgHdr::address ( const struct sockaddr_un addr)

Definition at line 85 of file TypedMsgHdr.cc.

References SUN_LEN.

Referenced by Ipc::UdsSender::UdsSender().

◆ allocControl()

void Ipc::TypedMsgHdr::allocControl ( )
private

Definition at line 266 of file TypedMsgHdr.cc.

References Must.

◆ allocData()

void Ipc::TypedMsgHdr::allocData ( )
private

Definition at line 246 of file TypedMsgHdr.cc.

References data, and Must.

◆ allocName()

void Ipc::TypedMsgHdr::allocName ( )
private

Definition at line 258 of file TypedMsgHdr.cc.

References Must.

◆ checkType()

◆ clear()

void Ipc::TypedMsgHdr::clear ( )
private

Definition at line 46 of file TypedMsgHdr.cc.

References data.

Referenced by TypedMsgHdr().

◆ getFd()

◆ getFixed()

void Ipc::TypedMsgHdr::getFixed ( void *  raw,
size_t  size 
) const

◆ getInt()

◆ getPod()

◆ getRaw()

void Ipc::TypedMsgHdr::getRaw ( void *  raw,
size_t  size 
) const
private

Definition at line 166 of file TypedMsgHdr.cc.

References data, and Must.

◆ getString()

◆ hasFd()

bool Ipc::TypedMsgHdr::hasFd ( ) const

Definition at line 187 of file TypedMsgHdr.cc.

References CMSG_FIRSTHDR, cmsghdr::cmsg_level, cmsghdr::cmsg_type, and SCM_RIGHTS.

Referenced by Snmp::Request::Request().

◆ hasMoreData()

bool Ipc::TypedMsgHdr::hasMoreData ( ) const
inline

Definition at line 64 of file TypedMsgHdr.h.

References data, offset, and Ipc::TypedMsgHdr::DataBuffer::size.

Referenced by Mgr::Response::Response().

◆ operator=()

Ipc::TypedMsgHdr & Ipc::TypedMsgHdr::operator= ( const TypedMsgHdr tmh)

Definition at line 31 of file TypedMsgHdr.cc.

References ctrl, data, data, ios, name, and offset.

◆ prepForReading()

void Ipc::TypedMsgHdr::prepForReading ( )

Definition at line 234 of file TypedMsgHdr.cc.

◆ putFd()

◆ putFixed()

void Ipc::TypedMsgHdr::putFixed ( const void *  raw,
size_t  size 
)

Definition at line 158 of file TypedMsgHdr.cc.

Referenced by Snmp::Pdu::pack(), Snmp::Session::pack(), and Snmp::Var::pack().

◆ putInt()

◆ putPod()

◆ putRaw()

void Ipc::TypedMsgHdr::putRaw ( const void *  raw,
size_t  size 
)
private

Definition at line 177 of file TypedMsgHdr.cc.

References data, and Must.

◆ putString()

◆ raw() [1/2]

char* Ipc::TypedMsgHdr::raw ( )
inline

Definition at line 73 of file TypedMsgHdr.h.

◆ raw() [2/2]

const char* Ipc::TypedMsgHdr::raw ( ) const
inline

Definition at line 74 of file TypedMsgHdr.h.

◆ rawType()

int Ipc::TypedMsgHdr::rawType ( ) const
inline

received or set message kind; may not be a MessageType value

Returns
0 if no message kind has been received or set

Definition at line 49 of file TypedMsgHdr.h.

Referenced by Ipc::Port::receive(), Ipc::Coordinator::receive(), Ipc::Strand::receive(), and Ipc::Port::receiveOrIgnore().

◆ setType()

◆ size()

size_t Ipc::TypedMsgHdr::size ( ) const
inline

Definition at line 75 of file TypedMsgHdr.h.

◆ sync()

void Ipc::TypedMsgHdr::sync ( void  )
private

Definition at line 58 of file TypedMsgHdr.cc.

References data, and Must.

Referenced by TypedMsgHdr().

Member Data Documentation

◆ ctrl

struct Ipc::TypedMsgHdr::CtrlBuffer Ipc::TypedMsgHdr::ctrl
private

Referenced by operator=().

◆ data

struct Ipc::TypedMsgHdr::DataBuffer Ipc::TypedMsgHdr::data
private

Referenced by hasMoreData(), and operator=().

◆ ios

struct iovec Ipc::TypedMsgHdr::ios[1]
private

Definition at line 86 of file TypedMsgHdr.h.

Referenced by operator=().

◆ msg_control

void* msghdr::msg_control
inherited

Definition at line 95 of file cmsg.h.

◆ msg_controllen

size_t msghdr::msg_controllen
inherited

Definition at line 96 of file cmsg.h.

◆ msg_flags

int msghdr::msg_flags
inherited

Definition at line 101 of file cmsg.h.

◆ msg_iov

struct iovec* msghdr::msg_iov
inherited

Definition at line 92 of file cmsg.h.

◆ msg_iovlen

size_t msghdr::msg_iovlen
inherited

Definition at line 93 of file cmsg.h.

◆ msg_name

void* msghdr::msg_name
inherited

Definition at line 89 of file cmsg.h.

◆ msg_namelen

socklen_t msghdr::msg_namelen
inherited

Definition at line 90 of file cmsg.h.

◆ name

struct sockaddr_un Ipc::TypedMsgHdr::name
private

Definition at line 86 of file TypedMsgHdr.h.

Referenced by operator=().

◆ offset

unsigned int Ipc::TypedMsgHdr::offset = 0
mutableprivate

Definition at line 109 of file TypedMsgHdr.h.

Referenced by hasMoreData(), and operator=().


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors