libbgp  0.6
A C++ BGP Library.
All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
libbgp::BgpCapability Class Referenceabstract

The BgpCapability base class. More...

#include <bgp-capability.h>

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

Public Member Functions

 BgpCapability (BgpLogHandler *logger)
 Construct a new Bgp Capability object. More...
 
virtual ssize_t parse (const uint8_t *from, size_t msg_sz)=0
 Deserialize a BGP open message capability. More...
 
virtual ssize_t write (uint8_t *to, size_t buf_sz) const =0
 Serialize a BGP open message capability. 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...
 

Public Attributes

uint8_t code
 

Protected Member Functions

ssize_t parseHeader (const uint8_t *from, size_t msg_sz)
 Parse the capability header (code, length). More...
 
- Protected Member Functions inherited from libbgp::Serializable
virtual ssize_t doPrint (size_t indent, uint8_t **to, size_t *buf_sz) const =0
 Print implementation. More...
 
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...
 

Protected Attributes

uint8_t length
 Length of the attribute. Used only when deserializer. More...
 
- Protected Attributes inherited from libbgp::Serializable
uint8_t err_code
 
uint8_t err_subcode
 
size_t err_len
 
uint8_t * err_data
 
BgpLogHandlerlogger
 

Additional Inherited Members

- 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...
 

Detailed Description

The BgpCapability base class.

Definition at line 40 of file bgp-capability.h.

Constructor & Destructor Documentation

◆ BgpCapability()

libbgp::BgpCapability::BgpCapability ( BgpLogHandler logger)

Construct a new Bgp Capability object.

Parameters
loggerPointer to logger object for error logging.

Definition at line 25 of file bgp-capability.cc.

References libbgp::Serializable::length().

Member Function Documentation

◆ parse()

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

Deserialize a BGP open message capability.

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::Serializable.

Implemented in libbgp::BgpCapabilityUnknow, libbgp::BgpCapabilityMpBgp, and libbgp::BgpCapability4BytesAsn.

◆ parseHeader()

ssize_t libbgp::BgpCapability::parseHeader ( const uint8_t *  from,
size_t  msg_sz 
)
protected

Parse the capability header (code, length).

Parameters
fromPointer to buffer.
msg_szMax read size.
Returns
ssize_t Bytes read.
Return values
-1Failed to deserialize header. errbuf may have details. (see bgp-error.h)
>=0Bytes read.

Definition at line 39 of file bgp-capability.cc.

References libbgp::Serializable::setError().

Referenced by libbgp::BgpCapability4BytesAsn::parse(), libbgp::BgpCapabilityMpBgp::parse(), and libbgp::BgpCapabilityUnknow::parse().

◆ write()

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

Serialize a BGP open message capability.

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::Serializable.

Implemented in libbgp::BgpCapabilityUnknow, libbgp::BgpCapabilityMpBgp, and libbgp::BgpCapability4BytesAsn.

Member Data Documentation

◆ length

uint8_t libbgp::BgpCapability::length
protected

Length of the attribute. Used only when deserializer.

Length field is only used in deserialization for parseHeader() to pass attribute length to the underlying deserializers. The length field is ignored when serialize (except BgpCapabilityUnknow).

Definition at line 84 of file bgp-capability.h.


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