Open Lighting Architecture  0.9.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | List of all members
ola::testing::MockUDPSocket Class Reference
Inheritance diagram for ola::testing::MockUDPSocket:
ola::network::UDPSocketInterface ola::io::BidirectionalFileDescriptor ola::io::ReadFileDescriptor ola::io::WriteFileDescriptor

Classes

struct  expected_call

Public Member Functions

bool Init ()
 Initialize the socket.
bool Bind (const ola::network::IPV4SocketAddress &endpoint)
 Bind this socket to an external address:port.
bool GetSocketAddress (ola::network::IPV4SocketAddress *address) const
 Return the local address this socket is bound to.
bool Close ()
 Close the socket.
ola::io::DescriptorHandle ReadDescriptor () const
 Returns the read descriptor for this socket.
ola::io::DescriptorHandle WriteDescriptor () const
 Returns the write descriptor for this socket.
ssize_t SendTo (const uint8_t *buffer, unsigned int size, const ola::network::IPV4Address &ip, unsigned short port) const
 Send data on this UDPSocket.
ssize_t SendTo (const uint8_t *buffer, unsigned int size, const ola::network::IPV4SocketAddress &dest) const
 Send data on this UDPSocket.
ssize_t SendTo (ola::io::IOVecInterface *data, const ola::network::IPV4Address &ip, unsigned short port) const
 Send data from an IOVecInterface.
ssize_t SendTo (ola::io::IOVecInterface *data, const ola::network::IPV4SocketAddress &dest) const
 Send data from an IOVecInterface.
bool RecvFrom (uint8_t *buffer, ssize_t *data_read) const
 Receive data.
bool RecvFrom (uint8_t *buffer, ssize_t *data_read, ola::network::IPV4Address &source) const
 Receive data.
bool RecvFrom (uint8_t *buffer, ssize_t *data_read, ola::network::IPV4Address &source, uint16_t &port) const
 Receive data and record the src address & port.
bool RecvFrom (uint8_t *buffer, ssize_t *data_read, ola::network::IPV4SocketAddress *source)
 Receive a datagram on the UDP Socket.
bool EnableBroadcast ()
 Enable broadcasting for this socket.
bool SetMulticastInterface (const ola::network::IPV4Address &iface)
 Set the outgoing interface to be used for multicast transmission.
bool JoinMulticast (const ola::network::IPV4Address &iface, const ola::network::IPV4Address &group, bool multicast_loop=false)
 Join a multicast group.
bool LeaveMulticast (const ola::network::IPV4Address &iface, const ola::network::IPV4Address &group)
 Leave a multicast group.
bool SetTos (uint8_t tos)
 Set the tos field for a socket.
void SetDiscardMode (bool discard_mode)
void AddExpectedData (const uint8_t *data, unsigned int size, const ola::network::IPV4Address &ip, uint16_t port)
void AddExpectedData (ola::io::IOQueue *queue, const ola::network::IPV4SocketAddress &dest)
void InjectData (const uint8_t *data, unsigned int size, const ola::network::IPV4Address &ip, uint16_t port)
void InjectData (const uint8_t *data, unsigned int size, const ola::network::IPV4SocketAddress &source)
void InjectData (ola::io::IOQueue *ioqueue, const ola::network::IPV4SocketAddress &source)
void Verify ()
bool CheckNetworkParamsMatch (bool init_called, bool bound_to_port, uint16_t port, bool broadcast_set)
void SetInterface (const ola::network::IPV4Address &iface)

Member Function Documentation

bool ola::testing::MockUDPSocket::Bind ( const ola::network::IPV4SocketAddress endpoint)
virtual

Bind this socket to an external address:port.

Parameters
endpointthe local socket address to bind to.
Returns
true if the bind succeeded, false if it failed.

Implements ola::network::UDPSocketInterface.

bool ola::testing::MockUDPSocket::Close ( )
virtual

Close the socket.

Returns
true if the call succeeded, false if it failed.

Implements ola::network::UDPSocketInterface.

bool ola::testing::MockUDPSocket::EnableBroadcast ( )
virtual

Enable broadcasting for this socket.

Returns
true if it worked, false otherwise

Implements ola::network::UDPSocketInterface.

bool ola::testing::MockUDPSocket::GetSocketAddress ( ola::network::IPV4SocketAddress address) const
virtual

Return the local address this socket is bound to.

Parameters
[out]addressthe local socket address this socket is bound to.
Returns
true if the call succeeded, false if it failed.

Implements ola::network::UDPSocketInterface.

bool ola::testing::MockUDPSocket::Init ( )
virtual

Initialize the socket.

Returns
false if initialization failed.

Implements ola::network::UDPSocketInterface.

void ola::testing::MockUDPSocket::InjectData ( const uint8_t *  data,
unsigned int  size,
const ola::network::IPV4Address ip,
uint16_t  port 
)

Ownership of the data is not transferred.

void ola::testing::MockUDPSocket::InjectData ( const uint8_t *  data,
unsigned int  size,
const ola::network::IPV4SocketAddress source 
)

Ownership of the data is not transferred.

void ola::testing::MockUDPSocket::InjectData ( ola::io::IOQueue ioqueue,
const ola::network::IPV4SocketAddress source 
)

Inject the data in an IOQueue into the socket. This acts as if the data was received on the UDP socket.

Parameters
ioqueuethe data to inject
sourcethe socket address where this fake data came from
bool ola::testing::MockUDPSocket::JoinMulticast ( const ola::network::IPV4Address iface,
const ola::network::IPV4Address group,
bool  multicast_loop = false 
)
virtual

Join a multicast group.

Parameters
ifacethe address of the interface to use.
groupthe address of the group to join
multicast_loopenable multicast loop
Returns
true if it worked, false otherwise

Implements ola::network::UDPSocketInterface.

bool ola::testing::MockUDPSocket::LeaveMulticast ( const ola::network::IPV4Address iface,
const ola::network::IPV4Address group 
)
virtual

Leave a multicast group.

Parameters
ifacethe address of the interface to use.
groupthe address of the group to join
Returns
true if it worked, false otherwise

Implements ola::network::UDPSocketInterface.

ola::io::DescriptorHandle ola::testing::MockUDPSocket::ReadDescriptor ( ) const
inlinevirtual

Returns the read descriptor for this socket.

Returns
the DescriptorHandle for this descriptor.

Implements ola::network::UDPSocketInterface.

bool ola::testing::MockUDPSocket::RecvFrom ( uint8_t *  buffer,
ssize_t *  data_read 
) const
virtual

Receive data.

Parameters
bufferthe buffer to store the data
data_readthe size of the buffer, updated with the number of bytes read
Returns
true or false

Implements ola::network::UDPSocketInterface.

bool ola::testing::MockUDPSocket::RecvFrom ( uint8_t *  buffer,
ssize_t *  data_read,
ola::network::IPV4Address source 
) const
virtual

Receive data.

Parameters
bufferthe buffer to store the data
data_readthe size of the buffer, updated with the number of bytes read
sourcethe src ip of the packet
Returns
true or false
Deprecated:
Use the IPV4SocketAddress version instead.

Implements ola::network::UDPSocketInterface.

bool ola::testing::MockUDPSocket::RecvFrom ( uint8_t *  buffer,
ssize_t *  data_read,
ola::network::IPV4Address source,
uint16_t &  port 
) const
virtual

Receive data and record the src address & port.

Parameters
bufferthe buffer to store the data
data_readthe size of the buffer, updated with the number of bytes read
sourcethe src ip of the packet
portthe src port of the packet in host byte order
Returns
true or false
Deprecated:
Use the IPV4SocketAddress version instead.

Implements ola::network::UDPSocketInterface.

bool ola::testing::MockUDPSocket::RecvFrom ( uint8_t *  buffer,
ssize_t *  data_read,
ola::network::IPV4SocketAddress source 
)
virtual

Receive a datagram on the UDP Socket.

Parameters
bufferthe buffer to store the data
data_readthe size of the buffer, updated with the number of bytes read
sourcethe source of the datagram.
Returns
true or false

Implements ola::network::UDPSocketInterface.

ssize_t ola::testing::MockUDPSocket::SendTo ( const uint8_t *  buffer,
unsigned int  size,
const ola::network::IPV4Address ip,
unsigned short  port 
) const
virtual

Send data on this UDPSocket.

Parameters
bufferthe data to send
sizethe length of the data
ipthe IP to send to
portthe port to send to in HOST byte order.
Returns
the number of bytes sent.
Deprecated:
Use the IPV4SocketAddress version instead.

Implements ola::network::UDPSocketInterface.

ssize_t ola::testing::MockUDPSocket::SendTo ( const uint8_t *  buffer,
unsigned int  size,
const ola::network::IPV4SocketAddress dest 
) const
inlinevirtual

Send data on this UDPSocket.

Parameters
bufferthe data to send
sizethe length of the data
destthe IP:Port to send the datagram to.
Returns
the number of bytes sent

Implements ola::network::UDPSocketInterface.

ssize_t ola::testing::MockUDPSocket::SendTo ( ola::io::IOVecInterface data,
const ola::network::IPV4Address ip,
unsigned short  port 
) const
virtual

Send data from an IOVecInterface.

Parameters
datathe IOVecInterface class to send.
ipthe IP to send to
portthe port to send to in HOST byte order.
Returns
the number of bytes sent.
Deprecated:
Use the IPV4SocketAddress version instead.

This will try to send as much data as possible. If the data exceeds the MTU the UDP packet will probably get fragmented at the IP layer (depends on OS really). Try to avoid this.

Implements ola::network::UDPSocketInterface.

ssize_t ola::testing::MockUDPSocket::SendTo ( ola::io::IOVecInterface data,
const ola::network::IPV4SocketAddress dest 
) const
inlinevirtual

Send data from an IOVecInterface.

Parameters
datathe IOVecInterface class to send.
destthe IPV4SocketAddress to send to
Returns
the number of bytes sent.

This will try to send as much data as possible. If the data exceeds the MTU the UDP packet will probably get fragmented at the IP layer (depends on OS really). Try to avoid this.

Implements ola::network::UDPSocketInterface.

bool ola::testing::MockUDPSocket::SetMulticastInterface ( const ola::network::IPV4Address iface)
virtual

Set the outgoing interface to be used for multicast transmission.

Parameters
ifacethe address of the interface to use.

Implements ola::network::UDPSocketInterface.

bool ola::testing::MockUDPSocket::SetTos ( uint8_t  tos)
virtual

Set the tos field for a socket.

Parameters
tosthe tos field
Returns
true if it worked, false otherwise

Implements ola::network::UDPSocketInterface.

ola::io::DescriptorHandle ola::testing::MockUDPSocket::WriteDescriptor ( ) const
inlinevirtual

Returns the write descriptor for this socket.

Returns
the DescriptorHandle for this descriptor.

Implements ola::network::UDPSocketInterface.


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