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

The BgpSink class. More...

#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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ BgpSink()

libbgp::BgpSink::BgpSink ( bool  use_4b_asn)

Construct a new Bgp Sink:: Bgp Sink object.

Parameters
use_4b_asnEnable four octets ASN support.

Definition at line 24 of file bgp-sink.cc.

Member Function Documentation

◆ fill()

ssize_t libbgp::BgpSink::fill ( const uint8_t *  buffer,
size_t  len 
)

Fill the sink with data.

Parameters
bufferThe pointer to data buffer.
lenThe length of data.
Returns
ssize_t Bytes consumed.
Return values
-1Failed to fill sink. error may be written to stderr with log handler.
>=0Bytes consumed.

Definition at line 50 of file bgp-sink.cc.

References libbgp::BgpLogHandler::log().

◆ getBytesInSink()

size_t libbgp::BgpSink::getBytesInSink ( ) const

Get amount to data in sink.

Returns
size_t Data size in bytes.

Definition at line 155 of file bgp-sink.cc.

◆ pour()

ssize_t libbgp::BgpSink::pour ( BgpPacket **  pkt)

Pour BGP packet out from sink.

Get a packet from sink and remove that packet from sink.

Parameters
pktPointer to BgpPacket pointer.
Returns
ssize_t Bytes poured.
Return values
-2Failed to pour packet. error may be written to stderr with log handler.
-1Packet 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.
>=0Bytes poured.
Exceptions
bad_packetParsed packet length mismatch.

Definition at line 86 of file bgp-sink.cc.

References libbgp::BgpLogHandler::log().

◆ setLogger()

void libbgp::BgpSink::setLogger ( BgpLogHandler logger)

Set the logger to use. If NULL or not set, nothing will be logger.

Parameters
loggerPointer to logger object for error logging.

Definition at line 164 of file bgp-sink.cc.


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