libbgp  0.6
A C++ BGP Library.
Public Member Functions | List of all members
libbgp::BgpBadMessage Class Reference

The BgpBadMessage class. More...

#include <bgp-bad-message.h>

Inheritance diagram for libbgp::BgpBadMessage:
Inheritance graph
[legend]
Collaboration diagram for libbgp::BgpBadMessage:
Collaboration graph
[legend]

Public Member Functions

 BgpBadMessage (BgpLogHandler *logger, uint8_t type)
 Construct a new Bgp Bad Message:: Bgp Bad Message object. More...
 
ssize_t doPrint (size_t indent, uint8_t **to, size_t *buf_sz) const
 Print implementation. More...
 
ssize_t parse (const uint8_t *from, size_t msg_sz)
 Deserialize a BGP message body. More...
 
ssize_t write (uint8_t *to, size_t buf_sz) const
 Serialize a BGP message body. More...
 
- Public Member Functions inherited from libbgp::BgpMessage
 BgpMessage (BgpLogHandler *logger)
 Construct a new Bgp Message object. More...
 
- Public Member Functions inherited from libbgp::Serializable
 Serializable (BgpLogHandler *logger)
 Construct a new Serializable:: Serializable object. More...
 
 ~Serializable ()
 Destroy the Serializable:: Serializable object.
 
ssize_t print (uint8_t *to, size_t buf_sz) const
 Print the Serializable object as human readable string. More...
 
ssize_t print (size_t indent, uint8_t *to, size_t buf_sz) const
 Print the Serializable object as human readable string, with indentation. More...
 
virtual ssize_t length () const
 Get size in bytes required to serialize the object. More...
 
bool hasError () const
 Check if error information available. More...
 
uint8_t getErrorCode () const
 
uint8_t getErrorSubCode () const
 
const uint8_t * getError () const
 
size_t getErrorLength () const
 
void setLogger (BgpLogHandler *logger)
 Replace logger for this object. More...
 

Additional Inherited Members

- Public Attributes inherited from libbgp::BgpMessage
uint8_t type
 
- Protected Member Functions inherited from libbgp::Serializable
void setError (uint8_t err, uint8_t suberr, const uint8_t *data, size_t data_len)
 Set the error information. More...
 
void forwardParseError (const Serializable &other)
 Forward error information from other Serializable object. More...
 
- Static Protected Member Functions inherited from libbgp::Serializable
static ssize_t _print (size_t indent, uint8_t **to, size_t *buf_left, const char *format,...)
 Print helper. More...
 
- Protected Attributes inherited from libbgp::Serializable
uint8_t err_code
 
uint8_t err_subcode
 
size_t err_len
 
uint8_t * err_data
 
BgpLogHandlerlogger
 

Detailed Description

The BgpBadMessage class.

Container class for invalid BGP message.

Definition at line 24 of file bgp-bad-message.h.

Constructor & Destructor Documentation

◆ BgpBadMessage()

libbgp::BgpBadMessage::BgpBadMessage ( BgpLogHandler logger,
uint8_t  type 
)

Construct a new Bgp Bad Message:: Bgp Bad Message object.

Parameters
loggerPointer to logger object for error logging.
typeMessage type.

Definition at line 23 of file bgp-bad-message.cc.

Member Function Documentation

◆ doPrint()

ssize_t libbgp::BgpBadMessage::doPrint ( size_t  indent,
uint8_t **  to,
size_t *  buf_sz 
) const
virtual

Print implementation.

Parameters
indentindent level.
toThe pointer to the pointer to the string buffer.
buf_szThe pointer to the counter of avaliable buffer space.
Returns
ssize_t ssize_t Bytes written.
Return values
-1Failed to print.
>=0 Bytes written.

Implements libbgp::Serializable.

Definition at line 38 of file bgp-bad-message.cc.

References libbgp::Serializable::_print().

◆ parse()

ssize_t libbgp::BgpBadMessage::parse ( const uint8_t *  from,
size_t  msg_sz 
)
virtual

Deserialize a BGP message body.

BgpMessage deserializer only deserialize message body. (i.e. message without BGP marker and message length field) To deserialize a BGP packet, use BgpPacket.

Parameters
fromPointer to message body buffer.
msg_szSize of message.
Returns
ssize_t Bytes read.
Return values
-1Deserialization error. Error may be logged.
>=0Bytes read.
Exceptions
bad_parseInternal deserialization error.
bad_typeThe type of message/field member in buffer does not match the attribute type of container.

Implements libbgp::BgpMessage.

Definition at line 27 of file bgp-bad-message.cc.

References libbgp::BgpLogHandler::log().

◆ write()

ssize_t libbgp::BgpBadMessage::write ( uint8_t *  to,
size_t  buf_sz 
) const
virtual

Serialize a BGP message body.

BgpMessage serializer only serialize message body. (i.e. message without BGP marker and message length field) To serialize a BGP packet, use BgpPacket.

Parameters
toPointer to destination buffer.
buf_szMax write size.
Returns
ssize_t Bytes written.
Return values
-1Serialization error. Error may be logged.
>=0Bytes written.

Implements libbgp::BgpMessage.

Definition at line 33 of file bgp-bad-message.cc.

References libbgp::BgpLogHandler::log().


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