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
 throws if stored type is not aType More...
 
int type () const
 returns stored type or zero if none More...
 
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 31 of file TypedMsgHdr.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
maxSize 

Definition at line 34 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.

References clear(), and operator=().

Member Function Documentation

◆ address()

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

Definition at line 92 of file TypedMsgHdr.cc.

References addr, allocName(), msghdr::msg_name, msghdr::msg_namelen, name, and SUN_LEN.

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

◆ allocControl()

void Ipc::TypedMsgHdr::allocControl ( )
private

Definition at line 273 of file TypedMsgHdr.cc.

References ctrl, msghdr::msg_control, msghdr::msg_controllen, and Must.

Referenced by prepForReading(), putFd(), and size().

◆ allocData()

void Ipc::TypedMsgHdr::allocData ( )
private

◆ allocName()

void Ipc::TypedMsgHdr::allocName ( )
private

Definition at line 265 of file TypedMsgHdr.cc.

References msghdr::msg_name, msghdr::msg_namelen, Must, and name.

Referenced by address(), prepForReading(), and size().

◆ checkType()

◆ clear()

void Ipc::TypedMsgHdr::clear ( )
private

Definition at line 46 of file TypedMsgHdr.cc.

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

Referenced by prepForReading(), size(), and TypedMsgHdr().

◆ getFd()

◆ getFixed()

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

Definition at line 158 of file TypedMsgHdr.cc.

References getRaw().

Referenced by getPod(), putPod(), Snmp::Session::unpack(), Snmp::Pdu::unpack(), and Snmp::Var::unpack().

◆ getInt()

◆ getPod()

◆ getRaw()

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

◆ getString()

◆ hasFd()

bool Ipc::TypedMsgHdr::hasFd ( ) const

◆ hasMoreData()

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

◆ operator=()

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

Definition at line 31 of file TypedMsgHdr.cc.

References ctrl, data, ios, name, offset, and sync().

Referenced by TypedMsgHdr().

◆ prepForReading()

void Ipc::TypedMsgHdr::prepForReading ( )

Definition at line 241 of file TypedMsgHdr.cc.

References allocControl(), allocData(), allocName(), and clear().

Referenced by Ipc::Port::doListen(), and hasMoreData().

◆ putFd()

◆ putFixed()

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

Definition at line 165 of file TypedMsgHdr.cc.

References putRaw().

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

◆ putInt()

◆ putPod()

◆ putRaw()

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

◆ putString()

◆ raw() [1/2]

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

◆ raw() [2/2]

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

Definition at line 73 of file TypedMsgHdr.h.

◆ setType()

◆ size()

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

◆ sync()

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

◆ type()

int Ipc::TypedMsgHdr::type ( ) const

Member Data Documentation

◆ ctrl

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

Referenced by allocControl(), clear(), operator=(), and sync().

◆ data

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

◆ ios

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

Definition at line 90 of file TypedMsgHdr.h.

Referenced by allocData(), clear(), operator=(), and sync().

◆ msg_control

void* msghdr::msg_control
inherited

Definition at line 95 of file cmsg.h.

Referenced by allocControl(), getFd(), and sync().

◆ msg_controllen

size_t msghdr::msg_controllen
inherited

Definition at line 96 of file cmsg.h.

Referenced by allocControl(), getFd(), putFd(), and sync().

◆ 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.

Referenced by allocData(), and sync().

◆ msg_iovlen

size_t msghdr::msg_iovlen
inherited

Definition at line 93 of file cmsg.h.

Referenced by allocData(), sync(), and type().

◆ msg_name

void* msghdr::msg_name
inherited

Definition at line 89 of file cmsg.h.

Referenced by address(), allocName(), and sync().

◆ msg_namelen

socklen_t msghdr::msg_namelen
inherited

Definition at line 90 of file cmsg.h.

Referenced by address(), allocName(), and sync().

◆ name

struct sockaddr_un Ipc::TypedMsgHdr::name
private

Definition at line 88 of file TypedMsgHdr.h.

Referenced by address(), allocName(), clear(), operator=(), and sync().

◆ offset

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

Definition at line 108 of file TypedMsgHdr.h.

Referenced by clear(), getRaw(), hasMoreData(), operator=(), and sync().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors