OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UdpServer Class Reference

#include <udp_server.h>

Inheritance diagram for UdpServer:
Collaboration diagram for UdpServer:

Classes

class  Reader
 

Public Types

enum  ServerState { OK = 42, Uninitialized, SocketOpenFailed, SocketBindFailed }
 
typedef
boost::asio::ip::udp::endpoint 
Endpoint
 
typedef
boost::asio::ip::udp::socket 
Socket
 

Public Member Functions

 UdpServer (EventManager *evm, int buffer_size=kDefaultBufferSize)
 
 UdpServer (boost::asio::io_context *io_service, int buffer_size=kDefaultBufferSize)
 
virtual ~UdpServer ()
 
virtual bool Initialize (unsigned short port)
 
virtual bool Initialize (const std::string &ipaddress, unsigned short port)
 
virtual bool Initialize (boost::asio::ip::udp::endpoint local_endpoint)
 
virtual void Shutdown ()
 
void StartSend (boost::asio::ip::udp::endpoint ep, std::size_t bytes_to_send, boost::asio::const_buffer buffer)
 
void StartReceive ()
 
ServerState GetServerState () const
 
boost::asio::ip::udp::endpoint GetLocalEndpoint (boost::system::error_code *error) const
 
std::string GetLocalEndpointAddress () const
 
int GetLocalEndpointPort () const
 
boost::asio::mutable_buffer AllocateBuffer ()
 
boost::asio::mutable_buffer AllocateBuffer (std::size_t s)
 
void DeallocateBuffer (const boost::asio::const_buffer &buffer)
 
const io::SocketStatsGetSocketStats () const
 
void GetRxSocketStats (SocketIOStats *socket_stats) const
 
void GetTxSocketStats (SocketIOStats *socket_stats) const
 

Static Public Attributes

static const int kDefaultBufferSize = 4 * 1024
 

Protected Member Functions

EventManagerevent_manager ()
 
virtual bool DisableSandeshLogMessages ()
 
virtual std::string ToString ()
 
virtual void HandleReceive (const boost::asio::const_buffer &recv_buffer, boost::asio::ip::udp::endpoint remote_endpoint, std::size_t bytes_transferred, const boost::system::error_code &error)
 
virtual void OnRead (const boost::asio::const_buffer &recv_buffer, const boost::asio::ip::udp::endpoint &remote_endpoint)
 
virtual int reader_task_id () const
 
virtual int reader_task_instance (const boost::asio::ip::udp::endpoint &remote_endpoint) const
 
virtual void HandleSend (boost::asio::const_buffer send_buffer, boost::asio::ip::udp::endpoint remote_endpoint, std::size_t bytes_transferred, const boost::system::error_code &error)
 

Private Member Functions

void SetName (boost::asio::ip::udp::endpoint ep)
 
void HandleReceiveInternal (boost::asio::const_buffer recv_buffer, std::size_t bytes_transferred, const boost::system::error_code &error)
 
void HandleSendInternal (boost::asio::const_buffer send_buffer, boost::asio::ip::udp::endpoint remote_endpoint, std::size_t bytes_transferred, const boost::system::error_code &error)
 
 DISALLOW_COPY_AND_ASSIGN (UdpServer)
 

Private Attributes

boost::asio::ip::udp::socket socket_
 
int buffer_size_
 
ServerState state_
 
EventManagerevm_
 
std::string name_
 
boost::asio::ip::udp::endpoint remote_endpoint_
 
tbb::mutex state_guard_
 
tbb::mutex pbuf_guard_
 
std::vector< uint8_t * > pbuf_
 
tbb::atomic< int > refcount_
 
io::SocketStats stats_
 

Static Private Attributes

static int reader_task_id_ = -1
 

Friends

void intrusive_ptr_add_ref (UdpServer *server)
 
void intrusive_ptr_release (UdpServer *server)
 

Detailed Description

Definition at line 18 of file udp_server.h.

Member Typedef Documentation

typedef boost::asio::ip::udp::endpoint UdpServer::Endpoint

Definition at line 20 of file udp_server.h.

typedef boost::asio::ip::udp::socket UdpServer::Socket

Definition at line 21 of file udp_server.h.

Member Enumeration Documentation

Enumerator
OK 
Uninitialized 
SocketOpenFailed 
SocketBindFailed 

Definition at line 23 of file udp_server.h.

Constructor & Destructor Documentation

UdpServer::UdpServer ( EventManager evm,
int  buffer_size = kDefaultBufferSize 
)
explicit

Definition at line 62 of file udp_server.cc.

Here is the call graph for this function:

UdpServer::UdpServer ( boost::asio::io_context *  io_service,
int  buffer_size = kDefaultBufferSize 
)
explicit

Definition at line 49 of file udp_server.cc.

Here is the call graph for this function:

UdpServer::~UdpServer ( )
virtual

Definition at line 86 of file udp_server.cc.

Member Function Documentation

mutable_buffer UdpServer::AllocateBuffer ( )

Definition at line 178 of file udp_server.cc.

mutable_buffer UdpServer::AllocateBuffer ( std::size_t  s)

Definition at line 169 of file udp_server.cc.

void UdpServer::DeallocateBuffer ( const boost::asio::const_buffer &  buffer)

Definition at line 182 of file udp_server.cc.

virtual bool UdpServer::DisableSandeshLogMessages ( )
inlineprotectedvirtual

Definition at line 68 of file udp_server.h.

UdpServer::DISALLOW_COPY_AND_ASSIGN ( UdpServer  )
private
EventManager* UdpServer::event_manager ( )
inlineprotected

Definition at line 67 of file udp_server.h.

udp::endpoint UdpServer::GetLocalEndpoint ( boost::system::error_code *  error) const

Definition at line 300 of file udp_server.cc.

std::string UdpServer::GetLocalEndpointAddress ( ) const

Definition at line 305 of file udp_server.cc.

Here is the call graph for this function:

int UdpServer::GetLocalEndpointPort ( ) const

Definition at line 313 of file udp_server.cc.

Here is the call graph for this function:

void UdpServer::GetRxSocketStats ( SocketIOStats *  socket_stats) const

Definition at line 321 of file udp_server.cc.

Here is the call graph for this function:

ServerState UdpServer::GetServerState ( ) const
inline

Definition at line 48 of file udp_server.h.

const io::SocketStats& UdpServer::GetSocketStats ( ) const
inline

Definition at line 62 of file udp_server.h.

void UdpServer::GetTxSocketStats ( SocketIOStats *  socket_stats) const

Definition at line 325 of file udp_server.cc.

Here is the call graph for this function:

void UdpServer::HandleReceive ( const boost::asio::const_buffer &  recv_buffer,
boost::asio::ip::udp::endpoint  remote_endpoint,
std::size_t  bytes_transferred,
const boost::system::error_code &  error 
)
protectedvirtual

Reimplemented in BFD::UDPConnectionManager::UDPRecvServer.

Definition at line 276 of file udp_server.cc.

Here is the call graph for this function:

void UdpServer::HandleReceiveInternal ( boost::asio::const_buffer  recv_buffer,
std::size_t  bytes_transferred,
const boost::system::error_code &  error 
)
private

Definition at line 251 of file udp_server.cc.

Here is the call graph for this function:

void UdpServer::HandleSend ( boost::asio::const_buffer  send_buffer,
boost::asio::ip::udp::endpoint  remote_endpoint,
std::size_t  bytes_transferred,
const boost::system::error_code &  error 
)
protectedvirtual

Definition at line 294 of file udp_server.cc.

Here is the call graph for this function:

void UdpServer::HandleSendInternal ( boost::asio::const_buffer  send_buffer,
boost::asio::ip::udp::endpoint  remote_endpoint,
std::size_t  bytes_transferred,
const boost::system::error_code &  error 
)
private

Definition at line 210 of file udp_server.cc.

Here is the call graph for this function:

bool UdpServer::Initialize ( unsigned short  port)
virtual

Definition at line 136 of file udp_server.cc.

bool UdpServer::Initialize ( const std::string &  ipaddress,
unsigned short  port 
)
virtual

Definition at line 123 of file udp_server.cc.

Here is the call graph for this function:

virtual bool UdpServer::Initialize ( boost::asio::ip::udp::endpoint  local_endpoint)
virtual
void UdpServer::OnRead ( const boost::asio::const_buffer &  recv_buffer,
const boost::asio::ip::udp::endpoint &  remote_endpoint 
)
protectedvirtual

Definition at line 288 of file udp_server.cc.

virtual int UdpServer::reader_task_id ( ) const
inlineprotectedvirtual

Definition at line 81 of file udp_server.h.

int UdpServer::reader_task_instance ( const boost::asio::ip::udp::endpoint &  remote_endpoint) const
protectedvirtual

Definition at line 75 of file udp_server.cc.

void UdpServer::SetName ( boost::asio::ip::udp::endpoint  ep)
private

Definition at line 79 of file udp_server.cc.

void UdpServer::Shutdown ( void  )
virtual

Definition at line 98 of file udp_server.cc.

void UdpServer::StartReceive ( )

Definition at line 235 of file udp_server.cc.

Here is the call graph for this function:

void UdpServer::StartSend ( boost::asio::ip::udp::endpoint  ep,
std::size_t  bytes_to_send,
boost::asio::const_buffer  buffer 
)

Definition at line 194 of file udp_server.cc.

Here is the call graph for this function:

virtual std::string UdpServer::ToString ( )
inlineprotectedvirtual

Definition at line 69 of file udp_server.h.

Friends And Related Function Documentation

void intrusive_ptr_add_ref ( UdpServer server)
friend

Definition at line 138 of file udp_server.h.

void intrusive_ptr_release ( UdpServer server)
friend

Definition at line 142 of file udp_server.h.

Member Data Documentation

int UdpServer::buffer_size_
private

Definition at line 122 of file udp_server.h.

EventManager* UdpServer::evm_
private

Definition at line 124 of file udp_server.h.

const int UdpServer::kDefaultBufferSize = 4 * 1024
static

Definition at line 29 of file udp_server.h.

std::string UdpServer::name_
private

Definition at line 125 of file udp_server.h.

std::vector<uint8_t *> UdpServer::pbuf_
private

Definition at line 129 of file udp_server.h.

tbb::mutex UdpServer::pbuf_guard_
private

Definition at line 128 of file udp_server.h.

int UdpServer::reader_task_id_ = -1
staticprivate

Definition at line 120 of file udp_server.h.

tbb::atomic<int> UdpServer::refcount_
private

Definition at line 130 of file udp_server.h.

boost::asio::ip::udp::endpoint UdpServer::remote_endpoint_
private

Definition at line 126 of file udp_server.h.

boost::asio::ip::udp::socket UdpServer::socket_
private

Definition at line 121 of file udp_server.h.

ServerState UdpServer::state_
private

Definition at line 123 of file udp_server.h.

tbb::mutex UdpServer::state_guard_
private

Definition at line 127 of file udp_server.h.

io::SocketStats UdpServer::stats_
private

Definition at line 131 of file udp_server.h.


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