diff options
| author | 2020-03-05 15:09:48 -0500 | |
|---|---|---|
| committer | 2020-03-05 15:09:48 -0500 | |
| commit | 4a8fe67964f427bd92def300023edfa12de8464e (patch) | |
| tree | 0e991618669943b8ad6faed1fed13152329c19a0 /src | |
| parent | Merge pull request #3451 from ReinUsesLisp/indexed-textures (diff) | |
| parent | input/udp - Add minor error handling to prevent bad input from crashing (diff) | |
| download | yuzu-4a8fe67964f427bd92def300023edfa12de8464e.tar.gz yuzu-4a8fe67964f427bd92def300023edfa12de8464e.tar.xz yuzu-4a8fe67964f427bd92def300023edfa12de8464e.zip | |
Merge pull request #3479 from jroweboy/dont-log-on-no-input
Minor fixes for udp input
Diffstat (limited to 'src')
| -rw-r--r-- | src/input_common/udp/client.cpp | 17 | ||||
| -rw-r--r-- | src/input_common/udp/protocol.cpp | 1 | ||||
| -rw-r--r-- | src/yuzu_cmd/default_ini.h | 2 |
3 files changed, 14 insertions, 6 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: | |||
| 32 | SocketCallback callback) | 32 | SocketCallback callback) |
| 33 | : callback(std::move(callback)), timer(io_service), | 33 | : callback(std::move(callback)), timer(io_service), |
| 34 | socket(io_service, udp::endpoint(udp::v4(), 0)), client_id(client_id), | 34 | socket(io_service, udp::endpoint(udp::v4(), 0)), client_id(client_id), |
| 35 | pad_index(pad_index), | 35 | pad_index(pad_index) { |
| 36 | send_endpoint(udp::endpoint(boost::asio::ip::make_address_v4(host), port)) {} | 36 | boost::system::error_code ec{}; |
| 37 | auto ipv4 = boost::asio::ip::make_address_v4(host, ec); | ||
| 38 | if (ec.failed()) { | ||
| 39 | LOG_ERROR(Input, "Invalid IPv4 address \"{}\" provided to socket", host); | ||
| 40 | ipv4 = boost::asio::ip::address_v4{}; | ||
| 41 | } | ||
| 42 | |||
| 43 | send_endpoint = {udp::endpoint(ipv4, port)}; | ||
| 44 | } | ||
| 37 | 45 | ||
| 38 | void Stop() { | 46 | void Stop() { |
| 39 | io_service.stop(); | 47 | io_service.stop(); |
| @@ -85,17 +93,18 @@ private: | |||
| 85 | } | 93 | } |
| 86 | 94 | ||
| 87 | void HandleSend(const boost::system::error_code& error) { | 95 | void HandleSend(const boost::system::error_code& error) { |
| 96 | boost::system::error_code _ignored{}; | ||
| 88 | // Send a request for getting port info for the pad | 97 | // Send a request for getting port info for the pad |
| 89 | Request::PortInfo port_info{1, {pad_index, 0, 0, 0}}; | 98 | Request::PortInfo port_info{1, {pad_index, 0, 0, 0}}; |
| 90 | const auto port_message = Request::Create(port_info, client_id); | 99 | const auto port_message = Request::Create(port_info, client_id); |
| 91 | std::memcpy(&send_buffer1, &port_message, PORT_INFO_SIZE); | 100 | std::memcpy(&send_buffer1, &port_message, PORT_INFO_SIZE); |
| 92 | socket.send_to(boost::asio::buffer(send_buffer1), send_endpoint); | 101 | socket.send_to(boost::asio::buffer(send_buffer1), send_endpoint, {}, _ignored); |
| 93 | 102 | ||
| 94 | // Send a request for getting pad data for the pad | 103 | // Send a request for getting pad data for the pad |
| 95 | Request::PadData pad_data{Request::PadData::Flags::Id, pad_index, EMPTY_MAC_ADDRESS}; | 104 | Request::PadData pad_data{Request::PadData::Flags::Id, pad_index, EMPTY_MAC_ADDRESS}; |
| 96 | const auto pad_message = Request::Create(pad_data, client_id); | 105 | const auto pad_message = Request::Create(pad_data, client_id); |
| 97 | std::memcpy(send_buffer2.data(), &pad_message, PAD_DATA_SIZE); | 106 | std::memcpy(send_buffer2.data(), &pad_message, PAD_DATA_SIZE); |
| 98 | socket.send_to(boost::asio::buffer(send_buffer2), send_endpoint); | 107 | socket.send_to(boost::asio::buffer(send_buffer2), send_endpoint, {}, _ignored); |
| 99 | StartSend(timer.expiry()); | 108 | StartSend(timer.expiry()); |
| 100 | } | 109 | } |
| 101 | 110 | ||
diff --git a/src/input_common/udp/protocol.cpp b/src/input_common/udp/protocol.cpp index a982ac49d..5e50bd612 100644 --- a/src/input_common/udp/protocol.cpp +++ b/src/input_common/udp/protocol.cpp | |||
| @@ -31,7 +31,6 @@ namespace Response { | |||
| 31 | */ | 31 | */ |
| 32 | std::optional<Type> Validate(u8* data, std::size_t size) { | 32 | std::optional<Type> Validate(u8* data, std::size_t size) { |
| 33 | if (size < sizeof(Header)) { | 33 | if (size < sizeof(Header)) { |
| 34 | LOG_DEBUG(Input, "Invalid UDP packet received"); | ||
| 35 | return std::nullopt; | 34 | return std::nullopt; |
| 36 | } | 35 | } |
| 37 | Header header{}; | 36 | Header header{}; |
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index df7473858..085ffbc81 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h | |||
| @@ -84,7 +84,7 @@ touch_device= | |||
| 84 | # from any cemuhook compatible motion program. | 84 | # from any cemuhook compatible motion program. |
| 85 | 85 | ||
| 86 | # IPv4 address of the udp input server (Default "127.0.0.1") | 86 | # IPv4 address of the udp input server (Default "127.0.0.1") |
| 87 | udp_input_address= | 87 | udp_input_address=127.0.0.1 |
| 88 | 88 | ||
| 89 | # Port of the udp input server. (Default 26760) | 89 | # Port of the udp input server. (Default 26760) |
| 90 | udp_input_port= | 90 | udp_input_port= |