|
libbgp
0.6
A C++ BGP Library.
|
The BgpUpdateMessage class. More...
#include <bgp-update-message.h>


Public Member Functions | |
| BgpUpdateMessage (BgpLogHandler *logger, bool use_4b_asn) | |
| Construct a new Bgp Update Message:: Bgp Update Message object. More... | |
| BgpPathAttrib & | getAttrib (uint8_t type) |
| Get mutable reference to attribute by typecode. More... | |
| const BgpPathAttrib & | getAttrib (uint8_t type) const |
| Get const reference to attribute by typecode. More... | |
| bool | hasAttrib (uint8_t type) const |
| Test if update message has an attribute. More... | |
| bool | addAttrib (const BgpPathAttrib &attrib) |
| Add an attribute to the update message. More... | |
| bool | setAttribs (const std::vector< std::shared_ptr< BgpPathAttrib >> &attrs) |
| Replace the attributes list with another attribute list. More... | |
| bool | dropAttrib (uint8_t type) |
| Drop (remove) an attribute from the update message. More... | |
| bool | updateAttribute (const BgpPathAttrib &attrib) |
| Add/Update an attribute. More... | |
| bool | dropNonTransitive () |
| Drop all non-transitive attributes from the update message. More... | |
| bool | setNextHop (uint32_t nexthop) |
| Set/Create nexthop attribtue. More... | |
| bool | prepend (uint32_t asn) |
| Prepend ASN to AS_PATH and AS4_PATH (if in 2b-mode ans AS4_PATH exists) More... | |
| bool | restoreAsPath () |
| Restore the AS_PATH attribute to four octets ASN flavor. More... | |
| bool | downgradeAsPath () |
| Downgrade the AS_PATH to two octets flavor. More... | |
| bool | restoreAggregator () |
| Restore aggregator attribute from as4_aggregator. More... | |
| bool | downgradeAggregator () |
| Downgrade aggregator to two octets. More... | |
| bool | setWithdrawn4 (const std::vector< Prefix4 > &routes) |
| Set withdrawn routes. More... | |
| bool | addWithdrawn4 (uint32_t prefix, uint8_t length) |
| Add withdrawn route. More... | |
| bool | addWithdrawn4 (const Prefix4 &route) |
| Add withdrawn route. More... | |
| bool | setNlri4 (const std::vector< Prefix4 > &routes) |
| Set NLRIs. More... | |
| bool | addNlri4 (uint32_t prefix, uint8_t length) |
| Add NLRI route. More... | |
| bool | addNlri4 (const Prefix4 &route) |
| Add NLRI route. More... | |
| bool | setWithdrawn6 (const std::vector< Prefix6 > &routes) |
| bool | setNlri6 (const std::vector< Prefix6 > &routes, const uint8_t nexthop_global[16], const uint8_t nexthop_linklocal[16]) |
| 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... | |
Public Attributes | |
| std::vector< Prefix4 > | withdrawn_routes |
| std::vector< std::shared_ptr< BgpPathAttrib > > | path_attribute |
| std::vector< Prefix4 > | nlri |
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 BgpUpdateMessage class.
This is deserializer/serializer for BGP update message body. If you want to deserializer/serializer a full BGP message. Take a look at BgpPacket class.
Definition at line 28 of file bgp-update-message.h.
| libbgp::BgpUpdateMessage::BgpUpdateMessage | ( | BgpLogHandler * | logger, |
| bool | use_4b_asn | ||
| ) |
Construct a new Bgp Update Message:: Bgp Update 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-update-message.cc.
| bool libbgp::BgpUpdateMessage::addAttrib | ( | const BgpPathAttrib & | attrib | ) |
Add an attribute to the update message.
| attrib | The attribute. |
Definition at line 83 of file bgp-update-message.cc.
References libbgp::BgpPathAttrib::clone(), hasAttrib(), and libbgp::BgpPathAttrib::type_code.
Referenced by updateAttribute().
| bool libbgp::BgpUpdateMessage::addNlri4 | ( | uint32_t | prefix, |
| uint8_t | length | ||
| ) |
Add NLRI route.
| prefix | Route prefix in network byte order. |
| length | Route netmask in CIDR notation. |
Definition at line 491 of file bgp-update-message.cc.
| bool libbgp::BgpUpdateMessage::addNlri4 | ( | const Prefix4 & | route | ) |
Add NLRI route.
| route | The route. |
Definition at line 504 of file bgp-update-message.cc.
| bool libbgp::BgpUpdateMessage::addWithdrawn4 | ( | uint32_t | prefix, |
| uint8_t | length | ||
| ) |
Add withdrawn route.
| prefix | Withdrawn route prefix in network byte order. |
| length | Withdrawn route netmask in CIDR notation. |
Definition at line 453 of file bgp-update-message.cc.
| bool libbgp::BgpUpdateMessage::addWithdrawn4 | ( | const Prefix4 & | route | ) |
Add withdrawn route.
| route | The withdrawn route. |
Definition at line 466 of file bgp-update-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 798 of file bgp-update-message.cc.
References libbgp::Serializable::_print().
| bool libbgp::BgpUpdateMessage::downgradeAggregator | ( | ) |
Downgrade aggregator to two octets.
Definition at line 417 of file bgp-update-message.cc.
References hasAttrib().
| bool libbgp::BgpUpdateMessage::downgradeAsPath | ( | ) |
Downgrade the AS_PATH to two octets flavor.
Create/Update AS_PATH and make four octets ASNs in AS_PATH AS_TRANS.
Definition at line 359 of file bgp-update-message.cc.
References hasAttrib().
| bool libbgp::BgpUpdateMessage::dropAttrib | ( | uint8_t | type | ) |
Drop (remove) an attribute from the update message.
| type | The attribute typecode. |
Definition at line 113 of file bgp-update-message.cc.
Referenced by updateAttribute().
| bool libbgp::BgpUpdateMessage::dropNonTransitive | ( | ) |
Drop all non-transitive attributes from the update message.
Definition at line 130 of file bgp-update-message.cc.
| BgpPathAttrib & libbgp::BgpUpdateMessage::getAttrib | ( | uint8_t | type | ) |
Get mutable reference to attribute by typecode.
| type | Attribute typecode. |
| no such attribute | if attribute does not exist. |
Definition at line 37 of file bgp-update-message.cc.
| const BgpPathAttrib & libbgp::BgpUpdateMessage::getAttrib | ( | uint8_t | type | ) | const |
Get const reference to attribute by typecode.
| type | Attribute typecode. |
| no such attribute | if attribute does not exist. |
Definition at line 52 of file bgp-update-message.cc.
| bool libbgp::BgpUpdateMessage::hasAttrib | ( | uint8_t | type | ) | const |
Test if update message has an attribute.
| type | Attribute typecode. |
Definition at line 67 of file bgp-update-message.cc.
Referenced by addAttrib(), downgradeAggregator(), downgradeAsPath(), prepend(), restoreAggregator(), and restoreAsPath().
|
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.
| 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::BgpMessage.
Definition at line 564 of file bgp-update-message.cc.
References libbgp::Serializable::setError().
| bool libbgp::BgpUpdateMessage::prepend | ( | uint32_t | asn | ) |
Prepend ASN to AS_PATH and AS4_PATH (if in 2b-mode ans AS4_PATH exists)
Prepend an ASN to AS_PATH. Depends on the setup, the given ASN may be prepended to AS4_PATH too.
| asn | Thr ASN. |
Definition at line 180 of file bgp-update-message.cc.
References hasAttrib().
| bool libbgp::BgpUpdateMessage::restoreAggregator | ( | ) |
Restore aggregator attribute from as4_aggregator.
Definition at line 396 of file bgp-update-message.cc.
References hasAttrib().
| bool libbgp::BgpUpdateMessage::restoreAsPath | ( | ) |
Restore the AS_PATH attribute to four octets ASN flavor.
Try to restore AS_TRANS in AS_PATH attribute with AS4_PATH.
Definition at line 245 of file bgp-update-message.cc.
References hasAttrib().
| bool libbgp::BgpUpdateMessage::setAttribs | ( | const std::vector< std::shared_ptr< BgpPathAttrib >> & | attrs | ) |
Replace the attributes list with another attribute list.
| attrs | List of attributes. |
Definition at line 97 of file bgp-update-message.cc.
| bool libbgp::BgpUpdateMessage::setNextHop | ( | uint32_t | nexthop | ) |
Set/Create nexthop attribtue.
| nexthop | Nexthop in network byte order. |
Definition at line 162 of file bgp-update-message.cc.
References libbgp::BgpPathAttribNexthop::next_hop, and updateAttribute().
| bool libbgp::BgpUpdateMessage::setNlri4 | ( | const std::vector< Prefix4 > & | routes | ) |
Set NLRIs.
| routes | Routes. |
Definition at line 478 of file bgp-update-message.cc.
| bool libbgp::BgpUpdateMessage::setWithdrawn4 | ( | const std::vector< Prefix4 > & | routes | ) |
Set withdrawn routes.
| routes | Withdrawn routes. |
Definition at line 440 of file bgp-update-message.cc.
| bool libbgp::BgpUpdateMessage::updateAttribute | ( | const BgpPathAttrib & | attrib | ) |
Add/Update an attribute.
| attrib | The attribute. |
Definition at line 150 of file bgp-update-message.cc.
References addAttrib(), dropAttrib(), and libbgp::BgpPathAttrib::type_code.
Referenced by setNextHop().
|
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 720 of file bgp-update-message.cc.
References libbgp::BgpLogHandler::log().
1.8.13