Kea 2.5.5
isc::tcp::TcpStreamRequest Class Reference

Implement a simple length:data input stream message. More...

#include <tcp_stream_msg.h>

+ Inheritance diagram for isc::tcp::TcpStreamRequest:

Public Member Functions

 TcpStreamRequest ()
 Constructor. More...
 
virtual ~TcpStreamRequest ()
 Destructor. More...
 
const uint8_t * getRequest () const
 Returns pointer to the first byte of the unpacked request data. More...
 
size_t getRequestSize () const
 Returns size of the unpacked request. More...
 
std::string getRequestString () const
 Fetches the unpacked request as a string. More...
 
virtual std::string logFormatRequest (const size_t limit=0) const
 Returns request contents formatted for log output. More...
 
virtual bool needData () const
 Returns true if the request is incomplete. More...
 
virtual size_t postBuffer (const void *buf, const size_t nbytes)
 Adds data to an incomplete request. More...
 
virtual void unpack ()
 Unpacks the wire data into a string request. More...
 
- Public Member Functions inherited from isc::tcp::TcpRequest
virtual ~TcpRequest ()
 Destructor. More...
 
virtual std::string logFormatRequest (const size_t limit=0) const =0
 Returns request contents formatted for log output. More...
 
virtual bool needData () const =0
 Returns true if the request is incomplete. More...
 
virtual size_t postBuffer (const void *buf, const size_t nbytes)=0
 Adds data to an incomplete request. More...
 
virtual void unpack ()=0
 Unpacks wire data once the message has been completely received. More...
 
- Public Member Functions inherited from isc::tcp::TcpMessage
virtual ~TcpMessage ()
 Destructor. More...
 
const uint8_t * getWireData () const
 Returns pointer to the first byte of the wire data. More...
 
size_t getWireDataSize () const
 Returns current size of the wire data. More...
 

Protected Attributes

std::vector< uint8_t > request_
 Unpacked request content. More...
 
- Protected Attributes inherited from isc::tcp::TcpMessage
WireData wire_data_
 Buffer used for data in wire format data. More...
 

Detailed Description

Implement a simple length:data input stream message.

This class can be used to receive a single message from a TCP stream where the message consists of a 16-bit unsigned length (in network order), followed by that number of bytes of data.

Definition at line 25 of file tcp_stream_msg.h.

Constructor & Destructor Documentation

◆ TcpStreamRequest()

isc::tcp::TcpStreamRequest::TcpStreamRequest ( )
inline

Constructor.

Definition at line 28 of file tcp_stream_msg.h.

◆ ~TcpStreamRequest()

virtual isc::tcp::TcpStreamRequest::~TcpStreamRequest ( )
inlinevirtual

Destructor.

Definition at line 32 of file tcp_stream_msg.h.

Member Function Documentation

◆ getRequest()

const uint8_t * isc::tcp::TcpStreamRequest::getRequest ( ) const
inline

Returns pointer to the first byte of the unpacked request data.

Returns
Constant raw pointer to the data.
Exceptions
InvalidOperationif request data is empty (i.e. getRequestSize() == 0).

Definition at line 66 of file tcp_stream_msg.h.

References isc_throw, and request_.

◆ getRequestSize()

size_t isc::tcp::TcpStreamRequest::getRequestSize ( ) const
inline

Returns size of the unpacked request.

Definition at line 58 of file tcp_stream_msg.h.

References request_.

◆ getRequestString()

std::string isc::tcp::TcpStreamRequest::getRequestString ( ) const
inline

Fetches the unpacked request as a string.

Returns
String containing the unpacked contents.

Definition at line 78 of file tcp_stream_msg.h.

References request_.

◆ logFormatRequest()

std::string isc::tcp::TcpStreamRequest::logFormatRequest ( const size_t  limit = 0) const
virtual

Returns request contents formatted for log output.

Parameters
limitMaximum length of the buffer to be output. If the limit is 0, the length of the output is unlimited.
Returns
Textual representation of the input buffer.

Implements isc::tcp::TcpRequest.

Definition at line 69 of file tcp_stream_msg.cc.

References isc::util::str::dumpAsHex(), and isc::tcp::TcpMessage::wire_data_.

+ Here is the call graph for this function:

◆ needData()

bool isc::tcp::TcpStreamRequest::needData ( ) const
virtual

Returns true if the request is incomplete.

Returns
true if the request is incomplete.

Implements isc::tcp::TcpRequest.

Definition at line 20 of file tcp_stream_msg.cc.

References isc::tcp::TcpMessage::wire_data_.

Referenced by unpack().

◆ postBuffer()

size_t isc::tcp::TcpStreamRequest::postBuffer ( const void *  buf,
const size_t  nbytes 
)
virtual

Adds data to an incomplete request.

Parameters
bufA pointer to the buffer holding the data.
nbytesSize of the data within the buffer.
Returns
number of bytes posted (consumed)

Implements isc::tcp::TcpRequest.

Definition at line 25 of file tcp_stream_msg.cc.

References isc::tcp::TcpMessage::wire_data_.

◆ unpack()

void isc::tcp::TcpStreamRequest::unpack ( )
virtual

Unpacks the wire data into a string request.

Implements isc::tcp::TcpRequest.

Definition at line 84 of file tcp_stream_msg.cc.

References isc_throw, needData(), request_, and isc::tcp::TcpMessage::wire_data_.

+ Here is the call graph for this function:

Member Data Documentation

◆ request_

std::vector<uint8_t> isc::tcp::TcpStreamRequest::request_
protected

Unpacked request content.

Definition at line 84 of file tcp_stream_msg.h.

Referenced by getRequest(), getRequestSize(), getRequestString(), and unpack().


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