summaryrefslogtreecommitdiffstats
path: root/src/input_common/udp/client.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-03-05 21:09:48 +0100
committerGitHub <noreply@github.com>2020-03-05 21:09:48 +0100
commit4a8fe67964f427bd92def300023edfa12de8464e (patch)
tree0e991618669943b8ad6faed1fed13152329c19a0 /src/input_common/udp/client.cpp
parentMerge pull request #3451 from ReinUsesLisp/indexed-textures (diff)
parentinput/udp - Add minor error handling to prevent bad input from crashing (diff)
downloadyuzu-4a8fe67964f427bd92def300023edfa12de8464e.tar
yuzu-4a8fe67964f427bd92def300023edfa12de8464e.tar.gz
yuzu-4a8fe67964f427bd92def300023edfa12de8464e.tar.bz2
yuzu-4a8fe67964f427bd92def300023edfa12de8464e.tar.lz
yuzu-4a8fe67964f427bd92def300023edfa12de8464e.tar.xz
yuzu-4a8fe67964f427bd92def300023edfa12de8464e.tar.zst
yuzu-4a8fe67964f427bd92def300023edfa12de8464e.zip
Diffstat (limited to 'src/input_common/udp/client.cpp')
-rw-r--r--src/input_common/udp/client.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp
index 2228571a6..e82ae7ef1 100644
--- a/src/input_common/udp/client.cpp
+++ b/src/input_common/udp/client.cpp
@@ -32,8 +32,16 @@ public:
SocketCallback callback)
: callback(std::move(callback)), timer(io_service),
socket(io_service, udp::endpoint(udp::v4(), 0)), client_id(client_id),
- pad_index(pad_index),
- send_endpoint(udp::endpoint(boost::asio::ip::make_address_v4(host), port)) {}
+ pad_index(pad_index) {
+ boost::system::error_code ec{};
+ auto ipv4 = boost::asio::ip::make_address_v4(host, ec);
+ if (ec.failed()) {
+ LOG_ERROR(Input, "Invalid IPv4 address \"{}\" provided to socket", host);
+ ipv4 = boost::asio::ip::address_v4{};
+ }
+
+ send_endpoint = {udp::endpoint(ipv4, port)};
+ }
void Stop() {
io_service.stop();
@@ -85,17 +93,18 @@ private:
}
void HandleSend(const boost::system::error_code& error) {
+ boost::system::error_code _ignored{};
// Send a request for getting port info for the pad
Request::PortInfo port_info{1, {pad_index, 0, 0, 0}};
const auto port_message = Request::Create(port_info, client_id);
std::memcpy(&send_buffer1, &port_message, PORT_INFO_SIZE);
- socket.send_to(boost::asio::buffer(send_buffer1), send_endpoint);
+ socket.send_to(boost::asio::buffer(send_buffer1), send_endpoint, {}, _ignored);
// Send a request for getting pad data for the pad
Request::PadData pad_data{Request::PadData::Flags::Id, pad_index, EMPTY_MAC_ADDRESS};
const auto pad_message = Request::Create(pad_data, client_id);
std::memcpy(send_buffer2.data(), &pad_message, PAD_DATA_SIZE);
- socket.send_to(boost::asio::buffer(send_buffer2), send_endpoint);
+ socket.send_to(boost::asio::buffer(send_buffer2), send_endpoint, {}, _ignored);
StartSend(timer.expiry());
}