Kea  2.3.5-git
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. More...
 
virtual CompressMode getCompressMode () const
 Return the compression mode of the renderer class object. More...
 
virtual size_t getLengthLimit () const
 Return the maximum length of rendered data that can fit in the corresponding DNS message without truncation. More...
 
virtual bool isTruncated () const
 Return whether truncation has occurred while rendering. More...
 
virtual void setCompressMode (CompressMode mode)
 This implementation does not allow this call in the middle of rendering (i.e. More...
 
virtual void setLengthLimit (size_t len)
 Set the maximum length of rendered data that can fit in the corresponding DNS message without truncation. More...
 
virtual void setTruncated ()
 Mark the renderer to indicate truncation has occurred while rendering. More...
 
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. More...
 
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. More...
 
- 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. More...
 
size_t getLength () const
 Return the length of data written in the internal buffer. More...
 
void setBuffer (isc::util::OutputBuffer *buffer)
 Set or reset a temporary output buffer. More...
 
void skip (size_t len)
 Insert a specified length of gap at the end of the buffer. More...
 
void trim (size_t len)
 Trim the specified length of data from the end of the internal buffer. More...
 
void writeUint8 (const uint8_t data)
 Write an unsigned 8-bit integer into the internal buffer. More...
 
void writeUint16 (uint16_t data)
 Write an unsigned 16-bit integer in host byte order into the internal buffer in network byte order. More...
 
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. More...
 
void writeUint32 (uint32_t data)
 Write an unsigned 32-bit integer in host byte order into the internal buffer in network byte order. More...
 
void writeData (const void *data, size_t len)
 Copy an arbitrary length of data into the internal buffer of the renderer object. More...
 
virtual ~AbstractMessageRenderer ()
 The destructor. More...
 

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
const isc::util::OutputBuffergetBuffer () const
 Return the output buffer we render into. More...
 
isc::util::OutputBuffergetBuffer ()
 
 AbstractMessageRenderer ()
 The default constructor. More...
 

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 221 of file messagerenderer.cc.

◆ ~MessageRenderer()

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

Definition at line 226 of file messagerenderer.cc.

Member Function Documentation

◆ clear()

◆ 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 272 of file messagerenderer.cc.

References isc::dns::MessageRenderer::MessageRendererImpl::compress_mode_.

◆ 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 252 of file messagerenderer.cc.

References isc::dns::MessageRenderer::MessageRendererImpl::msglength_limit_.

◆ 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 262 of file messagerenderer.cc.

References isc::dns::MessageRenderer::MessageRendererImpl::truncated_.

◆ 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 277 of file messagerenderer.cc.

References isc::dns::MessageRenderer::MessageRendererImpl::compress_mode_, 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 257 of file messagerenderer.cc.

References isc::dns::MessageRenderer::MessageRendererImpl::msglength_limit_.

◆ 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 267 of file messagerenderer.cc.

References isc::dns::MessageRenderer::MessageRendererImpl::truncated_.

◆ writeName() [1/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 360 of file messagerenderer.cc.

◆ writeName() [2/2]

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

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