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

AS Path attribute. More...

#include <bgp-path-attrib.h>

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

Public Member Functions

 BgpPathAttribAsPath (BgpLogHandler *logger, bool is_4b)
 Construct a new Bgp Path Attrib As Path:: Bgp Path Attrib As Path object. More...
 
BgpPathAttribclone () const
 Clone the attribute. More...
 
bool prepend (uint32_t asn)
 Prepend an ASN into AS path. More...
 
ssize_t parse (const uint8_t *buffer, size_t length)
 Deserialize a BGP update message path attribute. More...
 
ssize_t write (uint8_t *buffer, size_t buffer_sz) const
 Serialize a BGP update message path attribute. More...
 
ssize_t doPrint (size_t indent, uint8_t **to, size_t *buf_sz) const
 Print implementation. More...
 
ssize_t length () const
 Get size in bytes required to serialize the object. More...
 
- Public Member Functions inherited from libbgp::BgpPathAttrib
 BgpPathAttrib (BgpLogHandler *logger)
 Construct a new Bgp Path Attrib:: Bgp Path Attrib object. More...
 
 BgpPathAttrib (BgpLogHandler *logger, const uint8_t *value, uint16_t val_len)
 Construct a new Bgp Path Attrib:: Bgp Path Attrib object. More...
 
BgpPathAttribclone (BgpLogHandler *new_logger) const
 Clone the attribute and replace logger. More...
 
virtual ~BgpPathAttrib ()
 Destroy the Bgp Path Attrib:: Bgp Path Attrib object.
 
- 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...
 
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

std::vector< BgpAsPathSegmentas_paths
 The AS Path segments.
 
bool is_4b
 Is ASNs in the attribute four octets?
 
- Public Attributes inherited from libbgp::BgpPathAttrib
bool optional
 Attribute flag: Optional.
 
bool transitive
 Attribute flag: Transitive.
 
bool partial
 Attribute flag: partial.
 
bool extended
 Attribute flag: extended.
 
uint8_t type_code
 Attribute type code.
 

Additional Inherited Members

- Static Public Member Functions inherited from libbgp::BgpPathAttrib
static uint8_t GetTypeFromBuffer (const uint8_t *buffer, size_t buffer_sz)
 Get type of attribute from buffer. More...
 
- Protected Member Functions inherited from libbgp::BgpPathAttrib
ssize_t parseHeader (const uint8_t *buffer, size_t length)
 Utility function to parse attribute header. (Flag, type, length) More...
 
ssize_t printFlags (size_t indent, uint8_t **to, size_t *buf_sz) const
 Utility function to print flags for attribute. More...
 
ssize_t writeHeader (uint8_t *buffer, size_t buffer_sz) const
 Write attribute header to buffer. (Flag, Type) More...
 
- 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::BgpPathAttrib
uint16_t value_len
 Attribute length. Length field is only used in deserialization for parseHeader() to pass length field in header to the underlying deserializers. The length field is ignored when serialize.
 
- 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

AS Path attribute.

Definition at line 229 of file bgp-path-attrib.h.

Constructor & Destructor Documentation

◆ BgpPathAttribAsPath()

libbgp::BgpPathAttribAsPath::BgpPathAttribAsPath ( BgpLogHandler logger,
bool  is_4b 
)

Construct a new Bgp Path Attrib As Path:: Bgp Path Attrib As Path object.

Parameters
loggerPointer to logger object for error logging.
is_4bEnable four octets ASN support.

Definition at line 367 of file bgp-path-attrib.cc.

References is_4b, libbgp::BgpPathAttrib::transitive, and libbgp::BgpPathAttrib::type_code.

Member Function Documentation

◆ clone()

BgpPathAttrib * libbgp::BgpPathAttribAsPath::clone ( ) const
virtual

Clone the attribute.

Returns
BgpPathAttrib* Pointer to the cloned attribute.
Exceptions
has_errorThere's error in the attribute and the attribute can not be clone.

Reimplemented from libbgp::BgpPathAttrib.

Definition at line 408 of file bgp-path-attrib.cc.

References libbgp::Serializable::hasError(), and libbgp::BgpLogHandler::log().

◆ doPrint()

ssize_t libbgp::BgpPathAttribAsPath::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.

Reimplemented from libbgp::BgpPathAttrib.

Definition at line 416 of file bgp-path-attrib.cc.

References libbgp::Serializable::_print(), as_paths, is_4b, and libbgp::BgpPathAttrib::printFlags().

◆ length()

ssize_t libbgp::BgpPathAttribAsPath::length ( ) const
virtual

Get size in bytes required to serialize the object.

Returns
ssize_t Size in btyes.
Return values
-1Failed to get size.
>=0Size in btyes.

Reimplemented from libbgp::BgpPathAttrib.

Definition at line 510 of file bgp-path-attrib.cc.

References as_paths, and is_4b.

◆ parse()

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

Deserialize a BGP update message path attribute.

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.

Reimplemented from libbgp::BgpPathAttrib.

Definition at line 448 of file bgp-path-attrib.cc.

References libbgp::BgpPathAttrib::parseHeader(), and libbgp::BgpPathAttrib::type_code.

◆ prepend()

bool libbgp::BgpPathAttribAsPath::prepend ( uint32_t  asn)

Prepend an ASN into AS path.

This method will prepend an ASN to AS_SEQUENCE segment if the segment is the first in path. A new AS_SEQUENCE will be create and append to AS_PATH otherwise. A new AS_SEQUENCE will also be create if the current one is full.

Parameters
asnThe ASN to append.
Returns
true ASN prepended.
false Failed to append ASN. error may be written to stderr with log handler.

Definition at line 543 of file bgp-path-attrib.cc.

References as_paths, and libbgp::BgpAsPathSegment::type.

◆ write()

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

Serialize a BGP update message path attribute.

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

Reimplemented from libbgp::BgpPathAttrib.

Definition at line 573 of file bgp-path-attrib.cc.

References libbgp::BgpLogHandler::log().


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