/* * Author: Patrick-Christopher Mattulat * Company: Lynar Studios * E-Mail: webmaster@lynarstudios.com * Created: 2022-11-18 * Changed: 2022-12-09 * * */ #include #include #include #if defined(unix) || defined(__APPLE__) #include #include #endif ls::std::network::SocketAddressMapper::SocketAddressMapper() : ls::std::core::Class("SocketAddressMapper") {} ls::std::network::ConvertedSocketAddress ls::std::network::SocketAddressMapper::from(const ls::std::network::SocketAddressMapperParameter &_parameter) { ls::std::network::ConvertedSocketAddress convertedSocketAddress{}; #if defined(unix) || defined(__APPLE__) convertedSocketAddress.socketAddressUnix = ls::std::network::SocketAddressMapper::_toSockAddressUnix(_parameter); #endif return convertedSocketAddress; } #if defined(unix) || defined(__APPLE__) ::sockaddr_in ls::std::network::SocketAddressMapper::_toSockAddressUnix(const ls::std::network::SocketAddressMapperParameter &_parameter) { ::sockaddr_in socketAddressUnix{}; socketAddressUnix.sin_port = ::htons(_parameter.socketAddress.port); ls::std::network::ConvertedProtocolFamily convertedProtocolFamily = ls::std::network::ProtocolFamilyMapper::from(_parameter.protocolFamilyType); socketAddressUnix.sin_family = convertedProtocolFamily.unixDomain; ::inet_aton(_parameter.socketAddress.ipAddress.c_str(), &socketAddressUnix.sin_addr); return socketAddressUnix; } #endif