| Kea 3.0.2-git

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:
[legend]

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

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

## 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 | ( |  | ) |
| inline virtual

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

  InvalidOperation | if 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

  limit | Maximum 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

  buf | A pointer to the buffer holding the data.
  nbytes | Size 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:

- tcp_stream_msg.h
- tcp_stream_msg.cc