libbgp
0.6
A C++ BGP Library.
|
The BgpOpenMessage class. More...
#include <bgp-open-message.h>
Public Member Functions | |
BgpOpenMessage (BgpLogHandler *logger, bool use_4b_asn) | |
Construct a new Bgp Open Message:: Bgp Open Message object. More... | |
BgpOpenMessage (BgpLogHandler *logger, bool use_4b_asn, uint16_t my_asn, uint16_t hold_time, uint32_t bgp_id) | |
Construct a new Bgp Open Message:: Bgp Open Message object. More... | |
BgpOpenMessage (BgpLogHandler *logger, bool use_4b_asn, uint16_t my_asn, uint16_t hold_time, const char *bgp_id) | |
Construct a new Bgp Open Message:: Bgp Open Message object. More... | |
bool | setAsn (uint32_t my_asn) |
Set ASN. More... | |
uint32_t | getAsn () const |
Get ASN. More... | |
bool | hasCapability (uint8_t code) const |
Check if open message has a capability. More... | |
bool | addCapability (std::shared_ptr< BgpCapability > capability) |
Add a capability. 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) |
Parse a BGP open message body. More... | |
ssize_t | write (uint8_t *to, size_t buf_sz) const |
Serialize a BGP message body. More... | |
const std::vector< std::shared_ptr< BgpCapability > > & | getCapabilities () const |
Get capabilities list. 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... | |
Public Attributes | |
uint8_t | version |
uint16_t | my_asn |
uint16_t | hold_time |
uint32_t | bgp_id |
Public Attributes inherited from libbgp::BgpMessage | |
uint8_t | type |
Additional Inherited Members | |
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 |
BgpLogHandler * | logger |
The BgpOpenMessage class.
This is deserializer/serializer for BGP open message body. If you want to deserializer/serializer a full BGP message. Take a look at BgpPacket class.
Definition at line 27 of file bgp-open-message.h.
libbgp::BgpOpenMessage::BgpOpenMessage | ( | BgpLogHandler * | logger, |
bool | use_4b_asn | ||
) |
Construct a new Bgp Open Message:: Bgp Open Message object.
logger | Pointer to logger object for error logging. |
use_4b_asn | Enable four octets ASN support. |
Definition at line 25 of file bgp-open-message.cc.
libbgp::BgpOpenMessage::BgpOpenMessage | ( | BgpLogHandler * | logger, |
bool | use_4b_asn, | ||
uint16_t | my_asn, | ||
uint16_t | hold_time, | ||
uint32_t | bgp_id | ||
) |
Construct a new Bgp Open Message:: Bgp Open Message object.
use_4b_asn | Enable four octets ASN support. |
my_asn | Local ASN (2 octets). If you want to set a four octets ASN, make sure use_4b_asn is true and use BgpOpenMessage::setAsn(uint32_t my_asn) |
hold_time | Hold timer. |
bgp_id | Local BGP ID in network byte order |
Definition at line 43 of file bgp-open-message.cc.
References setAsn().
libbgp::BgpOpenMessage::BgpOpenMessage | ( | BgpLogHandler * | logger, |
bool | use_4b_asn, | ||
uint16_t | my_asn, | ||
uint16_t | hold_time, | ||
const char * | bgp_id | ||
) |
Construct a new Bgp Open Message:: Bgp Open Message object.
use_4b_asn | Enable four octets ASN support. |
my_asn | Local ASN (2 octets). If you want to set a four octets ASN, make sure use_4b_asn is true and use BgpOpenMessage::setAsn(uint32_t my_asn) |
hold_time | Hold timer. |
bgp_id | Local BGP ID in dotted string notation |
Definition at line 61 of file bgp-open-message.cc.
References setAsn().
bool libbgp::BgpOpenMessage::addCapability | ( | std::shared_ptr< BgpCapability > | capability | ) |
Add a capability.
capability | The capability. |
Definition at line 371 of file bgp-open-message.cc.
|
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.
Definition at line 258 of file bgp-open-message.cc.
References libbgp::Serializable::_print().
uint32_t libbgp::BgpOpenMessage::getAsn | ( | ) | const |
Get ASN.
Get ASN of the open message. Will check Capabilities for four octets ASN if four octets ASN support is enabled.
Definition at line 296 of file bgp-open-message.cc.
const std::vector< std::shared_ptr< BgpCapability > > & libbgp::BgpOpenMessage::getCapabilities | ( | ) | const |
Get capabilities list.
Definition at line 360 of file bgp-open-message.cc.
bool libbgp::BgpOpenMessage::hasCapability | ( | uint8_t | code | ) | const |
Check if open message has a capability.
code | Capability code |
Definition at line 347 of file bgp-open-message.cc.
|
virtual |
Parse a BGP open message body.
from | Pointer to message body buffer. |
msg_sz | Size of message. |
-1 | Parse error. Error may be logged. |
>=0 | Bytes read. |
bad_parse | Internal parser error. |
Implements libbgp::BgpMessage.
Definition at line 79 of file bgp-open-message.cc.
References libbgp::Serializable::setError().
bool libbgp::BgpOpenMessage::setAsn | ( | uint32_t | my_asn | ) |
Set ASN.
Set ASN of the open message. Will update/create four octets ASN capability if four octets ASN support is enabled.
my_asn | ASN |
Definition at line 319 of file bgp-open-message.cc.
Referenced by BgpOpenMessage().
|
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.
to | Pointer to destination buffer. |
buf_sz | Max write size. |
-1 | Serialization error. Error may be logged. |
>=0 | Bytes written. |
Implements libbgp::BgpMessage.
Definition at line 205 of file bgp-open-message.cc.
References libbgp::BgpLogHandler::log().