aboutsummaryrefslogtreecommitdiff
path: root/embassy-net/src/udp.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-net/src/udp.rs')
-rw-r--r--embassy-net/src/udp.rs14
1 files changed, 5 insertions, 9 deletions
diff --git a/embassy-net/src/udp.rs b/embassy-net/src/udp.rs
index 7baa89ea0..eca3980b9 100644
--- a/embassy-net/src/udp.rs
+++ b/embassy-net/src/udp.rs
@@ -30,7 +30,7 @@ pub enum SendError {
30 /// Socket not bound to an outgoing port. 30 /// Socket not bound to an outgoing port.
31 SocketNotBound, 31 SocketNotBound,
32 /// There is not enough transmit buffer capacity to ever send this packet. 32 /// There is not enough transmit buffer capacity to ever send this packet.
33 Truncated, 33 PacketTooLarge,
34} 34}
35 35
36/// Error returned by [`UdpSocket::recv_from`]. 36/// Error returned by [`UdpSocket::recv_from`].
@@ -252,11 +252,9 @@ impl<'a> UdpSocket<'a> {
252 T: Into<UdpMetadata>, 252 T: Into<UdpMetadata>,
253 { 253 {
254 // Don't need to wake waker in `with_mut` if the buffer will never fit the udp tx_buffer. 254 // Don't need to wake waker in `with_mut` if the buffer will never fit the udp tx_buffer.
255 let send_capacity_too_small = self 255 let send_capacity_too_small = self.with(|s, _| s.payload_send_capacity() < buf.len());
256 .stack
257 .with(|i| i.sockets.get::<udp::Socket>(self.handle).payload_send_capacity() < buf.len());
258 if send_capacity_too_small { 256 if send_capacity_too_small {
259 return Poll::Ready(Err(SendError::Truncated)); 257 return Poll::Ready(Err(SendError::PacketTooLarge));
260 } 258 }
261 259
262 self.with_mut(|s, _| match s.send_slice(buf, remote_endpoint) { 260 self.with_mut(|s, _| match s.send_slice(buf, remote_endpoint) {
@@ -291,11 +289,9 @@ impl<'a> UdpSocket<'a> {
291 F: FnOnce(&mut [u8]) -> R, 289 F: FnOnce(&mut [u8]) -> R,
292 { 290 {
293 // Don't need to wake waker in `with_mut` if the buffer will never fit the udp tx_buffer. 291 // Don't need to wake waker in `with_mut` if the buffer will never fit the udp tx_buffer.
294 let send_capacity_too_small = self 292 let send_capacity_too_small = self.with(|s, _| s.payload_send_capacity() < size);
295 .stack
296 .with(|i| i.sockets.get::<udp::Socket>(self.handle).payload_send_capacity() < size);
297 if send_capacity_too_small { 293 if send_capacity_too_small {
298 return Err(SendError::Truncated); 294 return Err(SendError::PacketTooLarge);
299 } 295 }
300 296
301 let mut f = Some(f); 297 let mut f = Some(f);