![]() |
F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
|
Helper for setting up Udp using Berkeley sockets as a client. More...
#include <Drv/Ip/UdpSocket.hpp>
Public Member Functions | |
| UdpSocket () | |
| Constructor for client socket udp implementation. More... | |
| virtual | ~UdpSocket () |
| to cleanup state created at instantiation More... | |
| SocketIpStatus | configure (const char *const ipv4_address, const U16 port, const U32 send_timeout_seconds, const U32 send_timeout_microseconds) override |
| configure is disabled More... | |
| SocketIpStatus | configureSend (const char *const ipv4_address, const U16 port, const U32 send_timeout_seconds, const U32 send_timeout_microseconds) |
| configure the udp socket for outgoing transmissions More... | |
| SocketIpStatus | configureRecv (const char *const ipv4_address, const U16 port) |
| configure the udp socket for incoming transmissions More... | |
| U16 | getRecvPort () |
| get the port being received on More... | |
| SocketIpStatus | send (const SocketDescriptor &socketDescriptor, const U8 *const data, const FwSizeType size) override |
| UDP-specific implementation of send that handles zero-length datagrams correctly. More... | |
Public Member Functions inherited from Drv::IpSocket | |
| IpSocket () | |
| virtual | ~IpSocket () |
| SocketIpStatus | open (SocketDescriptor &socketDescriptor) |
| open the IP socket for communications More... | |
| SocketIpStatus | recv (const SocketDescriptor &fd, U8 *const data, FwSizeType &size) |
| receive data from the IP socket from the given buffer More... | |
| void | close (const SocketDescriptor &socketDescriptor) |
| closes the socket More... | |
| void | shutdown (const SocketDescriptor &socketDescriptor) |
| shutdown the socket More... | |
Protected Member Functions | |
| SocketIpStatus | bind (const int fd) |
| bind the UDP to a port such that it can receive packets at the previously configured port More... | |
| SocketIpStatus | openProtocol (SocketDescriptor &socketDescriptor) override |
| udp specific implementation for opening a socket. More... | |
| FwSignedSizeType | sendProtocol (const SocketDescriptor &socketDescriptor, const U8 *const data, const FwSizeType size) override |
| Protocol specific implementation of send. Called directly with retry from send. More... | |
| FwSignedSizeType | recvProtocol (const SocketDescriptor &socketDescriptor, U8 *const data, const FwSizeType size) override |
| Protocol specific implementation of recv. Called directly with error handling from recv. More... | |
| SocketIpStatus | handleZeroReturn () override |
| Handle zero return from recvProtocol for UDP. More... | |
Protected Member Functions inherited from Drv::IpSocket | |
| virtual bool | isValidPort (U16 port) |
| Check if the given port is valid for the socket. More... | |
| SocketIpStatus | setupTimeouts (int socketFd) |
| setup the socket timeout properties of the opened outgoing socket More... | |
| SocketIpStatus | setupSocketOptions (int socketFd) |
| setup the socket options of the input socket as defined in IpCfg.hpp More... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from Drv::IpSocket | |
| static SocketIpStatus | addressToIp4 (const char *const ipv4_address, void *const out) |
| converts a given IPv4 address in dotted-quad form "x.x.x.x" to a network-order in_addr structure. ONLY works for IPv4; does NOT perform DNS resolution. More... | |
Protected Attributes inherited from Drv::IpSocket | |
| U32 | m_timeoutSeconds |
| U32 | m_timeoutMicroseconds |
| U16 | m_port |
| IP address port used. More... | |
| char | m_ipv4_address [SOCKET_MAX_IPV4_ADDRESS_SIZE] |
| IPv4 address (dotted-quad "x.x.x.x") More... | |
Helper for setting up Udp using Berkeley 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 44 of file UdpSocket.hpp.
| Drv::UdpSocket::UdpSocket | ( | ) |
Constructor for client socket udp implementation.
Definition at line 42 of file UdpSocket.cpp.
|
virtualdefault |
to cleanup state created at instantiation
|
protected |
bind the UDP to a port such that it can receive packets at the previously configured port
| socketDescriptor | socket descriptor used in bind |
Definition at line 96 of file UdpSocket.cpp.
|
overridevirtual |
configure is disabled
Reimplemented from Drv::IpSocket.
Definition at line 49 of file UdpSocket.cpp.
| SocketIpStatus Drv::UdpSocket::configureRecv | ( | const char *const | ipv4_address, |
| const U16 | port | ||
| ) |
configure the udp socket for incoming transmissions
Configures the UDP handler to use the given IPv4 address and port for incoming transmissions. Outgoing address and port are configured using the configureSend function call for UDP as it requires separate address/port pairs for outgoing and incoming transmissions.
It is possible to configure the UDP port as a single-direction receive port only.
| ipv4_address | IPv4 address (dotted-quad "x.x.x.x") to bind for receiving. |
| port | port socket uses for incoming transmissions. Can be 0 for ephemeral port assignment. |
Definition at line 71 of file UdpSocket.cpp.
| SocketIpStatus Drv::UdpSocket::configureSend | ( | const char *const | ipv4_address, |
| 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 IPv4 address and port for outgoing transmissions. Incoming address and port are configured using the configureRecv function call for UDP as it requires separate address/port pairs for outgoing and incoming transmissions.
If port is set to 0, the socket will be configured for ephemeral send (dynamic reply-to) and will use the sender's address from the first received datagram for replies. It is possible to configure the UDP port as a single-direction send port only.
Note: delegates to IpSocket::configure
| ipv4_address | IPv4 address (dotted-quad "x.x.x.x") for outgoing transmissions. |
| port | port socket uses for outgoing transmissions. Can be 0 for ephemeral reply-to mode. |
| send_timeout_seconds | send timeout seconds portion |
| send_timeout_microseconds | send timeout microseconds portion. Must be less than 1000000 |
Definition at line 61 of file UdpSocket.cpp.
| U16 Drv::UdpSocket::getRecvPort | ( | ) |
get the port being received on
Most useful when receive was configured to use port "0", this will return the port used for receiving data after a port has been determined. Will return 0 if the connection has not been setup.
Definition at line 92 of file UdpSocket.cpp.
|
overrideprotectedvirtual |
Handle zero return from recvProtocol for UDP.
For UDP, a return of 0 from recvfrom means a 0-byte datagram was received, which is a success case, not a disconnection.
Reimplemented from Drv::IpSocket.
Definition at line 273 of file UdpSocket.cpp.
|
overrideprotectedvirtual |
udp specific implementation for opening a socket.
| socketDescriptor | (output) file descriptor opened. Only valid on SOCK_SUCCESS. Otherwise will be invalid |
Implements Drv::IpSocket.
Definition at line 120 of file UdpSocket.cpp.
|
overrideprotectedvirtual |
Protocol specific implementation of recv. Called directly with error handling from recv.
| socketDescriptor | descriptor to recv from |
| data | data pointer to fill |
| size | size of data buffer |
Implements Drv::IpSocket.
Definition at line 218 of file UdpSocket.cpp.
|
overridevirtual |
UDP-specific implementation of send that handles zero-length datagrams correctly.
| socketDescriptor | descriptor to send to |
| data | data pointer to send |
| size | size of data to send |
Reimplemented from Drv::IpSocket.
Definition at line 242 of file UdpSocket.cpp.
|
overrideprotectedvirtual |
Protocol specific implementation of send. Called directly with retry from send.
| socketDescriptor | descriptor to send to |
| data | data to send |
| size | size of data to send |
Implements Drv::IpSocket.
Definition at line 206 of file UdpSocket.cpp.