21 return (!expected_size_ || (
wire_data_.size() < expected_size_));
31 const char* bufptr =
static_cast<const char*
>(buf);
32 size_t bytes_left = nbytes;
34 size_t bytes_used = 0;
38 size_t need_bytes = expected_size_ - wire_size;
39 size_t copy_bytes = (need_bytes <= bytes_left ? need_bytes : bytes_left);
42 bytes_used += copy_bytes;
47 while (wire_size < 2 && bytes_left) {
56 if (wire_size == 2 ) {
57 const uint8_t* cp =
static_cast<const uint8_t*
>(
wire_data_.data());
58 uint16_t len =
static_cast<unsigned int>(cp[0]) << 8;
59 len |=
static_cast<unsigned int>(cp[1]);
60 expected_size_ = len +
sizeof(len);
70 std::stringstream output;
73 output <<
"expected_size_: " << expected_size_ <<
", current size: " <<
wire_data_.size()
76 }
catch (
const std::exception& ex) {
77 output = std::stringstream();
78 output <<
"logFormatRequest error: " << ex.what();
81 return (output.str());
98 response_.assign(data, data + length);
103 response_.insert(response_.end(), data, data + length);
108 response_.assign(str.begin(), str.end());
113 response_.insert(response_.end(), str.begin(), str.end());
120 uint16_t size =
static_cast<uint16_t
>(response_.size());
121 wire_data_.push_back(
static_cast<uint8_t
>((size & 0xff00U) >> 8));
122 wire_data_.push_back(
static_cast<uint8_t
>(size & 0x00ffU));
A generic exception that is thrown if a function is called in a prohibited way.
A generic exception that is thrown when an unexpected error condition occurs.
WireData wire_data_
Buffer used for data in wire format data.
virtual std::string logFormatRequest(const size_t limit=0) const
Returns request contents formatted for log output.
virtual void unpack()
Unpacks the wire data into a string request.
virtual size_t postBuffer(const void *buf, const size_t nbytes)
Adds data to an incomplete request.
virtual bool needData() const
Returns true if the request is incomplete.
std::vector< uint8_t > request_
Unpacked request content.
virtual void appendResponseData(const uint8_t *data, size_t length)
Appends a data to the response content.
virtual void setResponseData(const uint8_t *data, size_t length)
Replaces the response content .
virtual void pack()
Packs the response content into wire data buffer.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
string dumpAsHex(const uint8_t *data, size_t length)
Dumps a buffer of bytes as a string of hexadecimal digits.
Defines the logger used by the top-level component of kea-lfc.