Kea 2.5.8
isc::dns::MessageRenderer Class Reference

The MessageRenderer is a concrete derived class of AbstractMessageRenderer as a general purpose implementation of the renderer interfaces. More...

#include <messagerenderer.h>

+ Inheritance diagram for isc::dns::MessageRenderer:

Classes

struct  MessageRendererImpl
 The MessageRendererImpl class is the actual implementation of MessageRenderer. More...
 

Public Member Functions

 MessageRenderer ()
 
virtual ~MessageRenderer ()
 
virtual void clear ()
 Clear the internal buffer and other internal resources.
 
virtual CompressMode getCompressMode () const
 Return the compression mode of the renderer class object.
 
virtual size_t getLengthLimit () const
 Return the maximum length of rendered data that can fit in the corresponding DNS message without truncation.
 
virtual bool isTruncated () const
 Return whether truncation has occurred while rendering.
 
virtual void setCompressMode (CompressMode mode)
 This implementation does not allow this call in the middle of rendering (i.e.
 
virtual void setLengthLimit (size_t len)
 Set the maximum length of rendered data that can fit in the corresponding DNS message without truncation.
 
virtual void setTruncated ()
 Mark the renderer to indicate truncation has occurred while rendering.
 
virtual void writeName (const LabelSequence &ls, bool compress=true)
 Write a LabelSequence object into the internal buffer in wire format, with or without name compression.
 
virtual void writeName (const Name &name, bool compress=true)
 Write a Name object into the internal buffer in wire format, with or without name compression.
 
- Public Member Functions inherited from isc::dns::AbstractMessageRenderer
const void * getData () const
 Return a pointer to the head of the data stored in the internal buffer.
 
size_t getLength () const
 Return the length of data written in the internal buffer.
 
void setBuffer (isc::util::OutputBuffer *buffer)
 Set or reset a temporary output buffer.
 
void skip (size_t len)
 Insert a specified length of gap at the end of the buffer.
 
void trim (size_t len)
 Trim the specified length of data from the end of the internal buffer.
 
void writeUint8 (const uint8_t data)
 Write an unsigned 8-bit integer into the internal buffer.
 
void writeUint16 (uint16_t data)
 Write an unsigned 16-bit integer in host byte order into the internal buffer in network byte order.
 
void writeUint16At (uint16_t data, size_t pos)
 Write an unsigned 16-bit integer in host byte order at the specified position of the internal buffer in network byte order.
 
void writeUint32 (uint32_t data)
 Write an unsigned 32-bit integer in host byte order into the internal buffer in network byte order.
 
void writeData (const void *data, size_t len)
 Copy an arbitrary length of data into the internal buffer of the renderer object.
 
virtual ~AbstractMessageRenderer ()
 The destructor.
 

Additional Inherited Members

- Public Types inherited from isc::dns::AbstractMessageRenderer
enum  CompressMode { CASE_INSENSITIVE , CASE_SENSITIVE }
 Compression mode constants. More...
 
- Protected Member Functions inherited from isc::dns::AbstractMessageRenderer
 AbstractMessageRenderer ()
 The default constructor.
 
const isc::util::OutputBuffergetBuffer () const
 Return the output buffer we render into.
 
isc::util::OutputBuffergetBuffer ()
 

Detailed Description

The MessageRenderer is a concrete derived class of AbstractMessageRenderer as a general purpose implementation of the renderer interfaces.

A MessageRenderer object is constructed with a OutputBuffer object, which is the buffer into which the rendered data will be written. Normally the buffer is expected to be empty on construction, but it doesn't have to be so; the renderer object will start rendering from the end of the buffer at the time of construction. However, if the pre-existing portion of the buffer contains DNS names, these names won't be considered for name compression.

Definition at line 356 of file messagerenderer.h.

Constructor & Destructor Documentation

◆ MessageRenderer()

isc::dns::MessageRenderer::MessageRenderer ( )

Definition at line 219 of file messagerenderer.cc.

◆ ~MessageRenderer()

isc::dns::MessageRenderer::~MessageRenderer ( )
virtual

Definition at line 224 of file messagerenderer.cc.

Member Function Documentation

◆ clear()

void isc::dns::MessageRenderer::clear ( )
virtual

Clear the internal buffer and other internal resources.

This method can be used to re-initialize and reuse the renderer without constructing a new one.

Reimplemented from isc::dns::AbstractMessageRenderer.

Definition at line 228 of file messagerenderer.cc.

References isc::dns::MessageRenderer::MessageRendererImpl::BUCKETS, CASE_INSENSITIVE, isc::dns::AbstractMessageRenderer::clear(), and isc::dns::MessageRenderer::MessageRendererImpl::RESERVED_ITEMS.

+ Here is the call graph for this function:

◆ getCompressMode()

MessageRenderer::CompressMode isc::dns::MessageRenderer::getCompressMode ( ) const
virtual

Return the compression mode of the renderer class object.

This method never throws an exception.

Returns
The current compression mode.

Implements isc::dns::AbstractMessageRenderer.

Definition at line 269 of file messagerenderer.cc.

◆ getLengthLimit()

size_t isc::dns::MessageRenderer::getLengthLimit ( ) const
virtual

Return the maximum length of rendered data that can fit in the corresponding DNS message without truncation.

This method never throws an exception.

Returns
The maximum length in bytes.

Implements isc::dns::AbstractMessageRenderer.

Definition at line 249 of file messagerenderer.cc.

◆ isTruncated()

bool isc::dns::MessageRenderer::isTruncated ( ) const
virtual

Return whether truncation has occurred while rendering.

Once the return value of this method is true, it doesn't make sense to try rendering more data, although this class itself doesn't reject the attempt.

This method never throws an exception.

Returns
true if truncation has occurred; otherwise false.

Implements isc::dns::AbstractMessageRenderer.

Definition at line 259 of file messagerenderer.cc.

◆ setCompressMode()

void isc::dns::MessageRenderer::setCompressMode ( CompressMode  mode)
virtual

This implementation does not allow this call in the middle of rendering (i.e.

after at least one name is rendered) due to restriction specific to the internal implementation. Such attempts will result in an isc::InvalidParameter exception.

This shouldn't be too restrictive in practice; there's no known practical case for such a mixed compression policy in a single message.

Implements isc::dns::AbstractMessageRenderer.

Definition at line 274 of file messagerenderer.cc.

References isc::dns::AbstractMessageRenderer::getLength(), and isc_throw.

+ Here is the call graph for this function:

◆ setLengthLimit()

void isc::dns::MessageRenderer::setLengthLimit ( size_t  len)
virtual

Set the maximum length of rendered data that can fit in the corresponding DNS message without truncation.

This method never throws an exception.

Parameters
lenThe maximum length in bytes.

Implements isc::dns::AbstractMessageRenderer.

Definition at line 254 of file messagerenderer.cc.

◆ setTruncated()

void isc::dns::MessageRenderer::setTruncated ( )
virtual

Mark the renderer to indicate truncation has occurred while rendering.

This method never throws an exception.

Implements isc::dns::AbstractMessageRenderer.

Definition at line 264 of file messagerenderer.cc.

◆ writeName() [1/2]

void isc::dns::MessageRenderer::writeName ( const LabelSequence ls,
bool  compress = true 
)
virtual

Write a LabelSequence object into the internal buffer in wire format, with or without name compression.

This is the same as the other version, which takes Name instead of LabelSequence, except for the parameter type. The passed LabelSequence must be absolute.

Parameters
lsA LabelSequence object to be written.
compressA boolean indicating whether to enable name compression.

Implements isc::dns::AbstractMessageRenderer.

Definition at line 283 of file messagerenderer.cc.

References CASE_SENSITIVE, isc::dns::Name::COMPRESS_POINTER_MARK16, isc::dns::AbstractMessageRenderer::getBuffer(), isc::dns::LabelSequence::getData(), isc::dns::LabelSequence::getDataLength(), isc::dns::LabelSequence::getHash(), isc::dns::LabelSequence::getLabelCount(), isc::dns::AbstractMessageRenderer::getLength(), isc::dns::Name::MAX_COMPRESS_POINTER, isc::dns::MessageRenderer::MessageRendererImpl::NO_OFFSET, isc::dns::LabelSequence::stripLeft(), isc::dns::LabelSequence::stripRight(), isc::dns::AbstractMessageRenderer::writeData(), and isc::dns::AbstractMessageRenderer::writeUint16().

+ Here is the call graph for this function:

◆ writeName() [2/2]

void isc::dns::MessageRenderer::writeName ( const Name name,
bool  compress = true 
)
virtual

Write a Name object into the internal buffer in wire format, with or without name compression.

If the optional parameter compress is true, this method tries to compress the name if possible, searching the entire message that has been rendered. Otherwise name compression is omitted. Its default value is true.

Note: even if compress is true, the position of the name (and possibly its ancestor names) in the message is recorded and may be used for compressing subsequent names.

Parameters
nameA Name object to be written.
compressA boolean indicating whether to enable name compression.

Implements isc::dns::AbstractMessageRenderer.

Definition at line 357 of file messagerenderer.cc.

References writeName().

Referenced by writeName().

+ Here is the call graph for this function:

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