F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
|
Helper for setting up Udp using Berkley sockets as a client. More...
#include <Drv/Ip/UdpSocket.hpp>
Public Member Functions | |
UdpSocket () | |
Constructor for client socket udp implementation. | |
virtual | ~UdpSocket () |
to cleanup state created at instantiation | |
SocketIpStatus | configureSend (const char *hostname, const U16 port, const U32 send_timeout_seconds, const U32 send_timeout_microseconds) |
configure the udp socket for outgoing transmissions | |
SocketIpStatus | configureRecv (const char *hostname, const U16 port) |
configure the udp socket for incoming transmissions | |
Public Member Functions inherited from Drv::IpSocket | |
IpSocket () | |
virtual | ~IpSocket () |
SocketIpStatus | configure (const char *hostname, const U16 port, const U32 send_timeout_seconds, const U32 send_timeout_microseconds) |
configure the ip socket with host and transmission timeouts | |
bool | isOpened () |
check if IP socket has previously been opened | |
SocketIpStatus | open () |
open the IP socket for communications | |
SocketIpStatus | send (const U8 *const data, const U32 size) |
send data out the IP socket from the given buffer | |
SocketIpStatus | recv (U8 *const data, I32 &size) |
receive data from the IP socket from the given buffer | |
void | close () |
closes the socket | |
Protected Member Functions | |
SocketIpStatus | bind (NATIVE_INT_TYPE fd) |
bind the UDP to a port such that it can receive packets at the previously configured port | |
SocketIpStatus | openProtocol (NATIVE_INT_TYPE &fd) |
udp specific implementation for opening a socket. | |
I32 | sendProtocol (const U8 *const data, const U32 size) |
Protocol specific implementation of send. Called directly with retry from send. | |
I32 | recvProtocol (U8 *const data, const U32 size) |
Protocol specific implementation of recv. Called directly with error handling from recv. | |
Protected Member Functions inherited from Drv::IpSocket | |
SocketIpStatus | setupTimeouts (NATIVE_INT_TYPE socketFd) |
setup the socket timeout properties of the opened outgoing socket | |
virtual SocketIpStatus | openProtocol (NATIVE_INT_TYPE &fd)=0 |
Protocol specific open implementation, called from open. | |
virtual I32 | sendProtocol (const U8 *const data, const U32 size)=0 |
Protocol specific implementation of send. Called directly with retry from send. | |
virtual I32 | recvProtocol (U8 *const data, const U32 size)=0 |
Protocol specific implementation of recv. Called directly with error handling from recv. | |
Additional Inherited Members | |
Static Protected Member Functions inherited from Drv::IpSocket | |
static SocketIpStatus | addressToIp4 (const char *address, void *ip4) |
converts a given address in dot form x.x.x.x to an ip address. ONLY works for IPv4. | |
Protected Attributes inherited from Drv::IpSocket | |
Os::Mutex | m_lock |
NATIVE_INT_TYPE | m_fd |
U32 | m_timeoutSeconds |
U32 | m_timeoutMicroseconds |
U16 | m_port |
IP address port used. | |
bool | m_open |
Have we successfully opened. | |
char | m_hostname [SOCKET_MAX_HOSTNAME_SIZE] |
Hostname to supply. | |
Helper for setting up Udp using Berkley sockets as a client.
Certain IP headers have conflicting definitions with the m_data member of various types in fprime. UdpSocket separates the ip setup from the incoming Fw::Buffer in the primary component class preventing this collision.
Definition at line 32 of file UdpSocket.hpp.
Drv::UdpSocket::UdpSocket | ( | ) |
Constructor for client socket udp implementation.
Definition at line 53 of file UdpSocket.cpp.
|
virtual |
to cleanup state created at instantiation
Definition at line 57 of file UdpSocket.cpp.
|
protected |
bind the UDP to a port such that it can receive packets at the previously configured port
fd | socket file descriptor used in bind |
Definition at line 74 of file UdpSocket.cpp.
SocketIpStatus Drv::UdpSocket::configureRecv | ( | const char * | hostname, |
const U16 | port | ||
) |
configure the udp socket for incoming transmissions
Configures the UDP handler to use the given hostname and port for incoming transmissions. Outgoing hostname and port are configured using the configureSend
function call for UDP as it requires separate host/port pairs for outgoing and incoming transmissions. Hostname DNS translation is left up to the caller and thus hostname must be an IP address in dot-notation of the form "x.x.x.x". Port cannot be set to 0 as dynamic port assignment is not supported. It is possible to configure the UDP port as a single-direction receive port only.
hostname | socket uses for incoming transmissions. Must be of form x.x.x.x |
port | port socket uses for incoming transmissions. Must NOT be 0. |
Definition at line 67 of file UdpSocket.cpp.
SocketIpStatus Drv::UdpSocket::configureSend | ( | const char * | hostname, |
const U16 | port, | ||
const U32 | send_timeout_seconds, | ||
const U32 | send_timeout_microseconds | ||
) |
configure the udp socket for outgoing transmissions
Configures the UDP handler to use the given hostname and port for outgoing transmissions. Incoming hostname and port are configured using the configureRecv
function call for UDP as it requires separate host/port pairs for outgoing and incoming transmissions. Hostname DNS translation is left up to the caller and thus hostname must be an IP address in dot-notation of the form "x.x.x.x". Port cannot be set to 0 as dynamic port assignment is not supported. It is possible to configure the UDP port as a single-direction send port only.
Note: delegates to IpSocket::configure
hostname | socket uses for outgoing transmissions. Must be of form x.x.x.x |
port | port socket uses for outgoing transmissions. Must NOT be 0. |
send_timeout_seconds | send timeout seconds portion |
send_timeout_microseconds | send timeout microseconds portion. Must be less than 1000000 |
Definition at line 62 of file UdpSocket.cpp.
|
protectedvirtual |
udp specific implementation for opening a socket.
fd | (output) file descriptor opened. Only valid on SOCK_SUCCESS. Otherwise will be invalid |
Implements Drv::IpSocket.
Definition at line 100 of file UdpSocket.cpp.
|
protectedvirtual |
Protocol specific implementation of recv. Called directly with error handling from recv.
data | data pointer to fill |
size | size of data buffer |
Implements Drv::IpSocket.
Definition at line 162 of file UdpSocket.cpp.
|
protectedvirtual |
Protocol specific implementation of send. Called directly with retry from send.
data | data to send |
size | size of data to send |
Implements Drv::IpSocket.
Definition at line 156 of file UdpSocket.cpp.