mirror of
https://github.com/smoltcp-rs/smoltcp.git
synced 2025-10-02 15:15:05 +00:00
Merge pull request #1003 from ProfFan/fan/add_send_recv_queue
Add `send_queue`/`recv_queue` to UDP/ICMP/Raw Socket
This commit is contained in:
commit
b8fb01cede
@ -412,6 +412,16 @@ impl<'a> Socket<'a> {
|
|||||||
Ok((length, endpoint))
|
Ok((length, endpoint))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the amount of octets queued in the transmit buffer.
|
||||||
|
pub fn send_queue(&self) -> usize {
|
||||||
|
self.tx_buffer.payload_bytes_count()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the amount of octets queued in the receive buffer.
|
||||||
|
pub fn recv_queue(&self) -> usize {
|
||||||
|
self.rx_buffer.payload_bytes_count()
|
||||||
|
}
|
||||||
|
|
||||||
/// Fitler determining whether the socket accepts a given ICMPv4 packet.
|
/// Fitler determining whether the socket accepts a given ICMPv4 packet.
|
||||||
/// Accepted packets are enqueued into the socket's receive buffer.
|
/// Accepted packets are enqueued into the socket's receive buffer.
|
||||||
#[cfg(feature = "proto-ipv4")]
|
#[cfg(feature = "proto-ipv4")]
|
||||||
|
@ -327,6 +327,16 @@ impl<'a> Socket<'a> {
|
|||||||
Ok(length)
|
Ok(length)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the amount of octets queued in the transmit buffer.
|
||||||
|
pub fn send_queue(&self) -> usize {
|
||||||
|
self.tx_buffer.payload_bytes_count()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the amount of octets queued in the receive buffer.
|
||||||
|
pub fn recv_queue(&self) -> usize {
|
||||||
|
self.rx_buffer.payload_bytes_count()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn accepts(&self, ip_repr: &IpRepr) -> bool {
|
pub(crate) fn accepts(&self, ip_repr: &IpRepr) -> bool {
|
||||||
if ip_repr.version() != self.ip_version {
|
if ip_repr.version() != self.ip_version {
|
||||||
return false;
|
return false;
|
||||||
|
@ -459,6 +459,22 @@ impl<'a> Socket<'a> {
|
|||||||
Ok((length, endpoint))
|
Ok((length, endpoint))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the amount of octets queued in the transmit buffer.
|
||||||
|
///
|
||||||
|
/// Note that the Berkeley sockets interface does not have an equivalent of this API.
|
||||||
|
pub fn send_queue(&self) -> usize {
|
||||||
|
self.tx_buffer.payload_bytes_count()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the amount of octets queued in the receive buffer. This value can be larger than
|
||||||
|
/// the slice read by the next `recv` or `peek` call because it includes all queued octets,
|
||||||
|
/// and not only the octets that may be returned as a contiguous slice.
|
||||||
|
///
|
||||||
|
/// Note that the Berkeley sockets interface does not have an equivalent of this API.
|
||||||
|
pub fn recv_queue(&self) -> usize {
|
||||||
|
self.rx_buffer.payload_bytes_count()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn accepts(&self, cx: &mut Context, ip_repr: &IpRepr, repr: &UdpRepr) -> bool {
|
pub(crate) fn accepts(&self, cx: &mut Context, ip_repr: &IpRepr, repr: &UdpRepr) -> bool {
|
||||||
if self.endpoint.port != repr.dst_port {
|
if self.endpoint.port != repr.dst_port {
|
||||||
return false;
|
return false;
|
||||||
|
@ -239,6 +239,11 @@ impl<'a, H> PacketBuffer<'a, H> {
|
|||||||
self.payload_ring.capacity()
|
self.payload_ring.capacity()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the current number of bytes in the payload ring buffer.
|
||||||
|
pub fn payload_bytes_count(&self) -> usize {
|
||||||
|
self.payload_ring.len()
|
||||||
|
}
|
||||||
|
|
||||||
/// Reset the packet buffer and clear any staged.
|
/// Reset the packet buffer and clear any staged.
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub(crate) fn reset(&mut self) {
|
pub(crate) fn reset(&mut self) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user