summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2017-03-19 21:38:24 -0500
committerGravatar Subv2017-05-15 13:05:16 -0500
commit846cc6cee3ab1cbde7c58d3e3227c03cad404005 (patch)
tree254bbcc176b7212d45373a5f1f0ce5f86dfbae6e /src
parentServices/UDS: Generate the UDS beacons when the beacon callback fires. (diff)
downloadyuzu-846cc6cee3ab1cbde7c58d3e3227c03cad404005.tar.gz
yuzu-846cc6cee3ab1cbde7c58d3e3227c03cad404005.tar.xz
yuzu-846cc6cee3ab1cbde7c58d3e3227c03cad404005.zip
Services/UDS: Implement RecvBeaconBroadcastData.
This allows the applications to retrieve 802.11 beacon frames from nearby UDS networks. Note that the networks are still not announced anywhere.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nwm/nwm_uds.cpp88
1 files changed, 69 insertions, 19 deletions
diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp
index f016550b5..e5ffefa65 100644
--- a/src/core/hle/service/nwm/nwm_uds.cpp
+++ b/src/core/hle/service/nwm/nwm_uds.cpp
@@ -86,29 +86,79 @@ static void Shutdown(Interface* self) {
86 * 1 : Result of function, 0 on success, otherwise error code 86 * 1 : Result of function, 0 on success, otherwise error code
87 */ 87 */
88static void RecvBeaconBroadcastData(Interface* self) { 88static void RecvBeaconBroadcastData(Interface* self) {
89 u32* cmd_buff = Kernel::GetCommandBuffer(); 89 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x0F, 16, 4);
90 u32 out_buffer_size = cmd_buff[1]; 90
91 u32 unk1 = cmd_buff[2]; 91 u32 out_buffer_size = rp.Pop<u32>();
92 u32 unk2 = cmd_buff[3]; 92 rp.Pop<u32>();
93 u32 mac_address = cmd_buff[4]; 93 rp.Pop<u32>();
94
95 MacAddress mac_address;
96 rp.PopRaw(mac_address);
97
98 // TODO(Subv): Use IPC::RequestParser::Skip when possible.
99 rp.Pop<u32>();
100 rp.Pop<u32>();
101 rp.Pop<u32>();
102 rp.Pop<u32>();
103 rp.Pop<u32>();
104 rp.Pop<u32>();
105 rp.Pop<u32>();
106 rp.Pop<u32>();
107 rp.Pop<u32>();
108
109 u32 wlan_comm_id = rp.Pop<u32>();
110 u32 id = rp.Pop<u32>();
111 Kernel::Handle input_handle = rp.PopHandle();
94 112
95 u32 unk3 = cmd_buff[6]; 113 size_t desc_size;
114 const VAddr out_buffer_ptr = rp.PopMappedBuffer(&desc_size);
115 ASSERT(desc_size == out_buffer_size);
96 116
97 u32 wlan_comm_id = cmd_buff[15]; 117 VAddr current_buffer_pos = out_buffer_ptr;
98 u32 ctr_gen_id = cmd_buff[16]; 118 u32 total_size = sizeof(BeaconDataReplyHeader);
99 u32 value = cmd_buff[17];
100 u32 input_handle = cmd_buff[18];
101 u32 new_buffer_size = cmd_buff[19];
102 u32 out_buffer_ptr = cmd_buff[20];
103 119
104 cmd_buff[1] = RESULT_SUCCESS.raw; 120 // Retrieve all beacon frames that were received from the desired mac address.
121 std::deque<WifiPacket> beacons =
122 GetReceivedPackets(WifiPacket::PacketType::Beacon, mac_address);
105 123
106 LOG_WARNING(Service_NWM, 124 BeaconDataReplyHeader data_reply_header{};
107 "(STUBBED) called out_buffer_size=0x%08X, unk1=0x%08X, unk2=0x%08X," 125 data_reply_header.total_entries = beacons.size();
108 "mac_address=0x%08X, unk3=0x%08X, wlan_comm_id=0x%08X, ctr_gen_id=0x%08X," 126 data_reply_header.max_output_size = out_buffer_size;
109 "value=%u, input_handle=0x%08X, new_buffer_size=0x%08X, out_buffer_ptr=0x%08X", 127
110 out_buffer_size, unk1, unk2, mac_address, unk3, wlan_comm_id, ctr_gen_id, value, 128 Memory::WriteBlock(current_buffer_pos, &data_reply_header, sizeof(BeaconDataReplyHeader));
111 input_handle, new_buffer_size, out_buffer_ptr); 129 current_buffer_pos += sizeof(BeaconDataReplyHeader);
130
131 // Write each of the received beacons into the buffer
132 for (const auto& beacon : beacons) {
133 BeaconEntryHeader entry{};
134 // TODO(Subv): Figure out what this size is used for.
135 entry.unk_size = sizeof(BeaconEntryHeader) + beacon.data.size();
136 entry.total_size = sizeof(BeaconEntryHeader) + beacon.data.size();
137 entry.wifi_channel = beacon.channel;
138 entry.header_size = sizeof(BeaconEntryHeader);
139 entry.mac_address = beacon.transmitter_address;
140
141 ASSERT(current_buffer_pos < out_buffer_ptr + out_buffer_size);
142
143 Memory::WriteBlock(current_buffer_pos, &entry, sizeof(BeaconEntryHeader));
144 current_buffer_pos += sizeof(BeaconEntryHeader);
145
146 Memory::WriteBlock(current_buffer_pos, beacon.data.data(), beacon.data.size());
147 current_buffer_pos += beacon.data.size();
148
149 total_size += sizeof(BeaconEntryHeader) + beacon.data.size();
150 }
151
152 // Update the total size in the structure and write it to the buffer again.
153 data_reply_header.total_size = total_size;
154 Memory::WriteBlock(out_buffer_ptr, &data_reply_header, sizeof(BeaconDataReplyHeader));
155
156 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
157 rb.Push(RESULT_SUCCESS);
158
159 LOG_DEBUG(Service_NWM, "called out_buffer_size=0x%08X, wlan_comm_id=0x%08X, id=0x%08X,"
160 "input_handle=0x%08X, out_buffer_ptr=0x%08X",
161 out_buffer_size, wlan_comm_id, id, input_handle, out_buffer_ptr);
112} 162}
113 163
114/** 164/**