|
2 | 2 |
|
3 | 3 | use core::ops::DerefMut;
|
4 | 4 | use core::time::Duration;
|
| 5 | +use uefi::proto::device_path::text::{AllowShortcuts, DisplayOnly}; |
| 6 | +use uefi::proto::device_path::DevicePath; |
5 | 7 |
|
6 | 8 | use uefi::proto::network::snp::{InterruptStatus, NetworkState, ReceiveFlags, SimpleNetwork};
|
7 | 9 | use uefi::proto::network::MacAddress;
|
@@ -41,11 +43,21 @@ pub fn test() {
|
41 | 43 | info!("Testing the simple network protocol");
|
42 | 44 |
|
43 | 45 | let handles = boot::find_handles::<SimpleNetwork>().unwrap_or_default();
|
44 |
| - |
45 | 46 | for handle in handles {
|
46 | 47 | let Ok(mut simple_network) = boot::open_protocol_exclusive::<SimpleNetwork>(handle) else {
|
47 | 48 | continue;
|
48 | 49 | };
|
| 50 | + // Print device path |
| 51 | + { |
| 52 | + let simple_network_dvp = boot::open_protocol_exclusive::<DevicePath>(handle) |
| 53 | + .expect("Should have device path"); |
| 54 | + log::info!( |
| 55 | + "Network interface: {}", |
| 56 | + simple_network_dvp |
| 57 | + .to_string(DisplayOnly(true), AllowShortcuts(true)) |
| 58 | + .unwrap() |
| 59 | + ); |
| 60 | + } |
49 | 61 |
|
50 | 62 | assert_eq!(
|
51 | 63 | simple_network.mode().state,
|
@@ -138,28 +150,28 @@ pub fn test() {
|
138 | 150 | let n = receive(simple_network.deref_mut(), &mut buffer).unwrap();
|
139 | 151 | debug!("Reply has {n} bytes");
|
140 | 152 |
|
141 |
| - // Check payload in UDP packet that was reversed by our EchoService. |
142 |
| - assert_eq!(buffer[42..47], [4, 4, 3, 2, 1]); |
| 153 | + // Check payload in UDP packet that was reversed by our EchoService. |
| 154 | + assert_eq!(buffer[42..47], [4, 4, 3, 2, 1]); |
143 | 155 |
|
144 |
| - // Get stats |
145 |
| - let res = simple_network.collect_statistics(); |
146 |
| - match res { |
147 |
| - Ok(stats) => { |
148 |
| - info!("Stats: {:?}", stats); |
| 156 | + // Get stats |
| 157 | + let res = simple_network.collect_statistics(); |
| 158 | + match res { |
| 159 | + Ok(stats) => { |
| 160 | + info!("Stats: {:?}", stats); |
149 | 161 |
|
150 |
| - // One frame should have been transmitted and one received |
151 |
| - assert_eq!(stats.tx_total_frames().unwrap(), 1); |
152 |
| - assert_eq!(stats.rx_total_frames().unwrap(), 1); |
153 |
| - } |
154 |
| - Err(e) => { |
155 |
| - if e == Status::UNSUPPORTED.into() { |
156 |
| - info!("Stats: unsupported."); |
157 |
| - } else { |
158 |
| - panic!("{e}"); |
159 |
| - } |
| 162 | + // One frame should have been transmitted and one received |
| 163 | + assert_eq!(stats.tx_total_frames().unwrap(), 1); |
| 164 | + assert_eq!(stats.rx_total_frames().unwrap(), 1); |
| 165 | + } |
| 166 | + Err(e) => { |
| 167 | + if e == Status::UNSUPPORTED.into() { |
| 168 | + info!("Stats: unsupported."); |
| 169 | + } else { |
| 170 | + panic!("{e}"); |
160 | 171 | }
|
161 | 172 | }
|
162 |
| - |
163 |
| - simple_network.shutdown().unwrap(); |
164 | 173 | }
|
| 174 | + |
| 175 | + simple_network.shutdown().unwrap(); |
165 | 176 | }
|
| 177 | +} |
0 commit comments