libbgp
0.6
A C++ BGP Library.
|
#include <bgp-sink.h>
Public Member Functions | |
BgpSink (bool use_4b_asn) | |
Construct a new Bgp Sink:: Bgp Sink object. More... | |
ssize_t | fill (const uint8_t *buffer, size_t len) |
Fill the sink with data. More... | |
ssize_t | pour (BgpPacket **pkt) |
Pour BGP packet out from sink. More... | |
size_t | getBytesInSink () const |
Get amount to data in sink. More... | |
void | drain () |
Drain the sink. (Remove all data from sink buffer) | |
void | setLogger (BgpLogHandler *logger) |
Set the logger to use. If NULL or not set, nothing will be logger. More... | |
~BgpSink () | |
Destroy the Bgp Sink:: Bgp Sink object. | |
The BgpSink class.
BGP sink is a packet buffering utility for BGP. It consumes binary buffer to fill the sink (buffer) and allows users to get full BGP packet from the sink (buffer). This is useful since BGP uses TCP, and TCP streams the data. (so we might not get a full BGP packet in buffer every time)
Definition at line 29 of file bgp-sink.h.
libbgp::BgpSink::BgpSink | ( | bool | use_4b_asn | ) |
Construct a new Bgp Sink:: Bgp Sink object.
use_4b_asn | Enable four octets ASN support. |
Definition at line 24 of file bgp-sink.cc.
ssize_t libbgp::BgpSink::fill | ( | const uint8_t * | buffer, |
size_t | len | ||
) |
Fill the sink with data.
buffer | The pointer to data buffer. |
len | The length of data. |
-1 | Failed to fill sink. error may be written to stderr with log handler. |
>=0 | Bytes consumed. |
Definition at line 50 of file bgp-sink.cc.
References libbgp::BgpLogHandler::log().
size_t libbgp::BgpSink::getBytesInSink | ( | ) | const |
Get amount to data in sink.
Definition at line 155 of file bgp-sink.cc.
ssize_t libbgp::BgpSink::pour | ( | BgpPacket ** | pkt | ) |
Pour BGP packet out from sink.
Get a packet from sink and remove that packet from sink.
pkt | Pointer to BgpPacket pointer. |
-2 | Failed to pour packet. error may be written to stderr with log handler. |
-1 | Packet poured, but parse error occurred. error may be written to stderr with log handler, notification message data that needs to be sent to peer may be avaliable. |
>=0 | Bytes poured. |
bad_packet | Parsed packet length mismatch. |
Definition at line 86 of file bgp-sink.cc.
References libbgp::BgpLogHandler::log().
void libbgp::BgpSink::setLogger | ( | BgpLogHandler * | logger | ) |
Set the logger to use. If NULL or not set, nothing will be logger.
logger | Pointer to logger object for error logging. |
Definition at line 164 of file bgp-sink.cc.