@@ -46,36 +46,42 @@ UdpSocket::UdpSocket() : IpSocket(), m_recv_configured(false) {
4646
4747UdpSocket::~UdpSocket () = default ;
4848
49- SocketIpStatus UdpSocket::configure (const char * const hostname ,
49+ SocketIpStatus UdpSocket::configure (const char * const ipv4_address ,
5050 const U16 port,
5151 const U32 timeout_seconds,
5252 const U32 timeout_microseconds) {
53+ (void )ipv4_address;
54+ (void )port;
55+ (void )timeout_seconds;
56+ (void )timeout_microseconds;
5357 FW_ASSERT (0 ); // Must use configureSend and/or configureRecv
5458 return SocketIpStatus::SOCK_INVALID_CALL;
5559}
5660
57- SocketIpStatus UdpSocket::configureSend (const char * const hostname ,
61+ SocketIpStatus UdpSocket::configureSend (const char * const ipv4_address ,
5862 const U16 port,
5963 const U32 timeout_seconds,
6064 const U32 timeout_microseconds) {
61- FW_ASSERT (hostname != nullptr );
65+ FW_ASSERT (ipv4_address != nullptr );
6266 FW_ASSERT (this ->isValidPort (port));
6367 FW_ASSERT (timeout_microseconds < 1000000 );
64- return IpSocket::configure (hostname , port, timeout_seconds, timeout_microseconds);
68+ return IpSocket::configure (ipv4_address , port, timeout_seconds, timeout_microseconds);
6569}
6670
67- SocketIpStatus UdpSocket::configureRecv (const char * hostname , const U16 port) {
68- FW_ASSERT (hostname != nullptr );
71+ SocketIpStatus UdpSocket::configureRecv (const char * const ipv4_address , const U16 port) {
72+ FW_ASSERT (ipv4_address != nullptr );
6973 FW_ASSERT (this ->isValidPort (port));
70- FW_ASSERT (Fw::StringUtils::string_length (hostname, SOCKET_MAX_HOSTNAME_SIZE) < SOCKET_MAX_HOSTNAME_SIZE);
74+ FW_ASSERT (Fw::StringUtils::string_length (ipv4_address,
75+ static_cast <FwSizeType>(SOCKET_MAX_IPV4_ADDRESS_SIZE))
76+ < static_cast <FwSizeType>(SOCKET_MAX_IPV4_ADDRESS_SIZE));
7177
7278 // Initialize the receive address structure
7379 (void )::memset (&m_addr_recv, 0 , sizeof (m_addr_recv));
7480 m_addr_recv.sin_family = AF_INET;
7581 m_addr_recv.sin_port = htons (port);
7682
77- // Convert hostname to IP address
78- SocketIpStatus status = IpSocket::addressToIp4 (hostname , &m_addr_recv.sin_addr );
83+ // Convert IPv4 address (dotted-quad) to network-order in_addr
84+ SocketIpStatus status = IpSocket::addressToIp4 (ipv4_address , &m_addr_recv.sin_addr );
7985 if (status != SOCK_SUCCESS) {
8086 return status;
8187 }
@@ -143,10 +149,11 @@ SocketIpStatus UdpSocket::openProtocol(SocketDescriptor& socketDescriptor) {
143149 address.sin_len = static_cast <U8>(sizeof (struct sockaddr_in ));
144150#endif
145151
146- // First IP address to socket sin_addr
147- status = IpSocket::addressToIp4 (m_hostname , &(address.sin_addr ));
152+ // Convert the configured IPv4 address (dotted-quad) to a network-order in_addr.
153+ status = IpSocket::addressToIp4 (this -> m_ipv4_address , &(address.sin_addr ));
148154 if (status != SOCK_SUCCESS) {
149- Fw::Logger::log (" Failed to resolve hostname %s: %d\n " , m_hostname, static_cast <I32>(status));
155+ Fw::Logger::log (" Failed to parse IPv4 address %s: %d\n " ,
156+ this ->m_ipv4_address , static_cast <I32>(status));
150157 ::close (socketFd);
151158 return status;
152159 };
@@ -187,9 +194,10 @@ SocketIpStatus UdpSocket::openProtocol(SocketDescriptor& socketDescriptor) {
187194 if ((port == 0 ) && (recv_port > 0 )) {
188195 Fw::Logger::log (" Setup to only receive udp at %s:%hu\n " , recv_addr, recv_port);
189196 } else if ((port > 0 ) && (recv_port == 0 )) {
190- Fw::Logger::log (" Setup to only send udp at %s:%hu\n " , m_hostname , port);
197+ Fw::Logger::log (" Setup to only send udp at %s:%hu\n " , this -> m_ipv4_address , port);
191198 } else if ((port > 0 ) && (recv_port > 0 )) {
192- Fw::Logger::log (" Setup to receive udp at %s:%hu and send to %s:%hu\n " , recv_addr, recv_port, m_hostname, port);
199+ Fw::Logger::log (" Setup to receive udp at %s:%hu and send to %s:%hu\n " ,
200+ recv_addr, recv_port, this ->m_ipv4_address , port);
193201 }
194202
195203 FW_ASSERT (status == SOCK_SUCCESS, static_cast <FwAssertArgType>(status));
0 commit comments