libbgp
0.6
A C++ BGP Library.
|
The BgpPathAttrib class. More...
#include <bgp-path-attrib.h>
Public Member Functions | |
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... | |
ssize_t | doPrint (size_t indent, uint8_t **to, size_t *buf_sz) const |
Print implementation. More... | |
virtual ssize_t | parse (const uint8_t *from, size_t msg_sz) |
Deserialize a BGP update message path attribute. More... | |
virtual ssize_t | write (uint8_t *to, size_t buf_sz) const |
Serialize a BGP update message path attribute. More... | |
virtual ssize_t | length () const |
Get size in bytes required to serialize the object. More... | |
BgpPathAttrib * | clone (BgpLogHandler *new_logger) const |
Clone the attribute and replace logger. More... | |
virtual BgpPathAttrib * | clone () const |
Clone the attribute. 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... | |
Static Public Member Functions | |
static uint8_t | GetTypeFromBuffer (const uint8_t *buffer, size_t buffer_sz) |
Get type of attribute from buffer. More... | |
Public Attributes | |
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. | |
Protected Member Functions | |
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... | |
Protected Attributes | |
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 |
BgpLogHandler * | logger |
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... | |
The BgpPathAttrib class.
Definition at line 47 of file bgp-path-attrib.h.
libbgp::BgpPathAttrib::BgpPathAttrib | ( | BgpLogHandler * | logger | ) |
Construct a new Bgp Path Attrib:: Bgp Path Attrib object.
logger | Pointer to logger object for error logging. |
Definition at line 39 of file bgp-path-attrib.cc.
References extended, optional, partial, and transitive.
Referenced by libbgp::BgpPathAttribCommunity::length().
libbgp::BgpPathAttrib::BgpPathAttrib | ( | BgpLogHandler * | logger, |
const uint8_t * | value, | ||
uint16_t | val_len | ||
) |
Construct a new Bgp Path Attrib:: Bgp Path Attrib object.
logger | Pointer to logger object for error logging. |
value | Pointer to value buffer of unknow type attribute. |
val_len | Length of the value buffer. |
Definition at line 51 of file bgp-path-attrib.cc.
References libbgp::BgpLogHandler::log(), and value_len.
BgpPathAttrib * libbgp::BgpPathAttrib::clone | ( | BgpLogHandler * | new_logger | ) | const |
Clone the attribute and replace logger.
new_logger | New logger to use. |
has_error | There's error in the attribute and the attribute can not be clone. |
Definition at line 69 of file bgp-path-attrib.cc.
References clone(), and libbgp::Serializable::setLogger().
Referenced by libbgp::BgpUpdateMessage::addAttrib().
|
virtual |
Clone the attribute.
has_error | There's error in the attribute and the attribute can not be clone. |
Reimplemented in libbgp::BgpPathAttribMpUnreachNlriUnknow, libbgp::BgpPathAttribMpUnreachNlriIpv6, libbgp::BgpPathAttribMpReachNlriUnknow, libbgp::BgpPathAttribMpReachNlriIpv6, libbgp::BgpPathAttribCommunity, libbgp::BgpPathAttribAs4Aggregator, libbgp::BgpPathAttribAs4Path, libbgp::BgpPathAttribAggregator, libbgp::BgpPathAttribAtomicAggregate, libbgp::BgpPathAttribLocalPref, libbgp::BgpPathAttribMed, libbgp::BgpPathAttribNexthop, libbgp::BgpPathAttribAsPath, and libbgp::BgpPathAttribOrigin.
Definition at line 75 of file bgp-path-attrib.cc.
References libbgp::Serializable::hasError(), and libbgp::BgpLogHandler::log().
Referenced by clone().
|
virtual |
Print implementation.
indent | indent level. |
to | The pointer to the pointer to the string buffer. |
buf_sz | The pointer to the counter of avaliable buffer space. |
-1 | Failed to print. |
>= | 0 Bytes written. |
Implements libbgp::Serializable.
Reimplemented in libbgp::BgpPathAttribMpUnreachNlriUnknow, libbgp::BgpPathAttribMpUnreachNlriIpv6, libbgp::BgpPathAttribMpReachNlriUnknow, libbgp::BgpPathAttribMpReachNlriIpv6, libbgp::BgpPathAttribCommunity, libbgp::BgpPathAttribAs4Aggregator, libbgp::BgpPathAttribAs4Path, libbgp::BgpPathAttribAggregator, libbgp::BgpPathAttribAtomicAggregate, libbgp::BgpPathAttribLocalPref, libbgp::BgpPathAttribMed, libbgp::BgpPathAttribNexthop, libbgp::BgpPathAttribAsPath, and libbgp::BgpPathAttribOrigin.
Definition at line 116 of file bgp-path-attrib.cc.
References libbgp::Serializable::_print(), printFlags(), and type_code.
|
static |
Get type of attribute from buffer.
from | Pointer to buffer. |
buffer_sz | Size of buffre. |
0 | Failed to get attribute type. |
>0 | Attribute type. |
Definition at line 29 of file bgp-path-attrib.cc.
|
virtual |
Get size in bytes required to serialize the object.
-1 | Failed to get size. |
>=0 | Size in btyes. |
Reimplemented from libbgp::Serializable.
Reimplemented in libbgp::BgpPathAttribMpUnreachNlriUnknow, libbgp::BgpPathAttribMpUnreachNlriIpv6, libbgp::BgpPathAttribMpReachNlriUnknow, libbgp::BgpPathAttribMpReachNlriIpv6, libbgp::BgpPathAttribCommunity, libbgp::BgpPathAttribAs4Aggregator, libbgp::BgpPathAttribAs4Path, libbgp::BgpPathAttribAggregator, libbgp::BgpPathAttribAtomicAggregate, libbgp::BgpPathAttribLocalPref, libbgp::BgpPathAttribMed, libbgp::BgpPathAttribNexthop, libbgp::BgpPathAttribAsPath, and libbgp::BgpPathAttribOrigin.
Definition at line 164 of file bgp-path-attrib.cc.
|
virtual |
Deserialize a BGP update message path attribute.
from | Pointer to message body buffer. |
msg_sz | Size of message. |
-1 | Deserialization error. Error may be logged. |
>=0 | Bytes read. |
bad_parse | Internal deserialization error. |
bad_type | The type of message/field member in buffer does not match the attribute type of container. |
Implements libbgp::Serializable.
Reimplemented in libbgp::BgpPathAttribMpUnreachNlriUnknow, libbgp::BgpPathAttribMpUnreachNlriIpv6, libbgp::BgpPathAttribMpReachNlriUnknow, libbgp::BgpPathAttribMpReachNlriIpv6, libbgp::BgpPathAttribCommunity, libbgp::BgpPathAttribAs4Aggregator, libbgp::BgpPathAttribAs4Path, libbgp::BgpPathAttribAggregator, libbgp::BgpPathAttribAtomicAggregate, libbgp::BgpPathAttribLocalPref, libbgp::BgpPathAttribMed, libbgp::BgpPathAttribNexthop, libbgp::BgpPathAttribAsPath, and libbgp::BgpPathAttribOrigin.
Definition at line 129 of file bgp-path-attrib.cc.
References optional, parseHeader(), libbgp::Serializable::setError(), and transitive.
|
protected |
Utility function to parse attribute header. (Flag, type, length)
from | Pointer to buffer. |
buffer_sz | Size of buffer. |
-1 | Failed to parse header. error may be written to stderr with log handler. |
>=0 | Bytes read. |
Definition at line 200 of file bgp-path-attrib.cc.
References libbgp::Serializable::setError().
Referenced by libbgp::BgpPathAttribCommunity::length(), parse(), libbgp::BgpPathAttribOrigin::parse(), libbgp::BgpPathAttribAsPath::parse(), libbgp::BgpPathAttribNexthop::parse(), libbgp::BgpPathAttribMed::parse(), libbgp::BgpPathAttribLocalPref::parse(), libbgp::BgpPathAttribAtomicAggregate::parse(), libbgp::BgpPathAttribAggregator::parse(), libbgp::BgpPathAttribAs4Path::parse(), libbgp::BgpPathAttribAs4Aggregator::parse(), libbgp::BgpPathAttribCommunity::parse(), libbgp::BgpPathAttribMpReachNlriIpv6::parse(), libbgp::BgpPathAttribMpReachNlriUnknow::parse(), libbgp::BgpPathAttribMpUnreachNlriIpv6::parse(), and libbgp::BgpPathAttribMpUnreachNlriUnknow::parse().
|
protected |
Utility function to print flags for attribute.
indent | Indentation level. |
to | Pointer to buffer pointer. |
buf_sz | Pointer to avaliable buffer counter. |
Definition at line 96 of file bgp-path-attrib.cc.
References libbgp::Serializable::_print(), extended, optional, partial, and transitive.
Referenced by doPrint(), libbgp::BgpPathAttribOrigin::doPrint(), libbgp::BgpPathAttribAsPath::doPrint(), libbgp::BgpPathAttribNexthop::doPrint(), libbgp::BgpPathAttribMed::doPrint(), libbgp::BgpPathAttribLocalPref::doPrint(), libbgp::BgpPathAttribAtomicAggregate::doPrint(), libbgp::BgpPathAttribAggregator::doPrint(), libbgp::BgpPathAttribAs4Path::doPrint(), libbgp::BgpPathAttribAs4Aggregator::doPrint(), libbgp::BgpPathAttribCommunity::doPrint(), libbgp::BgpPathAttribMpReachNlriIpv6::doPrint(), libbgp::BgpPathAttribMpReachNlriUnknow::doPrint(), libbgp::BgpPathAttribMpUnreachNlriIpv6::doPrint(), and libbgp::BgpPathAttribMpUnreachNlriUnknow::doPrint().
|
virtual |
Serialize a BGP update message path attribute.
to | Pointer to destination buffer. |
buf_sz | Max write size. |
-1 | Serialization error. Error may be logged. |
>=0 | Bytes written. |
Implements libbgp::Serializable.
Reimplemented in libbgp::BgpPathAttribMpUnreachNlriUnknow, libbgp::BgpPathAttribMpUnreachNlriIpv6, libbgp::BgpPathAttribMpReachNlriUnknow, libbgp::BgpPathAttribMpReachNlriIpv6, libbgp::BgpPathAttribCommunity, libbgp::BgpPathAttribAs4Aggregator, libbgp::BgpPathAttribAs4Path, libbgp::BgpPathAttribAggregator, libbgp::BgpPathAttribAtomicAggregate, libbgp::BgpPathAttribLocalPref, libbgp::BgpPathAttribMed, libbgp::BgpPathAttribNexthop, libbgp::BgpPathAttribAsPath, and libbgp::BgpPathAttribOrigin.
Definition at line 168 of file bgp-path-attrib.cc.
References libbgp::BgpLogHandler::log(), and value_len.
|
protected |
Write attribute header to buffer. (Flag, Type)
Write attribute header to buffer. Notice that only attribute flags and type will be written to buffer. You need to write attribute length yourself.
to | Destnation buiffer. |
buffer_sz | Max write size. |
-1 | Failed to write buffer. error may be written to stderr with log handler. |
>=0 | Bytes written. |
Definition at line 251 of file bgp-path-attrib.cc.
References extended, and libbgp::BgpLogHandler::log().
Referenced by libbgp::BgpPathAttribMpReachNlriIpv6::write().