Shadow Stack  0.2
 All Classes Namespaces Files Functions Variables Typedefs Macros
Classes | Macros | Functions
message.hpp File Reference
#include "utilities.hpp"
#include <sys/socket.h>
#include <unistd.h>
#include <string.h>

Go to the source code of this file.

Classes

class  Message
 A class used for defining all message types Messages come in two forms. More...
 
class  Message::Msg
 Defines the types of messages which can be sent. More...
 
struct  Message::Msg::MessageType< only_header, Info >
 A templated message class A valid message is defined by constructing a MessageType around it. More...
 
struct  Message::Msg::MessageType< true, Info >
 A specification for header only messages. More...
 
struct  Message::Msg::MessageType< false, Info >
 A specification for non-header only messages. More...
 
struct  Message::ContinueInfo
 A class containing the header of Continue message. More...
 
struct  Message::CallInfo
 A class containing the header of Call message. More...
 
struct  Message::RetInfo
 A class containing the header of Call message. More...
 
struct  Message::NewSignalInfo
 A class containing the header of NewSignal message. More...
 
struct  Message::ExecveInfo
 A class containing the header of Execve message. More...
 
struct  Message::ForkInfo
 A class containing the header of Fork message. More...
 
struct  Message::ThreadInfo
 A class containing the header of Thread message. More...
 

Macros

#define POINTER_SIZE   ( sizeof( void * ) )
 The size of a pointer in the target program Note: 64 bit can stil handle 32 bit programs. More...
 
#define MESSAGE_HEADER_LENGTH   4
 The number of characters a message header can be. More...
 
#define MESSAGE_SIZE   ( POINTER_SIZE + MESSAGE_HEADER_LENGTH )
 The size of a message. More...
 
#define MESSAGE_INTERNALS(HEADER_ONLY)
 The internals of a message. More...
 

Functions

template<typename Msg >
void send_msg (const int sock)
 Sends a header only Msg to sock. More...
 
template<typename Msg >
void send_msg (const int sock, const char *const bdy)
 Sends a non-header only Msg with body bdy to sock. More...
 
template<typename Msg >
void recv_msg (const int sock)
 Reads a header only Msg from sock. More...
 
template<typename Msg >
const char * recv_msg_and_body (const int sock)
 Reads a only Msg from sock This function is NOT re-entrant. More...
 

Macro Definition Documentation

#define MESSAGE_HEADER_LENGTH   4

The number of characters a message header can be.

#define MESSAGE_INTERNALS (   HEADER_ONLY)
Value:
\
static const constexpr bool header_only = HEADER_ONLY; \ \
static const constexpr int size = MESSAGE_SIZE; \ \
static const constexpr char *const header = Info::header; \ \
static_assert( strlen( Info::header ) == MESSAGE_HEADER_LENGTH, \
"Header is of wrong size." ); \ \
MessageType<HEADER_ONLY, Info>() = delete;
#define MESSAGE_HEADER_LENGTH
The number of characters a message header can be.
Definition: message.hpp:24
#define MESSAGE_SIZE
The size of a message.
Definition: message.hpp:27

The internals of a message.

We use a macro to enforce consistency

#define MESSAGE_SIZE   ( POINTER_SIZE + MESSAGE_HEADER_LENGTH )

The size of a message.

#define POINTER_SIZE   ( sizeof( void * ) )

The size of a pointer in the target program Note: 64 bit can stil handle 32 bit programs.

Function Documentation

template<typename Msg >
void recv_msg ( const int  sock)

Reads a header only Msg from sock.

template<typename Msg >
const char* recv_msg_and_body ( const int  sock)

Reads a only Msg from sock This function is NOT re-entrant.

template<typename Msg >
void send_msg ( const int  sock)

Sends a header only Msg to sock.

template<typename Msg >
void send_msg ( const int  sock,
const char *const  bdy 
)

Sends a non-header only Msg with body bdy to sock.